Bug 1470558: Delete Debugger::{resultToCompletion,newCompletionValue,receiveCompletionValue}. r=jorendorff
☠☠ backed out by 6a41c5908998 ☠ ☠
authorJim Blandy <jimb@mozilla.com>
Sat, 06 Jul 2019 21:26:48 +0000
changeset 541222 1a18ccfcdc98eec64d8f76850713f0348cd073e5
parent 541221 ef67e1b47f9cf2541784350a1bd5f322577b2e2c
child 541223 6a41c590899802f9636815ad69b14d67318582cf
push id11533
push userarchaeopteryx@coole-files.de
push dateMon, 08 Jul 2019 18:18:03 +0000
treeherdermozilla-beta@f4452e031aed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1470558
milestone69.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 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
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -2124,97 +2124,16 @@ struct MOZ_STACK_CLASS Completion::ToRes
   }
 };
 
 void Completion::toResumeMode(ResumeMode& resumeMode, MutableHandleValue value,
                               MutableHandleSavedFrame exnStack) const {
   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<PlainObject>(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<AutoRealm>& ar, bool ok,
-                                      HandleValue val, MutableHandleValue vp) {
-  JSContext* cx = ar->context();
-
-  Rooted<Completion> 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,
                                 const char* name, size_t argc, Value* argv,
                                 MutableHandleValue rval) {
   rval.setUndefined();
   JSAtom* atom = Atomize(cx, name, strlen(name));
   if (!atom) {
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -1309,56 +1309,16 @@ class Debugger : private mozilla::Linked
    * data is copied into it.
    */
   MOZ_MUST_USE bool getFrame(JSContext* cx, const FrameIter& iter,
                              MutableHandleValue vp);
   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<AutoRealm>& 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
    * a script in a debuggee realm.
    */
   JSObject* wrapScript(JSContext* cx, HandleScript script);
 
   JSObject* wrapLazyScript(JSContext* cx, Handle<LazyScript*> script);