Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Invalidate scripts when forbidding compilation (bug 792552, r=jandem).
Browse files Browse the repository at this point in the history
  • Loading branch information
David Anderson committed Sep 21, 2012
1 parent cb3030b commit f689ad5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
30 changes: 17 additions & 13 deletions js/src/ion/Ion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ TestIonCompile(JSContext *cx, JSScript *script, JSFunction *fun, jsbytecode *osr
{
if (!IonCompile<TestCompiler>(cx, script, fun, osrPc, constructing)) {
if (!cx->isExceptionPending())
ForbidCompilation(script);
ForbidCompilation(cx, script);
return false;
}
return true;
Expand Down Expand Up @@ -1202,7 +1202,7 @@ ion::CanEnterAtBranch(JSContext *cx, HandleScript script, StackFrame *fp, jsbyte

// Mark as forbidden if frame can't be handled.
if (!CheckFrame(fp)) {
ForbidCompilation(script);
ForbidCompilation(cx, script);
return Method_CantCompile;
}

Expand All @@ -1211,7 +1211,7 @@ ion::CanEnterAtBranch(JSContext *cx, HandleScript script, StackFrame *fp, jsbyte
MethodStatus status = Compile<TestCompiler>(cx, script, fun, pc, false);
if (status != Method_Compiled) {
if (status == Method_CantCompile)
ForbidCompilation(script);
ForbidCompilation(cx, script);
return status;
}

Expand Down Expand Up @@ -1258,7 +1258,7 @@ ion::CanEnter(JSContext *cx, HandleScript script, StackFrame *fp, bool newType)

// Mark as forbidden if frame can't be handled.
if (!CheckFrame(fp)) {
ForbidCompilation(script);
ForbidCompilation(cx, script);
return Method_CantCompile;
}

Expand All @@ -1267,7 +1267,7 @@ ion::CanEnter(JSContext *cx, HandleScript script, StackFrame *fp, bool newType)
MethodStatus status = Compile<TestCompiler>(cx, script, fun, NULL, fp->isConstructing());
if (status != Method_Compiled) {
if (status == Method_CantCompile)
ForbidCompilation(script);
ForbidCompilation(cx, script);
return status;
}

Expand Down Expand Up @@ -1634,7 +1634,9 @@ ion::Invalidate(JSContext *cx, JSScript *script, bool resetUses)
JS_ASSERT(script->hasIonScript());

Vector<types::RecompileInfo> scripts(cx);
scripts.append(script->ionScript()->recompileInfo());
if (!scripts.append(script->ionScript()->recompileInfo()))
return false;

Invalidate(cx, scripts, resetUses);
return true;
}
Expand Down Expand Up @@ -1667,17 +1669,19 @@ ion::MarkFromIon(JSCompartment *comp, Value *vp)
}

void
ion::ForbidCompilation(JSScript *script)
ion::ForbidCompilation(JSContext *cx, JSScript *script)
{
IonSpew(IonSpew_Abort, "Disabling Ion compilation of script %s:%d",
script->filename, script->lineno);

if (script->hasIonScript() && script->compartment()->needsBarrier()) {
// We're about to remove edges from the JSScript to gcthings
// embedded in the IonScript. Perform one final trace of the
// IonScript for the incremental GC, as it must know about
// those edges.
IonScript::Trace(script->compartment()->barrierTracer(), script->ion);
if (script->hasIonScript()) {
// It is only safe to modify script->ion if the script is not currently
// running, because IonFrameIterator needs to tell what ionScript to
// use (either the one on the JSScript, or the one hidden in the
// breadcrumbs Invalidation() leaves). Therefore, if invalidation
// fails, we cannot disable the script.
if (!Invalidate(cx, script, false))
return;
}

script->ion = ION_DISABLED_SCRIPT;
Expand Down
2 changes: 1 addition & 1 deletion js/src/ion/Ion.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static inline bool IsEnabled(JSContext *cx)
return cx->hasRunOption(JSOPTION_ION) && cx->typeInferenceEnabled();
}

void ForbidCompilation(JSScript *script);
void ForbidCompilation(JSContext *cx, JSScript *script);
uint32_t UsesBeforeIonRecompile(JSScript *script, jsbytecode *pc);

} // namespace ion
Expand Down
7 changes: 3 additions & 4 deletions js/src/ion/VMFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ InvokeFunction(JSContext *cx, JSFunction *fun, uint32 argc, Value *argv, Value *
JSScript *script = GetTopIonJSScript(cx);
if (script->hasIonScript() && ++script->ion->slowCallCount >= js_IonOptions.slowCallLimit) {
AutoFlushCache afc("InvokeFunction");
Invalidate(cx, script, false);

// Finally, poison the script so we don't try to run it again
ForbidCompilation(script);
// Poison the script so we don't try to run it again. This will
// trigger invalidation.
ForbidCompilation(cx, script);
}
}


// TI will return false for monitorReturnTypes, meaning there is no
// TypeBarrier or Monitor instruction following this. However, we need to
// explicitly monitor if the callee has not been analyzed yet. We special
Expand Down
2 changes: 1 addition & 1 deletion js/src/jsfun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValu
// detecting its use early.
JSScript *script = iter.script();
if (!script->hasIonScript())
ion::ForbidCompilation(script);
ion::ForbidCompilation(cx, script);
#endif

vp.setObject(*argsobj);
Expand Down

0 comments on commit f689ad5

Please sign in to comment.