Bug 823482 part 1 - Refactor JSOP_EXCEPTION implementation in the interpreter. r=djvj
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 26 Dec 2012 15:57:26 +0100
changeset 126146 1ab05052b3b579732742445876faffc49e2c02df
parent 126145 e11da9f516828ef9776ae5190eab93f83b85ebbd
child 126147 d7b8336e01d12f4014f21af7afbdf50260f39cdc
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdjvj
bugs823482
milestone20.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 823482 part 1 - Refactor JSOP_EXCEPTION implementation in the interpreter. r=djvj
js/src/jsinterp.cpp
js/src/jsinterp.h
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -3104,19 +3104,22 @@ BEGIN_CASE(JSOP_RETSUB)
     JS_ASSERT(rval.isInt32());
 
     /* Increment the PC by this much. */
     len = rval.toInt32() - int32_t(regs.pc - script->code);
 END_VARLEN_CASE
 }
 
 BEGIN_CASE(JSOP_EXCEPTION)
-    PUSH_COPY(cx->getPendingException());
-    cx->clearPendingException();
-    CHECK_BRANCH();
+{
+    PUSH_NULL();
+    MutableHandleValue res = MutableHandleValue::fromMarkedLocation(&regs.sp[-1]);
+    if (!GetAndClearException(cx, res))
+        goto error;
+}
 END_CASE(JSOP_EXCEPTION)
 
 BEGIN_CASE(JSOP_FINALLY)
     CHECK_BRANCH();
 END_CASE(JSOP_FINALLY)
 
 BEGIN_CASE(JSOP_THROWING)
 {
@@ -3905,16 +3908,29 @@ js::DefFunOperation(JSContext *cx, Handl
      * Second, this will produce warnings and/or errors as necessary if the
      * specified Call object property is not writable (const).
      */
 
     /* Step 5f. */
     return JSObject::setProperty(cx, parent, parent, name, &rval, script->strict);
 }
 
+bool
+js::GetAndClearException(JSContext *cx, MutableHandleValue res)
+{
+    // Check the interrupt flag to allow interrupting deeply nested exception
+    // handling.
+    if (cx->runtime->interrupt && !js_HandleExecutionInterrupt(cx))
+        return false;
+
+    res.set(cx->getPendingException());
+    cx->clearPendingException();
+    return true;
+}
+
 template <bool strict>
 bool
 js::SetProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &value)
 {
     RootedValue v(cx, value);
     return JSObject::setGeneric(cx, obj, obj, id, &v, strict);
 }
 
--- a/js/src/jsinterp.h
+++ b/js/src/jsinterp.h
@@ -379,11 +379,14 @@ SetProperty(JSContext *cx, HandleObject 
 
 template <bool strict>
 bool
 DeleteProperty(JSContext *ctx, HandleValue val, HandlePropertyName name, JSBool *bv);
 
 bool
 DefFunOperation(JSContext *cx, HandleScript script, HandleObject scopeChain, HandleFunction funArg);
 
+bool
+GetAndClearException(JSContext *cx, MutableHandleValue res);
+
 }  /* namespace js */
 
 #endif /* jsinterp_h___ */