OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_DEFERRED_OBJECTS_H_ | 5 #ifndef VM_DEFERRED_OBJECTS_H_ |
6 #define VM_DEFERRED_OBJECTS_H_ | 6 #define VM_DEFERRED_OBJECTS_H_ |
7 | 7 |
8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 // Forward declarations. | 12 // Forward declarations. |
13 class Instance; | 13 class Instance; |
14 class RawInstance; | 14 class RawInstance; |
15 class RawObject; | 15 class RawObject; |
| 16 class DeoptContext; |
16 | 17 |
17 // Used by the deoptimization infrastructure to defer allocation of | 18 // Used by the deoptimization infrastructure to defer allocation of |
18 // unboxed objects until frame is fully rewritten and GC is safe. | 19 // unboxed objects until frame is fully rewritten and GC is safe. |
19 // Describes a stack slot that should be populated with a reference to | 20 // Describes a stack slot that should be populated with a reference to |
20 // the materialized object. | 21 // the materialized object. |
21 class DeferredSlot { | 22 class DeferredSlot { |
22 public: | 23 public: |
23 DeferredSlot(RawInstance** slot, DeferredSlot* next) | 24 DeferredSlot(RawInstance** slot, DeferredSlot* next) |
24 : slot_(slot), next_(next) { } | 25 : slot_(slot), next_(next) { } |
25 virtual ~DeferredSlot() { } | 26 virtual ~DeferredSlot() { } |
26 | 27 |
27 RawInstance** slot() const { return slot_; } | 28 RawInstance** slot() const { return slot_; } |
28 DeferredSlot* next() const { return next_; } | 29 DeferredSlot* next() const { return next_; } |
29 | 30 |
30 virtual void Materialize() = 0; | 31 virtual void Materialize(DeoptContext* deopt_context) = 0; |
31 | 32 |
32 private: | 33 private: |
33 RawInstance** const slot_; | 34 RawInstance** const slot_; |
34 DeferredSlot* const next_; | 35 DeferredSlot* const next_; |
35 | 36 |
36 DISALLOW_COPY_AND_ASSIGN(DeferredSlot); | 37 DISALLOW_COPY_AND_ASSIGN(DeferredSlot); |
37 }; | 38 }; |
38 | 39 |
39 | 40 |
40 class DeferredDouble : public DeferredSlot { | 41 class DeferredDouble : public DeferredSlot { |
41 public: | 42 public: |
42 DeferredDouble(double value, RawInstance** slot, DeferredSlot* next) | 43 DeferredDouble(double value, RawInstance** slot, DeferredSlot* next) |
43 : DeferredSlot(slot, next), value_(value) { } | 44 : DeferredSlot(slot, next), value_(value) { } |
44 | 45 |
45 virtual void Materialize(); | 46 virtual void Materialize(DeoptContext* deopt_context); |
46 | 47 |
47 double value() const { return value_; } | 48 double value() const { return value_; } |
48 | 49 |
49 private: | 50 private: |
50 const double value_; | 51 const double value_; |
51 | 52 |
52 DISALLOW_COPY_AND_ASSIGN(DeferredDouble); | 53 DISALLOW_COPY_AND_ASSIGN(DeferredDouble); |
53 }; | 54 }; |
54 | 55 |
55 | 56 |
56 class DeferredMint : public DeferredSlot { | 57 class DeferredMint : public DeferredSlot { |
57 public: | 58 public: |
58 DeferredMint(int64_t value, RawInstance** slot, DeferredSlot* next) | 59 DeferredMint(int64_t value, RawInstance** slot, DeferredSlot* next) |
59 : DeferredSlot(slot, next), value_(value) { } | 60 : DeferredSlot(slot, next), value_(value) { } |
60 | 61 |
61 virtual void Materialize(); | 62 virtual void Materialize(DeoptContext* deopt_context); |
62 | 63 |
63 int64_t value() const { return value_; } | 64 int64_t value() const { return value_; } |
64 | 65 |
65 private: | 66 private: |
66 const int64_t value_; | 67 const int64_t value_; |
67 | 68 |
68 DISALLOW_COPY_AND_ASSIGN(DeferredMint); | 69 DISALLOW_COPY_AND_ASSIGN(DeferredMint); |
69 }; | 70 }; |
70 | 71 |
71 | 72 |
72 class DeferredFloat32x4 : public DeferredSlot { | 73 class DeferredFloat32x4 : public DeferredSlot { |
73 public: | 74 public: |
74 DeferredFloat32x4(simd128_value_t value, RawInstance** slot, | 75 DeferredFloat32x4(simd128_value_t value, RawInstance** slot, |
75 DeferredSlot* next) | 76 DeferredSlot* next) |
76 : DeferredSlot(slot, next), value_(value) { } | 77 : DeferredSlot(slot, next), value_(value) { } |
77 | 78 |
78 virtual void Materialize(); | 79 virtual void Materialize(DeoptContext* deopt_context); |
79 | 80 |
80 simd128_value_t value() const { return value_; } | 81 simd128_value_t value() const { return value_; } |
81 | 82 |
82 private: | 83 private: |
83 const simd128_value_t value_; | 84 const simd128_value_t value_; |
84 | 85 |
85 DISALLOW_COPY_AND_ASSIGN(DeferredFloat32x4); | 86 DISALLOW_COPY_AND_ASSIGN(DeferredFloat32x4); |
86 }; | 87 }; |
87 | 88 |
88 | 89 |
89 class DeferredInt32x4 : public DeferredSlot { | 90 class DeferredInt32x4 : public DeferredSlot { |
90 public: | 91 public: |
91 DeferredInt32x4(simd128_value_t value, RawInstance** slot, | 92 DeferredInt32x4(simd128_value_t value, RawInstance** slot, |
92 DeferredSlot* next) | 93 DeferredSlot* next) |
93 : DeferredSlot(slot, next), value_(value) { } | 94 : DeferredSlot(slot, next), value_(value) { } |
94 | 95 |
95 virtual void Materialize(); | 96 virtual void Materialize(DeoptContext* deopt_context); |
96 | 97 |
97 simd128_value_t value() const { return value_; } | 98 simd128_value_t value() const { return value_; } |
98 | 99 |
99 private: | 100 private: |
100 const simd128_value_t value_; | 101 const simd128_value_t value_; |
101 | 102 |
102 DISALLOW_COPY_AND_ASSIGN(DeferredInt32x4); | 103 DISALLOW_COPY_AND_ASSIGN(DeferredInt32x4); |
103 }; | 104 }; |
104 | 105 |
105 | 106 |
106 // Describes a slot that contains a reference to an object that had its | 107 // Describes a slot that contains a reference to an object that had its |
107 // allocation removed by AllocationSinking pass. | 108 // allocation removed by AllocationSinking pass. |
108 // Object itself is described and materialized by DeferredObject. | 109 // Object itself is described and materialized by DeferredObject. |
109 class DeferredObjectRef : public DeferredSlot { | 110 class DeferredObjectRef : public DeferredSlot { |
110 public: | 111 public: |
111 DeferredObjectRef(intptr_t index, RawInstance** slot, DeferredSlot* next) | 112 DeferredObjectRef(intptr_t index, RawInstance** slot, DeferredSlot* next) |
112 : DeferredSlot(slot, next), index_(index) { } | 113 : DeferredSlot(slot, next), index_(index) { } |
113 | 114 |
114 virtual void Materialize(); | 115 virtual void Materialize(DeoptContext* deopt_context); |
115 | 116 |
116 intptr_t index() const { return index_; } | 117 intptr_t index() const { return index_; } |
117 | 118 |
118 private: | 119 private: |
119 const intptr_t index_; | 120 const intptr_t index_; |
120 | 121 |
121 DISALLOW_COPY_AND_ASSIGN(DeferredObjectRef); | 122 DISALLOW_COPY_AND_ASSIGN(DeferredObjectRef); |
122 }; | 123 }; |
123 | 124 |
124 | 125 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 179 |
179 // Object materialized from this description. | 180 // Object materialized from this description. |
180 const Instance* object_; | 181 const Instance* object_; |
181 | 182 |
182 DISALLOW_COPY_AND_ASSIGN(DeferredObject); | 183 DISALLOW_COPY_AND_ASSIGN(DeferredObject); |
183 }; | 184 }; |
184 | 185 |
185 } // namespace dart | 186 } // namespace dart |
186 | 187 |
187 #endif // VM_DEFERRED_OBJECTS_H_ | 188 #endif // VM_DEFERRED_OBJECTS_H_ |
OLD | NEW |