Reviewers: Hannes Payer,

Description:
Use easier method to determine allocation space when serializing.

[email protected]

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

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

Affected files (+3, -15 lines):
  M src/serialize.h
  M src/serialize.cc


Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index 05a54188b86cfbeef9bc010a083fcad001d9adb5..9b6136799fc1e8080436a2bb08dbacd3b30d09e1 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);
+  const byte* addr = reinterpret_cast<const byte*>(object_);
+ AllocationSpace space = MemoryChunk::FromAddress(addr)->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: src/serialize.h
diff --git a/src/serialize.h b/src/serialize.h
index 64164c803a931c61b4808b64a025ab2c4d4e6e55..8118eef12ae14680e707f1b28b2f36bc1215ca2b 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) {


--
--
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