17#if !defined(DART_PRECOMPILED_RUNTIME)
26StubCode::StubCodeEntry StubCode::entries_[kNumStubEntries] = {
27#if defined(DART_PRECOMPILED_RUNTIME)
28#define STUB_CODE_DECLARE(name) {nullptr, #name},
30#define STUB_CODE_DECLARE(name) \
31 {nullptr, #name, &compiler::StubCodeCompiler::Generate##name##Stub},
34#undef STUB_CODE_DECLARE
36AcqRelAtomic<bool> StubCode::initialized_ = {
false};
38#if defined(DART_PRECOMPILED_RUNTIME)
50 for (
size_t i = 0; i <
ARRAY_SIZE(entries_); i++) {
53 Generate(entries_[i].
name, &object_pool_builder, entries_[i].generator);
59 for (
size_t i = 0; i <
ARRAY_SIZE(entries_); i++) {
60 entries_[i].code->set_object_pool(object_pool.
ptr());
65#if defined(DART_PRECOMPILER)
75 UntaggedFunction::kRegularFunction,
80 false, owner, TokenPosition::kNoSource);
81 StubCode::UnknownDartCode().set_owner(owner);
82 StubCode::UnknownDartCode().set_exception_handlers(
83 Object::empty_exception_handlers());
84 StubCode::UnknownDartCode().set_pc_descriptors(Object::empty_descriptors());
85 ASSERT(StubCode::UnknownDartCode().IsFunctionCode());
90#undef STUB_CODE_GENERATE
91#undef STUB_CODE_SET_OBJECT_POOL
103 Zone* zone = thread->zone();
106 (stubCodeCompiler.*GenerateStub)();
112 zone, pc_descriptors_list->FinalizePcDescriptors(code.PayloadStart()));
113 code.set_pc_descriptors(descriptors);
116 if (FLAG_support_disassembler && FLAG_disassemble_stubs) {
125 initialized_.
store(
false, std::memory_order_release);
127 for (
size_t i = 0; i <
ARRAY_SIZE(entries_); i++) {
128 entries_[i].code =
nullptr;
134 uword entry = StubCode::InvokeDartCode().EntryPoint();
135 uword size = StubCode::InvokeDartCodeSize();
136 return (pc >= entry) && (pc < (entry + size));
141 uword entry = StubCode::JumpToFrame().EntryPoint();
142 uword size = StubCode::JumpToFrameSize();
143 return (pc >= entry) && (pc < (entry + size));
146#if !defined(DART_PRECOMPILED_RUNTIME)
150 if (unresolved_calls->
length() == 0) {
153 const intptr_t array_length =
155 const auto& static_calls_table =
159 for (intptr_t i = 0; i < unresolved_calls->
length(); i++) {
160 auto& unresolved_call = (*unresolved_calls)[i];
163 kind_type_and_offset =
167 auto view = entries[i];
171 return static_calls_table.ptr();
183 return object_store->allocate_array_stub();
184#if !defined(TARGET_ARCH_IA32)
185 case kGrowableObjectArrayCid:
186 return object_store->allocate_growable_array_stub();
189 return object_store->allocate_context_stub();
190 case kUnhandledExceptionCid:
191 return object_store->allocate_unhandled_exception_stub();
193 return object_store->allocate_mint_stub();
195 return object_store->allocate_double_stub();
197 return object_store->allocate_float32x4_stub();
199 return object_store->allocate_float64x2_stub();
201 return object_store->allocate_int32x4_stub();
203 return object_store->allocate_closure_stub();
205 return object_store->allocate_record_stub();
214 : &object_pool_builder;
216 const auto pool_attachment = FLAG_precompiled_mode
220 auto zone = thread->
zone();
224 if (FLAG_precompiled_mode) {
225 allocate_object_stub = object_store->allocate_object_stub();
226 allocate_object_parametrized_stub =
227 object_store->allocate_object_parametrized_stub();
237 &unresolved_calls, cls, allocate_object_stub,
238 allocate_object_parametrized_stub);
240 const auto& static_calls_table =
242 zone, &unresolved_calls));
246 auto mutator_fun = [&]() {
253 if (!static_calls_table.IsNull()) {
271 if (FLAG_support_disassembler && FLAG_disassemble_stubs) {
282 case kTypedDataInt8ArrayCid:
283 return object_store->allocate_int8_array_stub();
284 case kTypedDataUint8ArrayCid:
285 return object_store->allocate_uint8_array_stub();
286 case kTypedDataUint8ClampedArrayCid:
287 return object_store->allocate_uint8_clamped_array_stub();
288 case kTypedDataInt16ArrayCid:
289 return object_store->allocate_int16_array_stub();
290 case kTypedDataUint16ArrayCid:
291 return object_store->allocate_uint16_array_stub();
292 case kTypedDataInt32ArrayCid:
293 return object_store->allocate_int32_array_stub();
294 case kTypedDataUint32ArrayCid:
295 return object_store->allocate_uint32_array_stub();
296 case kTypedDataInt64ArrayCid:
297 return object_store->allocate_int64_array_stub();
298 case kTypedDataUint64ArrayCid:
299 return object_store->allocate_uint64_array_stub();
300 case kTypedDataFloat32ArrayCid:
301 return object_store->allocate_float32_array_stub();
302 case kTypedDataFloat64ArrayCid:
303 return object_store->allocate_float64_array_stub();
304 case kTypedDataFloat32x4ArrayCid:
305 return object_store->allocate_float32x4_array_stub();
306 case kTypedDataInt32x4ArrayCid:
307 return object_store->allocate_int32x4_array_stub();
308 case kTypedDataFloat64x2ArrayCid:
309 return object_store->allocate_float64x2_array_stub();
317 switch (num_args_tested) {
319 return ZeroArgsUnoptimizedStaticCall();
321 return OneArgUnoptimizedStaticCall();
323 return TwoArgsUnoptimizedStaticCall();
331 for (
size_t i = 0; i <
ARRAY_SIZE(entries_); i++) {
332 if ((entries_[i].code !=
nullptr) && !entries_[i].code->IsNull() &&
333 (entries_[i].code->EntryPoint() == entry_point)) {
334 return entries_[i].name;
340#define MATCH(member, name) \
341 if (object_store->member() != Code::null() && \
342 entry_point == Code::EntryPointOf(object_store->member())) { \
343 return "_iso_stub_" #name "Stub"; \
void store(T arg, std::memory_order order=std::memory_order_release)
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
static constexpr intptr_t encode(CallKind value)
CodePtr allocation_stub() const
void set_allocation_stub(const Code &value) const
ErrorPtr EnsureIsAllocateFinalized(Thread *thread) const
static CodePtr FinalizeCodeAndNotify(const Function &function, FlowGraphCompiler *compiler, compiler::Assembler *assembler, PoolAttachment pool_attachment, bool optimized=false, CodeStatistics *stats=nullptr)
static void NotifyCodeObservers(const Code &code, bool optimized)
@ kSCallTableCodeOrTypeTarget
@ kSCallTableKindAndOffset
void set_static_calls_target_table(const Array &value) const
static CodePtr FinalizeCode(FlowGraphCompiler *compiler, compiler::Assembler *assembler, PoolAttachment pool_attachment, bool optimized, CodeStatistics *stats)
void set_owner(const Object &owner) const
static void DisassembleStub(const char *name, const Code &code)
static FunctionTypePtr New(intptr_t num_parent_type_arguments=0, Nullability nullability=Nullability::kLegacy, Heap::Space space=Heap::kOld)
static FunctionPtr New(const FunctionType &signature, const String &name, UntaggedFunction::Kind kind, bool is_static, bool is_const, bool is_abstract, bool is_external, bool is_native, const Object &owner, TokenPosition token_pos, Heap::Space space=Heap::kOld)
ObjectStore * object_store() const
SafepointRwLock * program_lock()
static IsolateGroup * Current()
void RunWithStoppedMutators(T single_current_mutator, S otherwise, bool use_force_growth_in_otherwise=false)
static ObjectPoolPtr NewFromBuilder(const compiler::ObjectPoolBuilder &builder)
static Object * ReadOnlyHandle()
virtual const char * ToCString() const
static ClassPtr void_class()
static Object & ZoneHandle()
static Precompiler * Instance()
compiler::ObjectPoolBuilder * global_object_pool_builder()
static SmiPtr New(intptr_t value)
static CodePtr GetAllocationStubForClass(const Class &cls)
static const Code & UnoptimizedStaticCallEntry(intptr_t num_args_tested)
static CodePtr GetAllocationStubForTypedData(classid_t class_id)
static const char * NameOfStub(uword entry_point)
static bool HasBeenInitialized()
static CodePtr Generate(const char *name, compiler::ObjectPoolBuilder *object_pool_builder, void(compiler::StubCodeCompiler::*GenerateStub)())
static void InitializationDone()
static bool InInvocationStub(uword pc)
static bool InJumpToFrameStub(uword pc)
static Thread * Current()
IsolateGroup * isolate_group() const
static ArrayPtr BuildStaticCallsTable(Zone *zone, compiler::UnresolvedPcRelativeCalls *unresolved_calls)
void GenerateAllocationStubForClass(UnresolvedPcRelativeCalls *unresolved_calls, const Class &cls, const dart::Code &allocate_object, const dart::Code &allocat_object_parametrized)
const uint8_t uint32_t uint32_t GError ** error
#define DECLARE_FLAG(type, name)
#define MATCH(member, name)
#define OBJECT_STORE_STUB_CODE_LIST(DO)
#define STUB_CODE_DECLARE(name)
#define VM_STUB_CODE_LIST(V)
#define ARRAY_SIZE(array)