Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Unified Diff: src/serialize.cc

Issue 545026: Add some interfaces to the GC that allow us to reserve space. This is needed... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698