OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 RUNTIME_VM_BECOME_H_ | 5 #ifndef RUNTIME_VM_BECOME_H_ |
6 #define RUNTIME_VM_BECOME_H_ | 6 #define RUNTIME_VM_BECOME_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/raw_object.h" | 9 #include "vm/raw_object.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 class Array; | 13 class Array; |
14 | 14 |
15 // Objects that are a source in a become are tranformed into forwarding | 15 // Objects that are a source in a become are tranformed into forwarding |
16 // corpses pointing to the corresponding target. Forwarding corpses have the | 16 // corpses pointing to the corresponding target. Forwarding corpses have the |
17 // same heap sizes as the source object to ensure the heap remains walkable. | 17 // same heap sizes as the source object to ensure the heap remains walkable. |
18 // If the heap sizes is small enough to be encoded in the size field of the | 18 // If the heap sizes is small enough to be encoded in the size field of the |
19 // header, a forwarding corpse consists only of a header and the target pointer. | 19 // header, a forwarding corpse consists only of a header and the target pointer. |
20 // If the heap size is too big to be encoded in the header's size field, the | 20 // If the heap size is too big to be encoded in the header's size field, the |
21 // word after the target pointer contains the size. This is the same | 21 // word after the target pointer contains the size. This is the same |
22 // representation as a FreeListElement. | 22 // representation as a FreeListElement. |
23 class ForwardingCorpse { | 23 class ForwardingCorpse { |
24 public: | 24 public: |
25 RawObject* target() const { | 25 RawObject* target() const { return target_; } |
26 return target_; | 26 void set_target(RawObject* target) { target_ = target; } |
27 } | |
28 void set_target(RawObject* target) { | |
29 target_ = target; | |
30 } | |
31 | 27 |
32 intptr_t Size() { | 28 intptr_t Size() { |
33 intptr_t size = RawObject::SizeTag::decode(tags_); | 29 intptr_t size = RawObject::SizeTag::decode(tags_); |
34 if (size != 0) return size; | 30 if (size != 0) return size; |
35 return *SizeAddress(); | 31 return *SizeAddress(); |
36 } | 32 } |
37 | 33 |
38 static ForwardingCorpse* AsForwarder(uword addr, intptr_t size); | 34 static ForwardingCorpse* AsForwarder(uword addr, intptr_t size); |
39 | 35 |
40 static void InitOnce(); | 36 static void InitOnce(); |
41 | 37 |
42 // Used to allocate class for forwarding corpses in Object::InitOnce. | 38 // Used to allocate class for forwarding corpses in Object::InitOnce. |
43 class FakeInstance { | 39 class FakeInstance { |
44 public: | 40 public: |
45 FakeInstance() { } | 41 FakeInstance() {} |
46 static cpp_vtable vtable() { return 0; } | 42 static cpp_vtable vtable() { return 0; } |
47 static intptr_t InstanceSize() { return 0; } | 43 static intptr_t InstanceSize() { return 0; } |
48 static intptr_t NextFieldOffset() { return -kWordSize; } | 44 static intptr_t NextFieldOffset() { return -kWordSize; } |
49 static const ClassId kClassId = kForwardingCorpse; | 45 static const ClassId kClassId = kForwardingCorpse; |
50 static bool IsInstance() { return true; } | 46 static bool IsInstance() { return true; } |
51 | 47 |
52 private: | 48 private: |
53 DISALLOW_ALLOCATION(); | 49 DISALLOW_ALLOCATION(); |
54 DISALLOW_COPY_AND_ASSIGN(FakeInstance); | 50 DISALLOW_COPY_AND_ASSIGN(FakeInstance); |
55 }; | 51 }; |
(...skipping 30 matching lines...) Expand all Loading... |
86 // (used for morphic instances during reload). | 82 // (used for morphic instances during reload). |
87 static void MakeDummyObject(const Instance& instance); | 83 static void MakeDummyObject(const Instance& instance); |
88 | 84 |
89 private: | 85 private: |
90 static void CrashDump(RawObject* before_obj, RawObject* after_obj); | 86 static void CrashDump(RawObject* before_obj, RawObject* after_obj); |
91 }; | 87 }; |
92 | 88 |
93 } // namespace dart | 89 } // namespace dart |
94 | 90 |
95 #endif // RUNTIME_VM_BECOME_H_ | 91 #endif // RUNTIME_VM_BECOME_H_ |
OLD | NEW |