Use easier method to determine allocation space when serializing.
authoryangguo <yangguo@chromium.org>
Wed, 25 Feb 2015 14:05:39 +0000 (06:05 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 25 Feb 2015 14:05:44 +0000 (14:05 +0000)
R=hpayer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#26851}

src/serialize.cc
src/serialize.h

index 05a5418..8a383db 100644 (file)
@@ -1888,7 +1888,9 @@ void Serializer::ObjectSerializer::Serialize() {
 
   int size = object_->Size();
   Map* map = object_->map();
-  SerializePrologue(Serializer::SpaceOfObject(object_), size, map);
+  AllocationSpace space =
+      MemoryChunk::FromAddress(object_->address())->owner()->identity();
+  SerializePrologue(space, size, map);
 
   // Serialize the rest of the object.
   CHECK_EQ(0, bytes_processed_so_far_);
@@ -2128,19 +2130,6 @@ int Serializer::ObjectSerializer::OutputRawData(
 }
 
 
-AllocationSpace Serializer::SpaceOfObject(HeapObject* object) {
-  for (int i = FIRST_SPACE; i <= LAST_SPACE; i++) {
-    AllocationSpace s = static_cast<AllocationSpace>(i);
-    if (object->GetHeap()->InSpace(object, s)) {
-      DCHECK(i < kNumberOfSpaces);
-      return s;
-    }
-  }
-  UNREACHABLE();
-  return FIRST_SPACE;
-}
-
-
 BackReference Serializer::AllocateLargeObject(int size) {
   // Large objects are allocated one-by-one when deserializing. We do not
   // have to keep track of multiple chunks.
index 64164c8..8118eef 100644 (file)
@@ -732,7 +732,6 @@ class Serializer : public SerializerDeserializer {
   bool BackReferenceIsAlreadyAllocated(BackReference back_reference);
 
   // This will return the space for an object.
-  static AllocationSpace SpaceOfObject(HeapObject* object);
   BackReference AllocateLargeObject(int size);
   BackReference Allocate(AllocationSpace space, int size);
   int EncodeExternalReference(Address addr) {