Bug 615277 - Implement topLevelHook for JM, match jsinterp.cpp implementation. r=dmandelin
authorSteve Fink <sfink@mozilla.com>
Fri, 10 Dec 2010 11:40:00 -0800
changeset 59885 ac952c471f5925330aae300dff4e892b1338c4b8
parent 59884 8a62a1f0bd4071c5646c7b4c42131729f9cd3a47
child 59886 df86d5999fefca6cb56e40aaaf4e3013fa57e299
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)
reviewersdmandelin
bugs615277
milestone2.0b8pre
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 615277 - Implement topLevelHook for JM, match jsinterp.cpp implementation. r=dmandelin
js/src/jsinterp.cpp
js/src/jsinterpinlines.h
js/src/methodjit/InvokeHelpers.cpp
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -991,31 +991,22 @@ Execute(JSContext *cx, JSObject *chain, 
         JSObject *thisp = chain->thisObject(cx);
         if (!thisp)
             return false;
         frame.fp()->globalThis().setObject(*thisp);
     }
 
     Probes::startExecution(cx, script);
 
-    void *hookData = NULL;
-    if (JSInterpreterHook hook = cx->debugHooks->executeHook)
-        hookData = hook(cx, frame.fp(), JS_TRUE, 0, cx->debugHooks->executeHookData);
-
     /* Run script until JSOP_STOP or error. */
     AutoPreserveEnumerators preserve(cx);
     JSBool ok = RunScript(cx, script, frame.fp());
     if (result)
         *result = frame.fp()->returnValue();
 
-    if (hookData) {
-        if (JSInterpreterHook hook = cx->debugHooks->executeHook)
-            hook(cx, frame.fp(), JS_FALSE, &ok, hookData);
-    }
-
     Probes::stopExecution(cx, script);
 
     return !!ok;
 }
 
 bool
 CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs,
                    JSObject **objp, JSProperty **propp)
@@ -2194,22 +2185,24 @@ static inline bool
 ScriptPrologue(JSContext *cx, JSStackFrame *fp)
 {
     if (fp->isConstructing()) {
         JSObject *obj = js_CreateThisForFunction(cx, &fp->callee());
         if (!obj)
             return false;
         fp->functionThis().setObject(*obj);
     }
-    JSInterpreterHook hook = cx->debugHooks->callHook;
-    if (JS_UNLIKELY(hook != NULL) && !fp->isExecuteFrame())
-        fp->setHookData(hook(cx, fp, JS_TRUE, 0, cx->debugHooks->callHookData));
-
-    if (!fp->isExecuteFrame())
+    if (fp->isExecuteFrame()) {
+        if (JSInterpreterHook hook = cx->debugHooks->executeHook)
+            fp->setHookData(hook(cx, fp, JS_TRUE, 0, cx->debugHooks->executeHookData));
+    } else {
+        if (JSInterpreterHook hook = cx->debugHooks->callHook)
+            fp->setHookData(hook(cx, fp, JS_TRUE, 0, cx->debugHooks->callHookData));
         Probes::enterJSFun(cx, fp->maybeFun(), fp->maybeScript());
+    }
 
     return true;
 }
 
 namespace js {
 
 JS_REQUIRES_STACK JS_NEVER_INLINE bool
 Interpret(JSContext *cx, JSStackFrame *entryFrame, uintN inlineCallCount, JSInterpMode interpMode)
--- a/js/src/jsinterpinlines.h
+++ b/js/src/jsinterpinlines.h
@@ -708,20 +708,21 @@ ValuePropertyBearer(JSContext *cx, const
 }
 
 static inline bool
 ScriptEpilogue(JSContext *cx, JSStackFrame *fp, JSBool ok)
 {
     if (!fp->isExecuteFrame())
         Probes::exitJSFun(cx, fp->maybeFun(), fp->maybeScript());
 
-    JSInterpreterHook hook = cx->debugHooks->callHook;
+    JSInterpreterHook hook =
+        fp->isExecuteFrame() ? cx->debugHooks->executeHook : cx->debugHooks->callHook;
+
     void* hookData;
-
-    if (hook && (hookData = fp->maybeHookData()) && !fp->isExecuteFrame())
+    if (JS_UNLIKELY(hook != NULL) && (hookData = fp->maybeHookData()))
         hook(cx, fp, JS_FALSE, &ok, hookData);
 
     /*
      * An eval frame's parent owns its activation objects. A yielding frame's
      * activation objects are transferred to the floating frame, stored in the
      * generator.
      */
     if (fp->isFunctionFrame() && !fp->isEvalFrame() && !fp->isYielding())
--- a/js/src/methodjit/InvokeHelpers.cpp
+++ b/js/src/methodjit/InvokeHelpers.cpp
@@ -585,37 +585,43 @@ stubs::CreateThis(VMFrame &f, JSObject *
 
 void JS_FASTCALL
 stubs::EnterScript(VMFrame &f)
 {
     JSStackFrame *fp = f.fp();
     JSContext *cx = f.cx;
 
     if (fp->script()->debugMode) {
-        JSInterpreterHook hook = cx->debugHooks->callHook;
-        if (JS_UNLIKELY(hook != NULL) && !fp->isExecuteFrame()) {
-            fp->setHookData(hook(cx, fp, JS_TRUE, 0, cx->debugHooks->callHookData));
+        if (fp->isExecuteFrame()) {
+            JSInterpreterHook hook = cx->debugHooks->executeHook;
+            if (JS_UNLIKELY(hook != NULL))
+                fp->setHookData(hook(cx, fp, JS_TRUE, 0, cx->debugHooks->executeHookData));
+        } else {
+            JSInterpreterHook hook = cx->debugHooks->callHook;
+            if (JS_UNLIKELY(hook != NULL))
+                fp->setHookData(hook(cx, fp, JS_TRUE, 0, cx->debugHooks->callHookData));
         }
     }
 
     Probes::enterJSFun(cx, fp->maybeFun(), fp->script());
 }
 
 void JS_FASTCALL
 stubs::LeaveScript(VMFrame &f)
 {
     JSStackFrame *fp = f.fp();
     JSContext *cx = f.cx;
     Probes::exitJSFun(cx, fp->maybeFun(), fp->maybeScript());
 
     if (fp->script()->debugMode) {
-        JSInterpreterHook hook = cx->debugHooks->callHook;
         void *hookData;
+        JSInterpreterHook hook =
+            fp->isExecuteFrame() ? cx->debugHooks->executeHook : cx->debugHooks->callHook;
 
-        if (hook && (hookData = fp->maybeHookData()) && !fp->isExecuteFrame()) {
+        if (JS_UNLIKELY(hook != NULL) && (hookData = fp->maybeHookData())) {
             JSBool ok = JS_TRUE;
             hook(cx, fp, JS_FALSE, &ok, hookData);
             if (!ok)
                 THROW();
         }
     }
 }