From 7e14fbd090eef79eb1d6b565aebe404cadde6e2e Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 29 Jul 2015 12:31:47 -0400 Subject: [PATCH] Bug 1180017 - Fix up the badly-horked backout and re-land. CLOSED TREE --- dom/base/nsWrapperCache.cpp | 2 +- dom/xbl/nsXBLDocumentInfo.cpp | 2 +- js/public/HeapAPI.h | 6 +++--- js/src/gc/Tracer.cpp | 2 +- js/src/gdb/mozilla/Root.py | 8 +++++++- js/src/jsfriendapi.cpp | 6 +++--- js/src/jsgc.cpp | 4 ++-- js/src/vm/UbiNode.cpp | 4 ++-- xpcom/base/CycleCollectedJSRuntime.cpp | 12 ++++++------ xpcom/glue/nsCycleCollectionParticipant.cpp | 4 ++-- 10 files changed, 28 insertions(+), 22 deletions(-) diff --git a/dom/base/nsWrapperCache.cpp b/dom/base/nsWrapperCache.cpp index 7ad24df3edb..0b19e1a3630 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 4c3e19bdd6d..6c7f834c846 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 9028e847a44..57c05b30fdf 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 cf34ab9fa21..ae4c8b3aef8 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 b60d49abea3..c93590731ac 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 05f0d453525..5d39a43980f 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 8db88609110..d5d4f5654db 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 d78cf7bc488..5bd529a0a51 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 6ec7c371a75..d8ec1b44ba6 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 d080d5674eb..ec452e9b013 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())); }