OLD | NEW |
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/api.h" | 7 #include "src/api.h" |
8 #include "src/assembler-inl.h" | 8 #include "src/assembler-inl.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/external-reference-table.h" | 10 #include "src/external-reference-table.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 // Issue code events for newly deserialized code objects. | 116 // Issue code events for newly deserialized code objects. |
117 LOG_CODE_EVENT(isolate_, LogCodeObjects()); | 117 LOG_CODE_EVENT(isolate_, LogCodeObjects()); |
118 LOG_CODE_EVENT(isolate_, LogBytecodeHandlers()); | 118 LOG_CODE_EVENT(isolate_, LogBytecodeHandlers()); |
119 LOG_CODE_EVENT(isolate_, LogCompiledFunctions()); | 119 LOG_CODE_EVENT(isolate_, LogCompiledFunctions()); |
120 } | 120 } |
121 | 121 |
122 MaybeHandle<Object> Deserializer::DeserializePartial( | 122 MaybeHandle<Object> Deserializer::DeserializePartial( |
123 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, | 123 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, |
124 v8::DeserializeInternalFieldsCallback internal_fields_deserializer) { | 124 v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) { |
125 Initialize(isolate); | 125 Initialize(isolate); |
126 if (!ReserveSpace()) { | 126 if (!ReserveSpace()) { |
127 V8::FatalProcessOutOfMemory("deserialize context"); | 127 V8::FatalProcessOutOfMemory("deserialize context"); |
128 return MaybeHandle<Object>(); | 128 return MaybeHandle<Object>(); |
129 } | 129 } |
130 | 130 |
131 AddAttachedObject(global_proxy); | 131 AddAttachedObject(global_proxy); |
132 | 132 |
133 DisallowHeapAllocation no_gc; | 133 DisallowHeapAllocation no_gc; |
134 // Keep track of the code space start and end pointers in case new | 134 // Keep track of the code space start and end pointers in case new |
135 // code objects were unserialized | 135 // code objects were unserialized |
136 OldSpace* code_space = isolate_->heap()->code_space(); | 136 OldSpace* code_space = isolate_->heap()->code_space(); |
137 Address start_address = code_space->top(); | 137 Address start_address = code_space->top(); |
138 Object* root; | 138 Object* root; |
139 VisitPointer(&root); | 139 VisitPointer(&root); |
140 DeserializeDeferredObjects(); | 140 DeserializeDeferredObjects(); |
141 DeserializeInternalFields(internal_fields_deserializer); | 141 DeserializeEmbedderFields(embedder_fields_deserializer); |
142 | 142 |
143 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); | 143 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); |
144 | 144 |
145 // There's no code deserialized here. If this assert fires then that's | 145 // There's no code deserialized here. If this assert fires then that's |
146 // changed and logging should be added to notify the profiler et al of the | 146 // changed and logging should be added to notify the profiler et al of the |
147 // new code, which also has to be flushed from instruction cache. | 147 // new code, which also has to be flushed from instruction cache. |
148 CHECK_EQ(start_address, code_space->top()); | 148 CHECK_EQ(start_address, code_space->top()); |
149 return Handle<Object>(root, isolate); | 149 return Handle<Object>(root, isolate); |
150 } | 150 } |
151 | 151 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 Object** end = reinterpret_cast<Object**>(obj_address + size); | 218 Object** end = reinterpret_cast<Object**>(obj_address + size); |
219 bool filled = ReadData(start, end, space, obj_address); | 219 bool filled = ReadData(start, end, space, obj_address); |
220 CHECK(filled); | 220 CHECK(filled); |
221 DCHECK(CanBeDeferred(object)); | 221 DCHECK(CanBeDeferred(object)); |
222 PostProcessNewObject(object, space); | 222 PostProcessNewObject(object, space); |
223 } | 223 } |
224 } | 224 } |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 void Deserializer::DeserializeInternalFields( | 228 void Deserializer::DeserializeEmbedderFields( |
229 v8::DeserializeInternalFieldsCallback internal_fields_deserializer) { | 229 v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) { |
230 if (!source_.HasMore() || source_.Get() != kInternalFieldsData) return; | 230 if (!source_.HasMore() || source_.Get() != kEmbedderFieldsData) return; |
231 DisallowHeapAllocation no_gc; | 231 DisallowHeapAllocation no_gc; |
232 DisallowJavascriptExecution no_js(isolate_); | 232 DisallowJavascriptExecution no_js(isolate_); |
233 DisallowCompilation no_compile(isolate_); | 233 DisallowCompilation no_compile(isolate_); |
234 DCHECK_NOT_NULL(internal_fields_deserializer.callback); | 234 DCHECK_NOT_NULL(embedder_fields_deserializer.callback); |
235 for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) { | 235 for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) { |
236 HandleScope scope(isolate_); | 236 HandleScope scope(isolate_); |
237 int space = code & kSpaceMask; | 237 int space = code & kSpaceMask; |
238 DCHECK(space <= kNumberOfSpaces); | 238 DCHECK(space <= kNumberOfSpaces); |
239 DCHECK(code - space == kNewObject); | 239 DCHECK(code - space == kNewObject); |
240 Handle<JSObject> obj(JSObject::cast(GetBackReferencedObject(space)), | 240 Handle<JSObject> obj(JSObject::cast(GetBackReferencedObject(space)), |
241 isolate_); | 241 isolate_); |
242 int index = source_.GetInt(); | 242 int index = source_.GetInt(); |
243 int size = source_.GetInt(); | 243 int size = source_.GetInt(); |
244 byte* data = new byte[size]; | 244 byte* data = new byte[size]; |
245 source_.CopyRaw(data, size); | 245 source_.CopyRaw(data, size); |
246 internal_fields_deserializer.callback(v8::Utils::ToLocal(obj), index, | 246 embedder_fields_deserializer.callback(v8::Utils::ToLocal(obj), index, |
247 {reinterpret_cast<char*>(data), size}, | 247 {reinterpret_cast<char*>(data), size}, |
248 internal_fields_deserializer.data); | 248 embedder_fields_deserializer.data); |
249 delete[] data; | 249 delete[] data; |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 // Used to insert a deserialized internalized string into the string table. | 253 // Used to insert a deserialized internalized string into the string table. |
254 class StringTableInsertionKey : public HashTableKey { | 254 class StringTableInsertionKey : public HashTableKey { |
255 public: | 255 public: |
256 explicit StringTableInsertionKey(String* string) | 256 explicit StringTableInsertionKey(String* string) |
257 : string_(string), hash_(HashForObject(string)) { | 257 : string_(string), hash_(HashForObject(string)) { |
258 DCHECK(string->IsInternalizedString()); | 258 DCHECK(string->IsInternalizedString()); |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 | 867 |
868 default: | 868 default: |
869 CHECK(false); | 869 CHECK(false); |
870 } | 870 } |
871 } | 871 } |
872 CHECK_EQ(limit, current); | 872 CHECK_EQ(limit, current); |
873 return true; | 873 return true; |
874 } | 874 } |
875 } // namespace internal | 875 } // namespace internal |
876 } // namespace v8 | 876 } // namespace v8 |
OLD | NEW |