Bug 612329 - Don't cache code-ptr in Invoke gatling gun (r=waldo)
authorLuke Wagner <lw@mozilla.com>
Mon, 03 Jan 2011 09:06:30 -0800
changeset 59983 da972b14d0a44895ae132fd7dbde7a5519c29813
parent 59982 6b7627584c94b728462995521f9e3e2fcb104440
child 59984 42bc53a5b27f977655554cbc3dd598d4232b43f3
push id17820
push usercleary@mozilla.com
push dateTue, 04 Jan 2011 21:40:57 +0000
treeherdermozilla-central@969691cfe40e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs612329
milestone2.0b9pre
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 612329 - Don't cache code-ptr in Invoke gatling gun (r=waldo)
js/src/jsinterp.cpp
js/src/jsinterpinlines.h
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -761,20 +761,16 @@ InvokeSessionGuard::start(JSContext *cx,
     if (!stack.pushInvokeArgs(cx, argc, &args_))
         return false;
 
     /* Callees may clobber 'this' or 'callee'. */
     savedCallee_ = args_.callee() = calleev;
     savedThis_ = args_.thisv() = thisv;
 
     do {
-        /* In debug mode, script->getJIT(fp->isConstructing()) can change. */
-        if (cx->compartment->debugMode)
-            break;
-
         /* Hoist dynamic checks from scripted Invoke. */
         if (!calleev.isObject())
             break;
         JSObject &callee = calleev.toObject();
         if (callee.getClass() != &js_FunctionClass)
             break;
         JSFunction *fun = callee.getFunctionPrivate();
         if (fun->isNative())
@@ -793,17 +789,17 @@ InvokeSessionGuard::start(JSContext *cx,
 
 #ifdef JS_METHODJIT
         /* Hoist dynamic checks from RunScript. */
         mjit::CompileStatus status = mjit::CanMethodJIT(cx, script_, fp);
         if (status == mjit::Compile_Error)
             return false;
         if (status != mjit::Compile_Okay)
             break;
-        code_ = script_->getJIT(fp->isConstructing())->invokeEntry;
+        /* Cannot also cache the raw code pointer; it can change. */
 
         /* Hoist dynamic checks from CheckStackAndEnterMethodJIT. */
         JS_CHECK_RECURSION(cx, return JS_FALSE);
         stackLimit_ = stack.getStackLimit(cx);
         if (!stackLimit_)
             return false;
 
         stop_ = script_->code + script_->length - 1;
--- a/js/src/jsinterpinlines.h
+++ b/js/src/jsinterpinlines.h
@@ -535,17 +535,16 @@ PutActivationObjects(JSContext *cx, JSSt
 class InvokeSessionGuard
 {
     InvokeArgsGuard args_;
     InvokeFrameGuard frame_;
     Value savedCallee_, savedThis_;
     Value *formals_, *actuals_;
     unsigned nformals_;
     JSScript *script_;
-    void *code_;
     Value *stackLimit_;
     jsbytecode *stop_;
 
     bool optimized() const { return frame_.pushed(); }
 
   public:
     InvokeSessionGuard() : args_(), frame_() {}
     ~InvokeSessionGuard() {}
@@ -578,35 +577,33 @@ inline bool
 InvokeSessionGuard::invoke(JSContext *cx) const
 {
     /* N.B. Must be kept in sync with Invoke */
 
     /* Refer to canonical (callee, this) for optimized() sessions. */
     formals_[-2] = savedCallee_;
     formals_[-1] = savedThis_;
 
-    if (!optimized())
+    void *code;
+    if (!optimized() || !(code = script_->getJIT(false /* !constructing */)->invokeEntry))
         return Invoke(cx, args_, 0);
 
     /* Clear any garbage left from the last Invoke. */
     JSStackFrame *fp = frame_.fp();
     fp->clearMissingArgs();
     fp->resetInvokeCallFrame();
     SetValueRangeToUndefined(fp->slots(), script_->nfixed);
 
     JSBool ok;
     {
         AutoPreserveEnumerators preserve(cx);
         Probes::enterJSFun(cx, fp->fun(), script_);
 #ifdef JS_METHODJIT
-        if (code_ != script_->getJIT(fp->isConstructing())->invokeEntry)
-            *(volatile int *)0x101 = 0;
-
         AutoInterpPreparer prepareInterp(cx, script_);
-        ok = mjit::EnterMethodJIT(cx, fp, code_, stackLimit_);
+        ok = mjit::EnterMethodJIT(cx, fp, code, stackLimit_);
         cx->regs->pc = stop_;
 #else
         cx->regs->pc = script_->code;
         ok = Interpret(cx, cx->fp());
 #endif
         Probes::exitJSFun(cx, fp->fun(), script_);
     }