Skip to content

Commit

Permalink
Merge mozilla-central to autoland. a=merge CLOSED TREE
Browse files Browse the repository at this point in the history
  • Loading branch information
shindli committed Apr 5, 2019
2 parents 3dee55d + d764f5c commit de3550a
Show file tree
Hide file tree
Showing 11 changed files with 669 additions and 31 deletions.
60 changes: 53 additions & 7 deletions js/src/wasm/WasmBaselineCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,9 @@ class BaseStackFrame final : public BaseStackFrameAllocator {
Local(MIRType type, int32_t offs) : type(type), offs(offs) {}
};

using LocalVector = Vector<Local, 8, SystemAllocPolicy>;
// Profiling shows that the number of parameters and locals frequently
// touches or exceeds 8. So 16 seems like a reasonable starting point.
using LocalVector = Vector<Local, 16, SystemAllocPolicy>;

// Initialize `localInfo` based on the types of `locals` and `args`.
bool setupLocals(const ValTypeVector& locals, const ValTypeVector& args,
Expand Down Expand Up @@ -1990,7 +1992,7 @@ struct Stk {
}
};

typedef Vector<Stk, 8, SystemAllocPolicy> StkVector;
typedef Vector<Stk, 0, SystemAllocPolicy> StkVector;

// MachineStackTracker, used for stack-slot pointerness tracking.

Expand Down Expand Up @@ -2565,8 +2567,9 @@ class BaseCompiler final : public BaseCompilerInterface {
BaseCompiler(const ModuleEnvironment& env, const FuncCompileInput& input,
const ValTypeVector& locals, const MachineState& trapExitLayout,
size_t trapExitLayoutNumWords, Decoder& decoder,
TempAllocator* alloc, MacroAssembler* masm,
StkVector& stkSource, TempAllocator* alloc, MacroAssembler* masm,
StackMaps* stackMaps);
~BaseCompiler();

MOZ_MUST_USE bool init();

Expand Down Expand Up @@ -2865,8 +2868,22 @@ class BaseCompiler final : public BaseCompilerInterface {
// to avoid problems with control flow and messy register usage
// patterns.

// This is the value stack actually used during compilation. It is a
// StkVector rather than a StkVector& since constantly dereferencing a
// StkVector& adds about 0.5% or more to the compiler's dynamic instruction
// count.
StkVector stk_;

// BaselineCompileFunctions() "lends" us the StkVector to use in this
// BaseCompiler object, and that is installed in |stk_| in our constructor.
// This is so as to avoid having to malloc/free the vector's contents at
// each creation/destruction of a BaseCompiler object. It does however mean
// that we need to hold on to a reference to BaselineCompileFunctions()'s
// vector, so we can swap (give) its contents back when this BaseCompiler
// object is destroyed. This significantly reduces the heap turnover of the
// baseline compiler. See bug 1532592.
StkVector& stkSource_;

#ifdef DEBUG
size_t countMemRefsOnStk() {
size_t nRefs = 0;
Expand Down Expand Up @@ -11776,8 +11793,8 @@ BaseCompiler::BaseCompiler(const ModuleEnvironment& env,
const ValTypeVector& locals,
const MachineState& trapExitLayout,
size_t trapExitLayoutNumWords, Decoder& decoder,
TempAllocator* alloc, MacroAssembler* masm,
StackMaps* stackMaps)
StkVector& stkSource, TempAllocator* alloc,
MacroAssembler* masm, StackMaps* stackMaps)
: env_(env),
iter_(env, decoder),
func_(func),
Expand All @@ -11799,7 +11816,28 @@ BaseCompiler::BaseCompiler(const ModuleEnvironment& env,
joinRegI64_(RegI64(ReturnReg64)),
joinRegPtr_(RegPtr(ReturnReg)),
joinRegF32_(RegF32(ReturnFloat32Reg)),
joinRegF64_(RegF64(ReturnDoubleReg)) {}
joinRegF64_(RegF64(ReturnDoubleReg)),
stkSource_(stkSource) {
// Our caller, BaselineCompileFunctions, will lend us the vector contents to
// use for the eval stack. To get hold of those contents, we'll temporarily
// installing an empty one in its place.
MOZ_ASSERT(stk_.empty());
stk_.swap(stkSource_);

// Assuming that previously processed wasm functions are well formed, the
// eval stack should now be empty. But empty it anyway; any non-emptyness
// at this point will cause chaos.
stk_.clear();
}

BaseCompiler::~BaseCompiler() {
stk_.swap(stkSource_);
// We've returned the eval stack vector contents to our caller,
// BaselineCompileFunctions. We expect the vector we get in return to be
// empty since that's what we swapped for the stack vector in our
// constructor.
MOZ_ASSERT(stk_.empty());
}

bool BaseCompiler::init() {
if (!SigD_.append(ValType::F64)) {
Expand Down Expand Up @@ -11880,6 +11918,14 @@ bool js::wasm::BaselineCompileFunctions(const ModuleEnvironment& env,
size_t trapExitLayoutNumWords;
GenerateTrapExitMachineState(&trapExitLayout, &trapExitLayoutNumWords);

// The compiler's operand stack. We reuse it across all functions so as to
// avoid malloc/free. Presize it to 128 elements in the hope of avoiding
// reallocation later.
StkVector stk;
if (!stk.reserve(128)) {
return false;
}

for (const FuncCompileInput& func : inputs) {
Decoder d(func.begin, func.end, func.lineOrBytecode, error);

Expand All @@ -11896,7 +11942,7 @@ bool js::wasm::BaselineCompileFunctions(const ModuleEnvironment& env,
// One-pass baseline compilation.

BaseCompiler f(env, func, locals, trapExitLayout, trapExitLayoutNumWords, d,
&alloc, &masm, &code->stackMaps);
stk, &alloc, &masm, &code->stackMaps);
if (!f.init()) {
return false;
}
Expand Down
11 changes: 9 additions & 2 deletions js/src/wasm/WasmTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ class Module;
class Instance;
class Table;

typedef Vector<uint32_t, 0, SystemAllocPolicy> Uint32Vector;
// Uint32Vector has initial size 8 on the basis that the dominant use cases
// (line numbers and control stacks) tend to have a small but nonzero number
// of elements.
typedef Vector<uint32_t, 8, SystemAllocPolicy> Uint32Vector;

typedef Vector<uint8_t, 0, SystemAllocPolicy> Bytes;
typedef UniquePtr<Bytes> UniqueBytes;
typedef UniquePtr<const Bytes> UniqueConstBytes;
Expand Down Expand Up @@ -451,7 +455,10 @@ class ValType {
bool operator!=(Code that) const { return !(*this == that); }
};

typedef Vector<ValType, 8, SystemAllocPolicy> ValTypeVector;
// The dominant use of this data type is for locals and args, and profiling
// with ZenGarden and Tanks suggests an initial size of 16 minimises heap
// allocation, both in terms of blocks and bytes.
typedef Vector<ValType, 16, SystemAllocPolicy> ValTypeVector;

// ValType utilities

Expand Down
25 changes: 25 additions & 0 deletions mfbt/Assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,31 @@ struct AssertionConditionType {
} while (false)
#endif

/*
* MOZ_DIAGNOSTIC_ALWAYS_TRUE is like MOZ_ALWAYS_TRUE, but using
* MOZ_DIAGNOSTIC_ASSERT as the underlying assert.
*
* See the block comment for MOZ_DIAGNOSTIC_ASSERT above for more details on how
* diagnostic assertions work and how to use them.
*/
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
# define MOZ_DIAGNOSTIC_ALWAYS_TRUE(expr) \
do { \
if ((expr)) { \
/* Do nothing. */ \
} else { \
MOZ_DIAGNOSTIC_ASSERT(false, #expr); \
} \
} while (false)
#else
# define MOZ_DIAGNOSTIC_ALWAYS_TRUE(expr) \
do { \
if ((expr)) { \
/* Silence MOZ_MUST_USE. */ \
} \
} while (false)
#endif

#undef MOZ_DUMP_ASSERTION_STACK
#undef MOZ_CRASH_CRASHREPORT

Expand Down
4 changes: 2 additions & 2 deletions taskcluster/ci/beetmover-repackage/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ job-template:
attributes:
artifact_map:
by-project:
mozilla-release: taskcluster/taskgraph/manifests/firefox_candidates.yml
mozilla-beta: taskcluster/taskgraph/manifests/firefox_candidates.yml
default: taskcluster/taskgraph/manifests/firefox_nightly.yml
mozilla-beta: taskcluster/taskgraph/manifests/firefox_candidates.yml
mozilla-release: taskcluster/taskgraph/manifests/firefox_candidates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ kind-dependencies:

job-template:
shipping-phase: promote
attributes:
artifact_prefix: public
artifact_map: taskcluster/taskgraph/manifests/firefox_candidates_checksums.yml
2 changes: 2 additions & 0 deletions taskcluster/ci/release-beetmover-signed-langpacks/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ job-template:
staging: scriptworker-prov-v1/beetmoverworker-dev
run-on-projects: []
shipping-phase: promote
attributes:
artifact_map: taskcluster/taskgraph/manifests/firefox_candidates.yml
Loading

0 comments on commit de3550a

Please sign in to comment.