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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 AddAttachedObject(global_proxy); | 121 AddAttachedObject(global_proxy); |
122 | 122 |
123 DisallowHeapAllocation no_gc; | 123 DisallowHeapAllocation no_gc; |
124 // Keep track of the code space start and end pointers in case new | 124 // Keep track of the code space start and end pointers in case new |
125 // code objects were unserialized | 125 // code objects were unserialized |
126 OldSpace* code_space = isolate_->heap()->code_space(); | 126 OldSpace* code_space = isolate_->heap()->code_space(); |
127 Address start_address = code_space->top(); | 127 Address start_address = code_space->top(); |
128 Object* root; | 128 Object* root; |
129 VisitPointer(&root); | 129 VisitPointer(&root); |
130 DeserializeDeferredObjects(); | 130 DeserializeDeferredObjects(); |
| 131 DeserializeInternalFields(); |
131 | 132 |
132 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); | 133 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); |
133 | 134 |
134 // There's no code deserialized here. If this assert fires then that's | 135 // There's no code deserialized here. If this assert fires then that's |
135 // changed and logging should be added to notify the profiler et al of the | 136 // changed and logging should be added to notify the profiler et al of the |
136 // new code, which also has to be flushed from instruction cache. | 137 // new code, which also has to be flushed from instruction cache. |
137 CHECK_EQ(start_address, code_space->top()); | 138 CHECK_EQ(start_address, code_space->top()); |
138 return Handle<Object>(root, isolate); | 139 return Handle<Object>(root, isolate); |
139 } | 140 } |
140 | 141 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 Object** end = reinterpret_cast<Object**>(obj_address + size); | 206 Object** end = reinterpret_cast<Object**>(obj_address + size); |
206 bool filled = ReadData(start, end, space, obj_address); | 207 bool filled = ReadData(start, end, space, obj_address); |
207 CHECK(filled); | 208 CHECK(filled); |
208 DCHECK(CanBeDeferred(object)); | 209 DCHECK(CanBeDeferred(object)); |
209 PostProcessNewObject(object, space); | 210 PostProcessNewObject(object, space); |
210 } | 211 } |
211 } | 212 } |
212 } | 213 } |
213 } | 214 } |
214 | 215 |
| 216 void Deserializer::DeserializeInternalFields() { |
| 217 if (!source_.HasMore() || source_.Get() != kInternalFieldsData) return; |
| 218 DisallowHeapAllocation no_gc; |
| 219 DisallowJavascriptExecution no_js(isolate_); |
| 220 DisallowCompilation no_compile(isolate_); |
| 221 v8::DeserializeInternalFieldsCallback callback = |
| 222 isolate_->deserialize_internal_fields_callback(); |
| 223 DCHECK_NOT_NULL(callback); |
| 224 for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) { |
| 225 HandleScope scope(isolate_); |
| 226 int space = code & kSpaceMask; |
| 227 DCHECK(space <= kNumberOfSpaces); |
| 228 DCHECK(code - space == kNewObject); |
| 229 Handle<JSObject> obj(JSObject::cast(GetBackReferencedObject(space)), |
| 230 isolate_); |
| 231 int index = source_.GetInt(); |
| 232 int size = source_.GetInt(); |
| 233 byte* data = new byte[size]; |
| 234 source_.CopyRaw(data, size); |
| 235 callback(v8::Utils::ToLocal(obj), index, |
| 236 {reinterpret_cast<char*>(data), size}); |
| 237 delete[] data; |
| 238 } |
| 239 } |
| 240 |
215 // Used to insert a deserialized internalized string into the string table. | 241 // Used to insert a deserialized internalized string into the string table. |
216 class StringTableInsertionKey : public HashTableKey { | 242 class StringTableInsertionKey : public HashTableKey { |
217 public: | 243 public: |
218 explicit StringTableInsertionKey(String* string) | 244 explicit StringTableInsertionKey(String* string) |
219 : string_(string), hash_(HashForObject(string)) { | 245 : string_(string), hash_(HashForObject(string)) { |
220 DCHECK(string->IsInternalizedString()); | 246 DCHECK(string->IsInternalizedString()); |
221 } | 247 } |
222 | 248 |
223 bool IsMatch(Object* string) override { | 249 bool IsMatch(Object* string) override { |
224 // We know that all entries in a hash table had their hash keys created. | 250 // We know that all entries in a hash table had their hash keys created. |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 851 |
826 default: | 852 default: |
827 CHECK(false); | 853 CHECK(false); |
828 } | 854 } |
829 } | 855 } |
830 CHECK_EQ(limit, current); | 856 CHECK_EQ(limit, current); |
831 return true; | 857 return true; |
832 } | 858 } |
833 } // namespace internal | 859 } // namespace internal |
834 } // namespace v8 | 860 } // namespace v8 |
OLD | NEW |