OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/snapshot.h" | 5 #include "vm/snapshot.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 str_(String::Handle(isolate)), | 184 str_(String::Handle(isolate)), |
185 library_(Library::Handle(isolate)), | 185 library_(Library::Handle(isolate)), |
186 type_(AbstractType::Handle(isolate)), | 186 type_(AbstractType::Handle(isolate)), |
187 type_arguments_(TypeArguments::Handle(isolate)), | 187 type_arguments_(TypeArguments::Handle(isolate)), |
188 tokens_(Array::Handle(isolate)), | 188 tokens_(Array::Handle(isolate)), |
189 stream_(TokenStream::Handle(isolate)), | 189 stream_(TokenStream::Handle(isolate)), |
190 data_(ExternalTypedData::Handle(isolate)), | 190 data_(ExternalTypedData::Handle(isolate)), |
191 typed_data_(TypedData::Handle(isolate)), | 191 typed_data_(TypedData::Handle(isolate)), |
192 error_(UnhandledException::Handle(isolate)), | 192 error_(UnhandledException::Handle(isolate)), |
193 max_vm_isolate_object_id_( | 193 max_vm_isolate_object_id_( |
194 Object::vm_isolate_snapshot_object_table().Length()), | 194 (kind == Snapshot::kFull) ? |
| 195 Object::vm_isolate_snapshot_object_table().Length() : 0), |
195 backward_references_(backward_refs) { | 196 backward_references_(backward_refs) { |
196 } | 197 } |
197 | 198 |
198 | 199 |
199 RawObject* SnapshotReader::ReadObject() { | 200 RawObject* SnapshotReader::ReadObject() { |
200 // Setup for long jump in case there is an exception while reading. | 201 // Setup for long jump in case there is an exception while reading. |
201 LongJumpScope jump; | 202 LongJumpScope jump; |
202 if (setjmp(*jump.Set()) == 0) { | 203 if (setjmp(*jump.Set()) == 0) { |
203 PassiveObject& obj = PassiveObject::Handle(isolate(), ReadObjectImpl()); | 204 PassiveObject& obj = PassiveObject::Handle(isolate(), ReadObjectImpl()); |
204 for (intptr_t i = 0; i < backward_references_->length(); i++) { | 205 for (intptr_t i = 0; i < backward_references_->length(); i++) { |
(...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2259 | 2260 |
2260 | 2261 |
2261 ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer, | 2262 ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer, |
2262 ReAlloc alloc) | 2263 ReAlloc alloc) |
2263 : SnapshotWriter(Snapshot::kScript, | 2264 : SnapshotWriter(Snapshot::kScript, |
2264 buffer, | 2265 buffer, |
2265 alloc, | 2266 alloc, |
2266 kInitialSize, | 2267 kInitialSize, |
2267 &forward_list_, | 2268 &forward_list_, |
2268 true), | 2269 true), |
2269 forward_list_(SnapshotWriter::FirstObjectId()) { | 2270 forward_list_(kMaxPredefinedObjectIds) { |
2270 ASSERT(buffer != NULL); | 2271 ASSERT(buffer != NULL); |
2271 ASSERT(alloc != NULL); | 2272 ASSERT(alloc != NULL); |
2272 } | 2273 } |
2273 | 2274 |
2274 | 2275 |
2275 void ScriptSnapshotWriter::WriteScriptSnapshot(const Library& lib) { | 2276 void ScriptSnapshotWriter::WriteScriptSnapshot(const Library& lib) { |
2276 ASSERT(kind() == Snapshot::kScript); | 2277 ASSERT(kind() == Snapshot::kScript); |
2277 ASSERT(isolate() != NULL); | 2278 ASSERT(isolate() != NULL); |
2278 ASSERT(ClassFinalizer::AllClassesFinalized()); | 2279 ASSERT(ClassFinalizer::AllClassesFinalized()); |
2279 | 2280 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2317 | 2318 |
2318 MessageWriter::MessageWriter(uint8_t** buffer, | 2319 MessageWriter::MessageWriter(uint8_t** buffer, |
2319 ReAlloc alloc, | 2320 ReAlloc alloc, |
2320 bool can_send_any_object) | 2321 bool can_send_any_object) |
2321 : SnapshotWriter(Snapshot::kMessage, | 2322 : SnapshotWriter(Snapshot::kMessage, |
2322 buffer, | 2323 buffer, |
2323 alloc, | 2324 alloc, |
2324 kInitialSize, | 2325 kInitialSize, |
2325 &forward_list_, | 2326 &forward_list_, |
2326 can_send_any_object), | 2327 can_send_any_object), |
2327 forward_list_(SnapshotWriter::FirstObjectId()) { | 2328 forward_list_(kMaxPredefinedObjectIds) { |
2328 ASSERT(buffer != NULL); | 2329 ASSERT(buffer != NULL); |
2329 ASSERT(alloc != NULL); | 2330 ASSERT(alloc != NULL); |
2330 } | 2331 } |
2331 | 2332 |
2332 | 2333 |
2333 void MessageWriter::WriteMessage(const Object& obj) { | 2334 void MessageWriter::WriteMessage(const Object& obj) { |
2334 ASSERT(kind() == Snapshot::kMessage); | 2335 ASSERT(kind() == Snapshot::kMessage); |
2335 ASSERT(isolate() != NULL); | 2336 ASSERT(isolate() != NULL); |
2336 | 2337 |
2337 // Setup for long jump in case there is an exception while writing | 2338 // Setup for long jump in case there is an exception while writing |
2338 // the message. | 2339 // the message. |
2339 LongJumpScope jump; | 2340 LongJumpScope jump; |
2340 if (setjmp(*jump.Set()) == 0) { | 2341 if (setjmp(*jump.Set()) == 0) { |
2341 NoSafepointScope no_safepoint; | 2342 NoSafepointScope no_safepoint; |
2342 WriteObject(obj.raw()); | 2343 WriteObject(obj.raw()); |
2343 UnmarkAll(); | 2344 UnmarkAll(); |
2344 } else { | 2345 } else { |
2345 ThrowException(exception_type(), exception_msg()); | 2346 ThrowException(exception_type(), exception_msg()); |
2346 } | 2347 } |
2347 } | 2348 } |
2348 | 2349 |
2349 | 2350 |
2350 } // namespace dart | 2351 } // namespace dart |
OLD | NEW |