From 2bf9548b9c84c8c8e862f128f5736608227e2973 Mon Sep 17 00:00:00 2001 From: Eddy Bruel Date: Wed, 17 Aug 2016 11:42:45 +0200 Subject: [PATCH] Bug 1294013 - Factor out processResumptionValue. r=jimb --- js/src/vm/Debugger.cpp | 36 ++++++++++++++++++++++++------------ js/src/vm/Debugger.h | 4 ++++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 41b96f062a65..e219e9b2086e 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -1536,6 +1536,29 @@ CheckResumptionValue(JSContext* cx, AbstractFramePtr frame, const Maybe& ac, AbstractFramePtr frame, + const Maybe& maybeThisv, HandleValue rval, + JSTrapStatus* statusp, MutableHandleValue vp) +{ + JSContext* cx = ac->context()->asJSContext(); + + if (!ParseResumptionValue(cx, rval, statusp, vp) || + !unwrapDebuggeeValue(cx, vp) || + !CheckResumptionValue(cx, frame, maybeThisv, *statusp, vp)) + { + return false; + } + + ac.reset(); + if (!cx->compartment()->wrap(cx, vp)) { + *statusp = JSTRAP_ERROR; + vp.setUndefined(); + } + + return true; +} + JSTrapStatus Debugger::parseResumptionValueHelper(Maybe& ac, bool ok, const Value& rv, const Maybe& thisVForCheck, AbstractFramePtr frame, @@ -1549,20 +1572,9 @@ Debugger::parseResumptionValueHelper(Maybe& ac, bool ok, const RootedValue rvRoot(cx, rv); JSTrapStatus status = JSTRAP_CONTINUE; RootedValue v(cx); - if (!ParseResumptionValue(cx, rvRoot, &status, &v) || - !unwrapDebuggeeValue(cx, &v) || - !CheckResumptionValue(cx, frame, thisVForCheck, status, &v)) - { + if (!processResumptionValue(ac, frame, thisVForCheck, rvRoot, &status, &v)) return handleUncaughtException(ac, vp, callHook, thisVForCheck, frame); - } - - ac.reset(); - if (!cx->compartment()->wrap(cx, &v)) { - vp.setUndefined(); - return JSTRAP_ERROR; - } vp.set(v); - return status; } diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h index 8a1f4885a594..1329e66e2546 100644 --- a/js/src/vm/Debugger.h +++ b/js/src/vm/Debugger.h @@ -566,6 +566,10 @@ class Debugger : private mozilla::LinkedListElement const mozilla::Maybe& thisVForCheck, AbstractFramePtr frame, MutableHandleValue vp, bool callHook); + bool processResumptionValue(mozilla::Maybe& ac, AbstractFramePtr frame, + const mozilla::Maybe& maybeThis, HandleValue rval, + JSTrapStatus* statusp, MutableHandleValue vp); + GlobalObject* unwrapDebuggeeArgument(JSContext* cx, const Value& v); static void traceObject(JSTracer* trc, JSObject* obj);