| 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/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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 void Deserializer::DeserializeInternalFields( | 218 void Deserializer::DeserializeInternalFields( |
| 219 v8::DeserializeInternalFieldsCallback internal_fields_deserializer) { | 219 v8::DeserializeInternalFieldsCallback internal_fields_deserializer) { |
| 220 if (!source_.HasMore() || source_.Get() != kInternalFieldsData) return; | 220 if (!source_.HasMore() || source_.Get() != kInternalFieldsData) return; |
| 221 DisallowHeapAllocation no_gc; | 221 DisallowHeapAllocation no_gc; |
| 222 DisallowJavascriptExecution no_js(isolate_); | 222 DisallowJavascriptExecution no_js(isolate_); |
| 223 DisallowCompilation no_compile(isolate_); | 223 DisallowCompilation no_compile(isolate_); |
| 224 DCHECK_NOT_NULL(internal_fields_deserializer); | 224 DCHECK_NOT_NULL(internal_fields_deserializer.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 internal_fields_deserializer(v8::Utils::ToLocal(obj), index, | 236 internal_fields_deserializer.callback(v8::Utils::ToLocal(obj), index, |
| 237 {reinterpret_cast<char*>(data), size}); | 237 {reinterpret_cast<char*>(data), size}, |
| 238 internal_fields_deserializer.data); |
| 238 delete[] data; | 239 delete[] data; |
| 239 } | 240 } |
| 240 } | 241 } |
| 241 | 242 |
| 242 // Used to insert a deserialized internalized string into the string table. | 243 // Used to insert a deserialized internalized string into the string table. |
| 243 class StringTableInsertionKey : public HashTableKey { | 244 class StringTableInsertionKey : public HashTableKey { |
| 244 public: | 245 public: |
| 245 explicit StringTableInsertionKey(String* string) | 246 explicit StringTableInsertionKey(String* string) |
| 246 : string_(string), hash_(HashForObject(string)) { | 247 : string_(string), hash_(HashForObject(string)) { |
| 247 DCHECK(string->IsInternalizedString()); | 248 DCHECK(string->IsInternalizedString()); |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 | 857 |
| 857 default: | 858 default: |
| 858 CHECK(false); | 859 CHECK(false); |
| 859 } | 860 } |
| 860 } | 861 } |
| 861 CHECK_EQ(limit, current); | 862 CHECK_EQ(limit, current); |
| 862 return true; | 863 return true; |
| 863 } | 864 } |
| 864 } // namespace internal | 865 } // namespace internal |
| 865 } // namespace v8 | 866 } // namespace v8 |
| OLD | NEW |