| 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 #ifndef VM_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
| 6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/atomic.h" | 9 #include "vm/atomic.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| 11 #include "vm/snapshot.h" |
| 11 #include "vm/token.h" | 12 #include "vm/token.h" |
| 12 #include "vm/snapshot.h" | 13 #include "vm/verified_memory.h" |
| 13 | 14 |
| 14 namespace dart { | 15 namespace dart { |
| 15 | 16 |
| 16 // Macrobatics to define the Object hierarchy of VM implementation classes. | 17 // Macrobatics to define the Object hierarchy of VM implementation classes. |
| 17 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \ | 18 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \ |
| 18 V(Class) \ | 19 V(Class) \ |
| 19 V(UnresolvedClass) \ | 20 V(UnresolvedClass) \ |
| 20 V(TypeArguments) \ | 21 V(TypeArguments) \ |
| 21 V(PatchClass) \ | 22 V(PatchClass) \ |
| 22 V(Function) \ | 23 V(Function) \ |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 } | 481 } |
| 481 | 482 |
| 482 // All writes to heap objects should ultimately pass through one of the | 483 // All writes to heap objects should ultimately pass through one of the |
| 483 // methods below or their counterparts in Object, to ensure that the | 484 // methods below or their counterparts in Object, to ensure that the |
| 484 // write barrier is correctly applied. | 485 // write barrier is correctly applied. |
| 485 | 486 |
| 486 template<typename type> | 487 template<typename type> |
| 487 void StorePointer(type const* addr, type value) { | 488 void StorePointer(type const* addr, type value) { |
| 488 // Ensure that this object contains the addr. | 489 // Ensure that this object contains the addr. |
| 489 ASSERT(Contains(reinterpret_cast<uword>(addr))); | 490 ASSERT(Contains(reinterpret_cast<uword>(addr))); |
| 490 *const_cast<type*>(addr) = value; | 491 VerifiedMemory::Write(const_cast<type*>(addr), value); |
| 491 // Filter stores based on source and target. | 492 // Filter stores based on source and target. |
| 492 if (!value->IsHeapObject()) return; | 493 if (!value->IsHeapObject()) return; |
| 493 if (value->IsNewObject() && this->IsOldObject() && | 494 if (value->IsNewObject() && this->IsOldObject() && |
| 494 !this->IsRemembered()) { | 495 !this->IsRemembered()) { |
| 495 this->SetRememberedBit(); | 496 this->SetRememberedBit(); |
| 496 Isolate::Current()->store_buffer()->AddObject(this); | 497 Isolate::Current()->store_buffer()->AddObject(this); |
| 497 } | 498 } |
| 498 } | 499 } |
| 499 | 500 |
| 500 // Use for storing into an explicitly Smi-typed field of an object | 501 // Use for storing into an explicitly Smi-typed field of an object |
| 501 // (i.e., both the previous and new value are Smis). | 502 // (i.e., both the previous and new value are Smis). |
| 502 void StoreSmi(RawSmi* const* addr, RawSmi* value) { | 503 void StoreSmi(RawSmi* const* addr, RawSmi* value) { |
| 503 // Can't use Contains, as array length is initialized through this method. | 504 // Can't use Contains, as array length is initialized through this method. |
| 504 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(this)); | 505 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(this)); |
| 505 *const_cast<RawSmi**>(addr) = value; | 506 VerifiedMemory::Write(const_cast<RawSmi**>(addr), value); |
| 506 } | 507 } |
| 507 | 508 |
| 508 friend class Api; | 509 friend class Api; |
| 509 friend class Array; | 510 friend class Array; |
| 510 friend class ByteBuffer; | 511 friend class ByteBuffer; |
| 511 friend class Code; | 512 friend class Code; |
| 512 friend class FreeListElement; | 513 friend class FreeListElement; |
| 513 friend class GCMarker; | 514 friend class GCMarker; |
| 514 friend class ExternalTypedData; | 515 friend class ExternalTypedData; |
| 515 friend class ForwardList; | 516 friend class ForwardList; |
| (...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2110 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2110 kTypedDataInt8ArrayViewCid + 15); | 2111 kTypedDataInt8ArrayViewCid + 15); |
| 2111 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2112 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2112 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2113 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2113 return (kNullCid - kTypedDataInt8ArrayCid); | 2114 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2114 } | 2115 } |
| 2115 | 2116 |
| 2116 } // namespace dart | 2117 } // namespace dart |
| 2117 | 2118 |
| 2118 #endif // VM_RAW_OBJECT_H_ | 2119 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |