dom::Nullable<uint64_t> DominatorTree::GetImmediateDominator( uint64_t aNodeId) const { JS::ubi::Node::Id id(aNodeId); Maybe<JS::ubi::Node> node = mHeapSnapshot->getNodeById(id); if (node.isNothing()) return dom::Nullable<uint64_t>(); JS::ubi::Node dominator = mDominatorTree.getImmediateDominator(*node); if (!dominator || dominator == *node) return dom::Nullable<uint64_t>(); return dom::Nullable<uint64_t>(dominator.identifier()); }
const char* className = "MyObjectClassName"; NodeId id = 1L << 33; uint64_t size = 1L << 60; MockDeserializedNode mocked(id, typeName, size); mocked.jsObjectClassName = mozilla::UniquePtr<char[]>(strdup(className)); ASSERT_TRUE(!!mocked.jsObjectClassName); DeserializedNode& deserialized = mocked; JS::ubi::Node ubi(&deserialized); // Test the ubi::Node accessors. EXPECT_EQ(size, ubi.size(fakeMallocSizeOf)); EXPECT_EQ(typeName, ubi.typeName()); EXPECT_EQ(id, ubi.identifier()); EXPECT_FALSE(ubi.isLive()); EXPECT_EQ(strcmp(ubi.jsObjectClassName(), className), 0); // Test the ubi::Node's edges. UniquePtr<DeserializedNode> referent1(new MockDeserializedNode(1, nullptr, 10)); DeserializedEdge edge1; edge1.referent = referent1->id; mocked.addEdge(Move(edge1)); EXPECT_CALL(mocked, getEdgeReferent(Field(&DeserializedEdge::referent, referent1->id))) .Times(1)