diff --git a/src/serialize.cc b/src/serialize.cc index d5d06a0677..0b39d25642 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -480,16 +480,14 @@ ExternalReferenceDecoder::~ExternalReferenceDecoder() { RootIndexMap::RootIndexMap(Isolate* isolate) { map_ = new HashMap(HashMap::PointersMatch); Object** root_array = isolate->heap()->roots_array_start(); - for (int i = 0; i < Heap::kStrongRootListLength; i++) { + for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) { Object* root = root_array[i]; if (root->IsHeapObject() && !isolate->heap()->InNewSpace(root)) { HeapObject* heap_object = HeapObject::cast(root); - if (LookupEntry(map_, heap_object, false) != NULL) { - // Some root values are initialized to the empty FixedArray(); - // Do not add them to the map. - // TODO(yangguo): This assert is not true. Some roots like - // instanceof_cache_answer can be e.g. null. - // DCHECK_EQ(isolate->heap()->empty_fixed_array(), heap_object); + HashMap::Entry* entry = LookupEntry(map_, heap_object, false); + if (entry != NULL) { + // Some are initialized to a previous value in the root list. + DCHECK_LT(GetValue(entry), i); } else { SetValue(LookupEntry(map_, heap_object, true), i); } diff --git a/src/serialize.h b/src/serialize.h index 6817c7efe6..06ed9fc4f2 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -150,8 +150,8 @@ class AddressMapBase { return static_cast(reinterpret_cast(entry->value)); } - static HashMap::Entry* LookupEntry(HashMap* map, HeapObject* obj, - bool insert) { + inline static HashMap::Entry* LookupEntry(HashMap* map, HeapObject* obj, + bool insert) { return map->Lookup(Key(obj), Hash(obj), insert); } @@ -195,9 +195,9 @@ class PartialCacheIndexMap : public AddressMapBase { // Lookup object in the map. Return its index if found, or create // a new entry with new_index as value, and return kInvalidIndex. int LookupOrInsert(HeapObject* obj, int new_index) { - HashMap::Entry* entry = LookupEntry(&map_, obj, true); - if (entry->value != NULL) return GetValue(entry); - SetValue(entry, static_cast(new_index)); + HashMap::Entry* entry = LookupEntry(&map_, obj, false); + if (entry != NULL) return GetValue(entry); + SetValue(LookupEntry(&map_, obj, true), static_cast(new_index)); return kInvalidIndex; }