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

Unified Diff: vm/snapshot.h

Issue 10535066: 1. Remove recursion during snapshot writing and reading (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 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: vm/snapshot.h
===================================================================
--- vm/snapshot.h (revision 8411)
+++ vm/snapshot.h (working copy)
@@ -18,11 +18,13 @@
// Forward declarations.
class AbstractType;
class AbstractTypeArguments;
+class Array;
class Class;
class Heap;
class Library;
class Object;
class ObjectStore;
+class RawAbstractTypeArguments;
class RawArray;
class RawBigint;
class RawClass;
@@ -355,11 +357,12 @@
// Reads an object.
RawObject* ReadObject();
- RawClass* ReadClassId(intptr_t object_id);
-
// Add object to backward references.
- void AddBackwardReference(intptr_t id, Object* obj);
+ void AddBackwardReference(intptr_t id, Object* obj, bool is_deserialized);
cshapiro 2012/06/08 22:04:39 Can we make this an enum instead of a bool?
siva 2012/06/11 20:49:06 Done.
+ // Get an object from the backward references list.
+ Object* GetBackwardReference(intptr_t id);
+
// Read a full snap shot.
void ReadFullSnapshot();
@@ -390,11 +393,28 @@
RawGrowableObjectArray* NewGrowableObjectArray();
private:
+ class BackwardReferenceNode : public ZoneAllocated {
+ public:
+ BackwardReferenceNode(Object* reference, bool is_deserialized)
cshapiro 2012/06/08 22:04:39 same here
siva 2012/06/11 20:49:06 Done.
+ : reference_(reference), is_deserialized_(is_deserialized) {}
+ Object* reference() const { return reference_; }
+ bool is_deserialized() const { return is_deserialized_; }
+ void set_is_deserialized(bool value) { is_deserialized_ = value; }
+
+ private:
+ Object* reference_;
+ bool is_deserialized_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackwardReferenceNode);
+ };
+
// Allocate uninitialized objects, this is used when reading a full snapshot.
RawObject* AllocateUninitialized(const Class& cls, intptr_t size);
- // Internal implementation of ReadObject once the header value is read.
+ RawClass* ReadClassId(intptr_t object_id);
+ RawObject* ReadObjectImpl();
RawObject* ReadObjectImpl(intptr_t header);
+ RawObject* ReadObjectRef();
// Read an object that was serialized as an Id (singleton, object store,
// or an object that was already serialized before).
@@ -406,6 +426,8 @@
// Based on header field check to see if it is an internal VM class.
RawClass* LookupInternalClass(intptr_t class_header);
+ void ArrayReadFrom(const Array& result, intptr_t len, intptr_t tags);
+
Snapshot::Kind kind_; // Indicates type of snapshot(full, script, message).
Isolate* isolate_; // Current isolate.
Class& cls_; // Temporary Class handle.
@@ -414,8 +436,27 @@
Library& library_; // Temporary library handle.
AbstractType& type_; // Temporary type handle.
AbstractTypeArguments& type_arguments_; // Temporary type argument handle.
- GrowableArray<Object*> backward_references_;
+ GrowableArray<BackwardReferenceNode*> backward_references_;
+ friend class Array;
+ friend class Class;
+ friend class Context;
+ friend class ContextScope;
+ friend class Field;
+ friend class Function;
+ friend class GrowableObjectArray;
+ friend class ImmutableArray;
+ friend class InstantiatedTypeArguments;
+ friend class JSRegExp;
+ friend class Library;
+ friend class LibraryPrefix;
+ friend class LiteralToken;
+ friend class Script;
+ friend class TokenStream;
+ friend class Type;
+ friend class TypeArguments;
+ friend class TypeParameter;
+ friend class UnresolvedClass;
DISALLOW_COPY_AND_ASSIGN(SnapshotReader);
};
@@ -508,11 +549,6 @@
// Serialize an object into the buffer.
void WriteObject(RawObject* raw);
- void WriteClassId(RawClass* cls);
-
- // Unmark all objects that were marked as forwarded for serializing.
- void UnmarkAll();
-
// Writes a full snapshot of the Isolate.
void WriteFullSnapshot();
@@ -521,22 +557,37 @@
private:
class ForwardObjectNode : public ZoneAllocated {
public:
- ForwardObjectNode(RawObject* raw, uword tags) : raw_(raw), tags_(tags) {}
+ ForwardObjectNode(RawObject* raw, uword tags, bool is_serialized)
cshapiro 2012/06/08 22:04:39 same here
siva 2012/06/11 20:49:06 Done.
+ : raw_(raw), tags_(tags), is_serialized_(is_serialized) {}
RawObject* raw() const { return raw_; }
uword tags() const { return tags_; }
+ bool is_serialized() const { return is_serialized_; }
+ void set_is_serialized(bool value) { is_serialized_ = value; }
private:
RawObject* raw_;
uword tags_;
+ bool is_serialized_;
DISALLOW_COPY_AND_ASSIGN(ForwardObjectNode);
};
- intptr_t MarkObject(RawObject* raw);
+ intptr_t MarkObject(RawObject* raw, bool is_serialized);
cshapiro 2012/06/08 22:04:39 same here
siva 2012/06/11 20:49:06 Done.
+ void UnmarkAll();
bool CheckAndWritePredefinedObject(RawObject* raw);
+ void WriteObjectRef(RawObject* raw);
+ void WriteClassId(RawClass* cls);
+ void WriteObjectImpl(RawObject* raw);
void WriteInlinedObject(RawObject* raw);
+ void WriteForwardedObjects();
+ void ArrayWriteTo(intptr_t object_id,
+ intptr_t array_kind,
+ intptr_t tags,
+ RawSmi* length,
+ RawAbstractTypeArguments* type_arguments,
+ RawObject* data[]);
ObjectStore* object_store() const { return object_store_; }
@@ -545,6 +596,17 @@
ClassTable* class_table_; // Class table for the class index to class lookup.
GrowableArray<ForwardObjectNode*> forward_list_;
+ friend class RawArray;
+ friend class RawClass;
+ friend class RawGrowableObjectArray;
+ friend class RawImmutableArray;
+ friend class RawJSRegExp;
+ friend class RawLibrary;
+ friend class RawLiteralToken;
+ friend class RawScript;
+ friend class RawTokenStream;
+ friend class RawTypeArguments;
+ friend class SnapshotWriterVisitor;
DISALLOW_COPY_AND_ASSIGN(SnapshotWriter);
};
@@ -571,12 +633,20 @@
class SnapshotWriterVisitor : public ObjectPointerVisitor {
public:
explicit SnapshotWriterVisitor(SnapshotWriter* writer)
- : ObjectPointerVisitor(Isolate::Current()), writer_(writer) {}
+ : ObjectPointerVisitor(Isolate::Current()),
+ writer_(writer),
+ as_references_(true) {}
+ SnapshotWriterVisitor(SnapshotWriter* writer, bool as_references)
+ : ObjectPointerVisitor(Isolate::Current()),
+ writer_(writer),
+ as_references_(as_references) {}
+
virtual void VisitPointers(RawObject** first, RawObject** last);
private:
SnapshotWriter* writer_;
+ bool as_references_;
DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
};
« vm/dart_api_message.cc ('K') | « vm/raw_object_snapshot.cc ('k') | vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698