Backed out changeset e3163482cc62 (bug 1635375) for bustages on BaselineIC.h. CLOSED TREE

This commit is contained in:
Csoregi Natalia 2020-07-07 09:27:06 +03:00
parent 4c0df0de7c
commit 0d0251640f
7 changed files with 39 additions and 102 deletions

View File

@ -1706,11 +1706,6 @@ static void HandleBoundsCheckFailure(JSContext* cx, HandleScript outerScript,
static void HandleShapeGuardFailure(JSContext* cx, HandleScript outerScript,
HandleScript innerScript) {
if (JitOptions.warpBuilder) {
// Warp handles this by invalidating when the IC stub changes.
return;
}
JitSpew(JitSpew_IonBailouts,
"Shape guard failure %s:%u:%u, inlined into %s:%u:%u",
innerScript->filename(), innerScript->lineno(), innerScript->column(),
@ -1727,11 +1722,6 @@ static void HandleShapeGuardFailure(JSContext* cx, HandleScript outerScript,
static void HandleBaselineInfoBailout(JSContext* cx, HandleScript outerScript,
HandleScript innerScript) {
if (JitOptions.warpBuilder) {
// Warp handles this by invalidating when the IC stub changes.
return;
}
JitSpew(JitSpew_IonBailouts,
"Baseline info failure %s:%u:%u, inlined into %s:%u:%u",
innerScript->filename(), innerScript->lineno(), innerScript->column(),

View File

@ -2215,7 +2215,6 @@ ICStub* js::jit::AttachBaselineCacheIRStub(
// attach. Just return nullptr, the caller should do nothing in this
// case.
if (updated) {
stub->maybeInvalidateWarp(cx, outerScript);
*attached = true;
} else {
JitSpew(JitSpew_BaselineICFallback,
@ -2241,8 +2240,6 @@ ICStub* js::jit::AttachBaselineCacheIRStub(
// about the chain much easier.
ResetEnteredCounts(stub);
stub->maybeInvalidateWarp(cx, outerScript);
switch (stubKind) {
case BaselineCacheIRStubKind::Regular: {
auto newStub = new (newStubMem) ICCacheIR_Regular(code, stubInfo);

View File

@ -546,14 +546,12 @@ ICStubIterator& ICStubIterator::operator++() {
return *this;
}
void ICStubIterator::unlink(JSContext* cx, JSScript* script) {
void ICStubIterator::unlink(JSContext* cx) {
MOZ_ASSERT(currentStub_->next() != nullptr);
MOZ_ASSERT(currentStub_ != fallbackStub_);
MOZ_ASSERT(!unlinked_);
fallbackStub_->maybeInvalidateWarp(cx, script);
fallbackStub_->unlinkStubDontInvalidateWarp(cx->zone(), previousStub_,
currentStub_);
fallbackStub_->unlinkStub(cx->zone(), previousStub_, currentStub_);
// Mark the current iterator position as unlinked, so operator++ works
// properly.
@ -605,19 +603,6 @@ uint32_t ICStub::getEnteredCount() const {
}
}
void ICFallbackStub::maybeInvalidateWarp(JSContext* cx, JSScript* script) {
if (!state_.usedByTranspiler()) {
return;
}
MOZ_ASSERT(JitOptions.warpBuilder);
clearUsedByTranspiler();
if (script->hasIonScript()) {
Invalidate(cx, script);
}
}
void ICStub::updateCode(JitCode* code) {
// Write barrier on the old code.
JitCode::writeBarrierPre(jitCode());
@ -787,7 +772,7 @@ static void TryAttachStub(const char* name, JSContext* cx, BaselineFrame* frame,
ICFallbackStub* stub, BaselineCacheIRStubKind kind,
Args&&... args) {
if (stub->state().maybeTransition()) {
stub->discardStubs(cx, frame->script());
stub->discardStubs(cx);
}
if (stub->state().canAttachStub()) {
@ -820,8 +805,7 @@ static void TryAttachStub(const char* name, JSContext* cx, BaselineFrame* frame,
}
}
void ICFallbackStub::unlinkStubDontInvalidateWarp(Zone* zone, ICStub* prev,
ICStub* stub) {
void ICFallbackStub::unlinkStub(Zone* zone, ICStub* prev, ICStub* stub) {
MOZ_ASSERT(stub->next());
if (prev) {
@ -865,9 +849,9 @@ void ICFallbackStub::unlinkStubDontInvalidateWarp(Zone* zone, ICStub* prev,
#endif
}
void ICFallbackStub::discardStubs(JSContext* cx, JSScript* script) {
void ICFallbackStub::discardStubs(JSContext* cx) {
for (ICStubIterator iter = beginChain(); !iter.atEnd(); iter++) {
iter.unlink(cx, script);
iter.unlink(cx);
}
}
@ -1833,8 +1817,7 @@ bool FallbackICCodeCompiler::emit_ToBool() {
return tailCallVM<Fn, DoToBoolFallback>(masm);
}
static void StripPreliminaryObjectStubs(JSContext* cx, ICFallbackStub* stub,
JSScript* script) {
static void StripPreliminaryObjectStubs(JSContext* cx, ICFallbackStub* stub) {
// Before the new script properties analysis has been performed on a type,
// all instances of that type have the maximum number of fixed slots.
// Afterwards, the objects (even the preliminary ones) might be changed
@ -1847,13 +1830,13 @@ static void StripPreliminaryObjectStubs(JSContext* cx, ICFallbackStub* stub,
for (ICStubIterator iter = stub->beginChain(); !iter.atEnd(); iter++) {
if (iter->isCacheIR_Regular() &&
iter->toCacheIR_Regular()->hasPreliminaryObject()) {
iter.unlink(cx, script);
iter.unlink(cx);
} else if (iter->isCacheIR_Monitored() &&
iter->toCacheIR_Monitored()->hasPreliminaryObject()) {
iter.unlink(cx, script);
iter.unlink(cx);
} else if (iter->isCacheIR_Updated() &&
iter->toCacheIR_Updated()->hasPreliminaryObject()) {
iter.unlink(cx, script);
iter.unlink(cx);
}
}
}
@ -1865,7 +1848,7 @@ static bool TryAttachGetPropStub(const char* name, JSContext* cx,
bool attached = false;
if (stub->state().maybeTransition()) {
stub->discardStubs(cx, frame->script());
stub->discardStubs(cx);
}
if (stub->state().canAttachStub()) {
@ -1886,7 +1869,7 @@ static bool TryAttachGetPropStub(const char* name, JSContext* cx,
if (gen.shouldNotePreliminaryObjectStub()) {
newStub->toCacheIR_Monitored()->notePreliminaryObject();
} else if (gen.shouldUnlinkPreliminaryObjectStubs()) {
StripPreliminaryObjectStubs(cx, stub, script);
StripPreliminaryObjectStubs(cx, stub);
}
}
} break;
@ -2147,7 +2130,7 @@ bool DoSetElemFallback(JSContext* cx, BaselineFrame* frame,
bool attached = false;
if (stub->state().maybeTransition()) {
stub->discardStubs(cx, script);
stub->discardStubs(cx);
}
if (stub->state().canAttachStub()) {
@ -2168,7 +2151,7 @@ bool DoSetElemFallback(JSContext* cx, BaselineFrame* frame,
if (gen.shouldNotePreliminaryObjectStub()) {
newStub->toCacheIR_Updated()->notePreliminaryObject();
} else if (gen.shouldUnlinkPreliminaryObjectStubs()) {
StripPreliminaryObjectStubs(cx, stub, script);
StripPreliminaryObjectStubs(cx, stub);
}
if (gen.attachedTypedArrayOOBStub()) {
@ -2229,7 +2212,7 @@ bool DoSetElemFallback(JSContext* cx, BaselineFrame* frame,
// The SetObjectElement call might have entered this IC recursively, so try
// to transition.
if (stub->state().maybeTransition()) {
stub->discardStubs(cx, script);
stub->discardStubs(cx);
}
bool canAttachStub = stub->state().canAttachStub();
@ -2256,7 +2239,7 @@ bool DoSetElemFallback(JSContext* cx, BaselineFrame* frame,
if (gen.shouldNotePreliminaryObjectStub()) {
newStub->toCacheIR_Updated()->notePreliminaryObject();
} else if (gen.shouldUnlinkPreliminaryObjectStubs()) {
StripPreliminaryObjectStubs(cx, stub, script);
StripPreliminaryObjectStubs(cx, stub);
}
}
} break;
@ -2739,7 +2722,7 @@ bool DoSetPropFallback(JSContext* cx, BaselineFrame* frame,
DeferType deferType = DeferType::None;
bool attached = false;
if (stub->state().maybeTransition()) {
stub->discardStubs(cx, script);
stub->discardStubs(cx);
}
if (stub->state().canAttachStub()) {
@ -2761,7 +2744,7 @@ bool DoSetPropFallback(JSContext* cx, BaselineFrame* frame,
if (gen.shouldNotePreliminaryObjectStub()) {
newStub->toCacheIR_Updated()->notePreliminaryObject();
} else if (gen.shouldUnlinkPreliminaryObjectStubs()) {
StripPreliminaryObjectStubs(cx, stub, script);
StripPreliminaryObjectStubs(cx, stub);
}
}
} break;
@ -2818,7 +2801,7 @@ bool DoSetPropFallback(JSContext* cx, BaselineFrame* frame,
// The SetProperty call might have entered this IC recursively, so try
// to transition.
if (stub->state().maybeTransition()) {
stub->discardStubs(cx, script);
stub->discardStubs(cx);
}
bool canAttachStub = stub->state().canAttachStub();
@ -2846,7 +2829,7 @@ bool DoSetPropFallback(JSContext* cx, BaselineFrame* frame,
if (gen.shouldNotePreliminaryObjectStub()) {
newStub->toCacheIR_Updated()->notePreliminaryObject();
} else if (gen.shouldUnlinkPreliminaryObjectStubs()) {
StripPreliminaryObjectStubs(cx, stub, script);
StripPreliminaryObjectStubs(cx, stub);
}
}
} break;
@ -2943,7 +2926,7 @@ bool DoCallFallback(JSContext* cx, BaselineFrame* frame, ICCall_Fallback* stub,
// Transition stub state to megamorphic or generic if warranted.
if (stub->state().maybeTransition()) {
stub->discardStubs(cx, script);
stub->discardStubs(cx);
}
bool canAttachStub = stub->state().canAttachStub();
@ -3016,7 +2999,7 @@ bool DoCallFallback(JSContext* cx, BaselineFrame* frame, ICCall_Fallback* stub,
// Try to transition again in case we called this IC recursively.
if (stub->state().maybeTransition()) {
stub->discardStubs(cx, script);
stub->discardStubs(cx);
}
canAttachStub = stub->state().canAttachStub();
@ -3076,7 +3059,7 @@ bool DoSpreadCallFallback(JSContext* cx, BaselineFrame* frame,
// Transition stub state to megamorphic or generic if warranted.
if (stub->state().maybeTransition()) {
stub->discardStubs(cx, script);
stub->discardStubs(cx);
}
// Try attaching a call stub.

View File

@ -373,7 +373,7 @@ class ICStubIterator {
bool atEnd() const { return currentStub_ == (ICStub*)fallbackStub_; }
void unlink(JSContext* cx, JSScript* script);
void unlink(JSContext* cx);
};
//
@ -705,16 +705,9 @@ class ICFallbackStub : public ICStub {
ICStubIterator beginChain() { return ICStubIterator(this); }
void discardStubs(JSContext* cx, JSScript* script);
void discardStubs(JSContext* cx);
void clearUsedByTranspiler() { state_.clearUsedByTranspiler(); }
void setUsedByTranspiler() { state_.setUsedByTranspiler(); }
// If the transpiler optimized based on this IC, invalidate the script's Warp
// code.
void maybeInvalidateWarp(JSContext* cx, JSScript* script);
void unlinkStubDontInvalidateWarp(Zone* zone, ICStub* prev, ICStub* stub);
void unlinkStub(Zone* zone, ICStub* prev, ICStub* stub);
// Return the number of times this stub has successfully provided a value to
// the caller.

View File

@ -26,11 +26,7 @@ class ICState {
enum class Mode : uint8_t { Specialized = 0, Megamorphic, Generic };
private:
uint32_t mode_ : 2;
// Whether WarpOracle created a snapshot based on stubs attached to this
// Baseline IC.
bool usedByTranspiler_ : 1;
Mode mode_;
// Number of optimized stubs currently attached to this IC.
uint8_t numOptimizedStubs_;
@ -40,14 +36,9 @@ class ICState {
static const size_t MaxOptimizedStubs = 6;
void setMode(Mode mode) {
mode_ = uint32_t(mode);
MOZ_ASSERT(Mode(mode_) == mode, "mode must fit in bitfield");
}
void transition(Mode mode) {
MOZ_ASSERT(mode > this->mode());
setMode(mode);
MOZ_ASSERT(mode > mode_);
mode_ = mode;
numFailures_ = 0;
}
@ -63,7 +54,7 @@ class ICState {
public:
ICState() { reset(); }
Mode mode() const { return Mode(mode_); }
Mode mode() const { return mode_; }
size_t numOptimizedStubs() const { return numOptimizedStubs_; }
bool hasFailures() const { return (numFailures_ != 0); }
@ -71,7 +62,7 @@ class ICState {
// Note: we cannot assert that numOptimizedStubs_ <= MaxOptimizedStubs
// because old-style baseline ICs may attach more stubs than
// MaxOptimizedStubs allows.
if (mode() == Mode::Generic || JitOptions.disableCacheIR) {
if (mode_ == Mode::Generic || JitOptions.disableCacheIR) {
return false;
}
return true;
@ -83,24 +74,23 @@ class ICState {
// Note: we cannot assert that numOptimizedStubs_ <= MaxOptimizedStubs
// because old-style baseline ICs may attach more stubs than
// MaxOptimizedStubs allows.
if (mode() == Mode::Generic) {
if (mode_ == Mode::Generic) {
return false;
}
if (numOptimizedStubs_ < MaxOptimizedStubs &&
numFailures_ < maxFailures()) {
return false;
}
if (numFailures_ == maxFailures() || mode() == Mode::Megamorphic) {
if (numFailures_ == maxFailures() || mode_ == Mode::Megamorphic) {
transition(Mode::Generic);
return true;
}
MOZ_ASSERT(mode() == Mode::Specialized);
MOZ_ASSERT(mode_ == Mode::Specialized);
transition(Mode::Megamorphic);
return true;
}
void reset() {
setMode(Mode::Specialized);
usedByTranspiler_ = false;
mode_ = Mode::Specialized;
numOptimizedStubs_ = 0;
numFailures_ = 0;
}
@ -128,10 +118,6 @@ class ICState {
numOptimizedStubs_--;
}
void trackUnlinkedAllStubs() { numOptimizedStubs_ = 0; }
void clearUsedByTranspiler() { usedByTranspiler_ = false; }
void setUsedByTranspiler() { usedByTranspiler_ = true; }
bool usedByTranspiler() const { return usedByTranspiler_; }
};
} // namespace jit

View File

@ -494,11 +494,7 @@ void ICScript::purgeOptimizedStubs(Zone* zone) {
while (stub->next()) {
if (!stub->allocatedInFallbackSpace()) {
// Note: this is called when discarding JIT code, after invalidating
// all Warp code, so we don't need to check for that here.
lastStub->toFallbackStub()->clearUsedByTranspiler();
lastStub->toFallbackStub()->unlinkStubDontInvalidateWarp(zone, prev,
stub);
lastStub->toFallbackStub()->unlinkStub(zone, prev, stub);
stub = stub->next();
continue;
}

View File

@ -727,16 +727,10 @@ AbortReasonOr<Ok> WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots,
const ICEntry& entry = getICEntry(loc);
ICStub* stub = entry.firstStub();
ICFallbackStub* fallbackStub = entry.fallbackStub();
uint32_t offset = loc.bytecodeToOffset(script_);
// Clear the used-by-transpiler flag on the IC. It can still be set from a
// previous compilation because we don't clear the flag on every IC when
// invalidating.
fallbackStub->clearUsedByTranspiler();
if (stub == fallbackStub) {
if (stub->isFallback()) {
[[maybe_unused]] unsigned line, column;
LineNumberAndColumn(script_, loc, &line, &column);
@ -744,11 +738,11 @@ AbortReasonOr<Ok> WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots,
JitSpew(JitSpew_WarpTranspiler,
"fallback stub (entered-count: %" PRIu32
") for JSOp::%s @ %s:%u:%u",
fallbackStub->enteredCount(), CodeName(loc.getOp()),
stub->toFallbackStub()->enteredCount(), CodeName(loc.getOp()),
script_->filename(), line, column);
// If the fallback stub was used but there's no optimized stub, use an IC.
if (fallbackStub->enteredCount() != 0) {
if (stub->toFallbackStub()->enteredCount() != 0) {
return Ok();
}
@ -860,7 +854,5 @@ AbortReasonOr<Ok> WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots,
return abort(AbortReason::Alloc);
}
fallbackStub->setUsedByTranspiler();
return Ok();
}