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

Unified Diff: runtime/vm/snapshot.h

Issue 1255003004: Implement patch records to patch canonical objects. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merged-to-tot Created 5 years, 5 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: runtime/vm/snapshot.h
diff --git a/runtime/vm/snapshot.h b/runtime/vm/snapshot.h
index 1989c7b495f10b4832cd7edd3648ad9ec069e443..b6a7b202d5955ea253502a392ba825ff9511ae4c 100644
--- a/runtime/vm/snapshot.h
+++ b/runtime/vm/snapshot.h
@@ -97,6 +97,7 @@ enum SerializedHeaderType {
static const int8_t kHeaderTagBits = 2;
static const int8_t kObjectIdBits = (kBitsPerInt32 - (kHeaderTagBits + 1));
static const intptr_t kMaxObjectId = (kMaxUint32 >> (kHeaderTagBits + 1));
+static const intptr_t kInvalidPatchIndex = -1;
class SerializedHeaderTag : public BitField<enum SerializedHeaderType,
@@ -248,21 +249,42 @@ class BaseReader {
class BackRefNode : public ValueObject {
public:
- BackRefNode(Object* reference, DeserializeState state)
- : reference_(reference), state_(state) {}
+ BackRefNode(Object* reference,
+ DeserializeState state,
+ bool defer_canonicalization)
+ : reference_(reference),
+ state_(state),
+ defer_canonicalization_(defer_canonicalization),
+ patch_records_(NULL) {}
Object* reference() const { return reference_; }
bool is_deserialized() const { return state_ == kIsDeserialized; }
void set_state(DeserializeState state) { state_ = state; }
+ bool defer_canonicalization() const { return defer_canonicalization_; }
+ ZoneGrowableArray<intptr_t>* patch_records() const { return patch_records_; }
BackRefNode& operator=(const BackRefNode& other) {
reference_ = other.reference_;
state_ = other.state_;
+ defer_canonicalization_ = other.defer_canonicalization_;
+ patch_records_ = other.patch_records_;
return *this;
}
+ void AddPatchRecord(intptr_t patch_object_id, intptr_t patch_offset) {
+ if (defer_canonicalization_) {
+ if (patch_records_ == NULL) {
+ patch_records_ = new ZoneGrowableArray<intptr_t>();
+ }
+ patch_records_->Add(patch_object_id);
+ patch_records_->Add(patch_offset);
+ }
+ }
+
private:
Object* reference_;
DeserializeState state_;
+ bool defer_canonicalization_;
+ ZoneGrowableArray<intptr_t>* patch_records_;
};
@@ -290,7 +312,10 @@ class SnapshotReader : public BaseReader {
RawObject* ReadObject();
// Add object to backward references.
- void AddBackRef(intptr_t id, Object* obj, DeserializeState state);
+ void AddBackRef(intptr_t id,
+ Object* obj,
+ DeserializeState state,
+ bool defer_canonicalization = false);
// Get an object from the backward references list.
Object* GetBackRef(intptr_t id);
@@ -367,24 +392,44 @@ class SnapshotReader : public BaseReader {
RawClass* ReadClassId(intptr_t object_id);
RawObject* ReadStaticImplicitClosure(intptr_t object_id, intptr_t cls_header);
- RawObject* ReadObjectImpl();
- RawObject* ReadObjectImpl(intptr_t header);
- RawObject* ReadObjectRef();
+ RawObject* ReadObjectImpl(intptr_t patch_object_id = kInvalidPatchIndex,
+ intptr_t patch_offset = 0);
+ RawObject* ReadObjectImpl(intptr_t header,
+ intptr_t patch_object_id,
+ intptr_t patch_offset);
+ RawObject* ReadObjectRef(intptr_t patch_object_id = kInvalidPatchIndex,
+ intptr_t patch_offset = 0);
// Read a VM isolate object that was serialized as an Id.
RawObject* ReadVMIsolateObject(intptr_t object_id);
// Read an object that was serialized as an Id (singleton in object store,
// or an object that was already serialized before).
- RawObject* ReadIndexedObject(intptr_t object_id);
+ RawObject* ReadIndexedObject(intptr_t object_id,
+ intptr_t patch_object_id,
+ intptr_t patch_offset);
// Read an inlined object from the stream.
- RawObject* ReadInlinedObject(intptr_t object_id);
+ RawObject* ReadInlinedObject(intptr_t object_id,
+ intptr_t patch_object_id,
+ intptr_t patch_offset);
+
+ // Add a patch record for the object so that objects whose canonicalization
+ // is deferred can be back patched after they are canonicalized.
+ void AddPatchRecord(intptr_t object_id,
+ intptr_t patch_object_id,
+ intptr_t patch_offset);
+
+ // Process all the deferred canonicalization entries and patch all references.
+ void ProcessDeferredCanonicalizations();
// Decode class id from the header field.
intptr_t LookupInternalClass(intptr_t class_header);
- void ArrayReadFrom(const Array& result, intptr_t len, intptr_t tags);
+ void ArrayReadFrom(intptr_t object_id,
+ const Array& result,
+ intptr_t len,
+ intptr_t tags);
intptr_t NextAvailableObjectId() const;

Powered by Google App Engine
This is Rietveld 408576698