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 453655 9ddc5bc1e961
parent 453654 fb64ff37f634
child 453656 1701613c165d
push id35365
push userdvarga@mozilla.com
push dateSun, 13 Jan 2019 10:05:55 +0000
treeherdermozilla-central@1218e374fbc7 [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()) {