| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 | 134 |
| 135 AddAttachedObject(global_proxy); | 135 AddAttachedObject(global_proxy); |
| 136 | 136 |
| 137 DisallowHeapAllocation no_gc; | 137 DisallowHeapAllocation no_gc; |
| 138 // Keep track of the code space start and end pointers in case new | 138 // Keep track of the code space start and end pointers in case new |
| 139 // code objects were unserialized | 139 // code objects were unserialized |
| 140 OldSpace* code_space = isolate_->heap()->code_space(); | 140 OldSpace* code_space = isolate_->heap()->code_space(); |
| 141 Address start_address = code_space->top(); | 141 Address start_address = code_space->top(); |
| 142 Object* root; | 142 Object* root; |
| 143 VisitPointer(&root); | 143 VisitRootPointer(Root::kPartialSnapshotCache, &root); |
| 144 DeserializeDeferredObjects(); | 144 DeserializeDeferredObjects(); |
| 145 DeserializeEmbedderFields(embedder_fields_deserializer); | 145 DeserializeEmbedderFields(embedder_fields_deserializer); |
| 146 | 146 |
| 147 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); | 147 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); |
| 148 | 148 |
| 149 // There's no code deserialized here. If this assert fires then that's | 149 // There's no code deserialized here. If this assert fires then that's |
| 150 // changed and logging should be added to notify the profiler et al of the | 150 // changed and logging should be added to notify the profiler et al of the |
| 151 // new code, which also has to be flushed from instruction cache. | 151 // new code, which also has to be flushed from instruction cache. |
| 152 CHECK_EQ(start_address, code_space->top()); | 152 CHECK_EQ(start_address, code_space->top()); |
| 153 return Handle<Object>(root, isolate); | 153 return Handle<Object>(root, isolate); |
| 154 } | 154 } |
| 155 | 155 |
| 156 MaybeHandle<HeapObject> Deserializer::DeserializeObject(Isolate* isolate) { | 156 MaybeHandle<HeapObject> Deserializer::DeserializeObject(Isolate* isolate) { |
| 157 Initialize(isolate); | 157 Initialize(isolate); |
| 158 if (!ReserveSpace()) { | 158 if (!ReserveSpace()) { |
| 159 return MaybeHandle<HeapObject>(); | 159 return MaybeHandle<HeapObject>(); |
| 160 } else { | 160 } else { |
| 161 deserializing_user_code_ = true; | 161 deserializing_user_code_ = true; |
| 162 HandleScope scope(isolate); | 162 HandleScope scope(isolate); |
| 163 Handle<HeapObject> result; | 163 Handle<HeapObject> result; |
| 164 { | 164 { |
| 165 DisallowHeapAllocation no_gc; | 165 DisallowHeapAllocation no_gc; |
| 166 Object* root; | 166 Object* root; |
| 167 VisitPointer(&root); | 167 VisitRootPointer(Root::kPartialSnapshotCache, &root); |
| 168 DeserializeDeferredObjects(); | 168 DeserializeDeferredObjects(); |
| 169 FlushICacheForNewCodeObjectsAndRecordEmbeddedObjects(); | 169 FlushICacheForNewCodeObjectsAndRecordEmbeddedObjects(); |
| 170 result = Handle<HeapObject>(HeapObject::cast(root)); | 170 result = Handle<HeapObject>(HeapObject::cast(root)); |
| 171 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); | 171 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); |
| 172 } | 172 } |
| 173 CommitPostProcessedObjects(isolate); | 173 CommitPostProcessedObjects(isolate); |
| 174 return scope.CloseAndEscape(result); | 174 return scope.CloseAndEscape(result); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 Deserializer::~Deserializer() { | 178 Deserializer::~Deserializer() { |
| 179 #ifdef DEBUG | 179 #ifdef DEBUG |
| 180 // Do not perform checks if we aborted deserialization. | 180 // Do not perform checks if we aborted deserialization. |
| 181 if (source_.position() == 0) return; | 181 if (source_.position() == 0) return; |
| 182 // Check that we only have padding bytes remaining. | 182 // Check that we only have padding bytes remaining. |
| 183 while (source_.HasMore()) CHECK_EQ(kNop, source_.Get()); | 183 while (source_.HasMore()) CHECK_EQ(kNop, source_.Get()); |
| 184 for (int space = 0; space < kNumberOfPreallocatedSpaces; space++) { | 184 for (int space = 0; space < kNumberOfPreallocatedSpaces; space++) { |
| 185 int chunk_index = current_chunk_[space]; | 185 int chunk_index = current_chunk_[space]; |
| 186 CHECK_EQ(reservations_[space].length(), chunk_index + 1); | 186 CHECK_EQ(reservations_[space].length(), chunk_index + 1); |
| 187 CHECK_EQ(reservations_[space][chunk_index].end, high_water_[space]); | 187 CHECK_EQ(reservations_[space][chunk_index].end, high_water_[space]); |
| 188 } | 188 } |
| 189 CHECK_EQ(allocated_maps_.length(), next_map_index_); | 189 CHECK_EQ(allocated_maps_.length(), next_map_index_); |
| 190 #endif // DEBUG | 190 #endif // DEBUG |
| 191 } | 191 } |
| 192 | 192 |
| 193 // This is called on the roots. It is the driver of the deserialization | 193 // This is called on the roots. It is the driver of the deserialization |
| 194 // process. It is also called on the body of each function. | 194 // process. It is also called on the body of each function. |
| 195 void Deserializer::VisitPointers(Object** start, Object** end) { | 195 void Deserializer::VisitRootPointers(Root root, Object** start, Object** end) { |
| 196 // The space must be new space. Any other space would cause ReadChunk to try | 196 // The space must be new space. Any other space would cause ReadChunk to try |
| 197 // to update the remembered using NULL as the address. | 197 // to update the remembered using NULL as the address. |
| 198 ReadData(start, end, NEW_SPACE, NULL); | 198 ReadData(start, end, NEW_SPACE, NULL); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void Deserializer::Synchronize(VisitorSynchronization::SyncTag tag) { | 201 void Deserializer::Synchronize(VisitorSynchronization::SyncTag tag) { |
| 202 static const byte expected = kSynchronize; | 202 static const byte expected = kSynchronize; |
| 203 CHECK_EQ(expected, source_.Get()); | 203 CHECK_EQ(expected, source_.Get()); |
| 204 } | 204 } |
| 205 | 205 |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 | 918 |
| 919 default: | 919 default: |
| 920 CHECK(false); | 920 CHECK(false); |
| 921 } | 921 } |
| 922 } | 922 } |
| 923 CHECK_EQ(limit, current); | 923 CHECK_EQ(limit, current); |
| 924 return true; | 924 return true; |
| 925 } | 925 } |
| 926 } // namespace internal | 926 } // namespace internal |
| 927 } // namespace v8 | 927 } // namespace v8 |
| OLD | NEW |