From a71ae32a0e3d08d177e6b19c71a86c89375ec63c Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sat, 6 Jul 2019 21:26:48 +0000 Subject: [PATCH] Bug 1470558: Delete Debugger::{resultToCompletion,newCompletionValue,receiveCompletionValue}. r=jorendorff All uses of these have been rewritten to use the Completion type. Differential Revision: https://phabricator.services.mozilla.com/D33079 --HG-- extra : moz-landing-system : lando --- js/src/vm/Debugger.cpp | 81 ------------------------------------------ js/src/vm/Debugger.h | 40 --------------------- 2 files changed, 121 deletions(-) diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 711ac4974641..7808b9a9c2e6 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -2129,87 +2129,6 @@ void Completion::toResumeMode(ResumeMode& resumeMode, MutableHandleValue value, resumeMode = variant.match(ToResumeModeMatcher(value, exnStack)); } -/* static */ -void Debugger::resultToCompletion(JSContext* cx, bool ok, const Value& rv, - ResumeMode* resumeMode, - MutableHandleValue value, - MutableHandleSavedFrame exnStack) { - MOZ_ASSERT_IF(ok, !cx->isExceptionPending()); - - if (ok) { - *resumeMode = ResumeMode::Return; - value.set(rv); - } else if (cx->isExceptionPending()) { - *resumeMode = ResumeMode::Throw; - if (!cx->getPendingException(value)) { - *resumeMode = ResumeMode::Terminate; - } - exnStack.set(cx->getPendingExceptionStack()); - cx->clearPendingException(); - } else { - *resumeMode = ResumeMode::Terminate; - value.setUndefined(); - } -} - -bool Debugger::newCompletionValue(JSContext* cx, ResumeMode resumeMode, - const Value& value_, SavedFrame* exnStack_, - MutableHandleValue result) { - // We must be in the debugger's compartment, since that's where we want - // to construct the completion value. - cx->check(object.get()); - cx->check(value_); - - RootedId key(cx); - RootedValue value(cx, value_); - RootedSavedFrame exnStack(cx, exnStack_); - - switch (resumeMode) { - case ResumeMode::Return: - key = NameToId(cx->names().return_); - break; - - case ResumeMode::Throw: - key = NameToId(cx->names().throw_); - break; - - case ResumeMode::Terminate: - result.setNull(); - return true; - - default: - MOZ_CRASH("bad resume mode passed to Debugger::newCompletionValue"); - } - - // Common tail for ResumeMode::Return and ResumeMode::Throw. - RootedPlainObject obj(cx, NewBuiltinClassInstance(cx)); - if (!obj || - !NativeDefineDataProperty(cx, obj, key, value, JSPROP_ENUMERATE)) { - return false; - } - - if (exnStack) { - RootedId nkey(cx, NameToId(cx->names().stack)); - RootedValue nvalue(cx, ObjectValue(*exnStack)); - if (!cx->compartment()->wrap(cx, &nvalue) || - !NativeDefineDataProperty(cx, obj, nkey, nvalue, JSPROP_ENUMERATE)) { - return false; - } - } - - result.setObject(*obj); - return true; -} - -bool Debugger::receiveCompletionValue(Maybe& ar, bool ok, - HandleValue val, MutableHandleValue vp) { - JSContext* cx = ar->context(); - - Rooted completion(cx, Completion::fromJSResult(cx, ok, val)); - ar.reset(); - return completion.get().buildCompletionValue(cx, this, vp); -} - /*** Firing debugger hooks **************************************************/ static bool CallMethodIfPresent(JSContext* cx, HandleObject obj, diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h index 1b534eceead8..f5f35de5bab0 100644 --- a/js/src/vm/Debugger.h +++ b/js/src/vm/Debugger.h @@ -1313,46 +1313,6 @@ class Debugger : private mozilla::LinkedListElement { MOZ_MUST_USE bool getFrame(JSContext* cx, const FrameIter& iter, MutableHandleDebuggerFrame result); - /* - * Set |*resumeMode| and |*value| to a (ResumeMode, Value) pair reflecting a - * standard SpiderMonkey call state: a boolean success value |ok|, a return - * value |rv|, and a context |cx| that may or may not have an exception set. - * If an exception was pending on |cx|, it is cleared (and |ok| is asserted - * to be false). On exceptional returns, exnStack will be set to any stack - * associated with the original throw, if available. - */ - static void resultToCompletion(JSContext* cx, bool ok, const Value& rv, - ResumeMode* resumeMode, - MutableHandleValue value, - MutableHandleSavedFrame exnStack); - - /* - * Set |*result| to a JavaScript completion value corresponding to - * |resumeMode| and |value|. |value| should be the return value or exception - * value, not wrapped as a debuggee value. When throwing an exception, - * |exnStack| may be set to the stack when the value was thrown. |cx| must be - * in the debugger compartment. - */ - MOZ_MUST_USE bool newCompletionValue(JSContext* cx, ResumeMode resumeMode, - const Value& value, SavedFrame* exnStack, - MutableHandleValue result); - - /* - * Precondition: we are in the debuggee realm (ar is entered) and ok is true - * if the operation in the debuggee realm succeeded, false on error or - * exception. - * - * Postcondition: we are in the debugger realm, having called `ar.reset()` - * even if an error occurred. - * - * On success, a completion value is in vp and ar.context does not have a - * pending exception. (This ordinarily returns true even if the ok argument - * is false.) - */ - MOZ_MUST_USE bool receiveCompletionValue(mozilla::Maybe& ar, - bool ok, HandleValue val, - MutableHandleValue vp); - /* * Return the Debugger.Script object for |script|, or create a new one if * needed. The context |cx| must be in the debugger realm; |script| must be