From 21795a7536d1ac3b3d71e47ab79897235aa737a0 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Wed, 26 Dec 2012 15:57:26 +0100 Subject: [PATCH] Bug 823482 part 1 - Refactor JSOP_EXCEPTION implementation in the interpreter. r=djvj --HG-- extra : rebase_source : ec8f44feae0e8c74245347b1763f0275867764f5 --- js/src/jsinterp.cpp | 22 +++++++++++++++++++--- js/src/jsinterp.h | 3 +++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 51a846a035c2..444bf6c76cbb 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -3109,9 +3109,12 @@ END_VARLEN_CASE } BEGIN_CASE(JSOP_EXCEPTION) - PUSH_COPY(cx->getPendingException()); - cx->clearPendingException(); - CHECK_BRANCH(); +{ + PUSH_NULL(); + MutableHandleValue res = MutableHandleValue::fromMarkedLocation(®s.sp[-1]); + if (!GetAndClearException(cx, res)) + goto error; +} END_CASE(JSOP_EXCEPTION) BEGIN_CASE(JSOP_FINALLY) @@ -3910,6 +3913,19 @@ js::DefFunOperation(JSContext *cx, HandleScript script, HandleObject scopeChain, 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 js::SetProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &value) diff --git a/js/src/jsinterp.h b/js/src/jsinterp.h index bc4d68463fca..a0c9f58d9642 100644 --- a/js/src/jsinterp.h +++ b/js/src/jsinterp.h @@ -384,6 +384,9 @@ DeleteProperty(JSContext *ctx, HandleValue val, HandlePropertyName name, JSBool bool DefFunOperation(JSContext *cx, HandleScript script, HandleObject scopeChain, HandleFunction funArg); +bool +GetAndClearException(JSContext *cx, MutableHandleValue res); + } /* namespace js */ #endif /* jsinterp_h___ */