| 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/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 DisallowHeapAllocation no_gc; | 141 DisallowHeapAllocation no_gc; |
| 142 // Keep track of the code space start and end pointers in case new | 142 // Keep track of the code space start and end pointers in case new |
| 143 // code objects were unserialized | 143 // code objects were unserialized |
| 144 OldSpace* code_space = isolate_->heap()->code_space(); | 144 OldSpace* code_space = isolate_->heap()->code_space(); |
| 145 Address start_address = code_space->top(); | 145 Address start_address = code_space->top(); |
| 146 Object* root; | 146 Object* root; |
| 147 VisitRootPointer(Root::kPartialSnapshotCache, &root); | 147 VisitRootPointer(Root::kPartialSnapshotCache, &root); |
| 148 DeserializeDeferredObjects(); | 148 DeserializeDeferredObjects(); |
| 149 DeserializeEmbedderFields(embedder_fields_deserializer); | 149 DeserializeEmbedderFields(embedder_fields_deserializer); |
| 150 | 150 |
| 151 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); | 151 isolate->heap()->RegisterDeserializedObjectsForBlackAllocation( |
| 152 reservations_, &deserialized_large_objects_); |
| 152 | 153 |
| 153 // There's no code deserialized here. If this assert fires then that's | 154 // There's no code deserialized here. If this assert fires then that's |
| 154 // changed and logging should be added to notify the profiler et al of the | 155 // changed and logging should be added to notify the profiler et al of the |
| 155 // new code, which also has to be flushed from instruction cache. | 156 // new code, which also has to be flushed from instruction cache. |
| 156 CHECK_EQ(start_address, code_space->top()); | 157 CHECK_EQ(start_address, code_space->top()); |
| 157 return Handle<Object>(root, isolate); | 158 return Handle<Object>(root, isolate); |
| 158 } | 159 } |
| 159 | 160 |
| 160 MaybeHandle<HeapObject> Deserializer::DeserializeObject(Isolate* isolate) { | 161 MaybeHandle<HeapObject> Deserializer::DeserializeObject(Isolate* isolate) { |
| 161 Initialize(isolate); | 162 Initialize(isolate); |
| 162 if (!ReserveSpace()) { | 163 if (!ReserveSpace()) { |
| 163 return MaybeHandle<HeapObject>(); | 164 return MaybeHandle<HeapObject>(); |
| 164 } else { | 165 } else { |
| 165 deserializing_user_code_ = true; | 166 deserializing_user_code_ = true; |
| 166 HandleScope scope(isolate); | 167 HandleScope scope(isolate); |
| 167 Handle<HeapObject> result; | 168 Handle<HeapObject> result; |
| 168 { | 169 { |
| 169 DisallowHeapAllocation no_gc; | 170 DisallowHeapAllocation no_gc; |
| 170 Object* root; | 171 Object* root; |
| 171 VisitRootPointer(Root::kPartialSnapshotCache, &root); | 172 VisitRootPointer(Root::kPartialSnapshotCache, &root); |
| 172 DeserializeDeferredObjects(); | 173 DeserializeDeferredObjects(); |
| 173 FlushICacheForNewCodeObjectsAndRecordEmbeddedObjects(); | 174 FlushICacheForNewCodeObjectsAndRecordEmbeddedObjects(); |
| 174 result = Handle<HeapObject>(HeapObject::cast(root)); | 175 result = Handle<HeapObject>(HeapObject::cast(root)); |
| 175 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); | 176 isolate->heap()->RegisterDeserializedObjectsForBlackAllocation( |
| 177 reservations_, &deserialized_large_objects_); |
| 176 } | 178 } |
| 177 CommitPostProcessedObjects(isolate); | 179 CommitPostProcessedObjects(isolate); |
| 178 return scope.CloseAndEscape(result); | 180 return scope.CloseAndEscape(result); |
| 179 } | 181 } |
| 180 } | 182 } |
| 181 | 183 |
| 182 Deserializer::~Deserializer() { | 184 Deserializer::~Deserializer() { |
| 183 #ifdef DEBUG | 185 #ifdef DEBUG |
| 184 // Do not perform checks if we aborted deserialization. | 186 // Do not perform checks if we aborted deserialization. |
| 185 if (source_.position() == 0) return; | 187 if (source_.position() == 0) return; |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 | 912 |
| 911 default: | 913 default: |
| 912 CHECK(false); | 914 CHECK(false); |
| 913 } | 915 } |
| 914 } | 916 } |
| 915 CHECK_EQ(limit, current); | 917 CHECK_EQ(limit, current); |
| 916 return true; | 918 return true; |
| 917 } | 919 } |
| 918 } // namespace internal | 920 } // namespace internal |
| 919 } // namespace v8 | 921 } // namespace v8 |
| OLD | NEW |