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

Unified Diff: vm/dart_api_message.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
« no previous file with comments | « platform/thread_macos.cc ('k') | vm/dart_api_message.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/dart_api_message.h
===================================================================
--- vm/dart_api_message.h (revision 8515)
+++ vm/dart_api_message.h (working copy)
@@ -33,6 +33,22 @@
Dart_CObject* ReadMessage();
private:
+ class BackRefNode {
+ public:
+ BackRefNode(Dart_CObject* reference, DeserializeState state)
+ : reference_(reference), state_(state) {}
+ Dart_CObject* reference() const { return reference_; }
+ void set_reference(Dart_CObject* reference) { reference_ = reference; }
+ bool is_deserialized() const { return state_ == kIsDeserialized; }
+ void set_state(DeserializeState value) { state_ = value; }
+
+ private:
+ Dart_CObject* reference_;
+ DeserializeState state_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackRefNode);
+ };
+
// Allocates a Dart_CObject object.
Dart_CObject* AllocateDartCObject();
// Allocates a Dart_CObject object with the specified type.
@@ -58,18 +74,25 @@
Dart_CObject* AllocateDartCObjectUint8Array(intptr_t length);
// Allocates a C array of Dart_CObject objects.
Dart_CObject* AllocateDartCObjectArray(intptr_t length);
+ // Allocates a backwards reference node.
+ BackRefNode* AllocateBackRefNode(Dart_CObject* ref, DeserializeState state);
void Init();
intptr_t LookupInternalClass(intptr_t class_header);
+ Dart_CObject* ReadInternalVMObject(intptr_t class_id, intptr_t object_id);
Dart_CObject* ReadInlinedObject(intptr_t object_id);
- Dart_CObject* ReadObjectImpl(intptr_t header);
+ Dart_CObject* ReadObjectImpl();
Dart_CObject* ReadIndexedObject(intptr_t object_id);
+ Dart_CObject* ReadObjectRef();
Dart_CObject* ReadObject();
// Add object to backward references.
- void AddBackwardReference(intptr_t id, Dart_CObject* obj);
+ void AddBackRef(intptr_t id, Dart_CObject* obj, DeserializeState state);
+ // Get an object from the backward references list.
+ Dart_CObject* GetBackRef(intptr_t id);
+
Dart_CObject_Internal* AsInternal(Dart_CObject* object) {
ASSERT(object->type >= Dart_CObject::kNumberOfTypes);
return reinterpret_cast<Dart_CObject_Internal*>(object);
@@ -79,7 +102,7 @@
// either in the supplied zone or using the supplied allocation
// function.
ReAlloc alloc_;
- ApiGrowableArray<Dart_CObject*> backward_references_;
+ ApiGrowableArray<BackRefNode*> backward_references_;
Dart_CObject type_arguments_marker;
Dart_CObject dynamic_type_marker;
@@ -89,10 +112,13 @@
class ApiMessageWriter : public BaseWriter {
public:
ApiMessageWriter(uint8_t** buffer, ReAlloc alloc)
- : BaseWriter(buffer, alloc), object_id_(0) {
+ : BaseWriter(buffer, alloc), object_id_(0),
+ forward_list_(NULL), forward_list_length_(0), forward_id_(0) {
ASSERT(kDartCObjectTypeMask >= Dart_CObject::kNumberOfTypes - 1);
}
- ~ApiMessageWriter() { }
+ ~ApiMessageWriter() {
+ delete forward_list_;
+ }
// Writes a message of integers.
void WriteMessage(intptr_t field_count, intptr_t *data);
@@ -114,6 +140,7 @@
bool IsCObjectMarked(Dart_CObject* object);
intptr_t GetMarkedCObjectMark(Dart_CObject* object);
void UnmarkAllCObjects(Dart_CObject* object);
+ void AddToForwardList(Dart_CObject* object);
void WriteSmi(int64_t value);
void WriteMint(Dart_CObject* object, int64_t value);
@@ -121,8 +148,14 @@
void WriteInt64(Dart_CObject* object);
void WriteInlinedHeader(Dart_CObject* object);
void WriteCObject(Dart_CObject* object);
+ void WriteCObjectRef(Dart_CObject* object);
+ void WriteForwardedCObject(Dart_CObject* object);
+ void WriteCObjectInlined(Dart_CObject* object, Dart_CObject::Type type);
intptr_t object_id_;
+ Dart_CObject** forward_list_;
+ intptr_t forward_list_length_;
+ intptr_t forward_id_;
DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter);
};
« no previous file with comments | « platform/thread_macos.cc ('k') | vm/dart_api_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698