Bug 1445854 - Part 2: Remove extra code to cope with prior bad behavior of GenericCreatePrototype. r=jwalden
authorJason Orendorff <jorendorff@mozilla.com>
Tue, 09 Oct 2018 15:13:48 +0000
changeset 496002 8de0d349f144c1464719ba93f6ff4826eefb10f6
parent 496001 ed9091a418b9393f04c82a18b03b484609958efd
child 496003 a3fa8bb51b3c4a1d3751fddf3db69bc770eb8aae
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs1445854
milestone64.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 1445854 - Part 2: Remove extra code to cope with prior bad behavior of GenericCreatePrototype. r=jwalden Depends on D7666 Differential Revision: https://phabricator.services.mozilla.com/D7667
js/src/vm/Debugger.cpp
js/src/vm/SavedFrame.h
js/src/vm/SavedStacks-inl.h
js/src/vm/SavedStacks.cpp
js/src/vm/StructuredClone.cpp
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -11051,17 +11051,17 @@ DebuggerObject::getBoundArguments(JSCont
 Debugger::getObjectAllocationSite(JSObject& obj)
 {
     JSObject* metadata = GetAllocationMetadata(&obj);
     if (!metadata) {
         return nullptr;
     }
 
     MOZ_ASSERT(!metadata->is<WrapperObject>());
-    return SavedFrame::isSavedFrameAndNotProto(*metadata)
+    return metadata->is<SavedFrame>()
         ? &metadata->as<SavedFrame>()
         : nullptr;
 }
 
 /* static */ bool
 DebuggerObject::getAllocationSite(JSContext* cx, HandleDebuggerObject object,
                                   MutableHandleObject result)
 {
--- a/js/src/vm/SavedFrame.h
+++ b/js/src/vm/SavedFrame.h
@@ -92,27 +92,22 @@ class SavedFrame : public NativeObject {
         RootedSavedFrame frame_;
 
       public:
         RootedRange(JSContext* cx, HandleSavedFrame frame) : frame_(cx, frame) { }
         RootedIterator begin() { return RootedIterator(*this); }
         RootedIterator end() { return RootedIterator(); }
     };
 
-    static bool isSavedFrameAndNotProto(JSObject& obj) {
-        return obj.is<SavedFrame>() &&
-               !obj.as<SavedFrame>().getReservedSlot(JSSLOT_SOURCE).isNull();
-    }
-
-    static bool isSavedFrameOrWrapperAndNotProto(JSObject& obj) {
+    static bool isSavedFrameOrWrapper(JSObject& obj) {
         auto unwrapped = CheckedUnwrap(&obj);
         if (!unwrapped) {
             return false;
         }
-        return isSavedFrameAndNotProto(*unwrapped);
+        return unwrapped->is<SavedFrame>();
     }
 
     struct Lookup;
     struct HashPolicy;
 
     typedef JS::GCHashSet<ReadBarriered<SavedFrame*>,
                           HashPolicy,
                           SystemAllocPolicy> Set;
--- a/js/src/vm/SavedStacks-inl.h
+++ b/js/src/vm/SavedStacks-inl.h
@@ -18,13 +18,13 @@
 // and use the original caller's compartment's principals to determine what
 // level of data to present. Unwrapping and entering the referent's compartment
 // would mess that up. See the module level documentation in
 // `js/src/vm/SavedStacks.h` as well as the comments in `js/src/jsapi.h`.
 inline void
 js::AssertObjectIsSavedFrameOrWrapper(JSContext* cx, HandleObject stack)
 {
     if (stack) {
-        MOZ_RELEASE_ASSERT(js::SavedFrame::isSavedFrameOrWrapperAndNotProto(*stack));
+        MOZ_RELEASE_ASSERT(js::SavedFrame::isSavedFrameOrWrapper(*stack));
     }
 }
 
 #endif // vm_SavedStacksInl_h
--- a/js/src/vm/SavedStacks.cpp
+++ b/js/src/vm/SavedStacks.cpp
@@ -737,25 +737,16 @@ SavedFrame_checkThis(JSContext* cx, Call
     JSObject* thisObject = CheckedUnwrap(&thisValue.toObject());
     if (!thisObject || !thisObject->is<SavedFrame>()) {
         JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
                                   SavedFrame::class_.name, fnName,
                                   thisObject ? thisObject->getClass()->name : "object");
         return false;
     }
 
-    // Check for SavedFrame.prototype, which has the same class as SavedFrame
-    // instances, however doesn't actually represent a captured stack frame. It
-    // is the only object that is<SavedFrame>() but doesn't have a source.
-    if (!SavedFrame::isSavedFrameAndNotProto(*thisObject)) {
-        JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
-                                  SavedFrame::class_.name, fnName, "prototype object");
-        return false;
-    }
-
     // Now set "frame" to the actual object we were invoked in (which may be a
     // wrapper), not the unwrapped version.  Consumers will need to know what
     // that original object was, and will do principal checks as needed.
     frame.set(&thisValue.toObject());
     return true;
 }
 
 // Get the SavedFrame * from the current this value and handle any errors that
@@ -787,17 +778,17 @@ UnwrapSavedFrame(JSContext* cx, JSPrinci
         return nullptr;
     }
 
     RootedObject savedFrameObj(cx, CheckedUnwrap(obj));
     if (!savedFrameObj) {
         return nullptr;
     }
 
-    MOZ_RELEASE_ASSERT(js::SavedFrame::isSavedFrameAndNotProto(*savedFrameObj));
+    MOZ_RELEASE_ASSERT(savedFrameObj->is<js::SavedFrame>());
     js::RootedSavedFrame frame(cx, &savedFrameObj->as<js::SavedFrame>());
     return GetFirstSubsumedFrame(cx, principals, frame, selfHosted, skippedAsync);
 }
 
 JS_PUBLIC_API(SavedFrameResult)
 GetSavedFrameSource(JSContext* cx, JSPrincipals* principals, HandleObject savedFrame,
                     MutableHandleString sourcep,
                     SavedFrameSelfHosted selfHosted /* = SavedFrameSelfHosted::Include */)
@@ -1136,24 +1127,24 @@ BuildStackString(JSContext* cx, JSPrinci
     stringp.set(str);
     return true;
 }
 
 JS_PUBLIC_API(bool)
 IsMaybeWrappedSavedFrame(JSObject* obj)
 {
     MOZ_ASSERT(obj);
-    return js::SavedFrame::isSavedFrameOrWrapperAndNotProto(*obj);
+    return js::SavedFrame::isSavedFrameOrWrapper(*obj);
 }
 
 JS_PUBLIC_API(bool)
 IsUnwrappedSavedFrame(JSObject* obj)
 {
     MOZ_ASSERT(obj);
-    return js::SavedFrame::isSavedFrameAndNotProto(*obj);
+    return obj->is<js::SavedFrame>();
 }
 
 } /* namespace JS */
 
 namespace js {
 
 /* static */ bool
 SavedFrame::sourceProperty(JSContext* cx, unsigned argc, Value* vp)
@@ -1308,17 +1299,17 @@ SavedStacks::copyAsyncStack(JSContext* c
 
     RootedAtom asyncCauseAtom(cx, AtomizeString(cx, asyncCause));
     if (!asyncCauseAtom) {
         return false;
     }
 
     RootedObject asyncStackObj(cx, CheckedUnwrap(asyncStack));
     MOZ_RELEASE_ASSERT(asyncStackObj);
-    MOZ_RELEASE_ASSERT(js::SavedFrame::isSavedFrameAndNotProto(*asyncStackObj));
+    MOZ_RELEASE_ASSERT(asyncStackObj->is<js::SavedFrame>());
     adoptedStack.set(&asyncStackObj->as<js::SavedFrame>());
 
     if (!adoptAsyncStack(cx, adoptedStack, asyncCauseAtom, maxFrameCount)) {
         return false;
     }
 
     return true;
 }
--- a/js/src/vm/StructuredClone.cpp
+++ b/js/src/vm/StructuredClone.cpp
@@ -1844,17 +1844,17 @@ JSStructuredCloneWriter::startWrite(Hand
                 return writeTypedArray(obj);
             }
             if (JS_IsDataViewObject(obj)) {
                 return writeDataView(obj);
             }
             if (wasm::IsSharedWasmMemoryObject(obj)) {
                 return writeSharedWasmMemory(obj);
             }
-            if (SavedFrame::isSavedFrameOrWrapperAndNotProto(*obj)) {
+            if (SavedFrame::isSavedFrameOrWrapper(*obj)) {
                 return traverseSavedFrame(obj);
             }
             break;
           }
         }
 
         if (out.buf.callbacks_ && out.buf.callbacks_->write) {
             return out.buf.callbacks_->write(context(), this, obj, out.buf.closure_);
@@ -2080,17 +2080,17 @@ JSStructuredCloneWriter::write(HandleVal
 
                 counts.back()--;
                 val = otherEntries.popCopy();
                 checkStack();
 
                 if (!startWrite(key) || !startWrite(val)) {
                     return false;
                 }
-            } else if (cls == ESClass::Set || SavedFrame::isSavedFrameOrWrapperAndNotProto(*obj)) {
+            } else if (cls == ESClass::Set || SavedFrame::isSavedFrameOrWrapper(*obj)) {
                 key = otherEntries.popCopy();
                 checkStack();
 
                 if (!startWrite(key)) {
                     return false;
                 }
             } else {
                 id = objectEntries.popCopy();