Bug 853394 - Enable ParallelArray tests, fix test failures. r=djvj
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 22 Mar 2013 11:23:10 +0100
changeset 127436 d34e3717e819724fcc0f5f2579530e74ab377dde
parent 127435 872c29501019d020a444538a3c234e0adc63a1ed
child 127437 d4656be592193788b86288abab6fbdf73c4aca3a
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdjvj
bugs853394
milestone22.0a1
Bug 853394 - Enable ParallelArray tests, fix test failures. r=djvj
js/src/ion/BaselineIC.cpp
js/src/jsinfer.cpp
js/src/vm/SelfHosting.cpp
--- a/js/src/ion/BaselineIC.cpp
+++ b/js/src/ion/BaselineIC.cpp
@@ -5346,16 +5346,19 @@ TryAttachCallStub(JSContext *cx, ICCall_
         return true;
 
     RootedFunction fun(cx, obj->toFunction());
     if (fun->hasScript()) {
         RootedScript calleeScript(cx, fun->nonLazyScript());
         if (!calleeScript->hasBaselineScript() && !calleeScript->hasIonScript())
             return true;
 
+        if (calleeScript->shouldCloneAtCallsite)
+            return true;
+
         // Check if this stub chain has already generalized scripted calls.
         if (stub->scriptedStubsAreGeneralized()) {
             IonSpew(IonSpew_BaselineIC, "  Chain already has generalized scripted call stub!");
             return true;
         }
 
         if (stub->scriptedStubCount() >= ICCall_Fallback::MAX_SCRIPTED_STUBS) {
             // Create a Call_AnyScripted stub.
@@ -5411,16 +5414,38 @@ TryAttachCallStub(JSContext *cx, ICCall_
         stub->addNewStub(newStub);
         return true;
     }
 
     return true;
 }
 
 static bool
+MaybeCloneFunctionAtCallsite(JSContext *cx, MutableHandleValue callee, HandleScript script,
+                             jsbytecode *pc)
+{
+    RootedFunction fun(cx);
+    if (!IsFunctionObject(callee, fun.address()))
+        return true;
+
+    if (!fun->hasScript() || !fun->nonLazyScript()->shouldCloneAtCallsite)
+        return true;
+
+    if (!cx->typeInferenceEnabled())
+        return true;
+
+    fun = CloneFunctionAtCallsite(cx, fun, script, pc);
+    if (!fun)
+        return false;
+
+    callee.setObject(*fun);
+    return true;
+}
+
+static bool
 DoCallFallback(JSContext *cx, BaselineFrame *frame, ICCall_Fallback *stub, uint32_t argc,
                Value *vp, MutableHandleValue res)
 {
     // Ensure vp array is rooted - we may GC in here.
     AutoArrayRooter vpRoot(cx, argc + 2, vp);
 
     RootedScript script(cx, frame->script());
     jsbytecode *pc = stub->icEntry()->pc(script);
@@ -5445,16 +5470,19 @@ DoCallFallback(JSContext *cx, BaselineFr
     bool newType = false;
     if (cx->typeInferenceEnabled())
         newType = types::UseNewType(cx, script, pc);
 
     // Try attaching a call stub.
     if (!TryAttachCallStub(cx, stub, script, op, argc, vp, constructing, newType))
         return false;
 
+    if (!MaybeCloneFunctionAtCallsite(cx, &callee, script, pc))
+        return false;
+
     if (op == JSOP_NEW) {
         if (!InvokeConstructor(cx, callee, argc, args, res.address()))
             return false;
     } else if (op == JSOP_EVAL && IsBuiltinEvalForScope(frame->scopeChain(), callee)) {
         if (!DirectEval(cx, CallArgsFromVp(argc, vp)))
             return false;
         res.set(vp[0]);
     } else {
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -20,16 +20,17 @@
 #include "jsobj.h"
 #include "jsscript.h"
 #include "jscntxt.h"
 #include "jsstr.h"
 #include "jsiter.h"
 #include "jsworkers.h"
 
 #ifdef JS_ION
+#include "ion/BaselineJIT.h"
 #include "ion/Ion.h"
 #include "ion/IonCompartment.h"
 #endif
 #include "frontend/TokenStream.h"
 #include "gc/Marking.h"
 #include "js/MemoryMetrics.h"
 #include "methodjit/MethodJIT.h"
 #include "methodjit/Retcon.h"
@@ -2905,17 +2906,18 @@ TypeCompartment::addPendingRecompile(JSC
             }
         }
     }
 
 # ifdef JS_ION
     CancelOffThreadIonCompile(cx->compartment, script);
 
     // Let the script warm up again before attempting another compile.
-    script->resetUseCount();
+    if (ion::IsBaselineEnabled(cx))
+        script->resetUseCount();
 
     if (script->hasIonScript())
         addPendingRecompile(cx, script->ionScript()->recompileInfo());
 
     if (script->hasParallelIonScript())
         addPendingRecompile(cx, script->parallelIonScript()->recompileInfo());
 # endif
 #endif
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -397,21 +397,17 @@ js::intrinsic_UnsafeSetElement(JSContext
  * conditions like --ion-eager or --no-ti.  However, running the tests
  * under those conditions HAS exposed bugs and thus we do not wish to
  * disable them entirely.  Instead, we simply disable the assertions
  * that state that no bailouts etc should occur.
  */
 static JSBool
 intrinsic_ParallelTestsShouldPass(JSContext *cx, unsigned argc, Value *vp)
 {
-    //XXX: FIXME: disable parallel array tests for now on the BC branch.
     CallArgs args = CallArgsFromVp(argc, vp);
-    args.rval().setBoolean(false);
-    return true;
-
 #if defined(JS_THREADSAFE) && defined(JS_ION)
     args.rval().setBoolean(ion::IsEnabled(cx) &&
                            !ion::js_IonOptions.eagerCompilation);
 #else
     args.rval().setBoolean(false);
 #endif
     return true;
 }