Commit e276f5d8 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[heap] Remove raw unchecked root set accessors.

R=hpayer@chromium.org
BUG=v8:1490
LOG=n

Review URL: https://codereview.chromium.org/1305163007

Cr-Commit-Position: refs/heads/master@{#30412}
parent ebda415e
...@@ -2577,7 +2577,8 @@ AllocationResult Heap::AllocatePartialMap(InstanceType instance_type, ...@@ -2577,7 +2577,8 @@ AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
if (!allocation.To(&result)) return allocation; if (!allocation.To(&result)) return allocation;
// Map::cast cannot be used due to uninitialized map field. // Map::cast cannot be used due to uninitialized map field.
reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); reinterpret_cast<Map*>(result)->set_map(
reinterpret_cast<Map*>(root(kMetaMapRootIndex)));
reinterpret_cast<Map*>(result)->set_instance_type(instance_type); reinterpret_cast<Map*>(result)->set_instance_type(instance_type);
reinterpret_cast<Map*>(result)->set_instance_size(instance_size); reinterpret_cast<Map*>(result)->set_instance_size(instance_size);
// Initialize to only containing tagged fields. // Initialize to only containing tagged fields.
...@@ -3562,11 +3563,14 @@ void Heap::CreateFillerObjectAt(Address addr, int size) { ...@@ -3562,11 +3563,14 @@ void Heap::CreateFillerObjectAt(Address addr, int size) {
if (size == 0) return; if (size == 0) return;
HeapObject* filler = HeapObject::FromAddress(addr); HeapObject* filler = HeapObject::FromAddress(addr);
if (size == kPointerSize) { if (size == kPointerSize) {
filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); filler->set_map_no_write_barrier(
reinterpret_cast<Map*>(root(kOnePointerFillerMapRootIndex)));
} else if (size == 2 * kPointerSize) { } else if (size == 2 * kPointerSize) {
filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); filler->set_map_no_write_barrier(
reinterpret_cast<Map*>(root(kTwoPointerFillerMapRootIndex)));
} else { } else {
filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); filler->set_map_no_write_barrier(
reinterpret_cast<Map*>(root(kFreeSpaceMapRootIndex)));
FreeSpace::cast(filler)->nobarrier_set_size(size); FreeSpace::cast(filler)->nobarrier_set_size(size);
} }
// At this point, we may be deserializing the heap from a snapshot, and // At this point, we may be deserializing the heap from a snapshot, and
...@@ -6269,7 +6273,7 @@ void PathTracer::TracePathFrom(Object** root) { ...@@ -6269,7 +6273,7 @@ void PathTracer::TracePathFrom(Object** root) {
static bool SafeIsNativeContext(HeapObject* obj) { static bool SafeIsNativeContext(HeapObject* obj) {
return obj->map() == obj->GetHeap()->raw_unchecked_native_context_map(); return obj->map() == obj->GetHeap()->root(Heap::kNativeContextMapRootIndex);
} }
......
...@@ -1177,15 +1177,8 @@ class Heap { ...@@ -1177,15 +1177,8 @@ class Heap {
// Root set access. ========================================================== // Root set access. ==========================================================
// =========================================================================== // ===========================================================================
// Heap root getters. We have versions with and without type::cast() here. // Heap root getters.
// You can't use type::cast during GC because the assert fails. #define ROOT_ACCESSOR(type, name, camel_name) inline type* name();
// TODO(1490): Try removing the unchecked accessors, now that GC marking does
// not corrupt the map.
#define ROOT_ACCESSOR(type, name, camel_name) \
inline type* name(); \
type* raw_unchecked_##name() { \
return reinterpret_cast<type*>(roots_[k##camel_name##RootIndex]); \
}
ROOT_LIST(ROOT_ACCESSOR) ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
......
...@@ -2527,7 +2527,7 @@ intptr_t FreeListCategory::SumFreeList() { ...@@ -2527,7 +2527,7 @@ intptr_t FreeListCategory::SumFreeList() {
intptr_t sum = 0; intptr_t sum = 0;
FreeSpace* cur = top(); FreeSpace* cur = top();
while (cur != NULL) { while (cur != NULL) {
DCHECK(cur->map() == cur->GetHeap()->raw_unchecked_free_space_map()); DCHECK(cur->map() == cur->GetHeap()->root(Heap::kFreeSpaceMapRootIndex));
sum += cur->nobarrier_size(); sum += cur->nobarrier_size();
cur = cur->next(); cur = cur->next();
} }
......
...@@ -3215,8 +3215,8 @@ int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key, ...@@ -3215,8 +3215,8 @@ int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key,
Object* element = KeyAt(entry); Object* element = KeyAt(entry);
// Empty entry. Uses raw unchecked accessors because it is called by the // Empty entry. Uses raw unchecked accessors because it is called by the
// string table during bootstrapping. // string table during bootstrapping.
if (element == isolate->heap()->raw_unchecked_undefined_value()) break; if (element == isolate->heap()->root(Heap::kUndefinedValueRootIndex)) break;
if (element != isolate->heap()->raw_unchecked_the_hole_value() && if (element != isolate->heap()->root(Heap::kTheHoleValueRootIndex) &&
Shape::IsMatch(key, element)) return entry; Shape::IsMatch(key, element)) return entry;
entry = NextProbe(entry, count++, capacity); entry = NextProbe(entry, count++, capacity);
} }
...@@ -3511,7 +3511,7 @@ int FreeSpace::Size() { return size(); } ...@@ -3511,7 +3511,7 @@ int FreeSpace::Size() { return size(); }
FreeSpace* FreeSpace::next() { FreeSpace* FreeSpace::next() {
DCHECK(map() == GetHeap()->raw_unchecked_free_space_map() || DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
(!GetHeap()->deserialization_complete() && map() == NULL)); (!GetHeap()->deserialization_complete() && map() == NULL));
DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size()); DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
return reinterpret_cast<FreeSpace*>( return reinterpret_cast<FreeSpace*>(
...@@ -3520,7 +3520,7 @@ FreeSpace* FreeSpace::next() { ...@@ -3520,7 +3520,7 @@ FreeSpace* FreeSpace::next() {
FreeSpace** FreeSpace::next_address() { FreeSpace** FreeSpace::next_address() {
DCHECK(map() == GetHeap()->raw_unchecked_free_space_map() || DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
(!GetHeap()->deserialization_complete() && map() == NULL)); (!GetHeap()->deserialization_complete() && map() == NULL));
DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size()); DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
return reinterpret_cast<FreeSpace**>(address() + kNextOffset); return reinterpret_cast<FreeSpace**>(address() + kNextOffset);
...@@ -3528,7 +3528,7 @@ FreeSpace** FreeSpace::next_address() { ...@@ -3528,7 +3528,7 @@ FreeSpace** FreeSpace::next_address() {
void FreeSpace::set_next(FreeSpace* next) { void FreeSpace::set_next(FreeSpace* next) {
DCHECK(map() == GetHeap()->raw_unchecked_free_space_map() || DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
(!GetHeap()->deserialization_complete() && map() == NULL)); (!GetHeap()->deserialization_complete() && map() == NULL));
DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size()); DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
base::NoBarrier_Store( base::NoBarrier_Store(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment