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