Reviewers: Hannes Payer (slow OOO soon),

Description:
[heap] Remove raw unchecked root set accessors.

[email protected]
BUG=v8:1490
LOG=n

Please review this at https://codereview.chromium.org/1305163007/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+17, -20 lines):
  M src/heap/heap.h
  M src/heap/heap.cc
  M src/heap/spaces.cc
  M src/objects-inl.h


Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 31a9681ef663ac2d2ee69af1e55328dabaf8fd04..4e115f515e16ea900ceb5276ebac7db355b35bf6 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -2576,7 +2576,8 @@ AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
   if (!allocation.To(&result)) return allocation;

   // 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_size(instance_size);
   // Initialize to only containing tagged fields.
@@ -3561,11 +3562,14 @@ void Heap::CreateFillerObjectAt(Address addr, int size) {
   if (size == 0) return;
   HeapObject* filler = HeapObject::FromAddress(addr);
   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) {
- filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map());
+    filler->set_map_no_write_barrier(
+        reinterpret_cast<Map*>(root(kTwoPointerFillerMapRootIndex)));
   } 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);
   }
   // At this point, we may be deserializing the heap from a snapshot, and
@@ -6266,7 +6270,7 @@ void PathTracer::TracePathFrom(Object** root) {


 static bool SafeIsNativeContext(HeapObject* obj) {
-  return obj->map() == obj->GetHeap()->raw_unchecked_native_context_map();
+ return obj->map() == obj->GetHeap()->root(Heap::kNativeContextMapRootIndex);
 }


Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index 20e6ed3e8c3a50fc98df0678ec4ba1e033bc6d23..e1f5788a231b652a146046c87682d5a3b08c7ed4 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1177,15 +1177,8 @@ class Heap {
// Root set access. ========================================================== // ===========================================================================

- // Heap root getters. We have versions with and without type::cast() here.
-  // You can't use type::cast during GC because the assert fails.
- // 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]); \
-  }
+  // Heap root getters.
+#define ROOT_ACCESSOR(type, name, camel_name) inline type* name();
   ROOT_LIST(ROOT_ACCESSOR)
 #undef ROOT_ACCESSOR

Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index 0b4c7690b2cc82e92d3901ccf1bddf4602f6ed52..30c2a5f4631f5f00664c72ef6eb26bf544fa66a6 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -2527,7 +2527,7 @@ intptr_t FreeListCategory::SumFreeList() {
   intptr_t sum = 0;
   FreeSpace* cur = top();
   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();
     cur = cur->next();
   }
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 304c6da09fb6aed02a96b7e6af881570955a07d3..57750c3459187f53f3bf43bda562d0bf3baeeaac 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -3215,8 +3215,8 @@ int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key,
     Object* element = KeyAt(entry);
// Empty entry. Uses raw unchecked accessors because it is called by the
     // string table during bootstrapping.
-    if (element == isolate->heap()->raw_unchecked_undefined_value()) break;
-    if (element != isolate->heap()->raw_unchecked_the_hole_value() &&
+ if (element == isolate->heap()->root(Heap::kUndefinedValueRootIndex)) break;
+    if (element != isolate->heap()->root(Heap::kTheHoleValueRootIndex) &&
         Shape::IsMatch(key, element)) return entry;
     entry = NextProbe(entry, count++, capacity);
   }
@@ -3511,7 +3511,7 @@ int FreeSpace::Size() { return size(); }


 FreeSpace* FreeSpace::next() {
-  DCHECK(map() == GetHeap()->raw_unchecked_free_space_map() ||
+  DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
          (!GetHeap()->deserialization_complete() && map() == NULL));
   DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
   return reinterpret_cast<FreeSpace*>(
@@ -3520,7 +3520,7 @@ FreeSpace* FreeSpace::next() {


 FreeSpace** FreeSpace::next_address() {
-  DCHECK(map() == GetHeap()->raw_unchecked_free_space_map() ||
+  DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
          (!GetHeap()->deserialization_complete() && map() == NULL));
   DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
   return reinterpret_cast<FreeSpace**>(address() + kNextOffset);
@@ -3528,7 +3528,7 @@ FreeSpace** FreeSpace::next_address() {


 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));
   DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
   base::NoBarrier_Store(


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to