Bug 1470558: Delete Debugger::{resultToCompletion,newCompletionValue,receiveCompletionValue}. r=jorendorff
authorJim Blandy <jimb@mozilla.com>
Sun, 07 Jul 2019 09:47:58 +0000
changeset 544422 483d687212fbf08e9b103c9b8565674b02fed827
parent 544421 3800d671c64ee26d9f59a773488cc18a6da3587a
child 544423 ec9aff5bd85633c81ebf964f54808f33ee6cf379
child 544432 7e6657f88b7694ecd841088963ff71d767e4ec22
child 545504 bea45a5fc3a6b3fcecdb8ed6222287fcfb891593
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1470558
milestone69.0a1
first release with
nightly linux32
483d687212fb / 69.0a1 / 20190707211726 / files
nightly linux64
483d687212fb / 69.0a1 / 20190707211726 / files
nightly mac
483d687212fb / 69.0a1 / 20190707211726 / files
nightly win32
483d687212fb / 69.0a1 / 20190707211726 / files
nightly win64
483d687212fb / 69.0a1 / 20190707211726 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
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);