62f929ff4c
New code should use nullptr instead of NULL. This patch updates existing use of NULL to nullptr where applicable, making the code base more consistent. BUG=v8:6928,v8:6921 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng;master.tryserver.v8:v8_linux_noi18n_rel_ng Change-Id: I4687f5b96fcfd88b41fa970a2b937b4f6538777c Reviewed-on: https://chromium-review.googlesource.com/718338 Commit-Queue: Mathias Bynens <mathias@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#48557}
46 lines
1.7 KiB
C++
46 lines
1.7 KiB
C++
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "src/address-map.h"
|
|
#include "src/heap/heap.h"
|
|
#include "src/isolate.h"
|
|
#include "src/objects-inl.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
RootIndexMap::RootIndexMap(Isolate* isolate) {
|
|
map_ = isolate->root_index_map();
|
|
if (map_ != nullptr) return;
|
|
map_ = new HeapObjectToIndexHashMap();
|
|
for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) {
|
|
Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i);
|
|
Object* root = isolate->heap()->root(root_index);
|
|
if (!root->IsHeapObject()) continue;
|
|
// Omit root entries that can be written after initialization. They must
|
|
// not be referenced through the root list in the snapshot.
|
|
// Since we map the raw address of an root item to its root list index, the
|
|
// raw address must be constant, i.e. the object must be immovable.
|
|
if (isolate->heap()->RootCanBeTreatedAsConstant(root_index)) {
|
|
HeapObject* heap_object = HeapObject::cast(root);
|
|
Maybe<uint32_t> maybe_index = map_->Get(heap_object);
|
|
if (maybe_index.IsJust()) {
|
|
// Some are initialized to a previous value in the root list.
|
|
DCHECK_LT(maybe_index.FromJust(), i);
|
|
} else {
|
|
map_->Set(heap_object, i);
|
|
}
|
|
} else {
|
|
// Immortal immovable root objects are constant and allocated on the first
|
|
// page of old space. Non-constant roots cannot be immortal immovable. The
|
|
// root index map contains all immortal immmovable root objects.
|
|
CHECK(!Heap::RootIsImmortalImmovable(root_index));
|
|
}
|
|
}
|
|
isolate->set_root_index_map(map_);
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|