Skip to content

Commit 45ec611

Browse files
committed
Merge mozilla-central to autoland. a=merge CLOSED TREE
2 parents 61bd4db + d1f516d commit 45ec611

File tree

11 files changed

+669
-31
lines changed

11 files changed

+669
-31
lines changed

js/src/wasm/WasmBaselineCompile.cpp

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,9 @@ class BaseStackFrame final : public BaseStackFrameAllocator {
15151515
Local(MIRType type, int32_t offs) : type(type), offs(offs) {}
15161516
};
15171517

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

15201522
// Initialize `localInfo` based on the types of `locals` and `args`.
15211523
bool setupLocals(const ValTypeVector& locals, const ValTypeVector& args,
@@ -1990,7 +1992,7 @@ struct Stk {
19901992
}
19911993
};
19921994

1993-
typedef Vector<Stk, 8, SystemAllocPolicy> StkVector;
1995+
typedef Vector<Stk, 0, SystemAllocPolicy> StkVector;
19941996

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

@@ -2565,8 +2567,9 @@ class BaseCompiler final : public BaseCompilerInterface {
25652567
BaseCompiler(const ModuleEnvironment& env, const FuncCompileInput& input,
25662568
const ValTypeVector& locals, const MachineState& trapExitLayout,
25672569
size_t trapExitLayoutNumWords, Decoder& decoder,
2568-
TempAllocator* alloc, MacroAssembler* masm,
2570+
StkVector& stkSource, TempAllocator* alloc, MacroAssembler* masm,
25692571
StackMaps* stackMaps);
2572+
~BaseCompiler();
25702573

25712574
MOZ_MUST_USE bool init();
25722575

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

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

2877+
// BaselineCompileFunctions() "lends" us the StkVector to use in this
2878+
// BaseCompiler object, and that is installed in |stk_| in our constructor.
2879+
// This is so as to avoid having to malloc/free the vector's contents at
2880+
// each creation/destruction of a BaseCompiler object. It does however mean
2881+
// that we need to hold on to a reference to BaselineCompileFunctions()'s
2882+
// vector, so we can swap (give) its contents back when this BaseCompiler
2883+
// object is destroyed. This significantly reduces the heap turnover of the
2884+
// baseline compiler. See bug 1532592.
2885+
StkVector& stkSource_;
2886+
28702887
#ifdef DEBUG
28712888
size_t countMemRefsOnStk() {
28722889
size_t nRefs = 0;
@@ -11776,8 +11793,8 @@ BaseCompiler::BaseCompiler(const ModuleEnvironment& env,
1177611793
const ValTypeVector& locals,
1177711794
const MachineState& trapExitLayout,
1177811795
size_t trapExitLayoutNumWords, Decoder& decoder,
11779-
TempAllocator* alloc, MacroAssembler* masm,
11780-
StackMaps* stackMaps)
11796+
StkVector& stkSource, TempAllocator* alloc,
11797+
MacroAssembler* masm, StackMaps* stackMaps)
1178111798
: env_(env),
1178211799
iter_(env, decoder),
1178311800
func_(func),
@@ -11799,7 +11816,28 @@ BaseCompiler::BaseCompiler(const ModuleEnvironment& env,
1179911816
joinRegI64_(RegI64(ReturnReg64)),
1180011817
joinRegPtr_(RegPtr(ReturnReg)),
1180111818
joinRegF32_(RegF32(ReturnFloat32Reg)),
11802-
joinRegF64_(RegF64(ReturnDoubleReg)) {}
11819+
joinRegF64_(RegF64(ReturnDoubleReg)),
11820+
stkSource_(stkSource) {
11821+
// Our caller, BaselineCompileFunctions, will lend us the vector contents to
11822+
// use for the eval stack. To get hold of those contents, we'll temporarily
11823+
// installing an empty one in its place.
11824+
MOZ_ASSERT(stk_.empty());
11825+
stk_.swap(stkSource_);
11826+
11827+
// Assuming that previously processed wasm functions are well formed, the
11828+
// eval stack should now be empty. But empty it anyway; any non-emptyness
11829+
// at this point will cause chaos.
11830+
stk_.clear();
11831+
}
11832+
11833+
BaseCompiler::~BaseCompiler() {
11834+
stk_.swap(stkSource_);
11835+
// We've returned the eval stack vector contents to our caller,
11836+
// BaselineCompileFunctions. We expect the vector we get in return to be
11837+
// empty since that's what we swapped for the stack vector in our
11838+
// constructor.
11839+
MOZ_ASSERT(stk_.empty());
11840+
}
1180311841

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

11921+
// The compiler's operand stack. We reuse it across all functions so as to
11922+
// avoid malloc/free. Presize it to 128 elements in the hope of avoiding
11923+
// reallocation later.
11924+
StkVector stk;
11925+
if (!stk.reserve(128)) {
11926+
return false;
11927+
}
11928+
1188311929
for (const FuncCompileInput& func : inputs) {
1188411930
Decoder d(func.begin, func.end, func.lineOrBytecode, error);
1188511931

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

1189811944
BaseCompiler f(env, func, locals, trapExitLayout, trapExitLayoutNumWords, d,
11899-
&alloc, &masm, &code->stackMaps);
11945+
stk, &alloc, &masm, &code->stackMaps);
1190011946
if (!f.init()) {
1190111947
return false;
1190211948
}

js/src/wasm/WasmTypes.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ class Module;
105105
class Instance;
106106
class Table;
107107

108-
typedef Vector<uint32_t, 0, SystemAllocPolicy> Uint32Vector;
108+
// Uint32Vector has initial size 8 on the basis that the dominant use cases
109+
// (line numbers and control stacks) tend to have a small but nonzero number
110+
// of elements.
111+
typedef Vector<uint32_t, 8, SystemAllocPolicy> Uint32Vector;
112+
109113
typedef Vector<uint8_t, 0, SystemAllocPolicy> Bytes;
110114
typedef UniquePtr<Bytes> UniqueBytes;
111115
typedef UniquePtr<const Bytes> UniqueConstBytes;
@@ -451,7 +455,10 @@ class ValType {
451455
bool operator!=(Code that) const { return !(*this == that); }
452456
};
453457

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

456463
// ValType utilities
457464

mfbt/Assertions.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,31 @@ struct AssertionConditionType {
691691
} while (false)
692692
#endif
693693

694+
/*
695+
* MOZ_DIAGNOSTIC_ALWAYS_TRUE is like MOZ_ALWAYS_TRUE, but using
696+
* MOZ_DIAGNOSTIC_ASSERT as the underlying assert.
697+
*
698+
* See the block comment for MOZ_DIAGNOSTIC_ASSERT above for more details on how
699+
* diagnostic assertions work and how to use them.
700+
*/
701+
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
702+
# define MOZ_DIAGNOSTIC_ALWAYS_TRUE(expr) \
703+
do { \
704+
if ((expr)) { \
705+
/* Do nothing. */ \
706+
} else { \
707+
MOZ_DIAGNOSTIC_ASSERT(false, #expr); \
708+
} \
709+
} while (false)
710+
#else
711+
# define MOZ_DIAGNOSTIC_ALWAYS_TRUE(expr) \
712+
do { \
713+
if ((expr)) { \
714+
/* Silence MOZ_MUST_USE. */ \
715+
} \
716+
} while (false)
717+
#endif
718+
694719
#undef MOZ_DUMP_ASSERTION_STACK
695720
#undef MOZ_CRASH_CRASHREPORT
696721

taskcluster/ci/beetmover-repackage/kind.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ job-template:
5858
attributes:
5959
artifact_map:
6060
by-project:
61-
mozilla-release: taskcluster/taskgraph/manifests/firefox_candidates.yml
62-
mozilla-beta: taskcluster/taskgraph/manifests/firefox_candidates.yml
6361
default: taskcluster/taskgraph/manifests/firefox_nightly.yml
62+
mozilla-beta: taskcluster/taskgraph/manifests/firefox_candidates.yml
63+
mozilla-release: taskcluster/taskgraph/manifests/firefox_candidates.yml

taskcluster/ci/release-beetmover-signed-langpacks-checksums/kind.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ kind-dependencies:
1414

1515
job-template:
1616
shipping-phase: promote
17+
attributes:
18+
artifact_prefix: public
19+
artifact_map: taskcluster/taskgraph/manifests/firefox_candidates_checksums.yml

taskcluster/ci/release-beetmover-signed-langpacks/kind.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ job-template:
2424
staging: scriptworker-prov-v1/beetmoverworker-dev
2525
run-on-projects: []
2626
shipping-phase: promote
27+
attributes:
28+
artifact_map: taskcluster/taskgraph/manifests/firefox_candidates.yml

0 commit comments

Comments
 (0)