| 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 10 matching lines...) Expand all Loading... |
| 21 #include "vm/verified_memory.h" | 21 #include "vm/verified_memory.h" |
| 22 #include "vm/version.h" | 22 #include "vm/version.h" |
| 23 | 23 |
| 24 // We currently only expect the Dart mutator to read snapshots. | 24 // We currently only expect the Dart mutator to read snapshots. |
| 25 #define ASSERT_NO_SAFEPOINT_SCOPE() \ | 25 #define ASSERT_NO_SAFEPOINT_SCOPE() \ |
| 26 isolate()->AssertCurrentThreadIsMutator(); \ | 26 isolate()->AssertCurrentThreadIsMutator(); \ |
| 27 ASSERT(thread()->no_safepoint_scope_depth() != 0) | 27 ASSERT(thread()->no_safepoint_scope_depth() != 0) |
| 28 | 28 |
| 29 namespace dart { | 29 namespace dart { |
| 30 | 30 |
| 31 DECLARE_FLAG(bool, use_field_guards); |
| 32 |
| 33 |
| 31 static const int kNumVmIsolateSnapshotReferences = 32 * KB; | 34 static const int kNumVmIsolateSnapshotReferences = 32 * KB; |
| 32 static const int kNumInitialReferencesInFullSnapshot = 160 * KB; | 35 static const int kNumInitialReferencesInFullSnapshot = 160 * KB; |
| 33 static const int kNumInitialReferences = 64; | 36 static const int kNumInitialReferences = 64; |
| 34 | 37 |
| 35 | 38 |
| 36 static bool IsSingletonClassId(intptr_t class_id) { | 39 static bool IsSingletonClassId(intptr_t class_id) { |
| 37 // Check if this is a singleton object class which is shared by all isolates. | 40 // Check if this is a singleton object class which is shared by all isolates. |
| 38 return ((class_id >= kClassCid && class_id <= kUnwindErrorCid) || | 41 return ((class_id >= kClassCid && class_id <= kUnwindErrorCid) || |
| 39 (class_id >= kNullCid && class_id <= kVoidCid)); | 42 (class_id >= kNullCid && class_id <= kVoidCid)); |
| 40 } | 43 } |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 ASSERT(next_field_offset > 0); | 506 ASSERT(next_field_offset > 0); |
| 504 // Instance::NextFieldOffset() returns the offset of the first field in | 507 // Instance::NextFieldOffset() returns the offset of the first field in |
| 505 // a Dart object. | 508 // a Dart object. |
| 506 bool read_as_reference = RawObject::IsCanonical(tags) ? false : true; | 509 bool read_as_reference = RawObject::IsCanonical(tags) ? false : true; |
| 507 intptr_t offset = Instance::NextFieldOffset(); | 510 intptr_t offset = Instance::NextFieldOffset(); |
| 508 intptr_t result_cid = result->GetClassId(); | 511 intptr_t result_cid = result->GetClassId(); |
| 509 while (offset < next_field_offset) { | 512 while (offset < next_field_offset) { |
| 510 pobj_ = ReadObjectImpl(read_as_reference); | 513 pobj_ = ReadObjectImpl(read_as_reference); |
| 511 result->SetFieldAtOffset(offset, pobj_); | 514 result->SetFieldAtOffset(offset, pobj_); |
| 512 if ((offset != type_argument_field_offset) && | 515 if ((offset != type_argument_field_offset) && |
| 513 (kind_ == Snapshot::kMessage)) { | 516 (kind_ == Snapshot::kMessage) && |
| 517 FLAG_use_field_guards) { |
| 514 // TODO(fschneider): Consider hoisting these lookups out of the loop. | 518 // TODO(fschneider): Consider hoisting these lookups out of the loop. |
| 515 // This would involve creating a handle, since cls_ can't be reused | 519 // This would involve creating a handle, since cls_ can't be reused |
| 516 // across the call to ReadObjectImpl. | 520 // across the call to ReadObjectImpl. |
| 517 cls_ = isolate()->class_table()->At(result_cid); | 521 cls_ = isolate()->class_table()->At(result_cid); |
| 518 array_ = cls_.OffsetToFieldMap(); | 522 array_ = cls_.OffsetToFieldMap(); |
| 519 field_ ^= array_.At(offset >> kWordSizeLog2); | 523 field_ ^= array_.At(offset >> kWordSizeLog2); |
| 520 ASSERT(!field_.IsNull()); | 524 ASSERT(!field_.IsNull()); |
| 521 ASSERT(field_.Offset() == offset); | 525 ASSERT(field_.Offset() == offset); |
| 522 obj_ = pobj_.raw(); | 526 obj_ = pobj_.raw(); |
| 523 field_.RecordStore(obj_); | 527 field_.RecordStore(obj_); |
| (...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2586 if (setjmp(*jump.Set()) == 0) { | 2590 if (setjmp(*jump.Set()) == 0) { |
| 2587 NoSafepointScope no_safepoint; | 2591 NoSafepointScope no_safepoint; |
| 2588 WriteObject(obj.raw()); | 2592 WriteObject(obj.raw()); |
| 2589 } else { | 2593 } else { |
| 2590 ThrowException(exception_type(), exception_msg()); | 2594 ThrowException(exception_type(), exception_msg()); |
| 2591 } | 2595 } |
| 2592 } | 2596 } |
| 2593 | 2597 |
| 2594 | 2598 |
| 2595 } // namespace dart | 2599 } // namespace dart |
| OLD | NEW |