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

Unified Diff: src/snapshot/deserializer.cc

Issue 2452333002: [serializer] introduce API to serialize internal fields (Closed)
Patch Set: avoid shadow variables Created 4 years, 2 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 | « src/snapshot/deserializer.h ('k') | src/snapshot/partial-serializer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot/deserializer.cc
diff --git a/src/snapshot/deserializer.cc b/src/snapshot/deserializer.cc
index 7a22a15f54f45af61e3e798ecf9777dc29fe20e5..c5cb8e5c2438345fd4a03e215540a71ee15c3af9 100644
--- a/src/snapshot/deserializer.cc
+++ b/src/snapshot/deserializer.cc
@@ -128,6 +128,7 @@ MaybeHandle<Object> Deserializer::DeserializePartial(
Object* root;
VisitPointer(&root);
DeserializeDeferredObjects();
+ DeserializeInternalFields();
isolate->heap()->RegisterReservationsForBlackAllocation(reservations_);
@@ -212,6 +213,31 @@ void Deserializer::DeserializeDeferredObjects() {
}
}
+void Deserializer::DeserializeInternalFields() {
+ if (!source_.HasMore() || source_.Get() != kInternalFieldsData) return;
+ DisallowHeapAllocation no_gc;
+ DisallowJavascriptExecution no_js(isolate_);
+ DisallowCompilation no_compile(isolate_);
+ v8::DeserializeInternalFieldsCallback callback =
+ isolate_->deserialize_internal_fields_callback();
+ DCHECK_NOT_NULL(callback);
+ for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) {
+ HandleScope scope(isolate_);
+ int space = code & kSpaceMask;
+ DCHECK(space <= kNumberOfSpaces);
+ DCHECK(code - space == kNewObject);
+ Handle<JSObject> obj(JSObject::cast(GetBackReferencedObject(space)),
+ isolate_);
+ int index = source_.GetInt();
+ int size = source_.GetInt();
+ byte* data = new byte[size];
+ source_.CopyRaw(data, size);
+ callback(v8::Utils::ToLocal(obj), index,
+ {reinterpret_cast<char*>(data), size});
+ delete[] data;
+ }
+}
+
// Used to insert a deserialized internalized string into the string table.
class StringTableInsertionKey : public HashTableKey {
public:
« no previous file with comments | « src/snapshot/deserializer.h ('k') | src/snapshot/partial-serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698