1 | // Copyright (c) 2019, 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_COMPILER_RUNTIME_API_H_ |
6 | #define RUNTIME_VM_COMPILER_RUNTIME_API_H_ |
7 | |
8 | // This header defines the API that compiler can use to interact with the |
9 | // underlying Dart runtime that it is embedded into. |
10 | // |
11 | // Compiler is not allowed to directly interact with any objects - it can only |
12 | // use classes like dart::Object, dart::Code, dart::Function and similar as |
13 | // opaque handles. All interactions should be done through helper methods |
14 | // provided by this header. |
15 | // |
16 | // This header also provides ways to get word sizes, frame layout, field |
17 | // offsets for the target runtime. Note that these can be different from |
18 | // those on the host. Helpers providing access to these values live |
19 | // in compiler::target namespace. |
20 | |
21 | #include "platform/globals.h" |
22 | #include "platform/utils.h" |
23 | #include "vm/allocation.h" |
24 | #include "vm/bitfield.h" |
25 | #include "vm/bss_relocs.h" |
26 | #include "vm/class_id.h" |
27 | #include "vm/code_entry_kind.h" |
28 | #include "vm/constants.h" |
29 | #include "vm/frame_layout.h" |
30 | #include "vm/pointer_tagging.h" |
31 | #include "vm/runtime_entry_list.h" |
32 | #include "vm/token.h" |
33 | |
34 | namespace dart { |
35 | |
36 | // Forward declarations. |
37 | class LocalVariable; |
38 | class Object; |
39 | class RuntimeEntry; |
40 | class Zone; |
41 | |
42 | #define DO(clazz) \ |
43 | class clazz##Layout; \ |
44 | class clazz; |
45 | CLASS_LIST_FOR_HANDLES(DO) |
46 | #undef DO |
47 | |
48 | namespace compiler { |
49 | class Assembler; |
50 | } |
51 | |
52 | namespace compiler { |
53 | |
54 | // Host word sizes. |
55 | // |
56 | // Code in the compiler namespace should not use kWordSize and derived |
57 | // constants directly because the word size on host and target might |
58 | // be different. |
59 | // |
60 | // To prevent this we introduce variables that would shadow these |
61 | // constants and introduce compilation errors when used. |
62 | // |
63 | // target::kWordSize and target::ObjectAlignment give access to |
64 | // word size and object aligment offsets for the target. |
65 | // |
66 | // Similarly kHostWordSize gives access to the host word size. |
67 | class InvalidClass {}; |
68 | extern InvalidClass kWordSize; |
69 | extern InvalidClass kWordSizeLog2; |
70 | extern InvalidClass kBitsPerWord; |
71 | extern InvalidClass kNewObjectAlignmentOffset; |
72 | extern InvalidClass kOldObjectAlignmentOffset; |
73 | extern InvalidClass kNewObjectBitPosition; |
74 | extern InvalidClass kObjectAlignment; |
75 | extern InvalidClass kObjectAlignmentLog2; |
76 | extern InvalidClass kObjectAlignmentMask; |
77 | extern InvalidClass kSmiBits; |
78 | extern InvalidClass kSmiMin; |
79 | extern InvalidClass kSmiMax; |
80 | |
81 | static constexpr intptr_t kHostWordSize = dart::kWordSize; |
82 | static constexpr intptr_t kHostWordSizeLog2 = dart::kWordSizeLog2; |
83 | |
84 | // |
85 | // Object handles. |
86 | // |
87 | |
88 | // Create an empty handle. |
89 | Object& NewZoneHandle(Zone* zone); |
90 | |
91 | // Clone the given handle. |
92 | Object& NewZoneHandle(Zone* zone, const Object&); |
93 | |
94 | // |
95 | // Constant objects. |
96 | // |
97 | |
98 | const Object& NullObject(); |
99 | const Object& SentinelObject(); |
100 | const Bool& TrueObject(); |
101 | const Bool& FalseObject(); |
102 | const Object& EmptyTypeArguments(); |
103 | const Type& DynamicType(); |
104 | const Type& ObjectType(); |
105 | const Type& VoidType(); |
106 | const Type& IntType(); |
107 | const Class& GrowableObjectArrayClass(); |
108 | const Class& MintClass(); |
109 | const Class& DoubleClass(); |
110 | const Array& OneArgArgumentsDescriptor(); |
111 | |
112 | template <typename To, typename From> |
113 | const To& CastHandle(const From& from) { |
114 | return reinterpret_cast<const To&>(from); |
115 | } |
116 | |
117 | // Returns true if [a] and [b] are the same object. |
118 | bool IsSameObject(const Object& a, const Object& b); |
119 | |
120 | // Returns true if [a] and [b] represent the same type (are equal). |
121 | bool IsEqualType(const AbstractType& a, const AbstractType& b); |
122 | |
123 | // Returns true if [type] is the "int" type. |
124 | bool IsIntType(const AbstractType& type); |
125 | |
126 | // Returns true if [type] is the "double" type. |
127 | bool IsDoubleType(const AbstractType& type); |
128 | |
129 | // Returns true if [type] is the "double" type. |
130 | bool IsBoolType(const AbstractType& type); |
131 | |
132 | // Returns true if [type] is the "_Smi" type. |
133 | bool IsSmiType(const AbstractType& type); |
134 | |
135 | // Returns true if the given handle is a zone handle or one of the global |
136 | // cached handles. |
137 | bool IsNotTemporaryScopedHandle(const Object& obj); |
138 | |
139 | // Returns true if [obj] resides in old space. |
140 | bool IsInOldSpace(const Object& obj); |
141 | |
142 | // Returns true if [obj] is not a Field/ICData clone. |
143 | // |
144 | // Used to assert that we are not embedding pointers to cloned objects that are |
145 | // used by background compiler into object pools / code. |
146 | bool IsOriginalObject(const Object& object); |
147 | |
148 | // Clear the given handle. |
149 | void SetToNull(Object* obj); |
150 | |
151 | // Helper functions to upcast handles. |
152 | // |
153 | // Note: compiler code cannot include object.h so it cannot see that Object is |
154 | // a superclass of Code or Function - thus we have to cast these pointers using |
155 | // reinterpret_cast. |
156 | inline const Object& ToObject(const Code& handle) { |
157 | return *reinterpret_cast<const Object*>(&handle); |
158 | } |
159 | |
160 | inline const Object& ToObject(const Function& handle) { |
161 | return *reinterpret_cast<const Object*>(&handle); |
162 | } |
163 | |
164 | // Returns some hash value for the given object. |
165 | // |
166 | // Note: the given hash value does not necessarily match Object.get:hashCode, |
167 | // or canonical hash. |
168 | intptr_t ObjectHash(const Object& obj); |
169 | |
170 | // If the given object represents a Dart integer returns true and sets [value] |
171 | // to the value of the integer. |
172 | bool HasIntegerValue(const dart::Object& obj, int64_t* value); |
173 | |
174 | // Creates a random cookie to be used for masking constants embedded in the |
175 | // generated code. |
176 | int32_t CreateJitCookie(); |
177 | |
178 | // Returns the size in bytes for the given class id. |
179 | word TypedDataElementSizeInBytes(classid_t cid); |
180 | |
181 | // Returns the size in bytes for the given class id. |
182 | word TypedDataMaxNewSpaceElements(classid_t cid); |
183 | |
184 | // Looks up the dart:math's _Random._A field. |
185 | const Field& LookupMathRandomStateFieldOffset(); |
186 | |
187 | // Looks up the dart:convert's _Utf8Decoder._scanFlags field. |
188 | const Field& LookupConvertUtf8DecoderScanFlagsField(); |
189 | |
190 | // Returns the offset in bytes of [field]. |
191 | word LookupFieldOffsetInBytes(const Field& field); |
192 | |
193 | #if defined(TARGET_ARCH_IA32) |
194 | uword SymbolsPredefinedAddress(); |
195 | #endif |
196 | |
197 | typedef void (*RuntimeEntryCallInternal)(const dart::RuntimeEntry*, |
198 | Assembler*, |
199 | intptr_t); |
200 | |
201 | const Code& StubCodeAllocateArray(); |
202 | const Code& StubCodeSubtype2TestCache(); |
203 | const Code& StubCodeSubtype6TestCache(); |
204 | |
205 | class RuntimeEntry : public ValueObject { |
206 | public: |
207 | virtual ~RuntimeEntry() {} |
208 | |
209 | void Call(Assembler* assembler, intptr_t argument_count) const { |
210 | ASSERT(call_ != NULL); |
211 | ASSERT(runtime_entry_ != NULL); |
212 | |
213 | // We call a manually set function pointer which points to the |
214 | // implementation of call for the subclass. We do this instead of just |
215 | // defining Call in this class as a pure virtual method and providing an |
216 | // implementation in the subclass as RuntimeEntry objects are declared as |
217 | // globals which causes problems on Windows. |
218 | // |
219 | // When exit() is called on Windows, global objects start to be destroyed. |
220 | // As part of an object's destruction, the vtable is reset to that of the |
221 | // base class. Since some threads may still be running and accessing these |
222 | // now destroyed globals, an invocation to dart::RuntimeEntry::Call would |
223 | // instead invoke dart::compiler::RuntimeEntry::Call. If |
224 | // dart::compiler::RuntimeEntry::Call were a pure virtual method, _purecall |
225 | // would be invoked to handle the invalid call and attempt to call exit(), |
226 | // causing the process to hang on a lock. |
227 | // |
228 | // By removing the need to rely on a potentially invalid vtable at exit, |
229 | // we should be able to avoid hanging or crashing the process at shutdown, |
230 | // even as global objects start to be destroyed. See issue #35855. |
231 | call_(runtime_entry_, assembler, argument_count); |
232 | } |
233 | |
234 | word OffsetFromThread() const; |
235 | |
236 | protected: |
237 | RuntimeEntry(const dart::RuntimeEntry* runtime_entry, |
238 | RuntimeEntryCallInternal call) |
239 | : runtime_entry_(runtime_entry), call_(call) {} |
240 | |
241 | private: |
242 | const dart::RuntimeEntry* runtime_entry_; |
243 | RuntimeEntryCallInternal call_; |
244 | }; |
245 | |
246 | #define DECLARE_RUNTIME_ENTRY(name) \ |
247 | extern const RuntimeEntry& k##name##RuntimeEntry; |
248 | RUNTIME_ENTRY_LIST(DECLARE_RUNTIME_ENTRY) |
249 | #undef DECLARE_RUNTIME_ENTRY |
250 | |
251 | #define DECLARE_RUNTIME_ENTRY(type, name, ...) \ |
252 | extern const RuntimeEntry& k##name##RuntimeEntry; |
253 | LEAF_RUNTIME_ENTRY_LIST(DECLARE_RUNTIME_ENTRY) |
254 | #undef DECLARE_RUNTIME_ENTRY |
255 | |
256 | // Allocate a string object with the given content in the runtime heap. |
257 | const String& AllocateString(const char* buffer); |
258 | |
259 | DART_NORETURN void BailoutWithBranchOffsetError(); |
260 | |
261 | // compiler::target namespace contains information about the target platform: |
262 | // |
263 | // - word sizes and derived constants |
264 | // - offsets of fields |
265 | // - sizes of structures |
266 | namespace target { |
267 | |
268 | #if defined(TARGET_ARCH_IS_32_BIT) |
269 | typedef int32_t word; |
270 | typedef uint32_t uword; |
271 | static constexpr int kWordSize = 4; |
272 | static constexpr int kWordSizeLog2 = 2; |
273 | #elif defined(TARGET_ARCH_IS_64_BIT) |
274 | typedef int64_t word; |
275 | typedef uint64_t uword; |
276 | static constexpr int kWordSize = 8; |
277 | static constexpr int kWordSizeLog2 = 3; |
278 | #else |
279 | #error "Unsupported architecture" |
280 | #endif |
281 | |
282 | static constexpr word kBitsPerWord = 8 * kWordSize; |
283 | static_assert((1 << kWordSizeLog2) == kWordSize, |
284 | "kWordSizeLog2 should match kWordSize" ); |
285 | |
286 | using ObjectAlignment = dart::ObjectAlignment<kWordSize, kWordSizeLog2>; |
287 | |
288 | constexpr word kWordMax = (static_cast<uword>(1) << (kBitsPerWord - 1)) - 1; |
289 | constexpr word kWordMin = -(static_cast<uword>(1) << (kBitsPerWord - 1)); |
290 | constexpr uword kUwordMax = static_cast<word>(-1); |
291 | |
292 | constexpr int kSmiBits = kBitsPerWord - 2; |
293 | constexpr word kSmiMax = (static_cast<uword>(1) << kSmiBits) - 1; |
294 | constexpr word kSmiMin = -(static_cast<uword>(1) << kSmiBits); |
295 | |
296 | // Information about heap pages. |
297 | extern const word kOldPageSize; |
298 | extern const word kOldPageSizeInWords; |
299 | extern const word kOldPageMask; |
300 | |
301 | static constexpr intptr_t kObjectAlignment = ObjectAlignment::kObjectAlignment; |
302 | static constexpr intptr_t kNumParameterFlagsPerElement = kBitsPerWord / 2; |
303 | static_assert(kNumParameterFlagsPerElement <= kSmiBits, |
304 | "kNumParameterFlagsPerElement should fit inside a Smi" ); |
305 | |
306 | inline intptr_t RoundedAllocationSize(intptr_t size) { |
307 | return Utils::RoundUp(size, kObjectAlignment); |
308 | } |
309 | // Information about frame_layout that compiler should be targeting. |
310 | extern FrameLayout frame_layout; |
311 | |
312 | constexpr intptr_t kIntSpillFactor = sizeof(int64_t) / kWordSize; |
313 | constexpr intptr_t kDoubleSpillFactor = sizeof(double) / kWordSize; |
314 | |
315 | // Returns the FP-relative index where [variable] can be found (assumes |
316 | // [variable] is not captured), in bytes. |
317 | inline int FrameOffsetInBytesForVariable(const LocalVariable* variable) { |
318 | return frame_layout.FrameSlotForVariable(variable) * kWordSize; |
319 | } |
320 | |
321 | // Check whether instance_size is small enough to be encoded in the size tag. |
322 | bool SizeFitsInSizeTag(uword instance_size); |
323 | |
324 | // Encode tag word for a heap allocated object with the given class id and |
325 | // size. |
326 | // |
327 | // Note: even on 64-bit platforms we only use lower 32-bits of the tag word. |
328 | uint32_t MakeTagWordForNewSpaceObject(classid_t cid, uword instance_size); |
329 | |
330 | // |
331 | // Target specific information about objects. |
332 | // |
333 | |
334 | // Returns true if the given object can be represented as a Smi on the target |
335 | // platform. |
336 | bool IsSmi(const dart::Object& a); |
337 | |
338 | // Returns true if the given value can be represented as a Smi on the target |
339 | // platform. |
340 | bool IsSmi(int64_t value); |
341 | |
342 | // Return raw Smi representation of the given object for the target platform. |
343 | word ToRawSmi(const dart::Object& a); |
344 | |
345 | // Return raw Smi representation of the given integer value for the target |
346 | // platform. |
347 | // |
348 | // Note: method assumes that caller has validated that value is representable |
349 | // as a Smi. |
350 | word ToRawSmi(intptr_t value); |
351 | |
352 | word SmiValue(const dart::Object& a); |
353 | |
354 | // If the given object can be loaded from the thread on the target then |
355 | // return true and set offset (if provided) to the offset from the |
356 | // thread pointer to a field that contains the object. |
357 | bool CanLoadFromThread(const dart::Object& object, intptr_t* offset = nullptr); |
358 | |
359 | // On IA32 we can embed raw pointers into generated code. |
360 | #if defined(TARGET_ARCH_IA32) |
361 | // Returns true if the pointer to the given object can be directly embedded |
362 | // into the generated code (because the object is immortal and immovable). |
363 | bool CanEmbedAsRawPointerInGeneratedCode(const dart::Object& obj); |
364 | |
365 | // Returns raw pointer value for the given object. Should only be invoked |
366 | // if CanEmbedAsRawPointerInGeneratedCode returns true. |
367 | word ToRawPointer(const dart::Object& a); |
368 | #endif // defined(TARGET_ARCH_IA32) |
369 | |
370 | bool WillAllocateNewOrRememberedContext(intptr_t num_context_variables); |
371 | |
372 | bool WillAllocateNewOrRememberedArray(intptr_t length); |
373 | |
374 | // |
375 | // Target specific offsets and constants. |
376 | // |
377 | // Currently we use the same names for classes, constants and getters to make |
378 | // migration easier. |
379 | |
380 | class ObjectLayout : public AllStatic { |
381 | public: |
382 | static const word kCardRememberedBit; |
383 | static const word kOldAndNotRememberedBit; |
384 | static const word kOldAndNotMarkedBit; |
385 | static const word kSizeTagPos; |
386 | static const word kSizeTagSize; |
387 | static const word kClassIdTagPos; |
388 | static const word kClassIdTagSize; |
389 | static const word kSizeTagMaxSizeTag; |
390 | static const word kTagBitsSizeTagPos; |
391 | static const word kBarrierOverlapShift; |
392 | |
393 | static bool IsTypedDataClassId(intptr_t cid); |
394 | }; |
395 | |
396 | class AbstractTypeLayout : public AllStatic { |
397 | public: |
398 | static const word kTypeStateFinalizedInstantiated; |
399 | }; |
400 | |
401 | class Object : public AllStatic { |
402 | public: |
403 | // Offset of the tags word. |
404 | static word tags_offset(); |
405 | static word InstanceSize(); |
406 | }; |
407 | |
408 | class ObjectPool : public AllStatic { |
409 | public: |
410 | // Return offset to the element with the given [index] in the object pool. |
411 | static word element_offset(intptr_t index); |
412 | static word InstanceSize(); |
413 | static word NextFieldOffset(); |
414 | }; |
415 | |
416 | class Class : public AllStatic { |
417 | public: |
418 | static word host_type_arguments_field_offset_in_words_offset(); |
419 | |
420 | static word target_type_arguments_field_offset_in_words_offset(); |
421 | |
422 | static word declaration_type_offset(); |
423 | |
424 | static word super_type_offset(); |
425 | |
426 | // The offset of the ObjectLayout::num_type_arguments_ field in bytes. |
427 | static word num_type_arguments_offset(); |
428 | |
429 | // The value used if no type arguments vector is present. |
430 | static const word kNoTypeArguments; |
431 | |
432 | static word InstanceSize(); |
433 | |
434 | static word NextFieldOffset(); |
435 | |
436 | // Return class id of the given class on the target. |
437 | static classid_t GetId(const dart::Class& handle); |
438 | |
439 | // Return instance size for the given class on the target. |
440 | static uword GetInstanceSize(const dart::Class& handle); |
441 | |
442 | // Returns the number of type arguments. |
443 | static intptr_t NumTypeArguments(const dart::Class& klass); |
444 | |
445 | // Whether [klass] has a type arguments vector field. |
446 | static bool HasTypeArgumentsField(const dart::Class& klass); |
447 | |
448 | // Returns the offset (in bytes) of the type arguments vector. |
449 | static intptr_t TypeArgumentsFieldOffset(const dart::Class& klass); |
450 | |
451 | // Whether to trace allocation for this klass. |
452 | static bool TraceAllocation(const dart::Class& klass); |
453 | }; |
454 | |
455 | class Instance : public AllStatic { |
456 | public: |
457 | // Returns the offset to the first field of [RawInstance]. |
458 | static word first_field_offset(); |
459 | static word DataOffsetFor(intptr_t cid); |
460 | static word ElementSizeFor(intptr_t cid); |
461 | static word InstanceSize(); |
462 | static word NextFieldOffset(); |
463 | }; |
464 | |
465 | class Function : public AllStatic { |
466 | public: |
467 | static word code_offset(); |
468 | static word entry_point_offset(CodeEntryKind kind = CodeEntryKind::kNormal); |
469 | static word usage_counter_offset(); |
470 | static word InstanceSize(); |
471 | static word NextFieldOffset(); |
472 | }; |
473 | |
474 | class CallSiteData : public AllStatic { |
475 | public: |
476 | static word arguments_descriptor_offset(); |
477 | }; |
478 | |
479 | class ICData : public AllStatic { |
480 | public: |
481 | static word owner_offset(); |
482 | static word entries_offset(); |
483 | static word receivers_static_type_offset(); |
484 | static word state_bits_offset(); |
485 | |
486 | static word CodeIndexFor(word num_args); |
487 | static word CountIndexFor(word num_args); |
488 | static word TargetIndexFor(word num_args); |
489 | static word ExactnessIndexFor(word num_args); |
490 | static word TestEntryLengthFor(word num_args, bool exactness_check); |
491 | static word EntryPointIndexFor(word num_args); |
492 | static word NumArgsTestedShift(); |
493 | static word NumArgsTestedMask(); |
494 | static word InstanceSize(); |
495 | static word NextFieldOffset(); |
496 | }; |
497 | |
498 | class MegamorphicCache : public AllStatic { |
499 | public: |
500 | static const word kSpreadFactor; |
501 | static word mask_offset(); |
502 | static word buckets_offset(); |
503 | static word InstanceSize(); |
504 | static word NextFieldOffset(); |
505 | }; |
506 | |
507 | class SingleTargetCache : public AllStatic { |
508 | public: |
509 | static word lower_limit_offset(); |
510 | static word upper_limit_offset(); |
511 | static word entry_point_offset(); |
512 | static word target_offset(); |
513 | static word InstanceSize(); |
514 | static word NextFieldOffset(); |
515 | }; |
516 | |
517 | class Array : public AllStatic { |
518 | public: |
519 | static word (); |
520 | static word tags_offset(); |
521 | static word data_offset(); |
522 | static word type_arguments_offset(); |
523 | static word length_offset(); |
524 | static word element_offset(intptr_t index); |
525 | static word InstanceSize(); |
526 | static word NextFieldOffset(); |
527 | |
528 | static const word kMaxElements; |
529 | static const word kMaxNewSpaceElements; |
530 | }; |
531 | |
532 | class GrowableObjectArray : public AllStatic { |
533 | public: |
534 | static word data_offset(); |
535 | static word type_arguments_offset(); |
536 | static word length_offset(); |
537 | static word InstanceSize(); |
538 | static word NextFieldOffset(); |
539 | }; |
540 | |
541 | class PointerBase : public AllStatic { |
542 | public: |
543 | static word data_field_offset(); |
544 | }; |
545 | |
546 | class TypedDataBase : public PointerBase { |
547 | public: |
548 | static word length_offset(); |
549 | static word InstanceSize(); |
550 | static word NextFieldOffset(); |
551 | }; |
552 | |
553 | class TypedData : public AllStatic { |
554 | public: |
555 | static word data_offset(); |
556 | static word InstanceSize(); |
557 | static word NextFieldOffset(); |
558 | }; |
559 | |
560 | class ExternalTypedData : public AllStatic { |
561 | public: |
562 | static word data_offset(); |
563 | static word InstanceSize(); |
564 | static word NextFieldOffset(); |
565 | }; |
566 | |
567 | class TypedDataView : public AllStatic { |
568 | public: |
569 | static word offset_in_bytes_offset(); |
570 | static word data_offset(); |
571 | static word InstanceSize(); |
572 | static word NextFieldOffset(); |
573 | }; |
574 | |
575 | class LinkedHashMap : public AllStatic { |
576 | public: |
577 | static word index_offset(); |
578 | static word data_offset(); |
579 | static word hash_mask_offset(); |
580 | static word used_data_offset(); |
581 | static word deleted_keys_offset(); |
582 | static word type_arguments_offset(); |
583 | static word InstanceSize(); |
584 | static word NextFieldOffset(); |
585 | }; |
586 | |
587 | class FutureOr : public AllStatic { |
588 | public: |
589 | static word type_arguments_offset(); |
590 | static word InstanceSize(); |
591 | static word NextFieldOffset(); |
592 | }; |
593 | |
594 | class ArgumentsDescriptor : public AllStatic { |
595 | public: |
596 | static word first_named_entry_offset(); |
597 | static word named_entry_size(); |
598 | static word position_offset(); |
599 | static word name_offset(); |
600 | static word count_offset(); |
601 | static word size_offset(); |
602 | static word type_args_len_offset(); |
603 | static word positional_count_offset(); |
604 | }; |
605 | |
606 | class LocalHandle : public AllStatic { |
607 | public: |
608 | static word raw_offset(); |
609 | }; |
610 | |
611 | class Pointer : public PointerBase { |
612 | public: |
613 | static word type_arguments_offset(); |
614 | static word InstanceSize(); |
615 | static word NextFieldOffset(); |
616 | }; |
617 | |
618 | class AbstractType : public AllStatic { |
619 | public: |
620 | static word type_test_stub_entry_point_offset(); |
621 | }; |
622 | |
623 | class Type : public AllStatic { |
624 | public: |
625 | static word hash_offset(); |
626 | static word type_state_offset(); |
627 | static word arguments_offset(); |
628 | static word signature_offset(); |
629 | static word type_class_id_offset(); |
630 | static word nullability_offset(); |
631 | static word InstanceSize(); |
632 | static word NextFieldOffset(); |
633 | }; |
634 | |
635 | class TypeRef : public AllStatic { |
636 | public: |
637 | static word type_offset(); |
638 | static word InstanceSize(); |
639 | static word NextFieldOffset(); |
640 | }; |
641 | |
642 | class Nullability : public AllStatic { |
643 | public: |
644 | static const int8_t kNullable; |
645 | static const int8_t kNonNullable; |
646 | static const int8_t kLegacy; |
647 | }; |
648 | |
649 | class Double : public AllStatic { |
650 | public: |
651 | static word value_offset(); |
652 | static word InstanceSize(); |
653 | static word NextFieldOffset(); |
654 | }; |
655 | |
656 | class Mint : public AllStatic { |
657 | public: |
658 | static word value_offset(); |
659 | static word InstanceSize(); |
660 | static word NextFieldOffset(); |
661 | }; |
662 | |
663 | class String : public AllStatic { |
664 | public: |
665 | static const word kHashBits; |
666 | static const word kMaxElements; |
667 | static word hash_offset(); |
668 | static word length_offset(); |
669 | static word InstanceSize(); |
670 | static word NextFieldOffset(); |
671 | }; |
672 | |
673 | class OneByteString : public AllStatic { |
674 | public: |
675 | static word data_offset(); |
676 | static word InstanceSize(); |
677 | static word NextFieldOffset(); |
678 | }; |
679 | |
680 | class TwoByteString : public AllStatic { |
681 | public: |
682 | static word data_offset(); |
683 | static word InstanceSize(); |
684 | static word NextFieldOffset(); |
685 | }; |
686 | |
687 | class ExternalOneByteString : public AllStatic { |
688 | public: |
689 | static word external_data_offset(); |
690 | static word InstanceSize(); |
691 | static word NextFieldOffset(); |
692 | }; |
693 | |
694 | class ExternalTwoByteString : public AllStatic { |
695 | public: |
696 | static word external_data_offset(); |
697 | static word InstanceSize(); |
698 | static word NextFieldOffset(); |
699 | }; |
700 | |
701 | class Int32x4 : public AllStatic { |
702 | public: |
703 | static word InstanceSize(); |
704 | static word NextFieldOffset(); |
705 | }; |
706 | |
707 | class Float32x4 : public AllStatic { |
708 | public: |
709 | static word value_offset(); |
710 | static word InstanceSize(); |
711 | static word NextFieldOffset(); |
712 | }; |
713 | |
714 | class Float64x2 : public AllStatic { |
715 | public: |
716 | static word value_offset(); |
717 | static word InstanceSize(); |
718 | static word NextFieldOffset(); |
719 | }; |
720 | |
721 | class DynamicLibrary : public AllStatic { |
722 | public: |
723 | static word InstanceSize(); |
724 | static word NextFieldOffset(); |
725 | }; |
726 | |
727 | class PatchClass : public AllStatic { |
728 | public: |
729 | static word InstanceSize(); |
730 | static word NextFieldOffset(); |
731 | }; |
732 | |
733 | class SignatureData : public AllStatic { |
734 | public: |
735 | static word InstanceSize(); |
736 | static word NextFieldOffset(); |
737 | }; |
738 | |
739 | class RedirectionData : public AllStatic { |
740 | public: |
741 | static word InstanceSize(); |
742 | static word NextFieldOffset(); |
743 | }; |
744 | |
745 | class FfiTrampolineData : public AllStatic { |
746 | public: |
747 | static word InstanceSize(); |
748 | static word NextFieldOffset(); |
749 | }; |
750 | |
751 | class Script : public AllStatic { |
752 | public: |
753 | static word InstanceSize(); |
754 | static word NextFieldOffset(); |
755 | }; |
756 | |
757 | class Library : public AllStatic { |
758 | public: |
759 | static word InstanceSize(); |
760 | static word NextFieldOffset(); |
761 | }; |
762 | |
763 | class Namespace : public AllStatic { |
764 | public: |
765 | static word InstanceSize(); |
766 | static word NextFieldOffset(); |
767 | }; |
768 | |
769 | class KernelProgramInfo : public AllStatic { |
770 | public: |
771 | static word InstanceSize(); |
772 | static word NextFieldOffset(); |
773 | }; |
774 | |
775 | class Bytecode : public AllStatic { |
776 | public: |
777 | static word InstanceSize(); |
778 | static word NextFieldOffset(); |
779 | }; |
780 | |
781 | class PcDescriptors : public AllStatic { |
782 | public: |
783 | static word InstanceSize(); |
784 | static word NextFieldOffset(); |
785 | }; |
786 | |
787 | class CodeSourceMap : public AllStatic { |
788 | public: |
789 | static word InstanceSize(); |
790 | static word NextFieldOffset(); |
791 | }; |
792 | |
793 | class CompressedStackMaps : public AllStatic { |
794 | public: |
795 | static word (); |
796 | static word InstanceSize(); |
797 | static word NextFieldOffset(); |
798 | }; |
799 | |
800 | class LocalVarDescriptors : public AllStatic { |
801 | public: |
802 | static word InstanceSize(); |
803 | static word NextFieldOffset(); |
804 | }; |
805 | |
806 | class ExceptionHandlers : public AllStatic { |
807 | public: |
808 | static word InstanceSize(); |
809 | static word NextFieldOffset(); |
810 | }; |
811 | |
812 | class ContextScope : public AllStatic { |
813 | public: |
814 | static word InstanceSize(); |
815 | static word NextFieldOffset(); |
816 | }; |
817 | |
818 | class ParameterTypeCheck : public AllStatic { |
819 | public: |
820 | static word InstanceSize(); |
821 | static word NextFieldOffset(); |
822 | }; |
823 | |
824 | class UnlinkedCall : public AllStatic { |
825 | public: |
826 | static word InstanceSize(); |
827 | static word NextFieldOffset(); |
828 | }; |
829 | |
830 | class ApiError : public AllStatic { |
831 | public: |
832 | static word InstanceSize(); |
833 | static word NextFieldOffset(); |
834 | }; |
835 | |
836 | class LanguageError : public AllStatic { |
837 | public: |
838 | static word InstanceSize(); |
839 | static word NextFieldOffset(); |
840 | }; |
841 | |
842 | class UnhandledException : public AllStatic { |
843 | public: |
844 | static word exception_offset(); |
845 | static word stacktrace_offset(); |
846 | static word InstanceSize(); |
847 | static word NextFieldOffset(); |
848 | }; |
849 | |
850 | class UnwindError : public AllStatic { |
851 | public: |
852 | static word InstanceSize(); |
853 | static word NextFieldOffset(); |
854 | }; |
855 | |
856 | class Bool : public AllStatic { |
857 | public: |
858 | static word InstanceSize(); |
859 | static word NextFieldOffset(); |
860 | }; |
861 | |
862 | class TypeParameter : public AllStatic { |
863 | public: |
864 | static word InstanceSize(); |
865 | static word NextFieldOffset(); |
866 | }; |
867 | |
868 | class LibraryPrefix : public AllStatic { |
869 | public: |
870 | static word InstanceSize(); |
871 | static word NextFieldOffset(); |
872 | }; |
873 | |
874 | class Capability : public AllStatic { |
875 | public: |
876 | static word InstanceSize(); |
877 | static word NextFieldOffset(); |
878 | }; |
879 | |
880 | class ReceivePort : public AllStatic { |
881 | public: |
882 | static word InstanceSize(); |
883 | static word NextFieldOffset(); |
884 | }; |
885 | |
886 | class SendPort : public AllStatic { |
887 | public: |
888 | static word InstanceSize(); |
889 | static word NextFieldOffset(); |
890 | }; |
891 | |
892 | class TransferableTypedData : public AllStatic { |
893 | public: |
894 | static word InstanceSize(); |
895 | static word NextFieldOffset(); |
896 | }; |
897 | |
898 | class StackTrace : public AllStatic { |
899 | public: |
900 | static word InstanceSize(); |
901 | static word NextFieldOffset(); |
902 | }; |
903 | |
904 | class Integer : public AllStatic { |
905 | public: |
906 | static word InstanceSize(); |
907 | static word NextFieldOffset(); |
908 | }; |
909 | |
910 | class Smi : public AllStatic { |
911 | public: |
912 | static word InstanceSize(); |
913 | static word NextFieldOffset(); |
914 | }; |
915 | |
916 | class WeakProperty : public AllStatic { |
917 | public: |
918 | static word InstanceSize(); |
919 | static word NextFieldOffset(); |
920 | }; |
921 | |
922 | class MirrorReference : public AllStatic { |
923 | public: |
924 | static word InstanceSize(); |
925 | static word NextFieldOffset(); |
926 | }; |
927 | |
928 | class Number : public AllStatic { |
929 | public: |
930 | static word InstanceSize(); |
931 | static word NextFieldOffset(); |
932 | }; |
933 | |
934 | class TimelineStream : public AllStatic { |
935 | public: |
936 | static word enabled_offset(); |
937 | }; |
938 | |
939 | class VMHandles : public AllStatic { |
940 | public: |
941 | static constexpr intptr_t kOffsetOfRawPtrInHandle = kWordSize; |
942 | }; |
943 | |
944 | class MonomorphicSmiableCall : public AllStatic { |
945 | public: |
946 | static word expected_cid_offset(); |
947 | static word entrypoint_offset(); |
948 | static word target_offset(); |
949 | static word InstanceSize(); |
950 | static word NextFieldOffset(); |
951 | }; |
952 | |
953 | class Thread : public AllStatic { |
954 | public: |
955 | static word api_top_scope_offset(); |
956 | static word exit_through_ffi_offset(); |
957 | static uword exit_through_runtime_call(); |
958 | static uword exit_through_ffi(); |
959 | static word dart_stream_offset(); |
960 | static word async_stack_trace_offset(); |
961 | static word predefined_symbols_address_offset(); |
962 | static word optimize_entry_offset(); |
963 | static word deoptimize_entry_offset(); |
964 | static word megamorphic_call_checked_entry_offset(); |
965 | static word active_exception_offset(); |
966 | static word active_stacktrace_offset(); |
967 | static word resume_pc_offset(); |
968 | static word saved_shadow_call_stack_offset(); |
969 | static word marking_stack_block_offset(); |
970 | static word top_exit_frame_info_offset(); |
971 | static word top_resource_offset(); |
972 | static word global_object_pool_offset(); |
973 | static word object_null_offset(); |
974 | static word bool_true_offset(); |
975 | static word bool_false_offset(); |
976 | static word dispatch_table_array_offset(); |
977 | static word top_offset(); |
978 | static word end_offset(); |
979 | static word isolate_offset(); |
980 | static word field_table_values_offset(); |
981 | static word store_buffer_block_offset(); |
982 | static word call_to_runtime_entry_point_offset(); |
983 | static word write_barrier_mask_offset(); |
984 | static word switchable_call_miss_entry_offset(); |
985 | static word write_barrier_wrappers_thread_offset(Register regno); |
986 | static word array_write_barrier_entry_point_offset(); |
987 | static word allocate_mint_with_fpu_regs_entry_point_offset(); |
988 | static word allocate_mint_without_fpu_regs_entry_point_offset(); |
989 | static word allocate_object_entry_point_offset(); |
990 | static word allocate_object_parameterized_entry_point_offset(); |
991 | static word allocate_object_slow_entry_point_offset(); |
992 | static word slow_type_test_entry_point_offset(); |
993 | static word write_barrier_entry_point_offset(); |
994 | static word vm_tag_offset(); |
995 | static uword vm_tag_compiled_id(); |
996 | |
997 | static word safepoint_state_offset(); |
998 | static uword safepoint_state_unacquired(); |
999 | static uword safepoint_state_acquired(); |
1000 | static intptr_t safepoint_state_inside_bit(); |
1001 | |
1002 | static word execution_state_offset(); |
1003 | static uword vm_execution_state(); |
1004 | static uword native_execution_state(); |
1005 | static uword generated_execution_state(); |
1006 | static word stack_overflow_flags_offset(); |
1007 | static word stack_overflow_shared_stub_entry_point_offset(bool fpu_regs); |
1008 | static word stack_limit_offset(); |
1009 | static word saved_stack_limit_offset(); |
1010 | static word unboxed_int64_runtime_arg_offset(); |
1011 | |
1012 | static word callback_code_offset(); |
1013 | |
1014 | static word AllocateArray_entry_point_offset(); |
1015 | static word write_barrier_code_offset(); |
1016 | static word array_write_barrier_code_offset(); |
1017 | static word fix_callers_target_code_offset(); |
1018 | static word fix_allocation_stub_code_offset(); |
1019 | |
1020 | static word switchable_call_miss_stub_offset(); |
1021 | static word lazy_specialize_type_test_stub_offset(); |
1022 | static word slow_type_test_stub_offset(); |
1023 | static word call_to_runtime_stub_offset(); |
1024 | static word invoke_dart_code_stub_offset(); |
1025 | static word interpret_call_entry_point_offset(); |
1026 | static word invoke_dart_code_from_bytecode_stub_offset(); |
1027 | static word null_error_shared_without_fpu_regs_stub_offset(); |
1028 | static word null_error_shared_with_fpu_regs_stub_offset(); |
1029 | static word null_arg_error_shared_without_fpu_regs_stub_offset(); |
1030 | static word null_arg_error_shared_with_fpu_regs_stub_offset(); |
1031 | static word null_cast_error_shared_without_fpu_regs_stub_offset(); |
1032 | static word null_cast_error_shared_with_fpu_regs_stub_offset(); |
1033 | static word range_error_shared_without_fpu_regs_stub_offset(); |
1034 | static word range_error_shared_with_fpu_regs_stub_offset(); |
1035 | static word stack_overflow_shared_without_fpu_regs_entry_point_offset(); |
1036 | static word stack_overflow_shared_without_fpu_regs_stub_offset(); |
1037 | static word stack_overflow_shared_with_fpu_regs_entry_point_offset(); |
1038 | static word stack_overflow_shared_with_fpu_regs_stub_offset(); |
1039 | static word lazy_deopt_from_return_stub_offset(); |
1040 | static word lazy_deopt_from_throw_stub_offset(); |
1041 | static word allocate_mint_with_fpu_regs_stub_offset(); |
1042 | static word allocate_mint_without_fpu_regs_stub_offset(); |
1043 | static word allocate_object_stub_offset(); |
1044 | static word allocate_object_parameterized_stub_offset(); |
1045 | static word allocate_object_slow_stub_offset(); |
1046 | static word optimize_stub_offset(); |
1047 | static word deoptimize_stub_offset(); |
1048 | static word enter_safepoint_stub_offset(); |
1049 | static word exit_safepoint_stub_offset(); |
1050 | static word call_native_through_safepoint_stub_offset(); |
1051 | static word call_native_through_safepoint_entry_point_offset(); |
1052 | |
1053 | static word bootstrap_native_wrapper_entry_point_offset(); |
1054 | static word no_scope_native_wrapper_entry_point_offset(); |
1055 | static word auto_scope_native_wrapper_entry_point_offset(); |
1056 | |
1057 | #define THREAD_XMM_CONSTANT_LIST(V) \ |
1058 | V(float_not) \ |
1059 | V(float_negate) \ |
1060 | V(float_absolute) \ |
1061 | V(float_zerow) \ |
1062 | V(double_negate) \ |
1063 | V(double_abs) |
1064 | |
1065 | #define DECLARE_CONSTANT_OFFSET_GETTER(name) \ |
1066 | static word name##_address_offset(); |
1067 | THREAD_XMM_CONSTANT_LIST(DECLARE_CONSTANT_OFFSET_GETTER) |
1068 | #undef DECLARE_CONSTANT_OFFSET_GETTER |
1069 | |
1070 | static word OffsetFromThread(const dart::Object& object); |
1071 | static intptr_t OffsetFromThread(const dart::RuntimeEntry* runtime_entry); |
1072 | }; |
1073 | |
1074 | class StoreBufferBlock : public AllStatic { |
1075 | public: |
1076 | static word top_offset(); |
1077 | static word pointers_offset(); |
1078 | static const word kSize; |
1079 | }; |
1080 | |
1081 | class MarkingStackBlock : public AllStatic { |
1082 | public: |
1083 | static word top_offset(); |
1084 | static word pointers_offset(); |
1085 | static const word kSize; |
1086 | }; |
1087 | |
1088 | class ObjectStore : public AllStatic { |
1089 | public: |
1090 | static word double_type_offset(); |
1091 | static word int_type_offset(); |
1092 | static word string_type_offset(); |
1093 | }; |
1094 | |
1095 | class Isolate : public AllStatic { |
1096 | public: |
1097 | static word cached_object_store_offset(); |
1098 | static word default_tag_offset(); |
1099 | static word current_tag_offset(); |
1100 | static word user_tag_offset(); |
1101 | static word cached_class_table_table_offset(); |
1102 | static word shared_class_table_offset(); |
1103 | static word ic_miss_code_offset(); |
1104 | #if !defined(PRODUCT) |
1105 | static word single_step_offset(); |
1106 | #endif // !defined(PRODUCT) |
1107 | }; |
1108 | |
1109 | class SharedClassTable : public AllStatic { |
1110 | public: |
1111 | static word class_heap_stats_table_offset(); |
1112 | }; |
1113 | |
1114 | class ClassTable : public AllStatic { |
1115 | public: |
1116 | #if !defined(PRODUCT) |
1117 | static word ClassOffsetFor(intptr_t cid); |
1118 | static word SharedTableOffsetFor(); |
1119 | static word SizeOffsetFor(intptr_t cid, bool is_new); |
1120 | #endif // !defined(PRODUCT) |
1121 | static const word kSizeOfClassPairLog2; |
1122 | }; |
1123 | |
1124 | class InstructionsSection : public AllStatic { |
1125 | public: |
1126 | static word (); |
1127 | static word (); |
1128 | static word InstanceSize(); |
1129 | static word NextFieldOffset(); |
1130 | }; |
1131 | |
1132 | class Instructions : public AllStatic { |
1133 | public: |
1134 | static const word kMonomorphicEntryOffsetJIT; |
1135 | static const word kPolymorphicEntryOffsetJIT; |
1136 | static const word kMonomorphicEntryOffsetAOT; |
1137 | static const word kPolymorphicEntryOffsetAOT; |
1138 | static word (); |
1139 | static word (); |
1140 | static word InstanceSize(); |
1141 | static word NextFieldOffset(); |
1142 | }; |
1143 | |
1144 | class Code : public AllStatic { |
1145 | public: |
1146 | #if defined(TARGET_ARCH_IA32) |
1147 | static uword EntryPointOf(const dart::Code& code); |
1148 | #endif // defined(TARGET_ARCH_IA32) |
1149 | |
1150 | static word object_pool_offset(); |
1151 | static word entry_point_offset(CodeEntryKind kind = CodeEntryKind::kNormal); |
1152 | static word saved_instructions_offset(); |
1153 | static word owner_offset(); |
1154 | static word InstanceSize(); |
1155 | static word NextFieldOffset(); |
1156 | }; |
1157 | |
1158 | class WeakSerializationReference : public AllStatic { |
1159 | public: |
1160 | static word InstanceSize(); |
1161 | static word NextFieldOffset(); |
1162 | }; |
1163 | |
1164 | class SubtypeTestCache : public AllStatic { |
1165 | public: |
1166 | static word cache_offset(); |
1167 | |
1168 | static const word kTestEntryLength; |
1169 | static const word kInstanceClassIdOrFunction; |
1170 | static const word kInstanceTypeArguments; |
1171 | static const word kInstantiatorTypeArguments; |
1172 | static const word kFunctionTypeArguments; |
1173 | static const word kInstanceParentFunctionTypeArguments; |
1174 | static const word kInstanceDelayedFunctionTypeArguments; |
1175 | static const word kTestResult; |
1176 | static word InstanceSize(); |
1177 | static word NextFieldOffset(); |
1178 | }; |
1179 | |
1180 | class LoadingUnit : public AllStatic { |
1181 | public: |
1182 | static word InstanceSize(); |
1183 | static word NextFieldOffset(); |
1184 | }; |
1185 | |
1186 | class Context : public AllStatic { |
1187 | public: |
1188 | static word (); |
1189 | static word parent_offset(); |
1190 | static word num_variables_offset(); |
1191 | static word variable_offset(word i); |
1192 | static word InstanceSize(word n); |
1193 | static word InstanceSize(); |
1194 | static word NextFieldOffset(); |
1195 | }; |
1196 | |
1197 | class Closure : public AllStatic { |
1198 | public: |
1199 | static word context_offset(); |
1200 | static word delayed_type_arguments_offset(); |
1201 | static word function_offset(); |
1202 | static word function_type_arguments_offset(); |
1203 | static word instantiator_type_arguments_offset(); |
1204 | static word hash_offset(); |
1205 | static word InstanceSize(); |
1206 | static word NextFieldOffset(); |
1207 | }; |
1208 | |
1209 | class ClosureData : public AllStatic { |
1210 | public: |
1211 | static word InstanceSize(); |
1212 | static word NextFieldOffset(); |
1213 | }; |
1214 | |
1215 | class OldPage : public AllStatic { |
1216 | public: |
1217 | static const word kBytesPerCardLog2; |
1218 | |
1219 | static word card_table_offset(); |
1220 | }; |
1221 | |
1222 | class Heap : public AllStatic { |
1223 | public: |
1224 | // Return true if an object with the given instance size is allocatable |
1225 | // in new space on the target. |
1226 | static bool IsAllocatableInNewSpace(intptr_t instance_size); |
1227 | }; |
1228 | |
1229 | class NativeArguments { |
1230 | public: |
1231 | static word thread_offset(); |
1232 | static word argc_tag_offset(); |
1233 | static word argv_offset(); |
1234 | static word retval_offset(); |
1235 | |
1236 | static word StructSize(); |
1237 | }; |
1238 | |
1239 | class NativeEntry { |
1240 | public: |
1241 | static const word kNumCallWrapperArguments; |
1242 | }; |
1243 | |
1244 | class RegExp : public AllStatic { |
1245 | public: |
1246 | static word function_offset(classid_t cid, bool sticky); |
1247 | static word InstanceSize(); |
1248 | static word NextFieldOffset(); |
1249 | }; |
1250 | |
1251 | class UserTag : public AllStatic { |
1252 | public: |
1253 | static word tag_offset(); |
1254 | static word InstanceSize(); |
1255 | static word NextFieldOffset(); |
1256 | }; |
1257 | |
1258 | class Symbols : public AllStatic { |
1259 | public: |
1260 | static const word kNumberOfOneCharCodeSymbols; |
1261 | static const word kNullCharCodeSymbolOffset; |
1262 | }; |
1263 | |
1264 | class Field : public AllStatic { |
1265 | public: |
1266 | static word OffsetOf(const dart::Field& field); |
1267 | |
1268 | static word guarded_cid_offset(); |
1269 | static word guarded_list_length_in_object_offset_offset(); |
1270 | static word guarded_list_length_offset(); |
1271 | static word is_nullable_offset(); |
1272 | static word kind_bits_offset(); |
1273 | static word initializer_function_offset(); |
1274 | static word host_offset_or_field_id_offset(); |
1275 | static word InstanceSize(); |
1276 | static word NextFieldOffset(); |
1277 | }; |
1278 | |
1279 | class TypeArguments : public AllStatic { |
1280 | public: |
1281 | static word instantiations_offset(); |
1282 | static word nullability_offset(); |
1283 | static word type_at_offset(intptr_t i); |
1284 | static word InstanceSize(); |
1285 | static word NextFieldOffset(); |
1286 | }; |
1287 | |
1288 | class FreeListElement : public AllStatic { |
1289 | public: |
1290 | class FakeInstance : public AllStatic { |
1291 | public: |
1292 | static word InstanceSize(); |
1293 | static word NextFieldOffset(); |
1294 | }; |
1295 | }; |
1296 | |
1297 | class ForwardingCorpse : public AllStatic { |
1298 | public: |
1299 | class FakeInstance : public AllStatic { |
1300 | public: |
1301 | static word InstanceSize(); |
1302 | static word NextFieldOffset(); |
1303 | }; |
1304 | }; |
1305 | |
1306 | class FieldTable : public AllStatic { |
1307 | public: |
1308 | static word OffsetOf(const dart::Field& field); |
1309 | }; |
1310 | |
1311 | } // namespace target |
1312 | } // namespace compiler |
1313 | } // namespace dart |
1314 | |
1315 | #endif // RUNTIME_VM_COMPILER_RUNTIME_API_H_ |
1316 | |