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

Side by Side Diff: src/snapshot/deserializer.cc

Issue 2619203002: [serializer] pass internal fields deserializer callback as argument. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « src/snapshot/deserializer.h ('k') | src/snapshot/partial-serializer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/snapshot/deserializer.h" 5 #include "src/snapshot/deserializer.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/external-reference-table.h" 8 #include "src/external-reference-table.h"
9 #include "src/heap/heap.h" 9 #include "src/heap/heap.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 isolate_->heap()->undefined_value()); 105 isolate_->heap()->undefined_value());
106 } 106 }
107 107
108 // Issue code events for newly deserialized code objects. 108 // Issue code events for newly deserialized code objects.
109 LOG_CODE_EVENT(isolate_, LogCodeObjects()); 109 LOG_CODE_EVENT(isolate_, LogCodeObjects());
110 LOG_CODE_EVENT(isolate_, LogBytecodeHandlers()); 110 LOG_CODE_EVENT(isolate_, LogBytecodeHandlers());
111 LOG_CODE_EVENT(isolate_, LogCompiledFunctions()); 111 LOG_CODE_EVENT(isolate_, LogCompiledFunctions());
112 } 112 }
113 113
114 MaybeHandle<Object> Deserializer::DeserializePartial( 114 MaybeHandle<Object> Deserializer::DeserializePartial(
115 Isolate* isolate, Handle<JSGlobalProxy> global_proxy) { 115 Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
116 v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
116 Initialize(isolate); 117 Initialize(isolate);
117 if (!ReserveSpace()) { 118 if (!ReserveSpace()) {
118 V8::FatalProcessOutOfMemory("deserialize context"); 119 V8::FatalProcessOutOfMemory("deserialize context");
119 return MaybeHandle<Object>(); 120 return MaybeHandle<Object>();
120 } 121 }
121 122
122 AddAttachedObject(global_proxy); 123 AddAttachedObject(global_proxy);
123 124
124 DisallowHeapAllocation no_gc; 125 DisallowHeapAllocation no_gc;
125 // Keep track of the code space start and end pointers in case new 126 // Keep track of the code space start and end pointers in case new
126 // code objects were unserialized 127 // code objects were unserialized
127 OldSpace* code_space = isolate_->heap()->code_space(); 128 OldSpace* code_space = isolate_->heap()->code_space();
128 Address start_address = code_space->top(); 129 Address start_address = code_space->top();
129 Object* root; 130 Object* root;
130 VisitPointer(&root); 131 VisitPointer(&root);
131 DeserializeDeferredObjects(); 132 DeserializeDeferredObjects();
132 DeserializeInternalFields(); 133 DeserializeInternalFields(internal_fields_deserializer);
133 134
134 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); 135 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_);
135 136
136 // There's no code deserialized here. If this assert fires then that's 137 // There's no code deserialized here. If this assert fires then that's
137 // changed and logging should be added to notify the profiler et al of the 138 // changed and logging should be added to notify the profiler et al of the
138 // new code, which also has to be flushed from instruction cache. 139 // new code, which also has to be flushed from instruction cache.
139 CHECK_EQ(start_address, code_space->top()); 140 CHECK_EQ(start_address, code_space->top());
140 return Handle<Object>(root, isolate); 141 return Handle<Object>(root, isolate);
141 } 142 }
142 143
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 Object** end = reinterpret_cast<Object**>(obj_address + size); 208 Object** end = reinterpret_cast<Object**>(obj_address + size);
208 bool filled = ReadData(start, end, space, obj_address); 209 bool filled = ReadData(start, end, space, obj_address);
209 CHECK(filled); 210 CHECK(filled);
210 DCHECK(CanBeDeferred(object)); 211 DCHECK(CanBeDeferred(object));
211 PostProcessNewObject(object, space); 212 PostProcessNewObject(object, space);
212 } 213 }
213 } 214 }
214 } 215 }
215 } 216 }
216 217
217 void Deserializer::DeserializeInternalFields() { 218 void Deserializer::DeserializeInternalFields(
219 v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
218 if (!source_.HasMore() || source_.Get() != kInternalFieldsData) return; 220 if (!source_.HasMore() || source_.Get() != kInternalFieldsData) return;
219 DisallowHeapAllocation no_gc; 221 DisallowHeapAllocation no_gc;
220 DisallowJavascriptExecution no_js(isolate_); 222 DisallowJavascriptExecution no_js(isolate_);
221 DisallowCompilation no_compile(isolate_); 223 DisallowCompilation no_compile(isolate_);
222 v8::DeserializeInternalFieldsCallback callback = 224 DCHECK_NOT_NULL(internal_fields_deserializer);
223 isolate_->deserialize_internal_fields_callback();
224 DCHECK_NOT_NULL(callback);
225 for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) { 225 for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) {
226 HandleScope scope(isolate_); 226 HandleScope scope(isolate_);
227 int space = code & kSpaceMask; 227 int space = code & kSpaceMask;
228 DCHECK(space <= kNumberOfSpaces); 228 DCHECK(space <= kNumberOfSpaces);
229 DCHECK(code - space == kNewObject); 229 DCHECK(code - space == kNewObject);
230 Handle<JSObject> obj(JSObject::cast(GetBackReferencedObject(space)), 230 Handle<JSObject> obj(JSObject::cast(GetBackReferencedObject(space)),
231 isolate_); 231 isolate_);
232 int index = source_.GetInt(); 232 int index = source_.GetInt();
233 int size = source_.GetInt(); 233 int size = source_.GetInt();
234 byte* data = new byte[size]; 234 byte* data = new byte[size];
235 source_.CopyRaw(data, size); 235 source_.CopyRaw(data, size);
236 callback(v8::Utils::ToLocal(obj), index, 236 internal_fields_deserializer(v8::Utils::ToLocal(obj), index,
237 {reinterpret_cast<char*>(data), size}); 237 {reinterpret_cast<char*>(data), size});
238 delete[] data; 238 delete[] data;
239 } 239 }
240 } 240 }
241 241
242 // Used to insert a deserialized internalized string into the string table. 242 // Used to insert a deserialized internalized string into the string table.
243 class StringTableInsertionKey : public HashTableKey { 243 class StringTableInsertionKey : public HashTableKey {
244 public: 244 public:
245 explicit StringTableInsertionKey(String* string) 245 explicit StringTableInsertionKey(String* string)
246 : string_(string), hash_(HashForObject(string)) { 246 : string_(string), hash_(HashForObject(string)) {
247 DCHECK(string->IsInternalizedString()); 247 DCHECK(string->IsInternalizedString());
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 856
857 default: 857 default:
858 CHECK(false); 858 CHECK(false);
859 } 859 }
860 } 860 }
861 CHECK_EQ(limit, current); 861 CHECK_EQ(limit, current);
862 return true; 862 return true;
863 } 863 }
864 } // namespace internal 864 } // namespace internal
865 } // namespace v8 865 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/deserializer.h ('k') | src/snapshot/partial-serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698