Bug 829175 - Allow reentering JM code if Ion was compiled for a different OSR point, r=dvander.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 14 Jan 2013 16:08:15 -0700
changeset 118806 73d7a2071c7c2acbb21d16c1b56623377deff677
parent 118805 43ae0a302e8c1701c95dc305cd49885f96ea67b0
child 118807 37eb156ec02cdfb65696b32f63b6fc121fd95890
push id24180
push useremorley@mozilla.com
push dateTue, 15 Jan 2013 22:58:27 +0000
treeherdermozilla-central@72e34ce7fd92 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs829175
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 829175 - Allow reentering JM code if Ion was compiled for a different OSR point, r=dvander.
js/src/methodjit/Compiler.cpp
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -932,17 +932,17 @@ MakeJITScript(JSContext *cx, HandleScrip
         CrossChunkEdge &edge = jitEdges[i];
         edge.shimLabel = shimCode + (size_t) edge.shimLabel;
     }
 
     return jit;
 }
 
 static inline bool
-IonGetsFirstChance(JSContext *cx, JSScript *script, CompileRequest request)
+IonGetsFirstChance(JSContext *cx, JSScript *script, jsbytecode *pc, CompileRequest request)
 {
 #ifdef JS_ION
     if (!ion::IsEnabled(cx))
         return false;
 
     // If the script is not hot, use JM. recompileCheckHelper will insert a check
     // to trigger a recompile when the script becomes hot.
     if (script->getUseCount() < ion::js_IonOptions.usesBeforeCompile)
@@ -955,16 +955,27 @@ IonGetsFirstChance(JSContext *cx, JSScri
     // If there's no way this script is going to be Ion compiled, let JM take over.
     if (!script->canIonCompile())
         return false;
 
     // If we cannot enter Ion because bailouts are expected, let JM take over.
     if (script->hasIonScript() && script->ion->bailoutExpected())
         return false;
 
+    // If we cannot enter Ion because it was compiled for OSR at a different PC,
+    // let JM take over until the PC is reached. Don't do this until the script
+    // reaches a high use count, as if we do this prematurely we may get stuck
+    // in JM code.
+    if (ion::js_IonOptions.parallelCompilation && script->hasIonScript() &&
+        pc && script->ionScript()->osrPc() && script->ionScript()->osrPc() != pc &&
+        script->getUseCount() >= ion::js_IonOptions.usesBeforeCompile * 2)
+    {
+        return false;
+    }
+
     // If ion compilation is pending or in progress on another thread, continue
     // using JM until that compilation finishes.
     if (script->ion == ION_COMPILING_SCRIPT)
         return false;
 
     return true;
 #endif
     return false;
@@ -993,18 +1004,21 @@ mjit::CanMethodJIT(JSContext *cx, Handle
      * good to go. If, however, the two are different, then we cannot emit JIT
      * code because the instrumentation will be wrong one way or another.
      */
     if (frame->script() == script && pc != script->code) {
         if (frame->hasPushedSPSFrame() != cx->runtime->spsProfiler.enabled())
             return Compile_Skipped;
     }
 
-    if (IonGetsFirstChance(cx, script, request))
+    if (IonGetsFirstChance(cx, script, pc, request)) {
+        if (script->hasIonScript())
+            script->incUseCount();
         return Compile_Skipped;
+    }
 
     if (script->hasMJITInfo()) {
         JSScript::JITScriptHandle *jith = script->jitHandle(construct, cx->compartment->compileBarriers());
         if (jith->isUnjittable())
             return Compile_Abort;
     }
 
     if (!cx->hasRunOption(JSOPTION_METHODJIT_ALWAYS) &&