Revision: 5613
Author: [email protected]
Date: Wed Oct 13 11:16:30 2010
Log: [Isolates] Remove more HEAP macros from GC.

Review URL: http://codereview.chromium.org/3679002
http://code.google.com/p/v8/source/detail?r=5613

Modified:
 /branches/experimental/isolates/src/mark-compact.cc
 /branches/experimental/isolates/src/mark-compact.h

=======================================
--- /branches/experimental/isolates/src/mark-compact.cc Fri Sep 24 17:27:22 2010 +++ /branches/experimental/isolates/src/mark-compact.cc Wed Oct 13 11:16:30 2010
@@ -234,7 +234,8 @@
   if ((type & kShortcutTypeMask) != kShortcutTypeTag) return object;

Object* second = reinterpret_cast<ConsString*>(object)->unchecked_second();
-  if (second != HEAP->raw_unchecked_empty_string()) {
+  Heap* heap = map_word.ToMap()->heap();
+  if (second != heap->raw_unchecked_empty_string()) {
     return object;
   }

@@ -242,7 +243,7 @@
   // page dirty marks. Therefore, we only replace the string with its left
   // substring when page dirty marks do not change.
   Object* first = reinterpret_cast<ConsString*>(object)->unchecked_first();
-  if (!HEAP->InNewSpace(object) && HEAP->InNewSpace(first)) return object;
+  if (!heap->InNewSpace(object) && heap->InNewSpace(first)) return object;

   *p = first;
   return HeapObject::cast(first);
@@ -1264,59 +1265,71 @@
 // Try to promote all objects in new space.  Heap numbers and sequential
// strings are promoted to the code space, large objects to large object space,
 // and all others to the old space.
-inline Object* MCAllocateFromNewSpace(HeapObject* object, int object_size) {
+inline Object* MCAllocateFromNewSpace(Heap* heap,
+                                      HeapObject* object,
+                                      int object_size) {
   Object* forwarded;
-  if (object_size > HEAP->MaxObjectSizeInPagedSpace()) {
+  if (object_size > heap->MaxObjectSizeInPagedSpace()) {
     forwarded = Failure::Exception();
   } else {
-    OldSpace* target_space = HEAP->TargetSpace(object);
-    ASSERT(target_space == HEAP->old_pointer_space() ||
-           target_space == HEAP->old_data_space());
+    OldSpace* target_space = heap->TargetSpace(object);
+    ASSERT(target_space == heap->old_pointer_space() ||
+           target_space == heap->old_data_space());
     forwarded = target_space->MCAllocateRaw(object_size);
   }
   if (forwarded->IsFailure()) {
-    forwarded = HEAP->new_space()->MCAllocateRaw(object_size);
+    forwarded = heap->new_space()->MCAllocateRaw(object_size);
   }
   return forwarded;
 }


// Allocation functions for the paged spaces call the space's MCAllocateRaw.
-inline Object* MCAllocateFromOldPointerSpace(HeapObject* ignore,
+inline Object* MCAllocateFromOldPointerSpace(Heap* heap,
+                                             HeapObject* ignore,
                                              int object_size) {
-  return HEAP->old_pointer_space()->MCAllocateRaw(object_size);
+  return heap->old_pointer_space()->MCAllocateRaw(object_size);
 }


-inline Object* MCAllocateFromOldDataSpace(HeapObject* ignore, int object_size) {
-  return HEAP->old_data_space()->MCAllocateRaw(object_size);
+inline Object* MCAllocateFromOldDataSpace(Heap* heap,
+                                          HeapObject* ignore,
+                                          int object_size) {
+  return heap->old_data_space()->MCAllocateRaw(object_size);
 }


-inline Object* MCAllocateFromCodeSpace(HeapObject* ignore, int object_size) {
-  return HEAP->code_space()->MCAllocateRaw(object_size);
+inline Object* MCAllocateFromCodeSpace(Heap* heap,
+                                       HeapObject* ignore,
+                                       int object_size) {
+  return heap->code_space()->MCAllocateRaw(object_size);
 }


-inline Object* MCAllocateFromMapSpace(HeapObject* ignore, int object_size) {
-  return HEAP->map_space()->MCAllocateRaw(object_size);
+inline Object* MCAllocateFromMapSpace(Heap* heap,
+                                      HeapObject* ignore,
+                                      int object_size) {
+  return heap->map_space()->MCAllocateRaw(object_size);
 }


-inline Object* MCAllocateFromCellSpace(HeapObject* ignore, int object_size) {
-  return HEAP->cell_space()->MCAllocateRaw(object_size);
+inline Object* MCAllocateFromCellSpace(Heap* heap,
+                                       HeapObject* ignore,
+                                       int object_size) {
+  return heap->cell_space()->MCAllocateRaw(object_size);
 }


 // The forwarding address is encoded at the same offset as the current
 // to-space object, but in from space.
-inline void EncodeForwardingAddressInNewSpace(HeapObject* old_object,
+inline void EncodeForwardingAddressInNewSpace(Heap* heap,
+                                              HeapObject* old_object,
                                               int object_size,
                                               Object* new_object,
                                               int* ignored) {
   int offset =
-      HEAP->new_space()->ToSpaceOffsetForAddress(old_object->address());
-  Memory::Address_at(HEAP->new_space()->FromSpaceLow() + offset) =
+      heap->new_space()->ToSpaceOffsetForAddress(old_object->address());
+  Memory::Address_at(heap->new_space()->FromSpaceLow() + offset) =
       HeapObject::cast(new_object)->address();
 }

@@ -1324,7 +1337,8 @@
 // The forwarding address is encoded in the map pointer of the object as an
// offset (in terms of live bytes) from the address of the first live object
 // in the page.
-inline void EncodeForwardingAddressInPagedSpace(HeapObject* old_object,
+inline void EncodeForwardingAddressInPagedSpace(Heap* heap,
+                                                HeapObject* old_object,
                                                 int object_size,
                                                 Object* new_object,
                                                 int* offset) {
@@ -1381,10 +1395,10 @@
       collector->tracer()->decrement_marked_count();
       object_size = object->Size();

-      Object* forwarded = Alloc(object, object_size);
+      Object* forwarded = Alloc(collector->heap(), object, object_size);
       // Allocation cannot fail, because we are compacting the space.
       ASSERT(!forwarded->IsFailure());
-      Encode(object, object_size, forwarded, offset);
+      Encode(collector->heap(), object, object_size, forwarded, offset);

 #ifdef DEBUG
       if (FLAG_gc_verbose) {
@@ -1420,8 +1434,8 @@
                                    EncodeForwardingAddressInNewSpace,
                                    IgnoreNonLiveObject>(
       this,
-      HEAP->new_space()->bottom(),
-      HEAP->new_space()->top(),
+      heap_->new_space()->bottom(),
+      heap_->new_space()->top(),
       &ignored);
 }

@@ -1831,24 +1845,24 @@
   // Objects in the active semispace of the young generation may be
   // relocated to the inactive semispace (if not promoted).  Set the
   // relocation info to the beginning of the inactive semispace.
-  HEAP->new_space()->MCResetRelocationInfo();
+  heap_->new_space()->MCResetRelocationInfo();

   // Compute the forwarding pointers in each space.
   EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldPointerSpace,
                                         ReportDeleteIfNeeded>(
-      HEAP->old_pointer_space());
+      heap_->old_pointer_space());

   EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldDataSpace,
                                         IgnoreNonLiveObject>(
-      HEAP->old_data_space());
+      heap_->old_data_space());

   EncodeForwardingAddressesInPagedSpace<MCAllocateFromCodeSpace,
                                         ReportDeleteIfNeeded>(
-      HEAP->code_space());
+      heap_->code_space());

   EncodeForwardingAddressesInPagedSpace<MCAllocateFromCellSpace,
                                         IgnoreNonLiveObject>(
-      HEAP->cell_space());
+      heap_->cell_space());


   // Compute new space next to last after the old and code spaces have been
@@ -1860,16 +1874,16 @@
   // non-live map pointers to get the sizes of non-live objects.
   EncodeForwardingAddressesInPagedSpace<MCAllocateFromMapSpace,
                                         IgnoreNonLiveObject>(
-      HEAP->map_space());
+      heap_->map_space());

// Write relocation info to the top page, so we can use it later. This is
   // done after promoting objects from the new space so we get the correct
   // allocation top.
-  HEAP->old_pointer_space()->MCWriteRelocationInfoToPage();
-  HEAP->old_data_space()->MCWriteRelocationInfoToPage();
-  HEAP->code_space()->MCWriteRelocationInfoToPage();
-  HEAP->map_space()->MCWriteRelocationInfoToPage();
-  HEAP->cell_space()->MCWriteRelocationInfoToPage();
+  heap_->old_pointer_space()->MCWriteRelocationInfoToPage();
+  heap_->old_data_space()->MCWriteRelocationInfoToPage();
+  heap_->code_space()->MCWriteRelocationInfoToPage();
+  heap_->map_space()->MCWriteRelocationInfoToPage();
+  heap_->cell_space()->MCWriteRelocationInfoToPage();
 }


@@ -2012,9 +2026,8 @@

     ASSERT(Map::kSize % 4 == 0);

-    HEAP->CopyBlockToOldSpaceAndUpdateRegionMarks(vacant_map->address(),
- map_to_evacuate->address(),
-                                                  Map::kSize);
+    map_to_evacuate->heap()->CopyBlockToOldSpaceAndUpdateRegionMarks(
+        vacant_map->address(), map_to_evacuate->address(), Map::kSize);

     ASSERT(vacant_map->IsMap());  // Due to memcpy above.

=======================================
--- /branches/experimental/isolates/src/mark-compact.h Fri Sep 24 17:27:22 2010 +++ /branches/experimental/isolates/src/mark-compact.h Wed Oct 13 11:16:30 2010
@@ -109,7 +109,9 @@
   // Object* that will be the object after forwarding.  There is a separate
   // allocation function for each (compactable) space based on the location
   // of the object before compaction.
- typedef Object* (*AllocationFunction)(HeapObject* object, int object_size);
+  typedef Object* (*AllocationFunction)(Heap* heap,
+                                        HeapObject* object,
+                                        int object_size);

   // Type of functions to encode the forwarding address for an object.
// Given the object, its size, and the new (non-failure) object it will be
@@ -119,7 +121,8 @@
   // page as input, and is updated to contain the offset to be used for the
   // next live object in the same page.  For spaces using a different
   // encoding (ie, contiguous spaces), the offset parameter is ignored.
-  typedef void (*EncodingFunction)(HeapObject* old_object,
+  typedef void (*EncodingFunction)(Heap* heap,
+                                   HeapObject* old_object,
                                    int object_size,
                                    Object* new_object,
                                    int* offset);
@@ -181,6 +184,8 @@
   // that indicate free regions.
   static const uint32_t kSingleFreeEncoding = 0;
   static const uint32_t kMultiFreeEncoding = 1;
+
+  inline Heap* heap() const { return heap_; }

  private:
   MarkCompactCollector();

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

Reply via email to