Bug 1352506: Don't conflate need for overrecursed check and static alignment in MIRGenerator; r=jandem

--HG--
extra : rebase_source : 6bded02c13b2456082925647c062b9f52e0c9a93
extra : histedit_source : 934351707818b5f3b34c83e18b5ccfba94b46ff3
This commit is contained in:
Benjamin Bouvier 2017-04-27 15:44:45 +02:00
parent b8c8ba37aa
commit b3dc24542f
5 changed files with 41 additions and 31 deletions

View File

@ -2265,13 +2265,13 @@ LIRGenerator::visitTruncateToInt32(MTruncateToInt32* truncate)
case MIRType::Double:
// May call into JS::ToInt32() on the slow OOL path.
gen->setPerformsCall();
gen->setNeedsStaticStackAlignment();
lowerTruncateDToInt32(truncate);
break;
case MIRType::Float32:
// May call into JS::ToInt32() on the slow OOL path.
gen->setPerformsCall();
gen->setNeedsStaticStackAlignment();
lowerTruncateFToInt32(truncate);
break;
@ -3705,10 +3705,9 @@ LIRGenerator::visitGetNameCache(MGetNameCache* ins)
{
MOZ_ASSERT(ins->envObj()->type() == MIRType::Object);
// Set the performs-call flag so that we don't omit the overrecursed check.
// This is necessary because the cache can attach a scripted getter stub
// that calls this script recursively.
gen->setPerformsCall();
// Emit an overrecursed check: this is necessary because the cache can
// attach a scripted getter stub that calls this script recursively.
gen->setNeedsOverrecursedCheck();
LGetNameCache* lir = new(alloc()) LGetNameCache(useRegister(ins->envObj()), temp());
defineBox(lir, ins);
@ -3736,10 +3735,9 @@ LIRGenerator::visitGetPropertyCache(MGetPropertyCache* ins)
id->type() == MIRType::Value);
if (ins->monitoredResult()) {
// Set the performs-call flag so that we don't omit the overrecursed
// check. This is necessary because the cache can attach a scripted
// getter stub that calls this script recursively.
gen->setPerformsCall();
// Emit an overrecursed check: this is necessary because the cache can
// attach a scripted getter stub that calls this script recursively.
gen->setNeedsOverrecursedCheck();
}
// If this is a GETPROP, the id is a constant string. Allow passing it as a
@ -4011,10 +4009,9 @@ LIRGenerator::visitSetPropertyCache(MSetPropertyCache* ins)
bool useConstId = id->type() == MIRType::String || id->type() == MIRType::Symbol;
bool useConstValue = IsNonNurseryConstant(ins->value());
// Set the performs-call flag so that we don't omit the overrecursed check.
// This is necessary because the cache can attach a scripted setter stub
// that calls this script recursively.
gen->setPerformsCall();
// Emit an overrecursed check: this is necessary because the cache can
// attach a scripted setter stub that calls this script recursively.
gen->setNeedsOverrecursedCheck();
// We need a double/float32 temp register for typed array stubs if this is
// a SETELEM or INITELEM op.
@ -4212,11 +4209,11 @@ LIRGenerator::visitHasOwnCache(MHasOwnCache* ins)
id->type() == MIRType::Int32 ||
id->type() == MIRType::Value);
gen->setPerformsCall();
// Emit an overrecursed check: this is necessary because the cache can
// attach a scripted getter stub that calls this script recursively.
gen->setNeedsOverrecursedCheck();
LHasOwnCache* lir =
new(alloc()) LHasOwnCache(useBoxOrTyped(value),
useBoxOrTyped(id));
LHasOwnCache* lir = new(alloc()) LHasOwnCache(useBoxOrTyped(value), useBoxOrTyped(id));
define(lir, ins);
assignSafepoint(lir, ins);
}
@ -4933,8 +4930,10 @@ LIRGenerator::visitInstruction(MInstruction* ins)
return false;
ins->accept(this);
if (ins->possiblyCalls())
gen->setPerformsCall();
if (ins->possiblyCalls()) {
gen->setNeedsStaticStackAlignment();
gen->setNeedsOverrecursedCheck();
}
if (ins->resumePoint())
updateResumeState(ins);

View File

@ -146,12 +146,21 @@ class MIRGenerator
uint32_t minWasmHeapLength() const {
return minWasmHeapLength_;
}
void setPerformsCall() {
performsCall_ = true;
void setNeedsOverrecursedCheck() {
needsOverrecursedCheck_ = true;
}
bool performsCall() const {
return performsCall_;
bool needsOverrecursedCheck() const {
return needsOverrecursedCheck_;
}
void setNeedsStaticStackAlignment() {
needsStaticStackAlignment_ = true;
}
bool needsStaticStackAlignment() const {
return needsOverrecursedCheck_;
}
// Traverses the graph to find if there's any SIMD instruction. Costful but
// the value is cached, so don't worry about calling it several times.
bool usesSimd();
@ -182,7 +191,8 @@ class MIRGenerator
mozilla::Atomic<bool, mozilla::Relaxed> cancelBuild_;
uint32_t wasmMaxStackArgBytes_;
bool performsCall_;
bool needsOverrecursedCheck_;
bool needsStaticStackAlignment_;
bool usesSimd_;
bool cachedUsesSimd_;

View File

@ -30,7 +30,8 @@ MIRGenerator::MIRGenerator(CompileCompartment* compartment, const JitCompileOpti
pauseBuild_(nullptr),
cancelBuild_(false),
wasmMaxStackArgBytes_(0),
performsCall_(false),
needsOverrecursedCheck_(false),
needsStaticStackAlignment_(false),
usesSimd_(false),
cachedUsesSimd_(false),
modifiesFrameArguments_(false),

View File

@ -89,14 +89,14 @@ CodeGeneratorShared::CodeGeneratorShared(MIRGenerator* gen, LIRGraph* graph, Mac
if (gen->usesSimd()) {
// If the function uses any SIMD then we may need to insert padding
// so that local slots are aligned for SIMD.
frameInitialAdjustment_ = ComputeByteAlignment(sizeof(wasm::Frame),
WasmStackAlignment);
frameInitialAdjustment_ = ComputeByteAlignment(sizeof(wasm::Frame), WasmStackAlignment);
frameDepth_ += frameInitialAdjustment_;
// Keep the stack aligned. Some SIMD sequences build values on the
// stack and need the stack aligned.
frameDepth_ += ComputeByteAlignment(sizeof(wasm::Frame) + frameDepth_,
WasmStackAlignment);
} else if (gen->performsCall()) {
} else if (gen->needsStaticStackAlignment()) {
// An MWasmCall does not align the stack pointer at calls sites but
// instead relies on the a priori stack adjustment. This must be the
// last adjustment of frameDepth_.
@ -1490,7 +1490,7 @@ CodeGeneratorShared::omitOverRecursedCheck() const
// stack overflow check. Note that the actual number here is somewhat
// arbitrary, and codegen actually uses small bounded amounts of
// additional stack space in some cases too.
return frameSize() < 64 && !gen->performsCall();
return frameSize() < 64 && !gen->needsOverrecursedCheck();
}
void

View File

@ -235,7 +235,7 @@ LIRGeneratorShared::defineReturn(LInstruction* lir, MDefinition* mir)
lir->setMir(mir);
MOZ_ASSERT(lir->isCall());
gen->setPerformsCall();
gen->setNeedsStaticStackAlignment();
uint32_t vreg = getVirtualRegister();