Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
dart::TypeTestingStubGenerator Class Reference

#include <type_testing_stubs.h>

Public Member Functions

 TypeTestingStubGenerator ()
 
CodePtr OptimizedCodeForType (const AbstractType &type)
 

Static Public Member Functions

static CodePtr DefaultCodeForType (const AbstractType &type, bool lazy_specialize=true)
 
static CodePtr SpecializeStubFor (Thread *thread, const AbstractType &type)
 

Detailed Description

Definition at line 42 of file type_testing_stubs.h.

Constructor & Destructor Documentation

◆ TypeTestingStubGenerator()

dart::TypeTestingStubGenerator::TypeTestingStubGenerator ( )

Definition at line 168 of file type_testing_stubs.cc.

169 : object_store_(IsolateGroup::Current()->object_store()) {}
static IsolateGroup * Current()
Definition isolate.h:534

Member Function Documentation

◆ DefaultCodeForType()

CodePtr dart::TypeTestingStubGenerator::DefaultCodeForType ( const AbstractType type,
bool  lazy_specialize = true 
)
static

Definition at line 114 of file type_testing_stubs.cc.

116 {
117 // During bootstrapping we have no access to stubs yet, so we'll just return
118 // `null` and patch these later in `Object::FinishInit()`.
120 ASSERT(type.IsType());
121 const classid_t cid = type.type_class_id();
123 return Code::null();
124 }
125
126 if (type.IsTopTypeForSubtyping()) {
127 return StubCode::TopTypeTypeTest().ptr();
128 }
129 if (type.IsTypeParameter()) {
130 const bool nullable = Instance::NullIsAssignableTo(type);
131 if (nullable) {
132 return StubCode::NullableTypeParameterTypeTest().ptr();
133 } else {
134 return StubCode::TypeParameterTypeTest().ptr();
135 }
136 }
137
138 if (type.IsFunctionType()) {
139 const bool nullable = Instance::NullIsAssignableTo(type);
140 return nullable ? StubCode::DefaultNullableTypeTest().ptr()
141 : StubCode::DefaultTypeTest().ptr();
142 }
143
144 if (type.IsType() || type.IsRecordType()) {
145 const bool should_specialize = !FLAG_precompiled_mode && lazy_specialize;
146 const bool nullable = Instance::NullIsAssignableTo(type);
147 if (should_specialize) {
148 return nullable ? StubCode::LazySpecializeNullableTypeTest().ptr()
149 : StubCode::LazySpecializeTypeTest().ptr();
150 } else {
151 return nullable ? StubCode::DefaultNullableTypeTest().ptr()
152 : StubCode::DefaultTypeTest().ptr();
153 }
154 }
155
156 return StubCode::UnreachableTypeTest().ptr();
157}
static bool NullIsAssignableTo(const AbstractType &other)
Definition object.cc:20715
static ObjectPtr null()
Definition object.h:433
static bool HasBeenInitialized()
Definition stub_code.h:41
#define ASSERT(E)
int32_t classid_t
Definition globals.h:524
@ kVoidCid
Definition class_id.h:254
@ kDynamicCid
Definition class_id.h:253
const intptr_t cid

◆ OptimizedCodeForType()

CodePtr dart::TypeTestingStubGenerator::OptimizedCodeForType ( const AbstractType type)

Definition at line 171 of file type_testing_stubs.cc.

172 {
173#if !defined(TARGET_ARCH_IA32)
175
176 if (type.IsTypeParameter()) {
178 type, /*lazy_specialize=*/false);
179 }
180
181 if (type.IsTopTypeForSubtyping()) {
182 return StubCode::TopTypeTypeTest().ptr();
183 }
184
185 if (type.IsCanonical()) {
186 // When adding any new types that can have specialized TTSes, also update
187 // CollectTypes::VisitObject appropriately.
188 if (type.IsType() || type.IsRecordType()) {
189#if !defined(DART_PRECOMPILED_RUNTIME)
190 const Code& code =
191 Code::Handle(TypeTestingStubGenerator::BuildCodeForType(type));
192 if (!code.IsNull()) {
193 return code.ptr();
194 }
195 const Error& error = Error::Handle(Thread::Current()->StealStickyError());
196 if (!error.IsNull()) {
197 if (error.ptr() == Object::out_of_memory_error().ptr()) {
199 } else {
200 UNREACHABLE();
201 }
202 }
203
204 // Fall back to default.
205#else
206 // In the precompiled runtime we cannot lazily create new optimized type
207 // testing stubs, so if we cannot find one, we'll just return the default
208 // one.
209#endif // !defined(DART_PRECOMPILED_RUNTIME)
210 }
211 }
212#endif // !defined(TARGET_ARCH_IA32)
214 type, /*lazy_specialize=*/false);
215}
#define UNREACHABLE()
Definition assert.h:248
static DART_NORETURN void ThrowOOM()
static Object & Handle()
Definition object.h:407
static Thread * Current()
Definition thread.h:361
static CodePtr DefaultCodeForType(const AbstractType &type, bool lazy_specialize=true)
const uint8_t uint32_t uint32_t GError ** error

◆ SpecializeStubFor()

CodePtr dart::TypeTestingStubGenerator::SpecializeStubFor ( Thread thread,
const AbstractType type 
)
static

Definition at line 160 of file type_testing_stubs.cc.

161 {
162 HierarchyInfo hi(thread);
163 TypeTestingStubGenerator generator;
164 return generator.OptimizedCodeForType(type);
165}

The documentation for this class was generated from the following files: