Bug 1250964: SharedStubs - Don't add invalid stubs, r=jandem

This commit is contained in:
Hannes Verschore 2016-03-15 12:21:18 -04:00
Родитель b7670f9851
Коммит 474d0151fe
4 изменённых файлов: 38 добавлений и 7 удалений

Просмотреть файл

@ -64,7 +64,7 @@ class DebugModeOSRVolatileStub
bool invalid() const {
if (engine_ == ICStubCompiler::Engine::IonMonkey)
return false;
return stub_->invalid();
MOZ_ASSERT(!frame_->isHandlingException());
ICEntry& entry = frame_->script()->baselineScript()->icEntryFromPCOffset(pcOffset_);
return stub_ != entry.fallbackStub();

Просмотреть файл

@ -1228,15 +1228,19 @@ IonScript::purgeOptimizedStubs(Zone* zone)
stub = stub->next();
}
lastStub->toFallbackStub()->setInvalid();
if (lastStub->isMonitoredFallback()) {
// Monitor stubs can't make calls, so are always in the
// optimized stub space.
ICTypeMonitor_Fallback* lastMonStub =
lastStub->toMonitoredFallbackStub()->fallbackMonitorStub();
lastMonStub->resetMonitorStubChain(zone);
lastMonStub->setInvalid();
}
} else if (lastStub->isTypeMonitor_Fallback()) {
lastStub->toTypeMonitor_Fallback()->resetMonitorStubChain(zone);
lastStub->toTypeMonitor_Fallback()->setInvalid();
} else {
MOZ_ASSERT(lastStub->isTableSwitch());
}

Просмотреть файл

@ -931,6 +931,7 @@ SharedStubInfo::outerScript(JSContext* cx)
++it;
MOZ_ASSERT(it.isIonJS());
outerScript_ = it.script();
MOZ_ASSERT(!it.ionScript()->invalidated());
}
return outerScript_;
}
@ -3056,7 +3057,7 @@ DoGetPropFallback(JSContext* cx, void* payload, ICGetProp_Fallback* stub_,
// After the Genericstub was added, we should never reach the Fallbackstub again.
MOZ_ASSERT(!stub->hasStub(ICStub::GetProp_Generic));
if (stub->numOptimizedStubs() >= ICGetProp_Fallback::MAX_OPTIMIZED_STUBS) {
if (stub->numOptimizedStubs() >= ICGetProp_Fallback::MAX_OPTIMIZED_STUBS && !stub.invalid()) {
// Discard all stubs in this IC and replace with generic getprop stub.
for (ICStubIterator iter = stub->beginChain(); !iter.atEnd(); iter++)
iter.unlink(cx);
@ -3069,8 +3070,9 @@ DoGetPropFallback(JSContext* cx, void* payload, ICGetProp_Fallback* stub_,
attached = true;
}
if (!attached && !TryAttachNativeGetAccessorPropStub(cx, &info, stub, name, val, res, &attached,
&isTemporarilyUnoptimizable))
if (!attached && !stub.invalid() &&
!TryAttachNativeGetAccessorPropStub(cx, &info, stub, name, val, res, &attached,
&isTemporarilyUnoptimizable))
{
return false;
}
@ -4170,6 +4172,7 @@ DoGetPropGeneric(JSContext* cx, void* payload, ICGetProp_Generic* stub,
{
ICFallbackStub* fallback = stub->getChainFallback();
SharedStubInfo info(cx, payload, fallback->icEntry());
MOZ_ASSERT(info.outerScript(cx));
HandleScript script = info.innerScript();
jsbytecode* pc = info.pc();
JSOp op = JSOp(*pc);
@ -4777,7 +4780,7 @@ DoTypeMonitorFallback(JSContext* cx, void* payload, ICTypeMonitor_Fallback* stub
TypeScript::Monitor(cx, script, pc, value);
}
if (!stub->addMonitorStubForValue(cx, &info, value))
if (!stub->invalid() && !stub->addMonitorStubForValue(cx, &info, value))
return false;
// Copy input value to res.

Просмотреть файл

@ -759,7 +759,8 @@ class ICFallbackStub : public ICStub
ICEntry* icEntry_;
// The number of stubs kept in the IC entry.
uint32_t numOptimizedStubs_;
uint32_t numOptimizedStubs_ : 31;
uint32_t invalid_ : 1;
// A pointer to the location stub pointer that needs to be
// changed to add a new "last" stub immediately before the fallback
@ -772,12 +773,14 @@ class ICFallbackStub : public ICStub
: ICStub(kind, ICStub::Fallback, stubCode),
icEntry_(nullptr),
numOptimizedStubs_(0),
invalid_(false),
lastStubPtrAddr_(nullptr) {}
ICFallbackStub(Kind kind, Trait trait, JitCode* stubCode)
: ICStub(kind, trait, stubCode),
icEntry_(nullptr),
numOptimizedStubs_(0),
invalid_(false),
lastStubPtrAddr_(nullptr)
{
MOZ_ASSERT(trait == ICStub::Fallback ||
@ -793,6 +796,14 @@ class ICFallbackStub : public ICStub
return (size_t) numOptimizedStubs_;
}
void setInvalid() {
invalid_ = 1;
}
bool invalid() const {
return invalid_;
}
// The icEntry and lastStubPtrAddr_ fields can't be initialized when the stub is
// created since the stub is created at compile time, and we won't know the IC entry
// address until after compile when the JitScript is created. This method
@ -806,6 +817,7 @@ class ICFallbackStub : public ICStub
// Add a new stub to the IC chain terminated by this fallback stub.
void addNewStub(ICStub* stub) {
MOZ_ASSERT(!invalid());
MOZ_ASSERT(*lastStubPtrAddr_ == this);
MOZ_ASSERT(stub->next() == nullptr);
stub->setNext(this);
@ -1272,7 +1284,9 @@ class ICTypeMonitor_Fallback : public ICStub
ICStub** lastMonitorStubPtrAddr_;
// Count of optimized type monitor stubs in this chain.
uint32_t numOptimizedMonitorStubs_ : 8;
uint32_t numOptimizedMonitorStubs_ : 7;
uint32_t invalid_ : 1;
// Whether this has a fallback stub referring to the IC entry.
bool hasFallbackStub_ : 1;
@ -1290,6 +1304,7 @@ class ICTypeMonitor_Fallback : public ICStub
firstMonitorStub_(thisFromCtor()),
lastMonitorStubPtrAddr_(nullptr),
numOptimizedMonitorStubs_(0),
invalid_(false),
hasFallbackStub_(mainFallbackStub != nullptr),
argumentIndex_(argumentIndex)
{ }
@ -1299,6 +1314,7 @@ class ICTypeMonitor_Fallback : public ICStub
}
void addOptimizedMonitorStub(ICStub* stub) {
MOZ_ASSERT(!invalid());
stub->setNext(this);
MOZ_ASSERT((lastMonitorStubPtrAddr_ != nullptr) ==
@ -1352,6 +1368,14 @@ class ICTypeMonitor_Fallback : public ICStub
return numOptimizedMonitorStubs_;
}
void setInvalid() {
invalid_ = 1;
}
bool invalid() const {
return invalid_;
}
inline bool monitorsThis() const {
return argumentIndex_ == 0;
}