diff --git a/js/src/gc/Zone.cpp b/js/src/gc/Zone.cpp index 922d6bc4fbb8..171209ac4f74 100644 --- a/js/src/gc/Zone.cpp +++ b/js/src/gc/Zone.cpp @@ -321,14 +321,9 @@ void Zone::discardJitCode(FreeOp* fop, jit::FinishInvalidation(fop, script); // Discard baseline script if it's not marked as active. - if (discardBaselineCode && script->hasBaselineScript()) { - if (script->jitScript()->active()) { - // ICs will be purged so the script will need to warm back up before it - // can be inlined during Ion compilation. - script->baselineScript()->clearIonCompiledOrInlined(); - } else { - jit::FinishDiscardBaselineScript(fop, script); - } + if (discardBaselineCode && script->hasBaselineScript() && + !script->jitScript()->active()) { + jit::FinishDiscardBaselineScript(fop, script); } // Warm-up counter for scripts are reset on GC. After discarding code we @@ -354,6 +349,10 @@ void Zone::discardJitCode(FreeOp* fop, // stubs because the optimizedStubSpace will be purged below. if (discardBaselineCode) { jitScript->purgeOptimizedStubs(script); + + // ICs were purged so the script will need to warm back up before it can + // be inlined during Ion compilation. + jitScript->clearIonCompiledOrInlined(); } // Finally, reset the active flag. diff --git a/js/src/jit/BaselineJIT.h b/js/src/jit/BaselineJIT.h index 8a24a0626ae6..2907ee995a39 100644 --- a/js/src/jit/BaselineJIT.h +++ b/js/src/jit/BaselineJIT.h @@ -266,28 +266,21 @@ struct BaselineScript final { public: enum Flag { - // (1 << 0) and (1 << 1) are unused. - // Flag set when the script contains any writes to its on-stack // (rather than call object stored) arguments. - MODIFIES_ARGUMENTS = 1 << 2, + MODIFIES_ARGUMENTS = 1 << 0, // Flag set when compiled for use with Debugger. Handles various // Debugger hooks and compiles toggled calls for traps. - HAS_DEBUG_INSTRUMENTATION = 1 << 3, - - // Flag set if this script has ever been Ion compiled, either directly - // or inlined into another script. This is cleared when the script's - // type information or caches are cleared. - ION_COMPILED_OR_INLINED = 1 << 4, + HAS_DEBUG_INSTRUMENTATION = 1 << 1, // Flag is set if this script has profiling instrumentation turned on. - PROFILER_INSTRUMENTATION_ON = 1 << 5, + PROFILER_INSTRUMENTATION_ON = 1 << 2, // Whether this script uses its environment chain. This is currently // determined by the BytecodeAnalysis and cached on the BaselineScript // for IonBuilder. - USES_ENVIRONMENT_CHAIN = 1 << 6, + USES_ENVIRONMENT_CHAIN = 1 << 3, }; private: @@ -339,10 +332,6 @@ struct BaselineScript final { return flags_ & HAS_DEBUG_INSTRUMENTATION; } - void setIonCompiledOrInlined() { flags_ |= ION_COMPILED_OR_INLINED; } - void clearIonCompiledOrInlined() { flags_ &= ~ION_COMPILED_OR_INLINED; } - bool ionCompiledOrInlined() const { return flags_ & ION_COMPILED_OR_INLINED; } - void setUsesEnvironmentChain() { flags_ |= USES_ENVIRONMENT_CHAIN; } bool usesEnvironmentChain() const { return flags_ & USES_ENVIRONMENT_CHAIN; } diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index 40ae728eb6e0..7ccbe2031c82 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -182,7 +182,7 @@ IonBuilder::IonBuilder(JSContext* analysisContext, CompileRealm* realm, MOZ_ASSERT(script_->numBytecodeTypeSets() < JSScript::MaxBytecodeTypeSets); if (!info->isAnalysis()) { - script()->baselineScript()->setIonCompiledOrInlined(); + script()->jitScript()->setIonCompiledOrInlined(); } } @@ -4352,7 +4352,7 @@ IonBuilder::InliningDecision IonBuilder::makeInliningDecision( // as the caller has not run yet. if (targetScript->getWarmUpCount() < optimizationInfo().inliningWarmUpThreshold() && - !targetScript->baselineScript()->ionCompiledOrInlined() && + !targetScript->jitScript()->ionCompiledOrInlined() && info().analysisMode() != Analysis_DefiniteProperties) { trackOptimizationOutcome(TrackedOutcome::CantInlineNotHot); JitSpew(JitSpew_Inlining, diff --git a/js/src/jit/JitScript.h b/js/src/jit/JitScript.h index 85ad2e130dcb..9571fe98a3d6 100644 --- a/js/src/jit/JitScript.h +++ b/js/src/jit/JitScript.h @@ -132,6 +132,11 @@ class alignas(uintptr_t) JitScript final { // Whether freeze constraints for stack type sets have been generated. bool hasFreezeConstraints : 1; + + // Flag set if this script has ever been Ion compiled, either directly or + // inlined into another script. This is cleared when the script's type + // information or caches are cleared. + bool ionCompiledOrInlined : 1; }; Flags flags_ = {}; // Zero-initialize flags. @@ -179,6 +184,10 @@ class alignas(uintptr_t) JitScript final { inline bool typesNeedsSweep(Zone* zone) const; void sweepTypes(const js::AutoSweepJitScript& sweep, Zone* zone); + void setIonCompiledOrInlined() { flags_.ionCompiledOrInlined = true; } + void clearIonCompiledOrInlined() { flags_.ionCompiledOrInlined = false; } + bool ionCompiledOrInlined() const { return flags_.ionCompiledOrInlined; } + RecompileInfoVector& inlinedCompilations( const js::AutoSweepJitScript& sweep) { MOZ_ASSERT(sweep.jitScript() == this);