Bug 684110 - Remove empty-script special case in Invoke (r=bhackett)
authorLuke Wagner <luke@mozilla.com>
Fri, 02 Sep 2011 17:23:36 -0700
changeset 76502 870f6dd8258639455c6a29682660cc042cc76e25
parent 76501 659f5c7d2cc9cbd4ff121c1927d602e4cf293d23
child 76503 e1ad65d6a7fd214c730f4b519d9f8677ef19ef33
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersbhackett
bugs684110
milestone9.0a1
Bug 684110 - Remove empty-script special case in Invoke (r=bhackett)
js/src/jsinterp.cpp
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -662,49 +662,33 @@ InvokeKernel(JSContext *cx, const CallAr
     }
 
     /* Invoke native functions. */
     JSFunction *fun = callee.getFunctionPrivate();
     JS_ASSERT_IF(construct, !fun->isConstructor());
     if (fun->isNative())
         return CallJSNative(cx, fun->u.n.native, args);
 
-    /* Handle the empty-script special case. */
-    JSScript *script = fun->script();
-    if (JS_UNLIKELY(script->isEmpty())) {
-        if (construct) {
-            bool newType = cx->typeInferenceEnabled() && cx->fp()->isScriptFrame() &&
-                UseNewType(cx, cx->fp()->script(), cx->regs().pc);
-            JSObject *obj = js_CreateThisForFunction(cx, &callee, newType);
-            if (!obj)
-                return false;
-            args.rval().setObject(*obj);
-        } else {
-            args.rval().setUndefined();
-        }
-        return true;
-    }
-
     TypeMonitorCall(cx, args, construct);
 
     /* Get pointer to new frame/slots, prepare arguments. */
     InvokeFrameGuard ifg;
     if (!cx->stack.pushInvokeFrame(cx, args, initial, &ifg))
         return false;
 
     /* Now that the new frame is rooted, maybe create a call object. */
     StackFrame *fp = ifg.fp();
     if (fun->isHeavyweight() && !CreateFunCallObject(cx, fp))
         return false;
 
     /* Run function until JSOP_STOP, JSOP_RETURN or error. */
     JSBool ok;
     {
         AutoPreserveEnumerators preserve(cx);
-        ok = RunScript(cx, script, fp);
+        ok = RunScript(cx, fun->script(), fp);
     }
 
     args.rval() = fp->returnValue();
     JS_ASSERT_IF(ok && construct, !args.rval().isPrimitive());
     return ok;
 }
 
 bool
@@ -734,17 +718,17 @@ InvokeSessionGuard::start(JSContext *cx,
             break;
         JSObject &callee = calleev.toObject();
         if (callee.getClass() != &FunctionClass)
             break;
         JSFunction *fun = callee.getFunctionPrivate();
         if (fun->isNative())
             break;
         script_ = fun->script();
-        if (fun->isHeavyweight() || script_->isEmpty())
+        if (fun->isHeavyweight())
             break;
 
         /*
          * The frame will remain pushed even when the callee isn't active which
          * will affect the observable current global, so avoid any change.
          */
         if (callee.getGlobal() != GetGlobalForScopeChain(cx))
             break;