Bug 1500187: Add entry counters to CacheIR_Monitored and CacheIR_Updated stubs r=jandem

This patch also extracts the shared functionality in the CacheIR stubs into a
seperate trait class.

Differential Revision: https://phabricator.services.mozilla.com/D11222

--HG--
extra : rebase_source : 9ae0421d0dbe93ede33c01fa06492f95cce8e479
This commit is contained in:
Matthew Gaudet 2018-11-07 13:00:42 -05:00
Родитель 59e4d470eb
Коммит 9400094ab4
3 изменённых файлов: 54 добавлений и 33 удалений

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

@ -164,6 +164,20 @@ BaselineCacheIRCompiler::tailCallVM(MacroAssembler& masm, const VMFunction& fun)
return true;
}
static size_t
GetEnteredOffset(BaselineCacheIRStubKind kind)
{
switch (kind) {
case BaselineCacheIRStubKind::Regular:
return ICCacheIR_Regular::offsetOfEnteredCount();
case BaselineCacheIRStubKind::Updated:
return ICCacheIR_Updated::offsetOfEnteredCount();
case BaselineCacheIRStubKind::Monitored:
return ICCacheIR_Monitored::offsetOfEnteredCount();
}
MOZ_CRASH("unhandled BaselineCacheIRStubKind");
}
JitCode*
BaselineCacheIRCompiler::compile()
{
@ -177,10 +191,8 @@ BaselineCacheIRCompiler::compile()
#endif
// Count stub entries: We count entries rather than successes as it much easier to
// ensure ICStubReg is valid at entry than at exit.
if (kind_ == BaselineCacheIRStubKind::Regular) {
Address enteredCount(ICStubReg, ICCacheIR_Regular::offsetOfEnteredCount());
masm.add32(Imm32(1), enteredCount);
}
Address enteredCount(ICStubReg, GetEnteredOffset(kind_));
masm.add32(Imm32(1), enteredCount);
do {
switch (reader.readOp()) {

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

@ -750,9 +750,11 @@ class ICFallbackStub : public ICStub
inline void incrementEnteredCount() { enteredCount_++; }
};
// Base class for Trait::Regular CacheIR stubs
class ICCacheIR_Regular : public ICStub
// Shared trait for all CacheIR stubs.
template <typename T>
class ICCacheIR_Trait
{
protected:
const CacheIRStubInfo* stubInfo_;
// Counts the number of times the stub was entered
@ -761,11 +763,29 @@ class ICCacheIR_Regular : public ICStub
// becomes a concern.
uint32_t enteredCount_;
public:
explicit ICCacheIR_Trait(const CacheIRStubInfo* stubInfo)
: stubInfo_(stubInfo),
enteredCount_(0)
{}
const CacheIRStubInfo* stubInfo() const {
return stubInfo_;
}
// Return the number of times this stub has successfully provided a value to the
// caller.
uint32_t enteredCount() const { return enteredCount_; }
static size_t offsetOfEnteredCount() { return offsetof(T, enteredCount_); }
};
// Base class for Trait::Regular CacheIR stubs
class ICCacheIR_Regular : public ICStub, public ICCacheIR_Trait<ICCacheIR_Regular>
{
public:
ICCacheIR_Regular(JitCode* stubCode, const CacheIRStubInfo* stubInfo)
: ICStub(ICStub::CacheIR_Regular, stubCode),
stubInfo_(stubInfo),
enteredCount_(0)
ICCacheIR_Trait(stubInfo)
{}
static ICCacheIR_Regular* Clone(JSContext* cx, ICStubSpace* space, ICStub* firstMonitorStub,
@ -778,16 +798,7 @@ class ICCacheIR_Regular : public ICStub
return extra_;
}
const CacheIRStubInfo* stubInfo() const {
return stubInfo_;
}
uint8_t* stubDataStart();
// Return the number of times this stub has successfully provided a value to the
// caller.
uint32_t enteredCount() const { return enteredCount_; }
static size_t offsetOfEnteredCount() { return offsetof(ICCacheIR_Regular, enteredCount_); }
};
// Monitored stubs are IC stubs that feed a single resulting value out to a
@ -820,15 +831,14 @@ class ICMonitoredStub : public ICStub
}
};
class ICCacheIR_Monitored : public ICMonitoredStub
class ICCacheIR_Monitored : public ICMonitoredStub, public ICCacheIR_Trait<ICCacheIR_Monitored>
{
const CacheIRStubInfo* stubInfo_;
public:
ICCacheIR_Monitored(JitCode* stubCode, ICStub* firstMonitorStub,
const CacheIRStubInfo* stubInfo)
: ICMonitoredStub(ICStub::CacheIR_Monitored, stubCode, firstMonitorStub),
stubInfo_(stubInfo)
ICCacheIR_Trait(stubInfo)
{}
static ICCacheIR_Monitored* Clone(JSContext* cx, ICStubSpace* space, ICStub* firstMonitorStub,
@ -841,10 +851,6 @@ class ICCacheIR_Monitored : public ICMonitoredStub
return extra_;
}
const CacheIRStubInfo* stubInfo() const {
return stubInfo_;
}
uint8_t* stubDataStart();
};
@ -917,16 +923,15 @@ class ICUpdatedStub : public ICStub
}
};
class ICCacheIR_Updated : public ICUpdatedStub
class ICCacheIR_Updated : public ICUpdatedStub, public ICCacheIR_Trait<ICCacheIR_Updated>
{
const CacheIRStubInfo* stubInfo_;
GCPtrObjectGroup updateStubGroup_;
GCPtrId updateStubId_;
public:
ICCacheIR_Updated(JitCode* stubCode, const CacheIRStubInfo* stubInfo)
: ICUpdatedStub(ICStub::CacheIR_Updated, stubCode),
stubInfo_(stubInfo),
ICCacheIR_Trait(stubInfo),
updateStubGroup_(nullptr),
updateStubId_(JSID_EMPTY)
{}
@ -948,10 +953,6 @@ class ICCacheIR_Updated : public ICUpdatedStub
return extra_;
}
const CacheIRStubInfo* stubInfo() const {
return stubInfo_;
}
uint8_t* stubDataStart();
};

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

@ -1171,11 +1171,19 @@ BaselineScript::purgeOptimizedStubs(Zone* zone)
static bool
GetStubEnteredCount(ICStub* stub, uint32_t* count)
{
if (stub->isCacheIR_Regular()) {
switch (stub->kind()) {
case ICStub::CacheIR_Regular:
*count = stub->toCacheIR_Regular()->enteredCount();
return true;
case ICStub::CacheIR_Updated:
*count = stub->toCacheIR_Updated()->enteredCount();
return true;
case ICStub::CacheIR_Monitored:
*count = stub->toCacheIR_Monitored()->enteredCount();
return true;
default:
return false;
}
return false;
}
void