| 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/exceptions.h" | 10 #include "vm/exceptions.h" |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 Advance(version_len); | 512 Advance(version_len); |
| 513 return ApiError::null(); | 513 return ApiError::null(); |
| 514 } | 514 } |
| 515 | 515 |
| 516 | 516 |
| 517 #define ALLOC_NEW_OBJECT_WITH_LEN(type, length) \ | 517 #define ALLOC_NEW_OBJECT_WITH_LEN(type, length) \ |
| 518 ASSERT(kind_ == Snapshot::kFull); \ | 518 ASSERT(kind_ == Snapshot::kFull); \ |
| 519 ASSERT(isolate()->no_gc_scope_depth() != 0); \ | 519 ASSERT(isolate()->no_gc_scope_depth() != 0); \ |
| 520 Raw##type* obj = reinterpret_cast<Raw##type*>( \ | 520 Raw##type* obj = reinterpret_cast<Raw##type*>( \ |
| 521 AllocateUninitialized(k##type##Cid, type::InstanceSize(length))); \ | 521 AllocateUninitialized(k##type##Cid, type::InstanceSize(length))); \ |
| 522 obj->ptr()->length_ = Smi::New(length); \ | 522 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(length)); \ |
| 523 return obj; \ | 523 return obj; \ |
| 524 | 524 |
| 525 | 525 |
| 526 RawArray* SnapshotReader::NewArray(intptr_t len) { | 526 RawArray* SnapshotReader::NewArray(intptr_t len) { |
| 527 ALLOC_NEW_OBJECT_WITH_LEN(Array, len); | 527 ALLOC_NEW_OBJECT_WITH_LEN(Array, len); |
| 528 } | 528 } |
| 529 | 529 |
| 530 | 530 |
| 531 RawImmutableArray* SnapshotReader::NewImmutableArray(intptr_t len) { | 531 RawImmutableArray* SnapshotReader::NewImmutableArray(intptr_t len) { |
| 532 ALLOC_NEW_OBJECT_WITH_LEN(ImmutableArray, len); | 532 ALLOC_NEW_OBJECT_WITH_LEN(ImmutableArray, len); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 return obj; | 623 return obj; |
| 624 } | 624 } |
| 625 | 625 |
| 626 | 626 |
| 627 RawTypedData* SnapshotReader::NewTypedData(intptr_t class_id, intptr_t len) { | 627 RawTypedData* SnapshotReader::NewTypedData(intptr_t class_id, intptr_t len) { |
| 628 ASSERT(kind_ == Snapshot::kFull); | 628 ASSERT(kind_ == Snapshot::kFull); |
| 629 ASSERT(isolate()->no_gc_scope_depth() != 0); | 629 ASSERT(isolate()->no_gc_scope_depth() != 0); |
| 630 const intptr_t lengthInBytes = len * TypedData::ElementSizeInBytes(class_id); | 630 const intptr_t lengthInBytes = len * TypedData::ElementSizeInBytes(class_id); |
| 631 RawTypedData* obj = reinterpret_cast<RawTypedData*>( | 631 RawTypedData* obj = reinterpret_cast<RawTypedData*>( |
| 632 AllocateUninitialized(class_id, TypedData::InstanceSize(lengthInBytes))); | 632 AllocateUninitialized(class_id, TypedData::InstanceSize(lengthInBytes))); |
| 633 obj->ptr()->length_ = Smi::New(len); | 633 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(len)); |
| 634 return obj; | 634 return obj; |
| 635 } | 635 } |
| 636 | 636 |
| 637 | 637 |
| 638 #define ALLOC_NEW_OBJECT(type) \ | 638 #define ALLOC_NEW_OBJECT(type) \ |
| 639 ASSERT(kind_ == Snapshot::kFull); \ | 639 ASSERT(kind_ == Snapshot::kFull); \ |
| 640 ASSERT(isolate()->no_gc_scope_depth() != 0); \ | 640 ASSERT(isolate()->no_gc_scope_depth() != 0); \ |
| 641 return reinterpret_cast<Raw##type*>( \ | 641 return reinterpret_cast<Raw##type*>( \ |
| 642 AllocateUninitialized(k##type##Cid, type::InstanceSize())); \ | 642 AllocateUninitialized(k##type##Cid, type::InstanceSize())); \ |
| 643 | 643 |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 NoGCScope no_gc; | 1759 NoGCScope no_gc; |
| 1760 WriteObject(obj.raw()); | 1760 WriteObject(obj.raw()); |
| 1761 UnmarkAll(); | 1761 UnmarkAll(); |
| 1762 } else { | 1762 } else { |
| 1763 ThrowException(exception_type(), exception_msg()); | 1763 ThrowException(exception_type(), exception_msg()); |
| 1764 } | 1764 } |
| 1765 } | 1765 } |
| 1766 | 1766 |
| 1767 | 1767 |
| 1768 } // namespace dart | 1768 } // namespace dart |
| OLD | NEW |