Reviewers: Mads Ager,

Description:
[Isolates] Get the current heap from page header instead of Map field.

Please review this at http://codereview.chromium.org/6469079/

Affected files:
  M include/v8.h
  M src/heap.cc
  M src/objects-inl.h
  M src/objects.h
  M src/serialize.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index c157dd565bc2787be4737e99f07c913e9da7b432..4f9017001f1d6b6594b5e26247b96ce678e461b8 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -3447,7 +3447,7 @@ class Internals {
   // These values match non-compiler-dependent values defined within
   // the implementation of v8.
   static const int kHeapObjectMapOffset = 0;
- static const int kMapInstanceTypeOffset = 2 * kApiPointerSize + kApiIntSize; + static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize;
   static const int kStringResourceOffset =
       InternalConstants<kApiPointerSize>::kStringResourceOffset;

Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 78166d00f32c96017f99c3b3e66db30b085c366a..6a407e4ce1665bc2093e7bed4a8e7e0b3617a877 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -1498,7 +1498,6 @@ MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type,

   // 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_heap(this);
   reinterpret_cast<Map*>(result)->set_instance_type(instance_type);
   reinterpret_cast<Map*>(result)->set_instance_size(instance_size);
   reinterpret_cast<Map*>(result)->set_visitor_id(
@@ -1520,7 +1519,6 @@ MaybeObject* Heap::AllocateMap(InstanceType instance_type, int instance_size) {

   Map* map = reinterpret_cast<Map*>(result);
   map->set_map(meta_map());
-  map->set_heap(this);
   map->set_instance_type(instance_type);
   map->set_visitor_id(
       StaticVisitorBase::GetVisitorId(instance_type, instance_size));
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 1ad9b0f6e46678783b46e0a981f1f15d58f188fc..aa541f72b0e576cf957f81ce15255804177b0c80 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2738,21 +2738,14 @@ Code* Code::GetCodeFromTargetAddress(Address address) {


 Heap* Map::heap() {
- Heap* heap = reinterpret_cast<Heap*>(READ_INTPTR_FIELD(this, kHeapOffset));
+  // NOTE: address() helper is not used to save one instruction.
+  Heap* heap = Page::FromAddress(reinterpret_cast<Address>(this))->heap_;
   ASSERT(heap != NULL);
   ASSERT(heap->isolate() == Isolate::Current());
   return heap;
 }


-void Map::set_heap(Heap* heap) {
-  ASSERT(heap != NULL);
-  ASSERT(heap->isolate() == Isolate::Current());
-  // WRITE_FIELD does not invoke write barrier, but there is no need here.
-  WRITE_INTPTR_FIELD(this, kHeapOffset, reinterpret_cast<intptr_t>(heap));
-}
-
-
 Object* Code::GetObjectFromEntryAddress(Address location_of_address) {
   return HeapObject::
FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize);
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 872f9dfc9aa4be5c3a19c9c41d17ab2a16da8c23..3bc2f4c0d33ea87895dd23f0e58fbd80c26e1237 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -3557,9 +3557,8 @@ class Map: public HeapObject {
   inline int visitor_id();
   inline void set_visitor_id(int visitor_id);

-  // Meta map has a heap pointer for fast access to Heap and Isolate.
+  // Returns the heap this map belongs to.
   inline Heap* heap();
-  inline void set_heap(Heap* heap);

   typedef void (*TraverseCallback)(Map* map, void* data);

@@ -3568,8 +3567,7 @@ class Map: public HeapObject {
   static const int kMaxPreAllocatedPropertyFields = 255;

   // Layout description.
-  static const int kHeapOffset = HeapObject::kHeaderSize;
-  static const int kInstanceSizesOffset = kHeapOffset + kPointerSize;
+  static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
   static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize;
   static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index 2b6e9ce8c8a3bb15ac315ca78feb4925fe73153a..0a4b610c09deb331528fc2e60f130188386eb3b3 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -713,13 +713,6 @@ void Deserializer::ReadObject(int space_number,
     LOG(SnapshotPositionEvent(address, source_->position()));
   }
   ReadChunk(current, limit, space_number, address);
-
-  if (space_number == MAP_SPACE) {
-    ASSERT(size == Map::kSize);
-    HeapObject* obj = HeapObject::FromAddress(address);
-    Map* map = reinterpret_cast<Map*>(obj);
-    map->set_heap(isolate_->heap());
-  }
 }




--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to