Bug 1543230 - Move JSScript::warmUpResetCount into MutableFlags r=nbp

This data is only needed for testing but is currently messing with the
structure packing. This reduces the size of the field and packs it into
free space saving one word per script on certain platforms.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ted Campbell 2019-04-10 16:12:37 +00:00
parent deea4dfb09
commit 0d70efd9b7
2 changed files with 44 additions and 34 deletions

View File

@ -2664,6 +2664,11 @@ static bool testingFunc_bailAfter(JSContext* cx, unsigned argc, Value* vp) {
return true;
}
static constexpr unsigned JitWarmupResetLimit = 20;
static_assert(JitWarmupResetLimit <=
unsigned(JSScript::MutableFlags::WarmupResets_MASK),
"JitWarmupResetLimit exceeds max value");
static bool testingFunc_inJit(JSContext* cx, unsigned argc, Value* vp) {
CallArgs args = CallArgsFromVp(argc, vp);
@ -2680,7 +2685,7 @@ static bool testingFunc_inJit(JSContext* cx, unsigned argc, Value* vp) {
// succeeds. Note: This script may have be inlined into its caller.
if (iter.isJSJit()) {
iter.script()->resetWarmUpResetCounter();
} else if (iter.script()->getWarmUpResetCount() >= 20) {
} else if (iter.script()->getWarmUpResetCount() >= JitWarmupResetLimit) {
return ReturnStringCopy(
cx, args, "Compilation is being repeatedly prevented. Giving up.");
}
@ -2708,7 +2713,7 @@ static bool testingFunc_inIon(JSContext* cx, unsigned argc, Value* vp) {
// succeeds. Note: This script may have be inlined into its caller.
if (iter.isIon()) {
iter.script()->resetWarmUpResetCounter();
} else if (iter.script()->getWarmUpResetCount() >= 20) {
} else if (iter.script()->getWarmUpResetCount() >= JitWarmupResetLimit) {
return ReturnStringCopy(
cx, args, "Compilation is being repeatedly prevented. Giving up.");
}

View File

@ -1822,28 +1822,28 @@ class JSScript : public js::gc::TenuredCell {
// behavior of this script. This is only public for the JITs.
public:
enum class MutableFlags : uint32_t {
// Number of times the |warmUpCount| was forcibly discarded. The counter is
// reset when a script is successfully jit-compiled.
WarmupResets_MASK = 0xFF,
// Have warned about uses of undefined properties in this script.
WarnedAboutUndefinedProp = 1 << 0,
WarnedAboutUndefinedProp = 1 << 8,
// If treatAsRunOnce, whether script has executed.
HasRunOnce = 1 << 1,
HasRunOnce = 1 << 9,
// Script has been reused for a clone.
HasBeenCloned = 1 << 2,
HasBeenCloned = 1 << 10,
// Whether the record/replay execution progress counter (see RecordReplay.h)
// should be updated as this script runs.
TrackRecordReplayProgress = 1 << 3,
// (1 << 4) is unused.
TrackRecordReplayProgress = 1 << 11,
// Script has an entry in Realm::scriptCountsMap.
HasScriptCounts = 1 << 5,
HasScriptCounts = 1 << 12,
// Script has an entry in Realm::debugScriptMap.
HasDebugScript = 1 << 6,
// (1 << 7) and (1 << 8) are unused.
HasDebugScript = 1 << 13,
// Do not relazify this script. This is used by the relazify() testing
// function for scripts that are on the stack and also by the AutoDelazify
@ -1851,37 +1851,37 @@ class JSScript : public js::gc::TenuredCell {
// scripts on the stack, but the relazify() testing function overrides that,
// and sometimes we're working with a cross-compartment function and need to
// keep it from relazifying.
DoNotRelazify = 1 << 9,
DoNotRelazify = 1 << 14,
// IonMonkey compilation hints.
// Script has had hoisted bounds checks fail.
FailedBoundsCheck = 1 << 10,
FailedBoundsCheck = 1 << 15,
// Script has had hoisted shape guard fail.
FailedShapeGuard = 1 << 11,
FailedShapeGuard = 1 << 16,
HadFrequentBailouts = 1 << 12,
HadOverflowBailout = 1 << 13,
HadFrequentBailouts = 1 << 17,
HadOverflowBailout = 1 << 18,
// Explicitly marked as uninlineable.
Uninlineable = 1 << 14,
Uninlineable = 1 << 19,
// Idempotent cache has triggered invalidation.
InvalidatedIdempotentCache = 1 << 15,
InvalidatedIdempotentCache = 1 << 20,
// Lexical check did fail and bail out.
FailedLexicalCheck = 1 << 16,
FailedLexicalCheck = 1 << 21,
// See comments below.
NeedsArgsAnalysis = 1 << 17,
NeedsArgsObj = 1 << 18,
NeedsArgsAnalysis = 1 << 22,
NeedsArgsObj = 1 << 23,
// Set if the debugger's onNewScript hook has not yet been called.
HideScriptFromDebugger = 1 << 19,
HideScriptFromDebugger = 1 << 24,
// Set if the script has opted into spew
SpewEnabled = 1 << 20,
SpewEnabled = 1 << 25,
};
private:
@ -1891,12 +1891,6 @@ class JSScript : public js::gc::TenuredCell {
// 16-bit fields.
/**
* Number of times the |warmUpCount| was forcibly discarded. The counter is
* reset when a script is successfully jit-compiled.
*/
uint16_t warmUpResetCount = 0;
/* ES6 function length. */
uint16_t funLength_ = 0;
@ -2611,11 +2605,22 @@ class JSScript : public js::gc::TenuredCell {
warmUpCount = 0;
}
uint16_t getWarmUpResetCount() const { return warmUpResetCount; }
uint16_t incWarmUpResetCounter(uint16_t amount = 1) {
return warmUpResetCount += amount;
unsigned getWarmUpResetCount() const {
constexpr uint32_t MASK = uint32_t(MutableFlags::WarmupResets_MASK);
return mutableFlags_ & MASK;
}
void incWarmUpResetCounter() {
constexpr uint32_t MASK = uint32_t(MutableFlags::WarmupResets_MASK);
uint32_t newCount = getWarmUpResetCount() + 1;
if (newCount <= MASK) {
mutableFlags_ &= ~MASK;
mutableFlags_ |= newCount;
}
}
void resetWarmUpResetCounter() {
constexpr uint32_t MASK = uint32_t(MutableFlags::WarmupResets_MASK);
mutableFlags_ &= ~MASK;
}
void resetWarmUpResetCounter() { warmUpResetCount = 0; }
public:
bool initScriptCounts(JSContext* cx);