Bug 1516578 Part 4 - Improve handling when encoding/decoding execution points with no position, r=lsmyth.
☠☠ backed out by 9e3564442734 ☠ ☠
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 27 Dec 2018 13:30:56 -1000
changeset 513640 9ddc5bc1e961af52dbd772f66559f3fe4199e572
parent 513639 fb64ff37f6345cfa2e8efc7d692bc3dc3a1cd6f5
child 513641 1701613c165d52565cc8dcf48b5e8a8bfebf7a23
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsmyth
bugs1516578
milestone66.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 1516578 Part 4 - Improve handling when encoding/decoding execution points with no position, r=lsmyth.
toolkit/recordreplay/ipc/JSControl.cpp
--- a/toolkit/recordreplay/ipc/JSControl.cpp
+++ b/toolkit/recordreplay/ipc/JSControl.cpp
@@ -148,38 +148,49 @@ BreakpointPosition::ToString(nsCString& 
 // Names of properties which JS code uses to specify the contents of an
 // ExecutionPoint.
 static const char gCheckpointProperty[] = "checkpoint";
 static const char gProgressProperty[] = "progress";
 static const char gPositionProperty[] = "position";
 
 JSObject* ExecutionPoint::Encode(JSContext* aCx) const {
   RootedObject obj(aCx, JS_NewObject(aCx, nullptr));
-  RootedObject position(aCx, mPosition.Encode(aCx));
-  if (!obj || !position ||
+  if (!obj ||
       !JS_DefineProperty(aCx, obj, gCheckpointProperty, (double)mCheckpoint,
                          JSPROP_ENUMERATE) ||
       !JS_DefineProperty(aCx, obj, gProgressProperty, (double)mProgress,
-                         JSPROP_ENUMERATE) ||
-      !JS_DefineProperty(aCx, obj, gPositionProperty, position,
                          JSPROP_ENUMERATE)) {
     return nullptr;
   }
+  if (HasPosition()) {
+    RootedObject position(aCx, mPosition.Encode(aCx));
+    if (!position ||
+        !JS_DefineProperty(aCx, obj, gPositionProperty, position,
+                           JSPROP_ENUMERATE)) {
+      return nullptr;
+    }
+  }
   return obj;
 }
 
 bool ExecutionPoint::Decode(JSContext* aCx, HandleObject aObject) {
   RootedValue v(aCx);
   if (!JS_GetProperty(aCx, aObject, gPositionProperty, &v)) {
     return false;
   }
 
-  RootedObject positionObject(aCx, NonNullObject(aCx, v));
-  return positionObject && mPosition.Decode(aCx, positionObject) &&
-         GetNumberProperty(aCx, aObject, gCheckpointProperty, &mCheckpoint) &&
+  if (v.isUndefined()) {
+    MOZ_RELEASE_ASSERT(!HasPosition());
+  } else {
+    RootedObject positionObject(aCx, NonNullObject(aCx, v));
+    if (!positionObject || !mPosition.Decode(aCx, positionObject)) {
+      return false;
+    }
+  }
+  return GetNumberProperty(aCx, aObject, gCheckpointProperty, &mCheckpoint) &&
          GetNumberProperty(aCx, aObject, gProgressProperty, &mProgress);
 }
 
 void
 ExecutionPoint::ToString(nsCString& aStr) const
 {
   aStr.AppendPrintf("{ Checkpoint %d", (int) mCheckpoint);
   if (HasPosition()) {