20#if !defined(DART_PRECOMPILED_RUNTIME)
29ArrayPtr ArgumentsDescriptor::cached_args_descriptors_[kCachedDescriptorCount];
32 const Array& arguments) {
34 const int kTypeArgsLen = 0;
48#if defined(USING_SAFE_STACK)
51 saved_safestack_limit_ = OSThread::GetCurrentSafestackPointer();
52 thread->set_saved_safestack_limit(saved_safestack_limit_);
57#if defined(USING_SAFE_STACK)
58 thread()->set_saved_safestack_limit(saved_safestack_limit_);
67#if defined(USING_SAFE_STACK)
68 uword saved_safestack_limit_ = 0;
75extern "C" typedef uword (*invokestub)(
76#if defined(DART_PRECOMPILED_RUNTIME)
81 uword arguments_descriptor,
86 const Array& arguments,
87 const Array& arguments_descriptor) {
88#if defined(DART_PRECOMPILER)
89 if (FLAG_precompiled_mode) {
90 FATAL(
"Should never invoke Dart code during AOT compilation");
98#if !defined(DART_PRECOMPILED_RUNTIME)
103 return Error::Cast(
result).ptr();
112 const uword stub = StubCode::InvokeDartCode().EntryPoint();
113#if defined(USING_SIMULATOR)
115 static_cast<intptr_t
>(stub),
116#
if defined(DART_PRECOMPILED_RUNTIME)
117 static_cast<intptr_t
>(
function.entry_point()),
119 static_cast<intptr_t
>(
function.CurrentCode()),
121 static_cast<intptr_t
>(arguments_descriptor.
ptr()),
122 static_cast<intptr_t
>(arguments.
ptr()),
123 reinterpret_cast<intptr_t
>(thread)));
126#if defined(DART_PRECOMPILED_RUNTIME)
131 static_cast<uword>(arguments_descriptor.
ptr()),
132 static_cast<uword>(arguments.
ptr()), thread));
139 const Array& arguments_descriptor,
140 const Array& arguments,
142#if defined(DART_PRECOMPILER)
143 if (FLAG_precompiled_mode) {
144 FATAL(
"Should never invoke Dart code during AOT compilation");
151 DartEntryScope dart_entry_scope(thread);
153 const uword stub = StubCode::InvokeDartCode().EntryPoint();
154#if defined(DART_PRECOMPILED_RUNTIME)
155#if defined(USING_SIMULATOR)
157 static_cast<intptr_t
>(stub),
static_cast<intptr_t
>(
code.EntryPoint()),
158 static_cast<intptr_t
>(arguments_descriptor.
ptr()),
159 static_cast<intptr_t
>(arguments.
ptr()),
160 reinterpret_cast<intptr_t
>(thread)));
162 return static_cast<ObjectPtr
>((
reinterpret_cast<invokestub>(stub))(
163 code.EntryPoint(), arguments_descriptor.
ptr(), arguments.
ptr(), thread));
166#if defined(USING_SIMULATOR)
168 static_cast<intptr_t
>(stub),
static_cast<intptr_t
>(
code.ptr()),
169 static_cast<intptr_t
>(arguments_descriptor.
ptr()),
170 static_cast<intptr_t
>(arguments.
ptr()),
171 reinterpret_cast<intptr_t
>(thread)));
173 return static_cast<ObjectPtr
>((
reinterpret_cast<invokestub>(stub))(
175 static_cast<uword>(arguments_descriptor.
ptr()),
176 static_cast<uword>(arguments.
ptr()), thread));
182ObjectPtr DartEntry::ResolveCallable(Thread* thread,
183 const Array& arguments,
184 const Array& arguments_descriptor) {
185 auto isolate_group = thread->isolate_group();
186 auto zone = thread->zone();
188 const ArgumentsDescriptor args_desc(arguments_descriptor);
189 const intptr_t receiver_index = args_desc.FirstArgIndex();
190 const intptr_t type_args_len = args_desc.TypeArgsLen();
191 const auto& getter_name = Symbols::GetCall();
199 instance ^= arguments.At(receiver_index)) {
230 zone, isolate_group->object_store()->stack_overflow());
235 getter_arguments.SetAt(0,
instance);
238 if (getter_result.IsError()) {
239 return getter_result.ptr();
241 ASSERT(getter_result.IsNull() || getter_result.IsInstance());
245 arguments.SetAt(receiver_index, getter_result);
252ObjectPtr DartEntry::InvokeCallable(Thread* thread,
253 const Function& callable_function,
254 const Array& arguments,
255 const Array& arguments_descriptor) {
256 auto const zone = thread->zone();
257 const ArgumentsDescriptor args_desc(arguments_descriptor);
258 if (callable_function.IsNull()) {
261 Instance::CheckedHandle(zone, arguments.At(args_desc.FirstArgIndex()));
270 arguments_descriptor);
274 zone, callable_function.DoArgumentTypesMatch(arguments, args_desc));
279 return InvokeFunction(callable_function, arguments, arguments_descriptor);
283 auto const zone = thread->
zone();
284 const int kTypeArgsLen = 0;
289 return InvokeClosure(thread, arguments, arguments_descriptor);
293 const Array& arguments,
294 const Array& arguments_descriptor) {
295 auto const zone = thread->
zone();
297 zone, ResolveCallable(thread, arguments, arguments_descriptor));
298 if (resolved_result.IsError()) {
299 return resolved_result.
ptr();
304 return InvokeCallable(thread,
function, arguments, arguments_descriptor);
309 const String& target_name,
310 const Array& arguments,
311 const Array& arguments_descriptor) {
312 auto const zone = thread->
zone();
315 CompressedInstancePtr(receiver.
ptr()).Decompress(thread->
heap_base()) ==
322 zone, core_lib.
PrivateName(Symbols::InvocationMirror()))));
327 zone, core_lib.
PrivateName(Symbols::AllocateInvocationMirror()));
331 const int kNumAllocationArgs = 4;
332 const Array& allocation_args =
334 allocation_args.
SetAt(0, target_name);
335 allocation_args.
SetAt(1, arguments_descriptor);
336 allocation_args.
SetAt(2, arguments);
340 if (invocation_mirror.IsError()) {
346 const int kNumArguments = 2;
352 args.SetAt(0, receiver);
353 args.SetAt(1, invocation_mirror);
377 kFirstNamedEntryIndex + (index * kNamedEntrySize) + kNameOffset;
385 kFirstNamedEntryIndex + (index * kNamedEntrySize) + kPositionOffset;
390 const String& other)
const {
396 if (num_named_args == 0) {
405 for (intptr_t
i = 0;
i < num_named_args; ++
i) {
406 const intptr_t index =
PositionAt(
i) - num_pos_args;
415 bool show_named_positions)
const {
428 buffer->Printf(
"%s", str.ToCString());
429 if (show_named_positions) {
445 intptr_t num_arguments,
446 intptr_t size_arguments,
447 const Array& optional_arguments_names,
449 const intptr_t num_named_args =
450 optional_arguments_names.
IsNull() ? 0 : optional_arguments_names.
Length();
451 if (num_named_args == 0) {
453 size_arguments, space);
455 ASSERT(type_args_len >= 0);
456 ASSERT(num_arguments >= 0);
457 const intptr_t num_pos_args = num_arguments - num_named_args;
466 const intptr_t descriptor_len = LengthFor(num_named_args);
484 for (intptr_t
i = 0;
i < num_named_args;
i++) {
485 name ^= optional_arguments_names.
At(
i);
487 intptr_t insert_index = kFirstNamedEntryIndex + (kNamedEntrySize *
i);
489 while (insert_index > kFirstNamedEntryIndex) {
490 intptr_t previous_index = insert_index - kNamedEntrySize;
491 previous_name ^= descriptor.
At(previous_index + kNameOffset);
492 intptr_t
result =
name.CompareTo(previous_name);
495 previous_pos ^= descriptor.
At(previous_index + kPositionOffset);
496 descriptor.
SetAt(insert_index + kNameOffset, previous_name);
497 descriptor.
SetAt(insert_index + kPositionOffset, previous_pos);
498 insert_index = previous_index;
501 descriptor.
SetAt(insert_index + kNameOffset,
name);
502 descriptor.
SetAt(insert_index + kPositionOffset,
pos);
505 descriptor.
SetAt(descriptor_len - 1, Object::null_object());
511 return descriptor.
ptr();
515 intptr_t num_arguments,
516 intptr_t size_arguments,
518 ASSERT(type_args_len >= 0);
519 ASSERT(num_arguments >= 0);
522 (num_arguments == size_arguments)) {
523 return cached_args_descriptors_[num_arguments];
525 return NewNonCached(type_args_len, num_arguments, size_arguments,
true,
529ArrayPtr ArgumentsDescriptor::NewNonCached(intptr_t type_args_len,
530 intptr_t num_arguments,
531 intptr_t size_arguments,
539 const intptr_t descriptor_len = LengthFor(0);
545 descriptor.
SetAt(kTypeArgsLenIndex,
549 descriptor.
SetAt(kCountIndex, arg_count);
552 descriptor.
SetAt(kSizeIndex, arg_size);
555 descriptor.
SetAt(kPositionalCountIndex, arg_count);
558 descriptor.
SetAt((descriptor_len - 1), Object::null_object());
566 return descriptor.
ptr();
571 cached_args_descriptors_[
i] =
579 cached_args_descriptors_[
i] =
nullptr;
585 const String& constructor_name,
586 const Array& arguments) {
590 const int kNumExtraArgs = 1;
592 const Array& constructor_arguments =
594 constructor_arguments.
SetAt(0, exception_object);
596 for (intptr_t
i = 0;
i < arguments.
Length();
i++) {
597 obj = arguments.
At(
i);
598 constructor_arguments.
SetAt((
i + kNumExtraArgs), obj);
609 if (retval.IsError()) {
612 return exception_object.
ptr();
622 const int kNumArguments = 1;
624 args.SetAt(0, receiver);
638 const int kNumArguments = 1;
640 args.SetAt(0, receiver);
654 const int kNumArguments = 2;
657 args.SetAt(1, right);
704 auto*
const zone = thread->
zone();
705 auto*
const isolate = thread->
isolate();
711 Array::Handle(zone, isolate->isolate_object_store()->dart_args_2());
718 return handler.
ptr();
723 if (FLAG_trace_finalizers) {
724 THR_Print(
"Running finalizer %p callback on isolate %p\n",
729 auto*
const zone = thread->
zone();
730 auto*
const isolate = thread->
isolate();
733 if (finalizer.IsFinalizer()) {
734 function ^= object_store->handle_finalizer_message_function();
736 ASSERT(finalizer.IsNativeFinalizer());
737 function ^= object_store->handle_native_finalizer_message_function();
741 Array::Handle(zone, isolate->isolate_object_store()->dart_args_1());
743 args.SetAt(0, finalizer);
747 return handler.
ptr();
756 Symbols::_runPendingImmediateCallback()));
769 Symbols::_ensureScheduleImmediate()));
779 const Object& array_or_growable_array) {
780 ASSERT(array_or_growable_array.IsArray() ||
781 array_or_growable_array.IsGrowableObjectArray());
784 ASSERT(!rehashing_function.IsNull());
787 arguments.SetAt(0, array_or_growable_array);
794 const Object& array_or_growable_array) {
795 auto zone = thread->
zone();
796 const auto& collections_lib =
798 return RehashObjects(zone, collections_lib, array_or_growable_array);
803 const Object& array_or_growable_array) {
804 auto zone = thread->
zone();
806 return RehashObjects(zone, core_lib, array_or_growable_array);
intptr_t PositionalCount() const
bool MatchesNameAt(intptr_t i, const String &other) const
intptr_t NamedCount() const
ArgumentsDescriptor(const Array &array)
const char * ToCString() const
static ArrayPtr New(intptr_t type_args_len, intptr_t num_arguments, intptr_t size_arguments, const Array &optional_arguments_names, Heap::Space space=Heap::kOld)
void PrintTo(BaseTextBuffer *buffer, bool show_named_positions=false) const
ArrayPtr GetArgumentNames() const
static ArrayPtr NewBoxed(intptr_t type_args_len, intptr_t num_arguments, const Array &optional_arguments_names, Heap::Space space=Heap::kOld)
intptr_t FirstArgIndex() const
intptr_t TypeArgsLen() const
intptr_t PositionAt(intptr_t i) const
StringPtr NameAt(intptr_t i) const
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
void MakeImmutable() const
ObjectPtr At(intptr_t index) const
void SetAt(intptr_t index, const Object &value) const
static const Bool & False()
FunctionPtr LookupConstructorAllowPrivate(const String &name) const
FunctionPtr LookupStaticFunction(const String &name) const
ErrorPtr EnsureIsFinalized(Thread *thread) const
static ObjectPtr CompileFunction(Thread *thread, const Function &function)
NO_SANITIZE_SAFE_STACK DartEntryScope(Thread *thread)
static ObjectPtr InvokeNoSuchMethod(Thread *thread, const Instance &receiver, const String &target_name, const Array &arguments, const Array &arguments_descriptor)
static ObjectPtr InvokeClosure(Thread *thread, const Array &arguments)
static ObjectPtr InvokeFunction(const Function &function, const Array &arguments)
static ObjectPtr HashCode(const Instance &receiver)
static ObjectPtr HandleMessage(Dart_Port port_id, const Instance &message)
static ObjectPtr RehashObjectsInDartCollection(Thread *thread, const Object &array_or_growable_array)
static ObjectPtr LookupHandler(Dart_Port port_id)
static ObjectPtr EnsureScheduleImmediate()
static ObjectPtr HandleFinalizerMessage(const FinalizerBase &finalizer)
static ObjectPtr RehashObjectsInDartCore(Thread *thread, const Object &array_or_growable_array)
static ObjectPtr InstanceCreate(const Library &library, const String &exception_name, const String &constructor_name, const Array &arguments)
static ObjectPtr LookupOpenPorts()
static ObjectPtr Equals(const Instance &left, const Instance &right)
static ObjectPtr ToString(const Instance &receiver)
static ObjectPtr DrainMicrotaskQueue()
bool SetResumeAction(ResumeAction action, intptr_t frame_index=1, const char **error=nullptr)
static DART_NORETURN void PropagateError(const Error &error)
Isolate * isolate() const
InstancePtr Canonicalize(Thread *thread) const
static InstancePtr New(const Class &cls, Heap::Space space=Heap::kNew)
static IntegerPtr New(const String &str, Heap::Space space=Heap::kNew)
ObjectStore * object_store() const
IsolateObjectStore * isolate_object_store() const
Debugger * debugger() const
static LibraryPtr CoreLibrary()
StringPtr PrivateName(const String &name) const
static LibraryPtr IsolateLibrary()
ClassPtr LookupClassAllowPrivate(const String &name) const
FunctionPtr LookupFunctionAllowPrivate(const String &name) const
static LibraryPtr CollectionLibrary()
static LibraryPtr AsyncLibrary()
ClassPtr LookupClass(const String &name) const
static OSThread * Current()
UntaggedObject * untag() const
static ObjectPtr RawCast(ObjectPtr obj)
static FunctionPtr ResolveDynamicAnyArgs(Zone *zone, const Class &receiver_class, const String &function_name, bool allow_add)
static Simulator * Current()
static SmiPtr New(intptr_t value)
static StringPtr Concat(const String &str1, const String &str2, Heap::Space space=Heap::kNew)
void set_long_jump_base(LongJumpScope *value)
LongJumpScope * long_jump_base() const
int32_t no_callback_scope_depth() const
static Thread * Current()
bool IsDartMutatorThread() const
Isolate * isolate() const
IsolateGroup * isolate_group() const
static UnhandledExceptionPtr New(const Instance &exception, const Instance &stacktrace, Heap::Space space=Heap::kNew)
#define THR_Print(format,...)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
Dart_NativeFunction function
static const char *const names[]
const char *const class_name
uword(* invokestub)(uword target_code, uword arguments_descriptor, uword arguments, Thread *thread)
const char *const function_name
static void DebuggerSetResumeIfStepping(Isolate *isolate)
static ObjectPtr RehashObjects(Zone *zone, const Library &library, const Object &array_or_growable_array)
DECLARE_FLAG(bool, show_invisible_frames)
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
#define NO_SANITIZE_SAFE_STACK