diff --git a/dom/base/nsWrapperCache.cpp b/dom/base/nsWrapperCache.cpp index 7ad24df3edb1..0b19e1a3630f 100644 --- a/dom/base/nsWrapperCache.cpp +++ b/dom/base/nsWrapperCache.cpp @@ -102,7 +102,7 @@ DebugWrapperTraceCallback(JS::GCCellPtr aPtr, const char* aName, void* aClosure) DebugWrapperTraversalCallback* callback = static_cast(aClosure); if (aPtr.is()) { - callback->NoteJSObject(&aPtr.to()); + callback->NoteJSObject(&aPtr.as()); } } diff --git a/dom/xbl/nsXBLDocumentInfo.cpp b/dom/xbl/nsXBLDocumentInfo.cpp index 4c3e19bdd6dc..6c7f834c8462 100644 --- a/dom/xbl/nsXBLDocumentInfo.cpp +++ b/dom/xbl/nsXBLDocumentInfo.cpp @@ -77,7 +77,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END static void UnmarkXBLJSObject(JS::GCCellPtr aPtr, const char* aName, void* aClosure) { - JS::ExposeObjectToActiveJS(&aPtr.to()); + JS::ExposeObjectToActiveJS(&aPtr.as()); } static PLDHashOperator diff --git a/js/public/HeapAPI.h b/js/public/HeapAPI.h index 9028e847a445..57c05b30fdf2 100644 --- a/js/public/HeapAPI.h +++ b/js/public/HeapAPI.h @@ -164,8 +164,8 @@ class JS_FRIEND_API(GCCellPtr) // Construction from an explicit type. template - explicit GCCellPtr(T* ptr) : ptr(checkedCast(ptr, JS::MapTypeToTraceKind::kind)) { } - explicit GCCellPtr(JSFunction* ptr) : ptr(checkedCast(ptr, JS::TraceKind::Object)) { } + explicit GCCellPtr(T* p) : ptr(checkedCast(p, JS::MapTypeToTraceKind::kind)) { } + explicit GCCellPtr(JSFunction* p) : ptr(checkedCast(p, JS::TraceKind::Object)) { } explicit GCCellPtr(JSFlatString* str) : ptr(checkedCast(str, JS::TraceKind::String)) { } explicit GCCellPtr(const Value& v); @@ -189,7 +189,7 @@ class JS_FRIEND_API(GCCellPtr) // Conversions to more specific types must match the kind. Access to // further refined types is not allowed directly from a GCCellPtr. template - T& to() const { + T& as() const { MOZ_ASSERT(kind() == JS::MapTypeToTraceKind::kind); // We can't use static_cast here, because the fact that JSObject // inherits from js::gc::Cell is not part of the public API. diff --git a/js/src/gc/Tracer.cpp b/js/src/gc/Tracer.cpp index cf34ab9fa21d..ae4c8b3aef84 100644 --- a/js/src/gc/Tracer.cpp +++ b/js/src/gc/Tracer.cpp @@ -341,7 +341,7 @@ ObjectGroupCycleCollectorTracer::onChild(const JS::GCCellPtr& thing) if (thing.is()) { // If this group is required to be in an ObjectGroup chain, trace it // via the provided worklist rather than continuing to recurse. - ObjectGroup& group = thing.to(); + ObjectGroup& group = thing.as(); if (group.maybeUnboxedLayout()) { for (size_t i = 0; i < seen.length(); i++) { if (seen[i] == &group) diff --git a/js/src/gdb/mozilla/Root.py b/js/src/gdb/mozilla/Root.py index b60d49abea38..c93590731aca 100644 --- a/js/src/gdb/mozilla/Root.py +++ b/js/src/gdb/mozilla/Root.py @@ -18,6 +18,10 @@ class Common(object): # the template member holds the referent directly. handle = False + # If True, we should strip typedefs from our referent type. (Rooted + # uses template magic that gives the referent a noisy type.) + strip_typedefs = False + # Initialize a pretty-printer for |value|, using |cache|. # # If given, |content_printer| is a pretty-printer constructor to use for @@ -42,6 +46,8 @@ class Common(object): ptr = self.value[self.member] if self.handle: ptr = ptr.dereference() + if self.strip_typedefs: + ptr = ptr.cast(ptr.type.strip_typedefs()) if self.content_printer: return self.content_printer(ptr, self.cache).to_string() else: @@ -53,7 +59,7 @@ class Common(object): @template_pretty_printer("JS::Rooted") class Rooted(Common): - pass + strip_typedefs = True @template_pretty_printer("JS::Handle") class Handle(Common): diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 05f0d4535256..5d39a43980fa 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -206,14 +206,14 @@ JS_FRIEND_API(void) JS_TraceShapeCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr shape) { MOZ_ASSERT(shape.is()); - TraceCycleCollectorChildren(trc, &shape.to()); + TraceCycleCollectorChildren(trc, &shape.as()); } JS_FRIEND_API(void) JS_TraceObjectGroupCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr group) { MOZ_ASSERT(group.is()); - TraceCycleCollectorChildren(trc, &group.to()); + TraceCycleCollectorChildren(trc, &group.as()); } static bool @@ -853,7 +853,7 @@ struct DumpHeapTracer : public JS::CallbackTracer, public WeakMapTracer void trace(JSObject* map, JS::GCCellPtr key, JS::GCCellPtr value) override { JSObject* kdelegate = nullptr; if (key.is()) - kdelegate = js::GetWeakmapKeyDelegate(&key.to()); + kdelegate = js::GetWeakmapKeyDelegate(&key.as()); fprintf(output, "WeakMapEntry map=%p key=%p keyDelegate=%p value=%p\n", map, key.asCell(), kdelegate, value.asCell()); diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 8db886091105..d5d4f5654dbe 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -7003,8 +7003,8 @@ JS::GCCellPtr::outOfLineKind() const bool JS::GCCellPtr::mayBeOwnedByOtherRuntime() const { - return (is() && to().isPermanentAtom()) || - (is() && to().isWellKnownSymbol()); + return (is() && as().isPermanentAtom()) || + (is() && as().isWellKnownSymbol()); } #ifdef JSGC_HASH_TABLE_CHECKS diff --git a/js/src/vm/UbiNode.cpp b/js/src/vm/UbiNode.cpp index d78cf7bc4883..5bd529a0a512 100644 --- a/js/src/vm/UbiNode.cpp +++ b/js/src/vm/UbiNode.cpp @@ -118,9 +118,9 @@ class SimpleEdgeVectorTracer : public JS::CallbackTracer { // Don't trace permanent atoms and well-known symbols that are owned by // a parent JSRuntime. - if (thing.is() && thing.to().isPermanentAtom()) + if (thing.is() && thing.as().isPermanentAtom()) return; - if (thing.is() && thing.to().isWellKnownSymbol()) + if (thing.is() && thing.as().isWellKnownSymbol()) return; char16_t* name16 = nullptr; diff --git a/xpcom/base/CycleCollectedJSRuntime.cpp b/xpcom/base/CycleCollectedJSRuntime.cpp index 6ec7c371a75b..d8ec1b44ba68 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -189,7 +189,7 @@ NoteWeakMapsTracer::trace(JSObject* aMap, JS::GCCellPtr aKey, JSObject* kdelegate = nullptr; if (aKey.is()) { - kdelegate = js::GetWeakmapKeyDelegate(&aKey.to()); + kdelegate = js::GetWeakmapKeyDelegate(&aKey.as()); } if (AddToCCKind(aValue.kind())) { @@ -245,7 +245,7 @@ struct FixWeakMappingGrayBitsTracer : public js::WeakMapTracer } if (delegateMightNeedMarking && aKey.is()) { - JSObject* kdelegate = js::GetWeakmapKeyDelegate(&aKey.to()); + JSObject* kdelegate = js::GetWeakmapKeyDelegate(&aKey.as()); if (kdelegate && !JS::ObjectIsMarkedGray(kdelegate)) { if (JS::UnmarkGrayGCThingRecursively(aKey)) { mAnyMarked = true; @@ -344,9 +344,9 @@ TraversalTracer::onChild(const JS::GCCellPtr& aThing) mCb.NoteNextEdgeName(buffer); } if (aThing.is()) { - mCb.NoteJSObject(&aThing.to()); + mCb.NoteJSObject(&aThing.as()); } else { - mCb.NoteJSScript(&aThing.to()); + mCb.NoteJSScript(&aThing.as()); } } else if (aThing.is()) { // The maximum depth of traversal when tracing a Shape is unbounded, due to @@ -484,7 +484,7 @@ CycleCollectedJSRuntime::DescribeGCThing(bool aIsMarked, JS::GCCellPtr aThing, char name[72]; uint64_t compartmentAddress = 0; if (aThing.is()) { - JSObject* obj = &aThing.to(); + JSObject* obj = &aThing.as(); compartmentAddress = (uint64_t)js::GetObjectCompartment(obj); const js::Class* clasp = js::GetObjectClass(obj); @@ -583,7 +583,7 @@ CycleCollectedJSRuntime::TraverseGCThing(TraverseSelect aTs, JS::GCCellPtr aThin } if (aThing.is()) { - JSObject* obj = &aThing.to(); + JSObject* obj = &aThing.as(); NoteGCThingXPCOMChildren(js::GetObjectClass(obj), obj, aCb); } } diff --git a/xpcom/glue/nsCycleCollectionParticipant.cpp b/xpcom/glue/nsCycleCollectionParticipant.cpp index d080d5674eb5..ec452e9b013d 100644 --- a/xpcom/glue/nsCycleCollectionParticipant.cpp +++ b/xpcom/glue/nsCycleCollectionParticipant.cpp @@ -24,9 +24,9 @@ nsScriptObjectTracer::NoteJSChild(JS::GCCellPtr aGCThing, const char* aName, static_cast(aClosure); NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, aName); if (aGCThing.is()) { - cb->NoteJSObject(&aGCThing.to()); + cb->NoteJSObject(&aGCThing.as()); } else if (aGCThing.is()) { - cb->NoteJSScript(&aGCThing.to()); + cb->NoteJSScript(&aGCThing.as()); } else { MOZ_ASSERT(!mozilla::AddToCCKind(aGCThing.kind())); }