Flutter Engine
The Flutter Engine
runtime_api.cc
Go to the documentation of this file.
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
6
8
9#include "vm/object.h"
10
11#if !defined(DART_PRECOMPILED_RUNTIME)
14#include "vm/dart_api_state.h"
15#include "vm/dart_entry.h"
16#include "vm/longjump.h"
17#include "vm/native_arguments.h"
18#include "vm/native_entry.h"
19#include "vm/object_store.h"
20#include "vm/runtime_entry.h"
21#include "vm/symbols.h"
22#include "vm/timeline.h"
23#endif // !defined(DART_PRECOMPILED_RUNTIME)
24
25namespace dart {
26namespace compiler {
27namespace target {
28
30
31bool IsSmi(int64_t v) {
32 return Utils::IsInt(kSmiBits + 1, v);
33}
34
35bool WillAllocateNewOrRememberedObject(intptr_t instance_size) {
37 return dart::IsAllocatableInNewSpace(instance_size);
38}
39
40bool WillAllocateNewOrRememberedContext(intptr_t num_context_variables) {
41 if (!dart::Context::IsValidLength(num_context_variables)) return false;
43 dart::Context::InstanceSize(num_context_variables));
44}
45
47 if (!dart::Array::IsValidLength(length)) return false;
49}
50
51} // namespace target
52} // namespace compiler
53} // namespace dart
54
55#if !defined(DART_PRECOMPILED_RUNTIME)
56
57namespace dart {
58namespace compiler {
59
60bool IsSameObject(const Object& a, const Object& b) {
61 if (a.IsInstance() && b.IsInstance()) {
62 return Instance::Cast(a).IsIdenticalTo(Instance::Cast(b));
63 }
64 return a.ptr() == b.ptr();
65}
66
67bool IsEqualType(const AbstractType& a, const AbstractType& b) {
68 return a.Equals(b);
69}
70
72 return type.IsDoubleType();
73}
74
76 return type.IsBoolType();
77}
78
80 return type.IsIntType() || type.IsIntegerImplementationType() ||
81 type.IsSmiType() || type.IsMintType();
82}
83
85 return type.IsSmiType();
86}
87
88#if defined(DEBUG)
89bool IsNotTemporaryScopedHandle(const Object& obj) {
90 return obj.IsNotTemporaryScopedHandle();
91}
92#endif
93
94#define DO(clazz) \
95 bool Is##clazz##Handle(const Object& obj) { \
96 return obj.Is##clazz(); \
97 }
99#undef DO
100
101bool IsInOldSpace(const Object& obj) {
102 return obj.IsSmi() || obj.IsOld();
103}
104
105intptr_t ObjectHash(const Object& obj) {
106 if (obj.IsNull()) {
107 return kNullIdentityHash;
108 }
109 // TypeArguments should be handled before Instance as TypeArguments extends
110 // Instance and TypeArguments::CanonicalizeHash just returns 0.
111 if (obj.IsTypeArguments()) {
112 return TypeArguments::Cast(obj).Hash();
113 }
114 if (obj.IsInstance()) {
115 return Instance::Cast(obj).CanonicalizeHash();
116 }
117 if (obj.IsCode()) {
118 return Code::Cast(obj).Hash();
119 }
120 if (obj.IsFunction()) {
121 return Function::Cast(obj).Hash();
122 }
123 if (obj.IsField()) {
124 return Field::Cast(obj).Hash();
125 }
126 if (obj.IsICData()) {
127 return ICData::Cast(obj).Hash();
128 }
129 // Unlikely.
130 return obj.GetClassId();
131}
132
133const char* ObjectToCString(const Object& obj) {
134 return obj.ToCString();
135}
136
137void SetToNull(Object* obj) {
138 *obj = Object::null();
139}
140
142 return Object::ZoneHandle(zone, Object::null());
143}
144
145Object& NewZoneHandle(Zone* zone, const Object& obj) {
146 return Object::ZoneHandle(zone, obj.ptr());
147}
148
150 return Object::null_object();
151}
152
154 return Object::sentinel();
155}
156
157const Bool& TrueObject() {
158 return dart::Bool::True();
159}
160
162 return dart::Bool::False();
163}
164
166 return Object::empty_type_arguments();
167}
168
170 return dart::Type::dynamic_type();
171}
172
173const Type& ObjectType() {
175}
176
177const Type& VoidType() {
178 return dart::Type::void_type();
179}
180
181const Type& IntType() {
183}
184
186 auto object_store = IsolateGroup::Current()->object_store();
187 return Class::Handle(object_store->growable_object_array_class());
188}
189
190const Class& MintClass() {
191 auto object_store = IsolateGroup::Current()->object_store();
192 return Class::Handle(object_store->mint_class());
193}
194
196 auto object_store = IsolateGroup::Current()->object_store();
197 return Class::Handle(object_store->double_class());
198}
199
201 auto object_store = IsolateGroup::Current()->object_store();
202 return Class::Handle(object_store->float32x4_class());
203}
204
206 auto object_store = IsolateGroup::Current()->object_store();
207 return Class::Handle(object_store->float64x2_class());
208}
209
211 auto object_store = IsolateGroup::Current()->object_store();
212 return Class::Handle(object_store->int32x4_class());
213}
214
216 auto object_store = IsolateGroup::Current()->object_store();
217 return Class::Handle(object_store->closure_class());
218}
219
220const Array& ArgumentsDescriptorBoxed(intptr_t type_args_len,
221 intptr_t num_arguments) {
222 return Array::ZoneHandle(
223 ArgumentsDescriptor::NewBoxed(type_args_len, num_arguments));
224}
225
226bool IsOriginalObject(const Object& object) {
227 if (object.IsICData()) {
228 return ICData::Cast(object).IsOriginal();
229 } else if (object.IsField()) {
230 return Field::Cast(object).IsOriginal();
231 }
232 return true;
233}
234
235const String& AllocateString(const char* buffer) {
237}
238
239bool HasIntegerValue(const dart::Object& object, int64_t* value) {
240 if (object.IsInteger()) {
241 *value = Integer::Cast(object).AsInt64Value();
242 return true;
243 }
244 return false;
245}
246
248 return static_cast<int32_t>(IsolateGroup::Current()->random()->NextUInt32());
249}
250
253}
254
258}
259
261 const auto& math_lib = dart::Library::Handle(dart::Library::MathLibrary());
262 ASSERT(!math_lib.IsNull());
263 const auto& random_class = dart::Class::Handle(
264 math_lib.LookupClassAllowPrivate(dart::Symbols::_Random()));
265 ASSERT(!random_class.IsNull());
266 const auto& state_field = dart::Field::ZoneHandle(
267 random_class.LookupInstanceFieldAllowPrivate(dart::Symbols::_state()));
268 return state_field;
269}
270
272 const auto& convert_lib =
274 ASSERT(!convert_lib.IsNull());
275 const auto& _utf8decoder_class = dart::Class::Handle(
276 convert_lib.LookupClassAllowPrivate(dart::Symbols::_Utf8Decoder()));
277 ASSERT(!_utf8decoder_class.IsNull());
278 const auto& scan_flags_field = dart::Field::ZoneHandle(
279 _utf8decoder_class.LookupInstanceFieldAllowPrivate(
280 dart::Symbols::_scanFlags()));
281 return scan_flags_field;
282}
283
285 return field.TargetOffset();
286}
287
288#if defined(TARGET_ARCH_IA32)
289uword SymbolsPredefinedAddress() {
290 return reinterpret_cast<uword>(dart::Symbols::PredefinedAddress());
291}
292#endif
293
295 return dart::StubCode::AllocateArray();
296}
297
299 return dart::StubCode::Subtype2TestCache();
300}
301
303 return dart::StubCode::Subtype3TestCache();
304}
305
307 return dart::StubCode::Subtype4TestCache();
308}
309
311 return dart::StubCode::Subtype6TestCache();
312}
313
315 return dart::StubCode::Subtype7TestCache();
316}
317
318#define DEFINE_ALIAS(name) \
319 const RuntimeEntry& k##name##RuntimeEntry(dart::k##name##RuntimeEntry);
321#undef DEFINE_ALIAS
322
323#define DEFINE_ALIAS(type, name, ...) \
324 const RuntimeEntry& k##name##RuntimeEntry(dart::k##name##RuntimeEntry);
326#undef DEFINE_ALIAS
327
329 Thread::Current()->long_jump_base()->Jump(1, Object::branch_offset_error());
330}
331
333 return target::Thread::OffsetFromThread(runtime_entry_);
334}
335
337 return runtime_entry_->is_leaf();
338}
339
341 return runtime_entry_->argument_count();
342}
343
344namespace target {
345
349
353}
354
355bool SizeFitsInSizeTag(uword instance_size) {
357 TranslateOffsetInWordsToHost(instance_size));
358}
359
362 TranslateOffsetInWordsToHost(instance_size)) |
369}
370
372 return 0;
373}
374
377
379
382
385
387
389
391
393
396
399
401
403
407
409 dart::UntaggedObject::TagBits::kSizeTagPos;
410
419
422
425
428
431
434
435bool IsTypedDataClassId(intptr_t cid) {
437}
438
440
442 return handle.id();
443}
444
447 return (offset / dart::kWordSize) * kWordSize;
448}
449
450static uword GetInstanceSizeImpl(const dart::Class& handle) {
451 switch (handle.id()) {
452 case kMintCid:
453 return Mint::InstanceSize();
454 case kDoubleCid:
455 return Double::InstanceSize();
456 case kInt32x4Cid:
457 return Int32x4::InstanceSize();
458 case kFloat32x4Cid:
460 case kFloat64x2Cid:
462 case kObjectCid:
463 return Object::InstanceSize();
464 case kInstanceCid:
465 return Instance::InstanceSize();
466 case kGrowableObjectArrayCid:
468 case kClosureCid:
469 return Closure::InstanceSize();
470 case kTypedDataBaseCid:
472 case kMapCid:
473 return Map::InstanceSize();
474 case kSetCid:
475 return Set::InstanceSize();
476 case kUnhandledExceptionCid:
478 case kWeakPropertyCid:
480 case kWeakReferenceCid:
482 case kFinalizerCid:
484 case kFinalizerEntryCid:
486 case kNativeFinalizerCid:
488 case kByteBufferCid:
489 case kByteDataViewCid:
491 case kPointerCid:
492 case kDynamicLibraryCid:
493#define HANDLE_CASE(clazz) case kFfi##clazz##Cid:
495#undef HANDLE_CASE
496#define HANDLE_CASE(clazz) \
497 case kTypedData##clazz##Cid: \
498 case kTypedData##clazz##ViewCid: \
499 case kExternalTypedData##clazz##Cid: \
500 case kUnmodifiableTypedData##clazz##ViewCid:
502#undef HANDLE_CASE
503 return handle.target_instance_size();
504 default:
505 if (handle.id() >= kNumPredefinedCids) {
506 return handle.target_instance_size();
507 }
508 }
509 FATAL("Unsupported class for size translation: %s (id=%" Pd
510 ", kNumPredefinedCids=%" Pd ")\n",
511 handle.ToCString(), handle.id(), kNumPredefinedCids);
512 return -1;
513}
514
516 return Utils::RoundUp(GetInstanceSizeImpl(handle),
518}
519
520// Currently, we only have compressed pointers on the target if we also have
521// compressed pointers on the host, since only 64-bit architectures can have
522// compressed pointers and there is no 32-bit host/64-bit target combination.
523// Thus, we cheat a little here and use the host information about compressed
524// pointers for the target, instead of storing this information in the extracted
525// offsets information.
527 return handle.HasCompressedPointers();
528}
529
530intptr_t Class::NumTypeArguments(const dart::Class& klass) {
531 return klass.NumTypeArguments();
532}
533
535 return klass.host_type_arguments_field_offset() !=
537}
538
541}
542
545}
546
549}
550
553}
554
557 // Elements start at offset 0 of the external data.
558 return 0;
559 }
562 }
563 switch (cid) {
564 case kArrayCid:
565 case kImmutableArrayCid:
566 return Array::data_offset();
567 case kTypeArgumentsCid:
569 case kOneByteStringCid:
571 case kTwoByteStringCid:
573 case kRecordCid:
574 return Record::field_offset(0);
575 default:
577 return Array::data_offset();
578 }
579}
580
586 }
587 switch (cid) {
588 case kArrayCid:
589 case kImmutableArrayCid:
590 return kCompressedWordSize;
591 case kTypeArgumentsCid:
592 return kCompressedWordSize;
593 case kOneByteStringCid:
595 case kTwoByteStringCid:
597 default:
599 return 0;
600 }
601}
602
604 return dart::ICData::CodeIndexFor(num_args);
605}
606
608 return dart::ICData::CountIndexFor(num_args);
609}
610
612 return dart::ICData::TargetIndexFor(num_args);
613}
614
616 return dart::ICData::ExactnessIndexFor(num_args);
617}
618
619word ICData::TestEntryLengthFor(word num_args, bool exactness_check) {
620 return dart::ICData::TestEntryLengthFor(num_args, exactness_check);
621}
622
624 return dart::ICData::EntryPointIndexFor(num_args);
625}
626
629
630// Currently we have two different axes for offset generation:
631//
632// * Target architecture
633// * DART_PRECOMPILED_RUNTIME (i.e, AOT vs. JIT)
634//
635// TODO(dartbug.com/43646): Add DART_PRECOMPILER as another axis.
636
637#define DEFINE_CONSTANT(Class, Name) const word Class::Name = Class##_##Name;
638
639#define DEFINE_ARRAY_SIZEOF(clazz, name, ElementOffset) \
640 word clazz::name() { \
641 return 0; \
642 } \
643 word clazz::name(intptr_t length) { \
644 return RoundedAllocationSize(clazz::ElementOffset(length)); \
645 }
646
647#define DEFINE_PAYLOAD_SIZEOF(clazz, name, header) \
648 word clazz::name() { \
649 return 0; \
650 } \
651 word clazz::name(word payload_size) { \
652 return RoundedAllocationSize(clazz::header() + payload_size); \
653 }
654
655#if defined(TARGET_ARCH_IA32)
656
657#define DEFINE_FIELD(clazz, name) \
658 word clazz::name() { \
659 return clazz##_##name; \
660 }
661
662#define DEFINE_ARRAY(clazz, name) \
663 word clazz::name(intptr_t index) { \
664 return clazz##_elements_start_offset + index * clazz##_element_size; \
665 }
666
667#define DEFINE_SIZEOF(clazz, name, what) \
668 word clazz::name() { \
669 return clazz##_##name; \
670 }
671
672#define DEFINE_RANGE(Class, Getter, Type, First, Last, Filter) \
673 word Class::Getter(Type index) { \
674 return Class##_##Getter[static_cast<intptr_t>(index) - \
675 static_cast<intptr_t>(First)]; \
676 }
677
685
693
694#else
695
696#define DEFINE_JIT_FIELD(clazz, name) \
697 word clazz::name() { \
698 if (FLAG_precompiled_mode) { \
699 FATAL("Use of JIT-only field %s in precompiled mode", \
700 #clazz "::" #name); \
701 } \
702 return clazz##_##name; \
703 }
704
705#define DEFINE_JIT_ARRAY(clazz, name) \
706 word clazz::name(intptr_t index) { \
707 if (FLAG_precompiled_mode) { \
708 FATAL("Use of JIT-only array %s in precompiled mode", \
709 #clazz "::" #name); \
710 } \
711 return clazz##_elements_start_offset + index * clazz##_element_size; \
712 }
713
714#define DEFINE_JIT_SIZEOF(clazz, name, what) \
715 word clazz::name() { \
716 if (FLAG_precompiled_mode) { \
717 FATAL("Use of JIT-only sizeof %s in precompiled mode", \
718 #clazz "::" #name); \
719 } \
720 return clazz##_##name; \
721 }
722
723#define DEFINE_JIT_RANGE(Class, Getter, Type, First, Last, Filter) \
724 word Class::Getter(Type index) { \
725 if (FLAG_precompiled_mode) { \
726 FATAL("Use of JIT-only range %s in precompiled mode", \
727 #Class "::" #Getter); \
728 } \
729 return Class##_##Getter[static_cast<intptr_t>(index) - \
730 static_cast<intptr_t>(First)]; \
731 }
732
740
741#undef DEFINE_JIT_FIELD
742#undef DEFINE_JIT_ARRAY
743#undef DEFINE_JIT_SIZEOF
744#undef DEFINE_JIT_RANGE
745
746#if defined(DART_PRECOMPILER)
747// The following could check FLAG_precompiled_mode for more safety, but that
748// causes problems for defining things like native Slots, where the definition
749// cannot be based on a runtime flag. Instead, we limit the visibility of these
750// definitions using DART_PRECOMPILER.
751
752#define DEFINE_AOT_FIELD(clazz, name) \
753 word clazz::name() { \
754 return AOT_##clazz##_##name; \
755 }
756
757#define DEFINE_AOT_ARRAY(clazz, name) \
758 word clazz::name(intptr_t index) { \
759 return AOT_##clazz##_elements_start_offset + \
760 index * AOT_##clazz##_element_size; \
761 }
762
763#define DEFINE_AOT_SIZEOF(clazz, name, what) \
764 word clazz::name() { \
765 return AOT_##clazz##_##name; \
766 }
767
768#define DEFINE_AOT_RANGE(Class, Getter, Type, First, Last, Filter) \
769 word Class::Getter(Type index) { \
770 return AOT_##Class##_##Getter[static_cast<intptr_t>(index) - \
771 static_cast<intptr_t>(First)]; \
772 }
773#else
774#define DEFINE_AOT_FIELD(clazz, name) \
775 word clazz::name() { \
776 FATAL("Use of AOT-only field %s outside of the precompiler", \
777 #clazz "::" #name); \
778 }
779
780#define DEFINE_AOT_ARRAY(clazz, name) \
781 word clazz::name(intptr_t index) { \
782 FATAL("Use of AOT-only array %s outside of the precompiler", \
783 #clazz "::" #name); \
784 }
785
786#define DEFINE_AOT_SIZEOF(clazz, name, what) \
787 word clazz::name() { \
788 FATAL("Use of AOT-only sizeof %s outside of the precompiler", \
789 #clazz "::" #name); \
790 }
791
792#define DEFINE_AOT_RANGE(Class, Getter, Type, First, Last, Filter) \
793 word Class::Getter(Type index) { \
794 FATAL("Use of AOT-only range %s outside of the precompiler", \
795 #Class "::" #Getter); \
796 }
797#endif // defined(DART_PRECOMPILER)
798
806
807#undef DEFINE_AOT_FIELD
808#undef DEFINE_AOT_ARRAY
809#undef DEFINE_AOT_SIZEOF
810#undef DEFINE_AOT_RANGE
811
812#define DEFINE_FIELD(clazz, name) \
813 word clazz::name() { \
814 return FLAG_precompiled_mode ? AOT_##clazz##_##name : clazz##_##name; \
815 }
816
817#define DEFINE_ARRAY(clazz, name) \
818 word clazz::name(intptr_t index) { \
819 if (FLAG_precompiled_mode) { \
820 return AOT_##clazz##_elements_start_offset + \
821 index * AOT_##clazz##_element_size; \
822 } else { \
823 return clazz##_elements_start_offset + index * clazz##_element_size; \
824 } \
825 }
826
827#define DEFINE_SIZEOF(clazz, name, what) \
828 word clazz::name() { \
829 return FLAG_precompiled_mode ? AOT_##clazz##_##name : clazz##_##name; \
830 }
831
832#define DEFINE_RANGE(Class, Getter, Type, First, Last, Filter) \
833 word Class::Getter(Type index) { \
834 if (FLAG_precompiled_mode) { \
835 return AOT_##Class##_##Getter[static_cast<intptr_t>(index) - \
836 static_cast<intptr_t>(First)]; \
837 } else { \
838 return Class##_##Getter[static_cast<intptr_t>(index) - \
839 static_cast<intptr_t>(First)]; \
840 } \
841 }
842
850
851#endif
852
853#undef DEFINE_FIELD
854#undef DEFINE_ARRAY
855#undef DEFINE_SIZEOF
856#undef DEFINE_RANGE
857#undef DEFINE_PAYLOAD_SIZEOF
858#undef DEFINE_CONSTANT
859
861
863
864// For InstructionsSections and Instructions, we define these by hand, because
865// they depend on flags or #defines.
866
867// Used for InstructionsSection and Instructions methods, since we don't
868// serialize Instructions objects in bare instructions mode, just payloads.
869DART_FORCE_INLINE static bool BareInstructionsPayloads() {
870 return FLAG_precompiled_mode;
871}
872
875 ? 0
877}
878
880 return 0;
881}
882
884 const intptr_t alignment = BareInstructionsPayloads()
887 return Utils::RoundUp(Instructions::HeaderSize() + payload_size, alignment);
888}
889
893}
894
897}
898
901}
902
904 return dart::Thread::ExecutionState::kThreadInGenerated;
905}
906
908 return dart::Thread::ExecutionState::kThreadInNative;
909}
910
912 return dart::Thread::ExecutionState::kThreadInVM;
913}
914
916 return dart::VMTag::kDartTagId;
917}
918
921}
922
925}
926
928 auto host_offset = dart::Thread::OffsetFromThread(object);
929 return object_null_offset() +
930 TranslateOffsetInWords(host_offset -
931 dart::Thread::object_null_offset());
932}
933
934intptr_t Thread::OffsetFromThread(const dart::RuntimeEntry* runtime_entry) {
935 auto host_offset = dart::Thread::OffsetFromThread(runtime_entry);
938 host_offset - dart::Thread::AllocateArray_entry_point_offset());
939}
940
942 intptr_t* offset /* = nullptr */) {
944 if (offset != nullptr) {
946 }
947 return true;
948 }
949 return false;
950}
951
952static_assert(
954 "Expected that size of Smi on HOST is at least as large as on target.");
955
956bool IsSmi(const dart::Object& a) {
957 return a.IsSmi() && IsSmi(dart::Smi::Cast(a).Value());
958}
959
962 return static_cast<compressed_word>(static_cast<intptr_t>(a.ptr()));
963}
964
965word ToRawSmi(intptr_t value) {
967}
968
971 return static_cast<word>(dart::Smi::Cast(a).Value());
972}
973
974bool IsDouble(const dart::Object& a) {
975 return a.IsDouble();
976}
977
978double DoubleValue(const dart::Object& a) {
980 return dart::Double::Cast(a).value();
981}
982
983#if defined(TARGET_ARCH_IA32)
985 static_assert(kHostWordSize == kWordSize,
986 "Can't embed raw pointers to runtime objects when host and "
987 "target word sizes are different");
988 return code.EntryPoint();
989}
990
991bool CanEmbedAsRawPointerInGeneratedCode(const dart::Object& obj) {
992 return obj.IsSmi() || obj.InVMIsolateHeap();
993}
994
995word ToRawPointer(const dart::Object& a) {
996 static_assert(kHostWordSize == kWordSize,
997 "Can't embed raw pointers to runtime objects when host and "
998 "target word sizes are different");
999 return static_cast<word>(a.ptr());
1000}
1001#endif // defined(TARGET_ARCH_IA32)
1002
1004#if !defined(DART_COMPRESSED_POINTERS)
1006#else
1007 // TODO(rmacnak): TranslateOffsetInWords doesn't account for, say, header
1008 // being 1 word and slots being half words.
1009 return dart::RegExp::function_offset(cid, sticky);
1010#endif
1011}
1012
1017
1019
1020const uint8_t Nullability::kNullable =
1021 static_cast<uint8_t>(dart::Nullability::kNullable);
1022const uint8_t Nullability::kNonNullable =
1023 static_cast<uint8_t>(dart::Nullability::kNonNullable);
1024
1025bool Heap::IsAllocatableInNewSpace(intptr_t instance_size) {
1026 return dart::IsAllocatableInNewSpace(instance_size);
1027}
1028
1030 return field.TargetOffset();
1031}
1032
1036}
1037
1039 return 0;
1040}
1041
1043 return 0;
1044}
1045
1048}
1049
1050intptr_t Array::index_at_offset(intptr_t offset_in_bytes) {
1052 TranslateOffsetInWordsToHost(offset_in_bytes));
1053}
1054
1055intptr_t Record::field_index_at_offset(intptr_t offset_in_bytes) {
1057 TranslateOffsetInWordsToHost(offset_in_bytes));
1058}
1059
1061 return RoundedAllocationSize(String::InstanceSize() + payload_size);
1062}
1063
1065 return 0;
1066}
1067
1070}
1071
1073 return 0;
1074}
1075
1078}
1079
1081 const dart::AbstractType& type) {
1082 if (field.is_static() || field.is_late()) {
1083 return;
1084 }
1085
1086 if (type.IsNullable()) {
1087 return;
1088 }
1089
1091 if (type.IsDoubleType()) {
1092 cid = kDoubleCid;
1093 } else if (type.IsFloat32x4Type()) {
1095 cid = kFloat32x4Cid;
1096 }
1097 } else if (type.IsFloat64x2Type()) {
1099 cid = kFloat64x2Cid;
1100 }
1101 }
1102
1103 if (cid != kIllegalCid) {
1104 field.set_guarded_cid(cid);
1105 field.set_is_nullable(false);
1106 field.set_is_unboxed(true);
1110 }
1111}
1112
1113} // namespace target
1114} // namespace compiler
1115} // namespace dart
1116
1117#else
1118
1119namespace dart {
1120namespace compiler {
1121namespace target {
1122
1123const word Array::kMaxElements = Array_kMaxElements;
1124const word Context::kMaxElements = Context_kMaxElements;
1125const word Record::kMaxElements = Record_kMaxElements;
1126
1127const word RecordShape::kNumFieldsMask = RecordShape_kNumFieldsMask;
1128const word RecordShape::kMaxNumFields = RecordShape_kMaxNumFields;
1130 RecordShape_kFieldNamesIndexShift;
1131const word RecordShape::kFieldNamesIndexMask = RecordShape_kFieldNamesIndexMask;
1132const word RecordShape::kMaxFieldNamesIndex = RecordShape_kMaxFieldNamesIndex;
1133
1134} // namespace target
1135} // namespace compiler
1136} // namespace dart
1137
1138#endif // !defined(DART_PRECOMPILED_RUNTIME)
#define RELEASE_ASSERT(cond)
Definition: assert.h:327
GLenum type
#define CLASS_LIST_FOR_HANDLES(V)
Definition: class_id.h:193
#define CLASS_LIST_FFI_TYPE_MARKER(V)
Definition: class_id.h:165
#define CLASS_LIST_TYPED_DATA(V)
Definition: class_id.h:137
static ArrayPtr NewBoxed(intptr_t type_args_len, intptr_t num_arguments, const Array &optional_arguments_names, Heap::Space space=Heap::kOld)
Definition: dart_entry.h:83
static intptr_t index_at_offset(intptr_t offset_in_bytes)
Definition: object.h:10842
static constexpr bool UseCardMarkingForAllocation(const intptr_t array_length)
Definition: object.h:10818
static constexpr bool IsValidLength(intptr_t len)
Definition: object.h:10932
static constexpr uword encode(ClassIdTagType value)
Definition: bitfield.h:165
static const Bool & False()
Definition: object.h:10799
static const Bool & True()
Definition: object.h:10797
bool TraceAllocation(IsolateGroup *isolate_group) const
Definition: object.cc:4434
intptr_t target_type_arguments_field_offset() const
Definition: object.h:1384
intptr_t id() const
Definition: object.h:1233
intptr_t target_instance_size() const
Definition: object.h:1147
intptr_t NumTypeArguments() const
Definition: object.cc:3640
intptr_t host_type_arguments_field_offset() const
Definition: object.h:1375
bool HasCompressedPointers() const
Definition: object.cc:2946
static constexpr intptr_t kNoTypeArguments
Definition: object.h:1374
static uword EntryPointOf(const CodePtr code)
Definition: object.h:6865
static bool IsValidLength(intptr_t len)
Definition: object.h:7444
static intptr_t InstanceSize()
Definition: object.h:7448
static intptr_t FieldOffsetFor(intptr_t field_id)
Definition: field_table.cc:51
void set_is_unboxed(bool b) const
Definition: object.h:4720
@ kUnknownLengthOffset
Definition: object.h:4727
@ kNoFixedLength
Definition: object.h:4729
intptr_t TargetOffset() const
Definition: object.h:13246
bool is_late() const
Definition: object.h:4444
bool is_static() const
Definition: object.h:4440
void set_guarded_cid(intptr_t cid) const
Definition: object.h:4660
void set_guarded_list_length_in_object_offset(intptr_t offset) const
Definition: object.h:4688
intptr_t field_id() const
Definition: object.h:13284
void set_is_nullable(bool val) const
Definition: object.h:4753
void set_guarded_list_length(intptr_t list_length) const
Definition: object.h:4678
static bool SupportsUnboxedSimd128()
@ kOld
Definition: heap.h:39
static intptr_t ExactnessIndexFor(intptr_t num_args)
Definition: object.h:2755
static intptr_t CodeIndexFor(intptr_t num_args)
Definition: object.h:2753
static intptr_t TargetIndexFor(intptr_t num_args)
Definition: object.h:2752
static intptr_t CountIndexFor(intptr_t num_args)
Definition: object.h:2749
static intptr_t TestEntryLengthFor(intptr_t num_args, bool tracking_exactness)
Definition: object.cc:16563
static intptr_t EntryPointIndexFor(intptr_t num_args)
Definition: object.h:2750
static intptr_t NextFieldOffset()
Definition: object.h:8355
static intptr_t NativeFieldsOffset()
Definition: object.h:8357
Random * random()
Definition: isolate.h:411
ObjectStore * object_store() const
Definition: isolate.h:510
static IsolateGroup * Current()
Definition: isolate.h:539
static LibraryPtr ConvertLibrary()
Definition: object.cc:14783
static LibraryPtr MathLibrary()
Definition: object.cc:14811
DART_NORETURN void Jump(int value, const Error &error)
Definition: longjump.cc:22
static constexpr intptr_t kSpreadFactor
Definition: object.h:7600
static ObjectPtr null()
Definition: object.h:433
intptr_t GetClassId() const
Definition: object.h:341
ObjectPtr ptr() const
Definition: object.h:332
bool InVMIsolateHeap() const
Definition: object.h:395
static bool ShouldHaveImmutabilityBitSet(classid_t class_id)
Definition: object.cc:2628
bool IsOld() const
Definition: object.h:391
virtual const char * ToCString() const
Definition: object.h:366
bool IsNull() const
Definition: object.h:363
static Object & Handle()
Definition: object.h:407
static Object & ZoneHandle()
Definition: object.h:419
static constexpr intptr_t kHashBits
Definition: object.h:323
static constexpr intptr_t kBytesPerElement
Definition: object.h:10542
uint32_t NextUInt32()
Definition: random.cc:73
static intptr_t field_index_at_offset(intptr_t offset_in_bytes)
Definition: object.h:11452
static intptr_t function_offset(intptr_t cid, bool sticky)
Definition: object.h:12815
intptr_t argument_count() const
Definition: runtime_entry.h:53
bool is_leaf() const
Definition: runtime_entry.h:54
static intptr_t RawValue(intptr_t value)
Definition: object.h:10022
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
static constexpr int kNumberOfOneCharCodeSymbols
Definition: symbols.h:601
static constexpr int kNullCharCodeSymbolOffset
Definition: symbols.h:605
static StringPtr * PredefinedAddress()
Definition: symbols.h:772
LongJumpScope * long_jump_base() const
Definition: thread_state.h:47
static uword full_safepoint_state_unacquired()
Definition: thread.h:1060
static intptr_t OffsetFromThread(const Object &object)
Definition: thread.cc:1178
static Thread * Current()
Definition: thread.h:362
@ kExitThroughRuntimeCall
Definition: thread.h:472
@ kExitThroughFfi
Definition: thread.h:469
static bool CanLoadFromThread(const Object &object)
Definition: thread.cc:1154
static uword full_safepoint_state_acquired()
Definition: thread.h:1064
static constexpr intptr_t kBytesPerElement
Definition: object.h:10683
static TypePtr IntType()
static TypePtr ObjectType()
intptr_t ElementSizeInBytes() const
Definition: object.h:11531
static constexpr intptr_t kNullabilityMask
Definition: raw_object.h:2787
static constexpr intptr_t kTypeStateBits
Definition: raw_object.h:2790
static constexpr intptr_t kTypeStateShift
Definition: raw_object.h:2789
static constexpr intptr_t kMaxSizeTagInUnitsOfAlignment
Definition: raw_object.h:199
static constexpr bool SizeFits(intptr_t size)
Definition: raw_object.h:216
static constexpr uword encode(intptr_t size)
Definition: raw_object.h:204
static constexpr intptr_t kIncrementalBarrierMask
Definition: raw_object.h:183
static constexpr intptr_t kGenerationalBarrierMask
Definition: raw_object.h:181
static constexpr intptr_t kBarrierOverlapShift
Definition: raw_object.h:184
static constexpr intptr_t kIsFunctionTypeParameterBit
Definition: raw_object.h:2892
static constexpr intptr_t kTypeClassIdShift
Definition: raw_object.h:2803
static bool IsInt(intptr_t N, T value)
Definition: utils.h:313
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:120
static constexpr bool IsAligned(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:92
Definition: il.h:75
intptr_t argument_count() const
Definition: runtime_api.cc:340
static intptr_t index_at_offset(intptr_t offset_in_bytes)
static const word kMaxElements
Definition: runtime_api.h:594
static bool TraceAllocation(const dart::Class &klass)
Definition: runtime_api.cc:543
static bool HasTypeArgumentsField(const dart::Class &klass)
Definition: runtime_api.cc:534
static intptr_t NumTypeArguments(const dart::Class &klass)
Definition: runtime_api.cc:530
static uword GetInstanceSize(const dart::Class &handle)
Definition: runtime_api.cc:515
static const word kNoTypeArguments
Definition: runtime_api.h:486
static bool HasCompressedPointers(const dart::Class &handle)
Definition: runtime_api.cc:526
static classid_t GetId(const dart::Class &handle)
Definition: runtime_api.cc:441
static intptr_t TypeArgumentsFieldOffset(const dart::Class &klass)
Definition: runtime_api.cc:539
static const word kMaxElements
Definition: runtime_api.h:1462
static word OffsetOf(const dart::Field &field)
static word OffsetOf(const dart::Field &field)
static bool IsAllocatableInNewSpace(intptr_t instance_size)
static word ExactnessIndexFor(word num_args)
Definition: runtime_api.cc:615
static word TestEntryLengthFor(word num_args, bool exactness_check)
Definition: runtime_api.cc:619
static word CodeIndexFor(word num_args)
Definition: runtime_api.cc:603
static word TargetIndexFor(word num_args)
Definition: runtime_api.cc:611
static word CountIndexFor(word num_args)
Definition: runtime_api.cc:607
static word EntryPointIndexFor(word num_args)
Definition: runtime_api.cc:623
static word ElementSizeFor(intptr_t cid)
Definition: runtime_api.cc:581
static word native_fields_array_offset()
Definition: runtime_api.cc:551
static word DataOffsetFor(intptr_t cid)
Definition: runtime_api.cc:555
static const word kNonBarePayloadAlignment
Definition: runtime_api.h:1384
static const uint8_t kNullable
Definition: runtime_api.h:762
static const uint8_t kNonNullable
Definition: runtime_api.h:763
static const word kMaxFieldNamesIndex
Definition: runtime_api.h:613
static const word kFieldNamesIndexShift
Definition: runtime_api.h:611
static const word kFieldNamesIndexMask
Definition: runtime_api.h:612
static word field_offset(intptr_t index)
static const word kMaxElements
Definition: runtime_api.h:625
static intptr_t field_index_at_offset(intptr_t offset_in_bytes)
static word function_offset(classid_t cid, bool sticky)
static const word kHashBits
Definition: runtime_api.h:782
static const word kNullCharCodeSymbolOffset
Definition: runtime_api.h:1533
static const word kNumberOfOneCharCodeSymbols
Definition: runtime_api.h:1532
static word stack_overflow_shared_stub_entry_point_offset(bool fpu_regs)
Definition: runtime_api.cc:890
static word OffsetFromThread(const dart::Object &object)
Definition: runtime_api.cc:927
static uword full_safepoint_state_acquired()
Definition: runtime_api.cc:899
static word AllocateArray_entry_point_offset()
static uword exit_through_runtime_call()
Definition: runtime_api.cc:919
static word stack_overflow_shared_with_fpu_regs_entry_point_offset()
static word stack_overflow_shared_without_fpu_regs_entry_point_offset()
static uword native_execution_state()
Definition: runtime_api.cc:907
static uword generated_execution_state()
Definition: runtime_api.cc:903
static uword full_safepoint_state_unacquired()
Definition: runtime_api.cc:895
static const word kGenerationalBarrierMask
Definition: runtime_api.h:434
static const word kNewOrEvacuationCandidateBit
Definition: runtime_api.h:421
#define UNIMPLEMENTED
#define ASSERT(E)
static bool b
struct MyStruct a[10]
#define FATAL(error)
uint8_t value
uint32_t * target
size_t length
static word TranslateOffsetInWords(word offset)
Definition: runtime_api.cc:445
JIT_OFFSETS_LIST(DEFINE_JIT_FIELD, DEFINE_JIT_ARRAY, DEFINE_JIT_SIZEOF, DEFINE_ARRAY_SIZEOF, DEFINE_PAYLOAD_SIZEOF, DEFINE_JIT_RANGE, DEFINE_CONSTANT) AOT_OFFSETS_LIST(DEFINE_AOT_FIELD
uword MakeTagWordForNewSpaceObject(classid_t cid, uword instance_size)
Definition: runtime_api.cc:360
bool WillAllocateNewOrRememberedContext(intptr_t num_context_variables)
Definition: runtime_api.cc:40
static uword GetInstanceSizeImpl(const dart::Class &handle)
Definition: runtime_api.cc:450
static word TranslateOffsetInWordsToHost(word offset)
Definition: runtime_api.cc:350
void UnboxFieldIfSupported(const dart::Field &field, const dart::AbstractType &type)
bool CanLoadFromThread(const dart::Object &object, intptr_t *offset)
Definition: runtime_api.cc:941
bool WillAllocateNewOrRememberedArray(intptr_t length)
Definition: runtime_api.cc:46
bool IsTypedDataClassId(intptr_t cid)
Definition: runtime_api.cc:435
double DoubleValue(const dart::Object &a)
Definition: runtime_api.cc:978
word ToRawSmi(const dart::Object &a)
Definition: runtime_api.cc:960
static constexpr intptr_t kWordSize
Definition: runtime_api.h:274
bool IsDouble(const dart::Object &a)
Definition: runtime_api.cc:974
static constexpr intptr_t kCompressedWordSize
Definition: runtime_api.h:286
bool IsSmi(int64_t v)
Definition: runtime_api.cc:31
bool SizeFitsInSizeTag(uword instance_size)
Definition: runtime_api.cc:355
constexpr intptr_t kSmiBits
Definition: runtime_api.h:301
bool WillAllocateNewOrRememberedObject(intptr_t instance_size)
Definition: runtime_api.cc:35
word SmiValue(const dart::Object &a)
Definition: runtime_api.cc:969
static DART_FORCE_INLINE bool BareInstructionsPayloads()
Definition: runtime_api.cc:869
const word kPageSizeInWords
Definition: runtime_api.cc:347
intptr_t RoundedAllocationSize(intptr_t size)
Definition: runtime_api.h:333
const Type & ObjectType()
Definition: runtime_api.cc:173
void BailoutWithBranchOffsetError()
Definition: runtime_api.cc:328
const Field & LookupConvertUtf8DecoderScanFlagsField()
Definition: runtime_api.cc:271
const Class & Int32x4Class()
Definition: runtime_api.cc:210
Object & NewZoneHandle(Zone *zone)
Definition: runtime_api.cc:141
static constexpr intptr_t kHostWordSize
Definition: runtime_api.h:90
const Class & Float64x2Class()
Definition: runtime_api.cc:205
bool IsBoolType(const AbstractType &type)
Definition: runtime_api.cc:75
const Type & VoidType()
Definition: runtime_api.cc:177
word LookupFieldOffsetInBytes(const Field &field)
Definition: runtime_api.cc:284
word TypedDataMaxNewSpaceElements(classid_t cid)
Definition: runtime_api.cc:255
const Class & GrowableObjectArrayClass()
Definition: runtime_api.cc:185
const Type & IntType()
Definition: runtime_api.cc:181
const Class & Float32x4Class()
Definition: runtime_api.cc:200
intptr_t ObjectHash(const Object &obj)
Definition: runtime_api.cc:105
word TypedDataElementSizeInBytes(classid_t cid)
Definition: runtime_api.cc:251
bool IsOriginalObject(const Object &object)
Definition: runtime_api.cc:226
int32_t CreateJitCookie()
Definition: runtime_api.cc:247
void SetToNull(Object *obj)
Definition: runtime_api.cc:137
const String & AllocateString(const char *buffer)
Definition: runtime_api.cc:235
const Array & ArgumentsDescriptorBoxed(intptr_t type_args_len, intptr_t num_arguments)
Definition: runtime_api.cc:220
const Code & StubCodeSubtype2TestCache()
Definition: runtime_api.cc:298
const Bool & TrueObject()
Definition: runtime_api.cc:157
bool IsDoubleType(const AbstractType &type)
Definition: runtime_api.cc:71
const Code & StubCodeSubtype6TestCache()
Definition: runtime_api.cc:310
const Code & StubCodeSubtype7TestCache()
Definition: runtime_api.cc:314
const Code & StubCodeSubtype3TestCache()
Definition: runtime_api.cc:302
bool IsInOldSpace(const Object &obj)
Definition: runtime_api.cc:101
const Object & SentinelObject()
Definition: runtime_api.cc:153
bool IsEqualType(const AbstractType &a, const AbstractType &b)
Definition: runtime_api.cc:67
bool IsSubtypeOfInt(const AbstractType &type)
Definition: runtime_api.cc:79
bool IsSameObject(const Object &a, const Object &b)
Definition: runtime_api.cc:60
const Class & ClosureClass()
Definition: runtime_api.cc:215
const Bool & FalseObject()
Definition: runtime_api.cc:161
const Object & NullObject()
Definition: runtime_api.cc:149
const Class & DoubleClass()
Definition: runtime_api.cc:195
const Field & LookupMathRandomStateFieldOffset()
Definition: runtime_api.cc:260
const Object & EmptyTypeArguments()
Definition: runtime_api.cc:165
bool IsSmiType(const AbstractType &type)
Definition: runtime_api.cc:84
const char * ObjectToCString(const Object &obj)
Definition: runtime_api.cc:133
const Code & StubCodeAllocateArray()
Definition: runtime_api.cc:294
const Class & MintClass()
Definition: runtime_api.cc:190
const Code & StubCodeSubtype4TestCache()
Definition: runtime_api.cc:306
bool HasIntegerValue(const dart::Object &object, int64_t *value)
Definition: runtime_api.cc:239
const Type & DynamicType()
Definition: runtime_api.cc:169
Definition: dart_vm.cc:33
static constexpr intptr_t kNullIdentityHash
Definition: object.h:10784
bool IsTypedDataViewClassId(intptr_t index)
Definition: class_id.h:439
bool IsTypedDataClassId(intptr_t index)
Definition: class_id.h:433
const intptr_t kSmiBits
Definition: globals.h:24
static constexpr intptr_t kPageSize
Definition: page.h:27
int32_t classid_t
Definition: globals.h:524
bool IsUnmodifiableTypedDataViewClassId(intptr_t index)
Definition: class_id.h:453
@ kIllegalCid
Definition: class_id.h:214
@ kNumPredefinedCids
Definition: class_id.h:257
@ kByteDataViewCid
Definition: class_id.h:244
@ kByteBufferCid
Definition: class_id.h:247
@ kUnmodifiableByteDataViewCid
Definition: class_id.h:245
intptr_t compressed_word
Definition: globals.h:45
uintptr_t uword
Definition: globals.h:501
intptr_t word
Definition: globals.h:500
bool IsAllocatableInNewSpace(intptr_t size)
Definition: spaces.h:57
const intptr_t cid
static constexpr intptr_t kCompressedWordSize
Definition: globals.h:42
constexpr intptr_t kWordSize
Definition: globals.h:509
static constexpr intptr_t kPageMask
Definition: page.h:29
static constexpr intptr_t kNewAllocatableSize
Definition: spaces.h:54
bool IsExternalTypedDataClassId(intptr_t index)
Definition: class_id.h:447
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
#define Pd
Definition: globals.h:408
#define DEFINE_JIT_SIZEOF(clazz, name, what)
Definition: runtime_api.cc:714
#define DEFINE_ARRAY(clazz, name)
Definition: runtime_api.cc:817
#define DEFINE_CONSTANT(Class, Name)
Definition: runtime_api.cc:637
#define DEFINE_ALIAS(name)
Definition: runtime_api.cc:323
#define DEFINE_AOT_FIELD(clazz, name)
#define DEFINE_FIELD(clazz, name)
Definition: runtime_api.cc:812
#define HANDLE_CASE(clazz)
#define DEFINE_JIT_RANGE(Class, Getter, Type, First, Last, Filter)
Definition: runtime_api.cc:723
#define DO(clazz)
Definition: runtime_api.cc:94
#define DEFINE_JIT_ARRAY(clazz, name)
Definition: runtime_api.cc:705
#define DEFINE_RANGE(Class, Getter, Type, First, Last, Filter)
Definition: runtime_api.cc:832
#define DEFINE_JIT_FIELD(clazz, name)
Definition: runtime_api.cc:696
#define DEFINE_SIZEOF(clazz, name, what)
Definition: runtime_api.cc:827
#define RUNTIME_ENTRY_LIST(V)
#define LEAF_RUNTIME_ENTRY_LIST(V)
#define AOT_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, ARRAY_SIZEOF, PAYLOAD_SIZEOF, RANGE, CONSTANT)
#define COMMON_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, ARRAY_SIZEOF, PAYLOAD_SIZEOF, RANGE, CONSTANT)
SeparatedVector2 offset
static constexpr intptr_t kObjectAlignment