Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
deferred_objects.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_DEFERRED_OBJECTS_H_
6#define RUNTIME_VM_DEFERRED_OBJECTS_H_
7
8#include "platform/globals.h"
9#include "vm/tagged_pointer.h"
10
11namespace dart {
12
13// Forward declarations.
14class Object;
15class DeoptContext;
16
17// Used by the deoptimization infrastructure to defer allocation of
18// 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// the materialized object.
22 public:
24 : slot_(slot), next_(next) {}
25 virtual ~DeferredSlot() {}
26
27 ObjectPtr* slot() const { return slot_; }
28 DeferredSlot* next() const { return next_; }
29
30 virtual void Materialize(DeoptContext* deopt_context) = 0;
31
32 private:
33 ObjectPtr* const slot_;
34 DeferredSlot* const next_;
35
37};
38
40 public:
43
44 virtual void Materialize(DeoptContext* deopt_context);
45
46 double value() const { return value_; }
47
48 private:
49 const double value_;
50
52};
53
54class DeferredMint : public DeferredSlot {
55 public:
58
59 virtual void Materialize(DeoptContext* deopt_context);
60
61 int64_t value() const { return value_; }
62
63 private:
64 const int64_t value_;
65
67};
68
70 public:
73
74 virtual void Materialize(DeoptContext* deopt_context);
75
76 simd128_value_t value() const { return value_; }
77
78 private:
79 const simd128_value_t value_;
80
82};
83
85 public:
88
89 virtual void Materialize(DeoptContext* deopt_context);
90
91 simd128_value_t value() const { return value_; }
92
93 private:
94 const simd128_value_t value_;
95
97};
98
100 public:
103
104 virtual void Materialize(DeoptContext* deopt_context);
105
106 simd128_value_t value() const { return value_; }
107
108 private:
109 const simd128_value_t value_;
110
112};
113
114// Describes a slot that contains a reference to an object that had its
115// allocation removed by AllocationSinking pass.
116// Object itself is described and materialized by DeferredObject.
118 public:
121
122 virtual void Materialize(DeoptContext* deopt_context);
123
124 intptr_t index() const { return index_; }
125
126 private:
127 const intptr_t index_;
128
130};
131
133 public:
135 intptr_t deopt_id,
138 : DeferredSlot(slot, next), index_(index), deopt_id_(deopt_id) {}
139
140 virtual void Materialize(DeoptContext* deopt_context);
141
142 intptr_t index() const { return index_; }
143
144 private:
145 const intptr_t index_;
146 const intptr_t deopt_id_;
147
149};
150
152 public:
155
156 virtual void Materialize(DeoptContext* deopt_context);
157
158 intptr_t index() const { return index_; }
159
160 private:
161 const intptr_t index_;
162
164};
165
166class DeferredPp : public DeferredSlot {
167 public:
170
171 virtual void Materialize(DeoptContext* deopt_context);
172
173 intptr_t index() const { return index_; }
174
175 private:
176 const intptr_t index_;
177
179};
180
181// Describes an object which allocation was removed by AllocationSinking pass.
182// Arguments for materialization are stored as a part of expression stack
183// for the bottommost deoptimized frame so that GC could discover them.
184// They will be removed from the stack at the very end of deoptimization.
186 public:
187 DeferredObject(intptr_t field_count, intptr_t* args)
188 : field_count_(field_count),
189 args_(reinterpret_cast<ObjectPtr*>(args)),
190 object_(nullptr) {}
191
192 intptr_t ArgumentCount() const {
193 return kFieldsStartIndex + kFieldEntrySize * field_count_;
194 }
195
197
198 // Fill object with actual field values.
199 void Fill();
200
201 private:
202 enum {
203 kClassIndex = 0,
204
205 // For contexts: number of context variables.
206 // For arrays and typed data objects: number of elements.
207 // For records: shape.
208 // -1 otherwise.
209 kLengthOrShapeIndex,
210
211 kFieldsStartIndex
212 };
213
214 enum {
215 kOffsetIndex = 0,
216 kValueIndex,
217 kFieldEntrySize,
218 };
219
220 // Allocate the object but keep its fields null-initialized. Actual field
221 // values will be filled later by the Fill method. This separation between
222 // allocation and filling is needed because dematerialized objects form
223 // a graph which can contain cycles.
224 void Create();
225
226 ObjectPtr GetArg(intptr_t index) const { return args_[index]; }
227
228 ObjectPtr GetClass() const { return GetArg(kClassIndex); }
229
230 ObjectPtr GetLengthOrShape() const { return GetArg(kLengthOrShapeIndex); }
231
232 ObjectPtr GetFieldOffset(intptr_t index) const {
233 return GetArg(kFieldsStartIndex + kFieldEntrySize * index + kOffsetIndex);
234 }
235
236 ObjectPtr GetValue(intptr_t index) const {
237 return GetArg(kFieldsStartIndex + kFieldEntrySize * index + kValueIndex);
238 }
239
240 // Amount of fields that have to be initialized.
241 const intptr_t field_count_;
242
243 // Pointer to the first materialization argument on the stack.
244 // The first argument is Class of the instance to materialize followed by
245 // Field, value pairs.
246 ObjectPtr* args_;
247
248 // Object materialized from this description.
249 const Object* object_;
250
251 DISALLOW_COPY_AND_ASSIGN(DeferredObject);
252};
253
254} // namespace dart
255
256#endif // RUNTIME_VM_DEFERRED_OBJECTS_H_
DeferredDouble(double value, ObjectPtr *slot, DeferredSlot *next)
virtual void Materialize(DeoptContext *deopt_context)
virtual void Materialize(DeoptContext *deopt_context)
DeferredFloat32x4(simd128_value_t value, ObjectPtr *slot, DeferredSlot *next)
simd128_value_t value() const
simd128_value_t value() const
DeferredFloat64x2(simd128_value_t value, ObjectPtr *slot, DeferredSlot *next)
virtual void Materialize(DeoptContext *deopt_context)
virtual void Materialize(DeoptContext *deopt_context)
simd128_value_t value() const
DeferredInt32x4(simd128_value_t value, ObjectPtr *slot, DeferredSlot *next)
virtual void Materialize(DeoptContext *deopt_context)
DeferredMint(int64_t value, ObjectPtr *slot, DeferredSlot *next)
int64_t value() const
DeferredObjectRef(intptr_t index, ObjectPtr *slot, DeferredSlot *next)
virtual void Materialize(DeoptContext *deopt_context)
intptr_t ArgumentCount() const
DeferredObject(intptr_t field_count, intptr_t *args)
virtual void Materialize(DeoptContext *deopt_context)
DeferredPcMarker(intptr_t index, ObjectPtr *slot, DeferredSlot *next)
DeferredPp(intptr_t index, ObjectPtr *slot, DeferredSlot *next)
virtual void Materialize(DeoptContext *deopt_context)
intptr_t index() const
virtual void Materialize(DeoptContext *deopt_context)
DeferredRetAddr(intptr_t index, intptr_t deopt_id, ObjectPtr *slot, DeferredSlot *next)
virtual void Materialize(DeoptContext *deopt_context)=0
ObjectPtr * slot() const
DeferredSlot * next() const
DeferredSlot(ObjectPtr *slot, DeferredSlot *next)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581