Index: src/serialize.cc |
=================================================================== |
--- src/serialize.cc (revision 3575) |
+++ src/serialize.cc (working copy) |
@@ -918,7 +918,8 @@ |
Serializer::Serializer(SnapshotByteSink* sink) |
: sink_(sink), |
current_root_index_(0), |
- external_reference_encoder_(NULL) { |
+ external_reference_encoder_(NULL), |
+ partial_(false) { |
for (int i = 0; i <= LAST_SPACE; i++) { |
fullness_[i] = 0; |
} |
@@ -946,6 +947,16 @@ |
} |
+void Serializer::SerializePartial(Object** object) { |
+ partial_ = true; |
+ external_reference_encoder_ = new ExternalReferenceEncoder(); |
+ this->VisitPointer(object); |
+ delete external_reference_encoder_; |
+ external_reference_encoder_ = NULL; |
+ SerializationAddressMapper::Zap(); |
+} |
+ |
+ |
void Serializer::VisitPointers(Object** start, Object** end) { |
for (Object** current = start; current < end; current++) { |
if ((*current)->IsSmi()) { |
@@ -961,11 +972,29 @@ |
} |
+int Serializer::RootIndex(HeapObject* heap_object) { |
+ for (int i = 0; i < Heap::kRootListLength; i++) { |
+ Object* root = Heap::roots_address()[i]; |
+ if (root == heap_object) return i; |
+ } |
+ return kInvalidRootIndex; |
+} |
+ |
+ |
void Serializer::SerializeObject( |
Object* o, |
ReferenceRepresentation reference_representation) { |
CHECK(o->IsHeapObject()); |
HeapObject* heap_object = HeapObject::cast(o); |
+ if (partial_) { |
+ int root_index = RootIndex(heap_object); |
+ if (root_index != kInvalidRootIndex) { |
+ sink_->Put(ROOT_SERIALIZATION, "RootSerialization"); |
+ sink_->PutInt(root_index, "root_index"); |
+ return; |
+ } |
+ // TODO(erikcorry): Handle symbols here. |
+ } |
if (SerializationAddressMapper::IsMapped(heap_object)) { |
int space = SpaceOfAlreadySerializedObject(heap_object); |
int address = SerializationAddressMapper::MappedTo(heap_object); |