diff --git a/devtools/shared/heapsnapshot/DeserializedNode.cpp b/devtools/shared/heapsnapshot/DeserializedNode.cpp index 286288b81309..fac4cccb9efd 100644 --- a/devtools/shared/heapsnapshot/DeserializedNode.cpp +++ b/devtools/shared/heapsnapshot/DeserializedNode.cpp @@ -121,7 +121,7 @@ Concrete::allocationStack() const js::UniquePtr -Concrete::edges(JSRuntime* rt, bool) const +Concrete::edges(JSContext* cx, bool) const { js::UniquePtr range(js_new(get())); diff --git a/devtools/shared/heapsnapshot/DeserializedNode.h b/devtools/shared/heapsnapshot/DeserializedNode.h index 5b738c20233a..60d1fb408a68 100644 --- a/devtools/shared/heapsnapshot/DeserializedNode.h +++ b/devtools/shared/heapsnapshot/DeserializedNode.h @@ -270,7 +270,7 @@ public: // We ignore the `bool wantNames` parameter because we can't control whether // the core dump was serialized with edge names or not. - js::UniquePtr edges(JSRuntime* rt, bool) const override; + js::UniquePtr edges(JSContext* cx, bool) const override; static const char16_t concreteTypeName[]; }; diff --git a/devtools/shared/heapsnapshot/HeapSnapshot.cpp b/devtools/shared/heapsnapshot/HeapSnapshot.cpp index 51283d534d0a..b6d97a87673e 100644 --- a/devtools/shared/heapsnapshot/HeapSnapshot.cpp +++ b/devtools/shared/heapsnapshot/HeapSnapshot.cpp @@ -489,7 +489,7 @@ HeapSnapshot::TakeCensus(JSContext* cx, JS::HandleObject options, { JS::AutoCheckCannotGC nogc; - JS::ubi::CensusTraversal traversal(JS_GetRuntime(cx), handler, nogc); + JS::ubi::CensusTraversal traversal(cx, handler, nogc); if (NS_WARN_IF(!traversal.init())) { rv.Throw(NS_ERROR_OUT_OF_MEMORY); return; @@ -556,10 +556,10 @@ HeapSnapshot::ComputeDominatorTree(ErrorResult& rv) { auto ccrt = CycleCollectedJSRuntime::Get(); MOZ_ASSERT(ccrt); - auto rt = ccrt->Runtime(); - MOZ_ASSERT(rt); - JS::AutoCheckCannotGC nogc(rt); - maybeTree = JS::ubi::DominatorTree::Create(rt, nogc, getRoot()); + auto cx = ccrt->Context(); + MOZ_ASSERT(cx); + JS::AutoCheckCannotGC nogc(JS_GetRuntime(cx)); + maybeTree = JS::ubi::DominatorTree::Create(cx, nogc, getRoot()); } if (NS_WARN_IF(maybeTree.isNothing())) { @@ -621,12 +621,8 @@ HeapSnapshot::ComputeShortestPaths(JSContext*cx, uint64_t start, Maybe maybeShortestPaths; { - auto ccrt = CycleCollectedJSRuntime::Get(); - MOZ_ASSERT(ccrt); - auto rt = ccrt->Runtime(); - MOZ_ASSERT(rt); - JS::AutoCheckCannotGC nogc(rt); - maybeShortestPaths = ShortestPaths::Create(rt, nogc, maxNumPaths, *startNode, + JS::AutoCheckCannotGC nogc(JS_GetRuntime(cx)); + maybeShortestPaths = ShortestPaths::Create(cx, nogc, maxNumPaths, *startNode, Move(targetsSet)); } @@ -1238,7 +1234,7 @@ public: protobufNode.set_size(ubiNode.size(mallocSizeOf)); if (includeEdges) { - auto edges = ubiNode.edges(JS_GetRuntime(cx), wantNames); + auto edges = ubiNode.edges(cx, wantNames); if (NS_WARN_IF(!edges)) return false; @@ -1380,7 +1376,7 @@ WriteHeapGraph(JSContext* cx, // core dump. HeapSnapshotHandler handler(writer, compartments); - HeapSnapshotHandler::Traversal traversal(JS_GetRuntime(cx), handler, noGC); + HeapSnapshotHandler::Traversal traversal(cx, handler, noGC); if (!traversal.init()) return false; traversal.wantNames = wantNames; @@ -1545,7 +1541,7 @@ ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global, { Maybe maybeNoGC; - ubi::RootList rootList(JS_GetRuntime(cx), maybeNoGC, wantNames); + ubi::RootList rootList(cx, maybeNoGC, wantNames); if (!EstablishBoundaries(cx, rv, boundaries, rootList, compartments)) return; diff --git a/devtools/shared/heapsnapshot/tests/gtest/DeserializedNodeUbiNodes.cpp b/devtools/shared/heapsnapshot/tests/gtest/DeserializedNodeUbiNodes.cpp index 374aa90bd48e..e236a0acf797 100644 --- a/devtools/shared/heapsnapshot/tests/gtest/DeserializedNodeUbiNodes.cpp +++ b/devtools/shared/heapsnapshot/tests/gtest/DeserializedNodeUbiNodes.cpp @@ -90,7 +90,7 @@ DEF_TEST(DeserializedNodeUbiNodes, { .Times(1) .WillOnce(Return(JS::ubi::Node(referent3.get()))); - auto range = ubi.edges(rt); + auto range = ubi.edges(cx); ASSERT_TRUE(!!range); for ( ; !range->empty(); range->popFront()) { diff --git a/devtools/shared/heapsnapshot/tests/gtest/DevTools.h b/devtools/shared/heapsnapshot/tests/gtest/DevTools.h index ae675b5f49cb..481b8d9ff1de 100644 --- a/devtools/shared/heapsnapshot/tests/gtest/DevTools.h +++ b/devtools/shared/heapsnapshot/tests/gtest/DevTools.h @@ -158,7 +158,7 @@ class Concrete : public Base return concreteTypeName; } - js::UniquePtr edges(JSRuntime*, bool) const override { + js::UniquePtr edges(JSContext*, bool) const override { return js::UniquePtr(js_new(get().edges)); } @@ -209,8 +209,8 @@ void AddEdge(FakeNode& node, FakeNode& referent, const char16_t* edgeName = null namespace testing { // Ensure that given node has the expected number of edges. -MATCHER_P2(EdgesLength, rt, expectedLength, "") { - auto edges = arg.edges(rt); +MATCHER_P2(EdgesLength, cx, expectedLength, "") { + auto edges = arg.edges(cx); if (!edges) return false; @@ -223,8 +223,8 @@ MATCHER_P2(EdgesLength, rt, expectedLength, "") { } // Get the nth edge and match it with the given matcher. -MATCHER_P3(Edge, rt, n, matcher, "") { - auto edges = arg.edges(rt); +MATCHER_P3(Edge, cx, n, matcher, "") { + auto edges = arg.edges(cx); if (!edges) return false; diff --git a/devtools/shared/heapsnapshot/tests/gtest/SerializesEdgeNames.cpp b/devtools/shared/heapsnapshot/tests/gtest/SerializesEdgeNames.cpp index 42337b17da13..5f3ff338bacc 100644 --- a/devtools/shared/heapsnapshot/tests/gtest/SerializesEdgeNames.cpp +++ b/devtools/shared/heapsnapshot/tests/gtest/SerializesEdgeNames.cpp @@ -28,12 +28,12 @@ DEF_TEST(SerializesEdgeNames, { // Should get the node with edges once. EXPECT_CALL( writer, - writeNode(AllOf(EdgesLength(rt, 3), - Edge(rt, 0, Field(&JS::ubi::Edge::name, + writeNode(AllOf(EdgesLength(cx, 3), + Edge(cx, 0, Field(&JS::ubi::Edge::name, UniqueUTF16StrEq(edgeName))), - Edge(rt, 1, Field(&JS::ubi::Edge::name, + Edge(cx, 1, Field(&JS::ubi::Edge::name, UniqueUTF16StrEq(emptyStr))), - Edge(rt, 2, Field(&JS::ubi::Edge::name, + Edge(cx, 2, Field(&JS::ubi::Edge::name, UniqueIsNull()))), _) ) diff --git a/js/public/UbiNode.h b/js/public/UbiNode.h index deb5c1bb8d2d..c8742f33f1e9 100644 --- a/js/public/UbiNode.h +++ b/js/public/UbiNode.h @@ -71,7 +71,7 @@ // One can construct a ubi::Node value given a pointer to a type that ubi::Node // supports. In the other direction, one can convert a ubi::Node back to a // pointer; these downcasts are checked dynamically. In particular, one can -// convert a 'JSRuntime*' to a ubi::Node, yielding a node with an outgoing edge +// convert a 'JSContext*' to a ubi::Node, yielding a node with an outgoing edge // for every root registered with the runtime; starting from this, one can walk // the entire heap. (Of course, one could also start traversal at any other kind // of type to which one has a pointer.) @@ -591,7 +591,7 @@ class Base { // // If wantNames is true, compute names for edges. Doing so can be expensive // in time and memory. - virtual js::UniquePtr edges(JSRuntime* rt, bool wantNames) const = 0; + virtual js::UniquePtr edges(JSContext* cx, bool wantNames) const = 0; // Return the Zone to which this node's referent belongs, or nullptr if the // referent is not of a type allocated in SpiderMonkey Zones. @@ -792,8 +792,8 @@ class Node { return size; } - js::UniquePtr edges(JSRuntime* rt, bool wantNames = true) const { - return base()->edges(rt, wantNames); + js::UniquePtr edges(JSContext* cx, bool wantNames = true) const { + return base()->edges(cx, wantNames); } bool hasAllocationStack() const { return base()->hasAllocationStack(); } @@ -958,7 +958,7 @@ class PreComputedEdgeRange : public EdgeRange { // // { // mozilla::Maybe maybeNoGC; -// JS::ubi::RootList rootList(rt, maybeNoGC); +// JS::ubi::RootList rootList(cx, maybeNoGC); // if (!rootList.init()) // return false; // @@ -973,11 +973,11 @@ class MOZ_STACK_CLASS RootList { Maybe& noGC; public: - JSRuntime* rt; + JSContext* cx; EdgeVector edges; bool wantNames; - RootList(JSRuntime* rt, Maybe& noGC, bool wantNames = false); + RootList(JSContext* cx, Maybe& noGC, bool wantNames = false); // Find all GC roots. MOZ_MUST_USE bool init(); @@ -1009,7 +1009,7 @@ class Concrete : public Base { public: static void construct(void* storage, RootList* ptr) { new (storage) Concrete(ptr); } - js::UniquePtr edges(JSRuntime* rt, bool wantNames) const override; + js::UniquePtr edges(JSContext* cx, bool wantNames) const override; const char16_t* typeName() const override { return concreteTypeName; } static const char16_t concreteTypeName[]; @@ -1019,7 +1019,7 @@ class Concrete : public Base { // JS::TraceChildren. template class TracerConcrete : public Base { - js::UniquePtr edges(JSRuntime* rt, bool wantNames) const override; + js::UniquePtr edges(JSContext* cx, bool wantNames) const override; JS::Zone* zone() const override; protected: @@ -1118,7 +1118,7 @@ template<> class Concrete : public Base { const char16_t* typeName() const override; Size size(mozilla::MallocSizeOf mallocSizeOf) const override; - js::UniquePtr edges(JSRuntime* rt, bool wantNames) const override; + js::UniquePtr edges(JSContext* cx, bool wantNames) const override; JS::Zone* zone() const override; JSCompartment* compartment() const override; CoarseType coarseType() const final; diff --git a/js/public/UbiNodeBreadthFirst.h b/js/public/UbiNodeBreadthFirst.h index d5a833ff7c82..8446dbc6afaf 100644 --- a/js/public/UbiNodeBreadthFirst.h +++ b/js/public/UbiNodeBreadthFirst.h @@ -83,8 +83,8 @@ struct BreadthFirst { // // We do nothing with noGC, other than require it to exist, with a lifetime // that encloses our own. - BreadthFirst(JSRuntime* rt, Handler& handler, const JS::AutoCheckCannotGC& noGC) - : wantNames(true), rt(rt), visited(), handler(handler), pending(), + BreadthFirst(JSContext* cx, Handler& handler, const JS::AutoCheckCannotGC& noGC) + : wantNames(true), cx(cx), visited(), handler(handler), pending(), traversalBegun(false), stopRequested(false), abandonRequested(false) { } @@ -126,7 +126,7 @@ struct BreadthFirst { pending.popFront(); // Get a range containing all origin's outgoing edges. - auto range = origin.edges(rt, wantNames); + auto range = origin.edges(cx, wantNames); if (!range) return false; @@ -181,8 +181,8 @@ struct BreadthFirst { // Other edges *to* that referent will still be traversed. void abandonReferent() { abandonRequested = true; } - // The runtime with which we were constructed. - JSRuntime* rt; + // The context with which we were constructed. + JSContext* cx; // A map associating each node N that we have reached with a // Handler::NodeData, for |handler|'s use. This is public, so that diff --git a/js/public/UbiNodeDominatorTree.h b/js/public/UbiNodeDominatorTree.h index 9231e8ca8c02..3422b76bc1fc 100644 --- a/js/public/UbiNodeDominatorTree.h +++ b/js/public/UbiNodeDominatorTree.h @@ -323,7 +323,7 @@ class JS_PUBLIC_API(DominatorTree) // Do the post order traversal of the heap graph and populate our // predecessor sets. - static MOZ_MUST_USE bool doTraversal(JSRuntime* rt, AutoCheckCannotGC& noGC, const Node& root, + static MOZ_MUST_USE bool doTraversal(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root, JS::ubi::Vector& postOrder, PredecessorSets& predecessorSets) { uint32_t nodeCount = 0; @@ -349,7 +349,7 @@ class JS_PUBLIC_API(DominatorTree) return p->value()->put(origin); }; - PostOrder traversal(rt, noGC); + PostOrder traversal(cx, noGC); return traversal.init() && traversal.addStart(root) && traversal.traverse(onNode, onEdge); @@ -513,10 +513,10 @@ class JS_PUBLIC_API(DominatorTree) * responsibility to handle and report the OOM. */ static mozilla::Maybe - Create(JSRuntime* rt, AutoCheckCannotGC& noGC, const Node& root) { + Create(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root) { JS::ubi::Vector postOrder; PredecessorSets predecessorSets; - if (!predecessorSets.init() || !doTraversal(rt, noGC, root, postOrder, predecessorSets)) + if (!predecessorSets.init() || !doTraversal(cx, noGC, root, postOrder, predecessorSets)) return mozilla::Nothing(); MOZ_ASSERT(postOrder.length() < UINT32_MAX); diff --git a/js/public/UbiNodePostOrder.h b/js/public/UbiNodePostOrder.h index f0bf3878b1e9..a5042677697a 100644 --- a/js/public/UbiNodePostOrder.h +++ b/js/public/UbiNodePostOrder.h @@ -83,7 +83,7 @@ struct PostOrder { using Stack = js::Vector; using Set = js::HashSet, js::SystemAllocPolicy>; - JSRuntime* rt; + JSContext* cx; Set seen; Stack stack; #ifdef DEBUG @@ -102,7 +102,7 @@ struct PostOrder { MOZ_MUST_USE bool pushForTraversing(const Node& node) { EdgeVector edges; - auto range = node.edges(rt, /* wantNames */ false); + auto range = node.edges(cx, /* wantNames */ false); return range && fillEdgesFromRange(edges, range) && stack.append(OriginAndEdges(node, mozilla::Move(edges))); @@ -115,8 +115,8 @@ struct PostOrder { // The traversal asserts that no GC happens in its runtime during its // lifetime via the `AutoCheckCannotGC&` parameter. We do nothing with it, // other than require it to exist with a lifetime that encloses our own. - PostOrder(JSRuntime* rt, AutoCheckCannotGC&) - : rt(rt) + PostOrder(JSContext* cx, AutoCheckCannotGC&) + : cx(cx) , seen() , stack() #ifdef DEBUG diff --git a/js/public/UbiNodeShortestPaths.h b/js/public/UbiNodeShortestPaths.h index 1e554c8a6e24..edd5aebbe566 100644 --- a/js/public/UbiNodeShortestPaths.h +++ b/js/public/UbiNodeShortestPaths.h @@ -245,7 +245,7 @@ struct JS_PUBLIC_API(ShortestPaths) * responsibility to handle and report the OOM. */ static mozilla::Maybe - Create(JSRuntime* rt, AutoCheckCannotGC& noGC, uint32_t maxNumPaths, const Node& root, NodeSet&& targets) { + Create(JSContext* cx, AutoCheckCannotGC& noGC, uint32_t maxNumPaths, const Node& root, NodeSet&& targets) { MOZ_ASSERT(targets.count() > 0); MOZ_ASSERT(maxNumPaths > 0); @@ -255,7 +255,7 @@ struct JS_PUBLIC_API(ShortestPaths) return mozilla::Nothing(); Handler handler(paths); - Traversal traversal(rt, handler, noGC); + Traversal traversal(cx, handler, noGC); traversal.wantNames = true; if (!traversal.init() || !traversal.addStart(root) || !traversal.traverse()) return mozilla::Nothing(); diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 0b183a72eb18..a0f2398d0563 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -2698,7 +2698,7 @@ FindPath(JSContext* cx, unsigned argc, Value* vp) JS::ubi::Node start(args[0]), target(args[1]); heaptools::FindPathHandler handler(cx, start, target, &nodes, edges); - heaptools::FindPathHandler::Traversal traversal(cx->runtime(), handler, autoCannotGC); + heaptools::FindPathHandler::Traversal traversal(cx, handler, autoCannotGC); if (!traversal.init() || !traversal.addStart(start)) { ReportOutOfMemory(cx); return false; @@ -2845,7 +2845,7 @@ ShortestPaths(JSContext* cx, unsigned argc, Value* vp) } JS::ubi::Node root(args[0]); - auto maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx->runtime(), noGC, maxNumPaths, + auto maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, maxNumPaths, root, mozilla::Move(targets)); if (maybeShortestPaths.isNothing()) { ReportOutOfMemory(cx); diff --git a/js/src/jsapi-tests/testUbiNode.cpp b/js/src/jsapi-tests/testUbiNode.cpp index 93adc9de07c1..075e777d673f 100644 --- a/js/src/jsapi-tests/testUbiNode.cpp +++ b/js/src/jsapi-tests/testUbiNode.cpp @@ -50,7 +50,7 @@ class Concrete : public Base public: static void construct(void* storage, FakeNode* ptr) { new (storage) Concrete(ptr); } - UniquePtr edges(JSRuntime* rt, bool wantNames) const override { + UniquePtr edges(JSContext* cx, bool wantNames) const override { return UniquePtr(js_new(get().edges)); } @@ -375,8 +375,8 @@ BEGIN_TEST(test_ubiPostOrder) // `expectedEdges` as we find them to ensure that we only find each edge // once. - JS::AutoCheckCannotGC nogc(rt); - JS::ubi::PostOrder traversal(rt, nogc); + JS::AutoCheckCannotGC nogc(cx); + JS::ubi::PostOrder traversal(cx, nogc); CHECK(traversal.init()); CHECK(traversal.addStart(&r)); @@ -523,8 +523,8 @@ BEGIN_TEST(test_JS_ubi_DominatorTree) mozilla::Maybe maybeTree; { - JS::AutoCheckCannotGC noGC(rt); - maybeTree = JS::ubi::DominatorTree::Create(rt, noGC, &r); + JS::AutoCheckCannotGC noGC(cx); + maybeTree = JS::ubi::DominatorTree::Create(cx, noGC, &r); } CHECK(maybeTree.isSome()); @@ -693,13 +693,13 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_no_path) mozilla::Maybe maybeShortestPaths; { - JS::AutoCheckCannotGC noGC(rt); + JS::AutoCheckCannotGC noGC(cx); JS::ubi::NodeSet targets; CHECK(targets.init()); CHECK(targets.put(&b)); - maybeShortestPaths = JS::ubi::ShortestPaths::Create(rt, noGC, 10, &a, + maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 10, &a, mozilla::Move(targets)); } @@ -735,13 +735,13 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_one_path) mozilla::Maybe maybeShortestPaths; { - JS::AutoCheckCannotGC noGC(rt); + JS::AutoCheckCannotGC noGC(cx); JS::ubi::NodeSet targets; CHECK(targets.init()); CHECK(targets.put(&b)); - maybeShortestPaths = JS::ubi::ShortestPaths::Create(rt, noGC, 10, &a, + maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 10, &a, mozilla::Move(targets)); } @@ -802,13 +802,13 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_multiple_paths) mozilla::Maybe maybeShortestPaths; { - JS::AutoCheckCannotGC noGC(rt); + JS::AutoCheckCannotGC noGC(cx); JS::ubi::NodeSet targets; CHECK(targets.init()); CHECK(targets.put(&f)); - maybeShortestPaths = JS::ubi::ShortestPaths::Create(rt, noGC, 10, &a, + maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 10, &a, mozilla::Move(targets)); } @@ -894,13 +894,13 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_more_paths_than_max) mozilla::Maybe maybeShortestPaths; { - JS::AutoCheckCannotGC noGC(rt); + JS::AutoCheckCannotGC noGC(cx); JS::ubi::NodeSet targets; CHECK(targets.init()); CHECK(targets.put(&f)); - maybeShortestPaths = JS::ubi::ShortestPaths::Create(rt, noGC, 1, &a, + maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 1, &a, mozilla::Move(targets)); } @@ -944,13 +944,13 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_multiple_edges_to_target) mozilla::Maybe maybeShortestPaths; { - JS::AutoCheckCannotGC noGC(rt); + JS::AutoCheckCannotGC noGC(cx); JS::ubi::NodeSet targets; CHECK(targets.init()); CHECK(targets.put(&b)); - maybeShortestPaths = JS::ubi::ShortestPaths::Create(rt, noGC, 10, &a, + maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 10, &a, mozilla::Move(targets)); } diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 9164e70f997c..c0bef4877ff4 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -4523,13 +4523,13 @@ class MOZ_STACK_CLASS Debugger::ObjectQuery */ Maybe maybeNoGC; RootedObject dbgObj(cx, dbg->object); - JS::ubi::RootList rootList(cx->runtime(), maybeNoGC); + JS::ubi::RootList rootList(cx, maybeNoGC); if (!rootList.init(dbgObj)) { ReportOutOfMemory(cx); return false; } - Traversal traversal(cx->runtime(), *this, maybeNoGC.ref()); + Traversal traversal(cx, *this, maybeNoGC.ref()); if (!traversal.init()) { ReportOutOfMemory(cx); return false; diff --git a/js/src/vm/DebuggerMemory.cpp b/js/src/vm/DebuggerMemory.cpp index 39cad2a137b3..a8619a21b0db 100644 --- a/js/src/vm/DebuggerMemory.cpp +++ b/js/src/vm/DebuggerMemory.cpp @@ -414,13 +414,13 @@ DebuggerMemory::takeCensus(JSContext* cx, unsigned argc, Value* vp) { Maybe maybeNoGC; - JS::ubi::RootList rootList(cx->runtime(), maybeNoGC); + JS::ubi::RootList rootList(cx, maybeNoGC); if (!rootList.init(dbgObj)) { ReportOutOfMemory(cx); return false; } - JS::ubi::CensusTraversal traversal(cx->runtime(), handler, maybeNoGC.ref()); + JS::ubi::CensusTraversal traversal(cx, handler, maybeNoGC.ref()); if (!traversal.init()) { ReportOutOfMemory(cx); return false; diff --git a/js/src/vm/UbiNode.cpp b/js/src/vm/UbiNode.cpp index 1b37b278842d..049b8d5a4592 100644 --- a/js/src/vm/UbiNode.cpp +++ b/js/src/vm/UbiNode.cpp @@ -159,7 +159,7 @@ JS::Zone* Concrete::zone() const { MOZ_CRASH("null ubi::Node") JSCompartment* Concrete::compartment() const { MOZ_CRASH("null ubi::Node"); } UniquePtr -Concrete::edges(JSRuntime*, bool) const { +Concrete::edges(JSContext*, bool) const { MOZ_CRASH("null ubi::Node"); } @@ -314,24 +314,24 @@ template JS::Zone* TracerConcrete::zone() const; template UniquePtr -TracerConcrete::edges(JSRuntime* rt, bool wantNames) const { +TracerConcrete::edges(JSContext* cx, bool wantNames) const { UniquePtr> range(js_new()); if (!range) return nullptr; - if (!range->init(rt, ptr, JS::MapTypeToTraceKind::kind, wantNames)) + if (!range->init(cx, ptr, JS::MapTypeToTraceKind::kind, wantNames)) return nullptr; return UniquePtr(range.release()); } -template UniquePtr TracerConcrete::edges(JSRuntime* rt, bool wantNames) const; -template UniquePtr TracerConcrete::edges(JSRuntime* rt, bool wantNames) const; -template UniquePtr TracerConcrete::edges(JSRuntime* rt, bool wantNames) const; -template UniquePtr TracerConcrete::edges(JSRuntime* rt, bool wantNames) const; -template UniquePtr TracerConcrete::edges(JSRuntime* rt, bool wantNames) const; -template UniquePtr TracerConcrete::edges(JSRuntime* rt, bool wantNames) const; -template UniquePtr TracerConcrete::edges(JSRuntime* rt, bool wantNames) const; +template UniquePtr TracerConcrete::edges(JSContext* cx, bool wantNames) const; +template UniquePtr TracerConcrete::edges(JSContext* cx, bool wantNames) const; +template UniquePtr TracerConcrete::edges(JSContext* cx, bool wantNames) const; +template UniquePtr TracerConcrete::edges(JSContext* cx, bool wantNames) const; +template UniquePtr TracerConcrete::edges(JSContext* cx, bool wantNames) const; +template UniquePtr TracerConcrete::edges(JSContext* cx, bool wantNames) const; +template UniquePtr TracerConcrete::edges(JSContext* cx, bool wantNames) const; template JSCompartment* @@ -398,9 +398,9 @@ const char16_t Concrete::concreteTypeName[] = u"js::ObjectGroup namespace JS { namespace ubi { -RootList::RootList(JSRuntime* rt, Maybe& noGC, bool wantNames /* = false */) +RootList::RootList(JSContext* cx, Maybe& noGC, bool wantNames /* = false */) : noGC(noGC), - rt(rt), + cx(cx), edges(), wantNames(wantNames) { } @@ -409,11 +409,11 @@ RootList::RootList(JSRuntime* rt, Maybe& noGC, bool wantNames bool RootList::init() { - EdgeVectorTracer tracer(rt, &edges, wantNames); + EdgeVectorTracer tracer(cx, &edges, wantNames); js::TraceRuntime(&tracer); if (!tracer.okay) return false; - noGC.emplace(rt); + noGC.emplace(cx); return true; } @@ -421,7 +421,7 @@ bool RootList::init(CompartmentSet& debuggees) { EdgeVector allRootEdges; - EdgeVectorTracer tracer(rt, &allRootEdges, wantNames); + EdgeVectorTracer tracer(cx, &allRootEdges, wantNames); ZoneSet debuggeeZones; if (!debuggeeZones.init()) @@ -453,7 +453,7 @@ RootList::init(CompartmentSet& debuggees) return false; } - noGC.emplace(rt); + noGC.emplace(cx); return true; } @@ -506,7 +506,7 @@ RootList::addRoot(Node node, const char16_t* edgeName) const char16_t Concrete::concreteTypeName[] = u"JS::ubi::RootList"; UniquePtr -Concrete::edges(JSRuntime* rt, bool wantNames) const { +Concrete::edges(JSContext* cx, bool wantNames) const { MOZ_ASSERT_IF(wantNames, get().wantNames); return UniquePtr(js_new(get().edges)); } diff --git a/js/src/vm/UbiNodeShortestPaths.cpp b/js/src/vm/UbiNodeShortestPaths.cpp index 0e4647ba8509..a1a2939979f8 100644 --- a/js/src/vm/UbiNodeShortestPaths.cpp +++ b/js/src/vm/UbiNodeShortestPaths.cpp @@ -45,18 +45,18 @@ dumpNode(const JS::ubi::Node& node) } JS_PUBLIC_API(void) -dumpPaths(JSRuntime* rt, Node node, uint32_t maxNumPaths /* = 10 */) +dumpPaths(JSContext* cx, Node node, uint32_t maxNumPaths /* = 10 */) { mozilla::Maybe nogc; - JS::ubi::RootList rootList(rt, nogc, true); + JS::ubi::RootList rootList(cx, nogc, true); MOZ_ASSERT(rootList.init()); NodeSet targets; bool ok = targets.init() && targets.putNew(node); MOZ_ASSERT(ok); - auto paths = ShortestPaths::Create(rt, nogc.ref(), maxNumPaths, &rootList, mozilla::Move(targets)); + auto paths = ShortestPaths::Create(cx, nogc.ref(), maxNumPaths, &rootList, mozilla::Move(targets)); MOZ_ASSERT(paths.isSome()); int i = 0;