| 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" | 
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" | 
| 12 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" | 
| 13 #include "vm/heap.h" | 13 #include "vm/heap.h" | 
| 14 #include "vm/lockers.h" | 14 #include "vm/lockers.h" | 
| 15 #include "vm/longjump.h" | 15 #include "vm/longjump.h" | 
| 16 #include "vm/object.h" | 16 #include "vm/object.h" | 
| 17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" | 
| 18 #include "vm/snapshot_ids.h" | 18 #include "vm/snapshot_ids.h" | 
| 19 #include "vm/stub_code.h" | 19 #include "vm/stub_code.h" | 
| 20 #include "vm/symbols.h" | 20 #include "vm/symbols.h" | 
| 21 #include "vm/timeline.h" | 21 #include "vm/timeline.h" | 
| 22 #include "vm/verified_memory.h" |  | 
| 23 #include "vm/version.h" | 22 #include "vm/version.h" | 
| 24 | 23 | 
| 25 // We currently only expect the Dart mutator to read snapshots. | 24 // We currently only expect the Dart mutator to read snapshots. | 
| 26 #define ASSERT_NO_SAFEPOINT_SCOPE()                            \ | 25 #define ASSERT_NO_SAFEPOINT_SCOPE()                            \ | 
| 27     isolate()->AssertCurrentThreadIsMutator();                 \ | 26     isolate()->AssertCurrentThreadIsMutator();                 \ | 
| 28     ASSERT(thread()->no_safepoint_scope_depth() != 0) | 27     ASSERT(thread()->no_safepoint_scope_depth() != 0) | 
| 29 | 28 | 
| 30 namespace dart { | 29 namespace dart { | 
| 31 | 30 | 
| 32 static const int kNumInitialReferences = 64; | 31 static const int kNumInitialReferences = 64; | 
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1421   ASSERT(IsObjectStoreClassId(class_id) || IsSingletonClassId(class_id)); | 1420   ASSERT(IsObjectStoreClassId(class_id) || IsSingletonClassId(class_id)); | 
| 1422   return class_id; | 1421   return class_id; | 
| 1423 } | 1422 } | 
| 1424 | 1423 | 
| 1425 | 1424 | 
| 1426 RawObject* SnapshotReader::AllocateUninitialized(intptr_t class_id, | 1425 RawObject* SnapshotReader::AllocateUninitialized(intptr_t class_id, | 
| 1427                                                  intptr_t size) { | 1426                                                  intptr_t size) { | 
| 1428   ASSERT_NO_SAFEPOINT_SCOPE(); | 1427   ASSERT_NO_SAFEPOINT_SCOPE(); | 
| 1429   ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 1428   ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 
| 1430 | 1429 | 
| 1431   // Allocate memory where all words look like smis. This is currently |  | 
| 1432   // only needed for DEBUG-mode validation in StorePointer/StoreSmi, but will |  | 
| 1433   // be essential with the upcoming deletion barrier. |  | 
| 1434   uword address = | 1430   uword address = | 
| 1435       old_space()->TryAllocateSmiInitializedLocked(size, | 1431       old_space()->TryAllocateDataBumpLocked(size, PageSpace::kForceGrowth); | 
| 1436                                                    PageSpace::kForceGrowth); |  | 
| 1437   if (address == 0) { | 1432   if (address == 0) { | 
| 1438     // Use the preallocated out of memory exception to avoid calling | 1433     // Use the preallocated out of memory exception to avoid calling | 
| 1439     // into dart code or allocating any code. | 1434     // into dart code or allocating any code. | 
| 1440     // We do a longjmp at this point to unwind out of the entire | 1435     // We do a longjmp at this point to unwind out of the entire | 
| 1441     // read part and return the error object back. | 1436     // read part and return the error object back. | 
| 1442     const UnhandledException& error = UnhandledException::Handle( | 1437     const UnhandledException& error = UnhandledException::Handle( | 
| 1443         object_store()->preallocated_unhandled_exception()); | 1438         object_store()->preallocated_unhandled_exception()); | 
| 1444     thread()->long_jump_base()->Jump(1, error); | 1439     thread()->long_jump_base()->Jump(1, error); | 
| 1445   } | 1440   } | 
| 1446   VerifiedMemory::Accept(address, size); |  | 
| 1447 | 1441 | 
| 1448   RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 1442   RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 
| 1449   uword tags = 0; | 1443   uword tags = 0; | 
| 1450   ASSERT(class_id != kIllegalCid); | 1444   ASSERT(class_id != kIllegalCid); | 
| 1451   tags = RawObject::ClassIdTag::update(class_id, tags); | 1445   tags = RawObject::ClassIdTag::update(class_id, tags); | 
| 1452   tags = RawObject::SizeTag::update(size, tags); | 1446   tags = RawObject::SizeTag::update(size, tags); | 
| 1453   tags = RawObject::VMHeapObjectTag::update(is_vm_isolate(), tags); | 1447   tags = RawObject::VMHeapObjectTag::update(is_vm_isolate(), tags); | 
| 1454   raw_obj->ptr()->tags_ = tags; | 1448   raw_obj->ptr()->tags_ = tags; | 
| 1455   return raw_obj; | 1449   return raw_obj; | 
| 1456 } | 1450 } | 
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2439   if (setjmp(*jump.Set()) == 0) { | 2433   if (setjmp(*jump.Set()) == 0) { | 
| 2440     NoSafepointScope no_safepoint; | 2434     NoSafepointScope no_safepoint; | 
| 2441     WriteObject(obj.raw()); | 2435     WriteObject(obj.raw()); | 
| 2442   } else { | 2436   } else { | 
| 2443     ThrowException(exception_type(), exception_msg()); | 2437     ThrowException(exception_type(), exception_msg()); | 
| 2444   } | 2438   } | 
| 2445 } | 2439 } | 
| 2446 | 2440 | 
| 2447 | 2441 | 
| 2448 }  // namespace dart | 2442 }  // namespace dart | 
| OLD | NEW | 
|---|