5 #include "src/address-map.h" 6 #include "src/heap/heap.h" 7 #include "src/isolate.h" 8 #include "src/objects-inl.h" 13 RootIndexMap::RootIndexMap(Isolate* isolate) {
14 map_ = isolate->root_index_map();
15 if (map_ !=
nullptr)
return;
16 map_ =
new HeapObjectToIndexHashMap();
17 for (RootIndex root_index = RootIndex::kFirstStrongOrReadOnlyRoot;
18 root_index <= RootIndex::kLastStrongOrReadOnlyRoot; ++root_index) {
19 Object* root = isolate->root(root_index);
20 if (!root->IsHeapObject())
continue;
25 if (RootsTable::IsImmortalImmovable(root_index)) {
26 HeapObject* heap_object = HeapObject::cast(root);
27 Maybe<uint32_t> maybe_index = map_->Get(heap_object);
29 if (maybe_index.IsJust()) {
31 DCHECK_LT(maybe_index.FromJust(), index);
33 map_->Set(heap_object, index);
37 isolate->set_root_index_map(map_);