Bug 1286795 part 3 - Change UbiNode APIs to take JSContext instead of JSRuntime. r=fitzgen

This commit is contained in:
Jan de Mooij 2016-07-23 19:52:25 +02:00
Родитель 8073c28728
Коммит 0770a8d8b4
17 изменённых файлов: 88 добавлений и 92 удалений

Просмотреть файл

@ -121,7 +121,7 @@ Concrete<DeserializedNode>::allocationStack() const
js::UniquePtr<EdgeRange>
Concrete<DeserializedNode>::edges(JSRuntime* rt, bool) const
Concrete<DeserializedNode>::edges(JSContext* cx, bool) const
{
js::UniquePtr<DeserializedEdgeRange> range(js_new<DeserializedEdgeRange>(get()));

Просмотреть файл

@ -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<EdgeRange> edges(JSRuntime* rt, bool) const override;
js::UniquePtr<EdgeRange> edges(JSContext* cx, bool) const override;
static const char16_t concreteTypeName[];
};

Просмотреть файл

@ -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<ShortestPaths> 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<AutoCheckCannotGC> maybeNoGC;
ubi::RootList rootList(JS_GetRuntime(cx), maybeNoGC, wantNames);
ubi::RootList rootList(cx, maybeNoGC, wantNames);
if (!EstablishBoundaries(cx, rv, boundaries, rootList, compartments))
return;

Просмотреть файл

@ -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()) {

Просмотреть файл

@ -158,7 +158,7 @@ class Concrete<FakeNode> : public Base
return concreteTypeName;
}
js::UniquePtr<EdgeRange> edges(JSRuntime*, bool) const override {
js::UniquePtr<EdgeRange> edges(JSContext*, bool) const override {
return js::UniquePtr<EdgeRange>(js_new<PreComputedEdgeRange>(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;

Просмотреть файл

@ -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()))),
_)
)

Просмотреть файл

@ -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<EdgeRange> edges(JSRuntime* rt, bool wantNames) const = 0;
virtual js::UniquePtr<EdgeRange> 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<EdgeRange> edges(JSRuntime* rt, bool wantNames = true) const {
return base()->edges(rt, wantNames);
js::UniquePtr<EdgeRange> 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<JS::AutoCheckCannotGC> 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<AutoCheckCannotGC>& noGC;
public:
JSRuntime* rt;
JSContext* cx;
EdgeVector edges;
bool wantNames;
RootList(JSRuntime* rt, Maybe<AutoCheckCannotGC>& noGC, bool wantNames = false);
RootList(JSContext* cx, Maybe<AutoCheckCannotGC>& noGC, bool wantNames = false);
// Find all GC roots.
MOZ_MUST_USE bool init();
@ -1009,7 +1009,7 @@ class Concrete<RootList> : public Base {
public:
static void construct(void* storage, RootList* ptr) { new (storage) Concrete(ptr); }
js::UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override;
js::UniquePtr<EdgeRange> 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<RootList> : public Base {
// JS::TraceChildren.
template<typename Referent>
class TracerConcrete : public Base {
js::UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override;
js::UniquePtr<EdgeRange> edges(JSContext* cx, bool wantNames) const override;
JS::Zone* zone() const override;
protected:
@ -1118,7 +1118,7 @@ template<>
class Concrete<void> : public Base {
const char16_t* typeName() const override;
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
js::UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override;
js::UniquePtr<EdgeRange> edges(JSContext* cx, bool wantNames) const override;
JS::Zone* zone() const override;
JSCompartment* compartment() const override;
CoarseType coarseType() const final;

Просмотреть файл

@ -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

Просмотреть файл

@ -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<Node>& 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<DominatorTree>
Create(JSRuntime* rt, AutoCheckCannotGC& noGC, const Node& root) {
Create(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root) {
JS::ubi::Vector<Node> 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);

Просмотреть файл

@ -83,7 +83,7 @@ struct PostOrder {
using Stack = js::Vector<OriginAndEdges, 256, js::SystemAllocPolicy>;
using Set = js::HashSet<Node, js::DefaultHasher<Node>, 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

Просмотреть файл

@ -245,7 +245,7 @@ struct JS_PUBLIC_API(ShortestPaths)
* responsibility to handle and report the OOM.
*/
static mozilla::Maybe<ShortestPaths>
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();

Просмотреть файл

@ -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);

Просмотреть файл

@ -50,7 +50,7 @@ class Concrete<FakeNode> : public Base
public:
static void construct(void* storage, FakeNode* ptr) { new (storage) Concrete(ptr); }
UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override {
UniquePtr<EdgeRange> edges(JSContext* cx, bool wantNames) const override {
return UniquePtr<EdgeRange>(js_new<PreComputedEdgeRange>(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<JS::ubi::DominatorTree> 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<JS::ubi::ShortestPaths> 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<JS::ubi::ShortestPaths> 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<JS::ubi::ShortestPaths> 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<JS::ubi::ShortestPaths> 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<JS::ubi::ShortestPaths> 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));
}

Просмотреть файл

@ -4523,13 +4523,13 @@ class MOZ_STACK_CLASS Debugger::ObjectQuery
*/
Maybe<JS::AutoCheckCannotGC> 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;

Просмотреть файл

@ -414,13 +414,13 @@ DebuggerMemory::takeCensus(JSContext* cx, unsigned argc, Value* vp)
{
Maybe<JS::AutoCheckCannotGC> 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;

Просмотреть файл

@ -159,7 +159,7 @@ JS::Zone* Concrete<void>::zone() const { MOZ_CRASH("null ubi::Node")
JSCompartment* Concrete<void>::compartment() const { MOZ_CRASH("null ubi::Node"); }
UniquePtr<EdgeRange>
Concrete<void>::edges(JSRuntime*, bool) const {
Concrete<void>::edges(JSContext*, bool) const {
MOZ_CRASH("null ubi::Node");
}
@ -314,24 +314,24 @@ template JS::Zone* TracerConcrete<JSString>::zone() const;
template<typename Referent>
UniquePtr<EdgeRange>
TracerConcrete<Referent>::edges(JSRuntime* rt, bool wantNames) const {
TracerConcrete<Referent>::edges(JSContext* cx, bool wantNames) const {
UniquePtr<SimpleEdgeRange, JS::DeletePolicy<SimpleEdgeRange>> range(js_new<SimpleEdgeRange>());
if (!range)
return nullptr;
if (!range->init(rt, ptr, JS::MapTypeToTraceKind<Referent>::kind, wantNames))
if (!range->init(cx, ptr, JS::MapTypeToTraceKind<Referent>::kind, wantNames))
return nullptr;
return UniquePtr<EdgeRange>(range.release());
}
template UniquePtr<EdgeRange> TracerConcrete<JSScript>::edges(JSRuntime* rt, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::LazyScript>::edges(JSRuntime* rt, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::Shape>::edges(JSRuntime* rt, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::BaseShape>::edges(JSRuntime* rt, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::ObjectGroup>::edges(JSRuntime* rt, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<JS::Symbol>::edges(JSRuntime* rt, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<JSString>::edges(JSRuntime* rt, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<JSScript>::edges(JSContext* cx, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::LazyScript>::edges(JSContext* cx, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::Shape>::edges(JSContext* cx, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::BaseShape>::edges(JSContext* cx, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::ObjectGroup>::edges(JSContext* cx, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<JS::Symbol>::edges(JSContext* cx, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<JSString>::edges(JSContext* cx, bool wantNames) const;
template<typename Referent>
JSCompartment*
@ -398,9 +398,9 @@ const char16_t Concrete<js::ObjectGroup>::concreteTypeName[] = u"js::ObjectGroup
namespace JS {
namespace ubi {
RootList::RootList(JSRuntime* rt, Maybe<AutoCheckCannotGC>& noGC, bool wantNames /* = false */)
RootList::RootList(JSContext* cx, Maybe<AutoCheckCannotGC>& noGC, bool wantNames /* = false */)
: noGC(noGC),
rt(rt),
cx(cx),
edges(),
wantNames(wantNames)
{ }
@ -409,11 +409,11 @@ RootList::RootList(JSRuntime* rt, Maybe<AutoCheckCannotGC>& 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<RootList>::concreteTypeName[] = u"JS::ubi::RootList";
UniquePtr<EdgeRange>
Concrete<RootList>::edges(JSRuntime* rt, bool wantNames) const {
Concrete<RootList>::edges(JSContext* cx, bool wantNames) const {
MOZ_ASSERT_IF(wantNames, get().wantNames);
return UniquePtr<EdgeRange>(js_new<PreComputedEdgeRange>(get().edges));
}

Просмотреть файл

@ -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<AutoCheckCannotGC> 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;