From 30a6e46a395ef14f367507d4778bf6acfa5ea510 Mon Sep 17 00:00:00 2001 From: yangguo Date: Wed, 25 Feb 2015 06:05:39 -0800 Subject: [PATCH] Use easier method to determine allocation space when serializing. R=hpayer@chromium.org Review URL: https://codereview.chromium.org/944923005 Cr-Commit-Position: refs/heads/master@{#26851} --- src/serialize.cc | 17 +++-------------- src/serialize.h | 1 - 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/serialize.cc b/src/serialize.cc index 05a5418..8a383db 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -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(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. diff --git a/src/serialize.h b/src/serialize.h index 64164c8..8118eef 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -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) { -- 2.7.4