24 int num_type_args_expected) {
26 "Wrong number of type arguments (%i), expected %i type arguments",
27 num_type_args, num_type_args_expected));
39 int number_of_arguments,
40 bool* auto_setup_scope) {
56 resolver(api_function_name, number_of_arguments, auto_setup_scope);
66 if (symbol_resolver ==
nullptr) {
79 intptr_t num_libs =
libs.Length();
80 for (intptr_t
i = 0;
i < num_libs;
i++) {
100 if (
UNLIKELY(retval->IsHeapObject() &&
117#if defined(USING_SIMULATOR)
145 reinterpret_cast<void*
>(func))(thread, zone.
GetZone(), arguments);
146 if (return_value_unsafe != Object::sentinel().ptr()) {
148 arguments->SetReturnUnsafe(return_value_unsafe);
156#if defined(USING_SIMULATOR)
167 NoScopeNativeCallWrapperNoStackCheck(
args, func);
170void NativeEntry::NoScopeNativeCallWrapperNoStackCheck(
182 MaybePropagateError(arguments);
189#if defined(USING_SIMULATOR)
200 AutoScopeNativeCallWrapperNoStackCheck(
args, func);
203void NativeEntry::AutoScopeNativeCallWrapperNoStackCheck(
221 MaybePropagateError(arguments);
230 bool* is_bootstrap_native,
231 bool* is_auto_scope) {
235 *is_bootstrap_native =
243 library, native_name, num_params, is_auto_scope);
244 if (native_function ==
nullptr) {
245 FATAL(
"Failed to resolve native function '%s' in '%s'\n",
248 return native_function;
264 bool is_bootstrap_native =
false;
265 bool is_auto_scope =
true;
279 if (FLAG_trace_natives) {
285 &is_bootstrap_native, &is_auto_scope);
286 ASSERT(target_function !=
nullptr);
290 const Code& current_trampoline =
292 caller_frame->
pc(),
code, ¤t_function));
295 ASSERT(current_function ==
297 current_function == target_function);
298 ASSERT(current_trampoline.
ptr() == StubCode::CallBootstrapNative().ptr() ||
299 current_function == target_function);
304 if (is_bootstrap_native) {
305 trampoline = StubCode::CallBootstrapNative().
ptr();
306 }
else if (is_auto_scope) {
307 trampoline = StubCode::CallAutoScopeNative().
ptr();
309 trampoline = StubCode::CallNoScopeNative().
ptr();
312 patch_target_function, trampoline);
314 if (FLAG_trace_natives) {
315 THR_Print(
" -> %p (%s)\n", target_function,
316 is_bootstrap_native ?
"bootstrap" :
"non-bootstrap");
321 if (is_bootstrap_native) {
324 }
else if (is_auto_scope) {
327 NativeEntry::AutoScopeNativeCallWrapperNoStackCheck(
332 NativeEntry::NoScopeNativeCallWrapperNoStackCheck(
337#if !defined(DART_PRECOMPILED_RUNTIME)
340NativeEntryData::Payload* NativeEntryData::FromTypedArray(TypedDataPtr
data) {
341 return reinterpret_cast<Payload*
>(
data->untag()->data());
345 return FromTypedArray(data_.
ptr())->kind;
349 FromTypedArray(data_.
ptr())->kind =
value;
353 return FromTypedArray(
data)->kind;
357 return FromTypedArray(data_.
ptr())->trampoline;
361 FromTypedArray(data_.
ptr())->trampoline =
value;
365 return FromTypedArray(
data)->trampoline;
369 return FromTypedArray(data_.
ptr())->native_function;
373 FromTypedArray(data_.
ptr())->native_function =
value;
377 return FromTypedArray(
data)->native_function;
381 return FromTypedArray(data_.
ptr())->argc_tag;
385 FromTypedArray(data_.
ptr())->argc_tag =
value;
389 return FromTypedArray(
data)->argc_tag;
static Dart_Handle NewHandle(Thread *thread, ObjectPtr raw)
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
void SetAt(intptr_t index, const Object &value) const
static bool IsBootstrapResolver(Dart_NativeEntryResolver resolver)
LibraryPtr library() const
static CodePtr GetNativeCallAt(uword return_address, const Code &caller_code, NativeFunction *target)
static void PatchNativeCallAt(uword return_address, const Code &caller_code, NativeFunction target, const Code &trampoline)
static DART_NORETURN void ThrowByType(ExceptionType type, const Array &arguments)
static DART_NORETURN void ThrowArgumentError(const Instance &arg)
static DART_NORETURN void PropagateError(const Error &error)
StringPtr native_name() const
const char * ToQualifiedCString() const
ObjectStore * object_store() const
ApiState * api_state() const
IsolateGroup * group() const
Dart_NativeEntrySymbol native_entry_symbol_resolver() const
Dart_NativeEntryResolver native_entry_resolver() const
static intptr_t ParameterCountForResolution(const Function &function)
ObjectPtr ReturnValue() const
void set_native_function(NativeFunction value) const
static MethodRecognizer::Kind GetKind(TypedDataPtr data)
void set_trampoline(NativeFunctionWrapper value) const
static NativeFunction GetNativeFunction(TypedDataPtr data)
NativeFunctionWrapper trampoline() const
void set_kind(MethodRecognizer::Kind value) const
void set_argc_tag(intptr_t value) const
static intptr_t GetArgcTag(TypedDataPtr data)
intptr_t argc_tag() const
static TypedDataPtr New(MethodRecognizer::Kind kind, NativeFunctionWrapper trampoline, NativeFunction native_function, intptr_t argc_tag)
MethodRecognizer::Kind kind() const
NativeFunction native_function() const
static NativeFunctionWrapper GetTrampoline(TypedDataPtr data)
static void AutoScopeNativeCallWrapper(Dart_NativeArguments args, Dart_NativeFunction func)
static void BootstrapNativeCallWrapper(Dart_NativeArguments args, Dart_NativeFunction func)
static const uint8_t * ResolveSymbol(uword pc)
static NativeFunction ResolveNative(const Library &library, const String &function_name, int number_of_arguments, bool *auto_setup_scope)
static void NoScopeNativeCallWrapper(Dart_NativeArguments args, Dart_NativeFunction func)
static uword NoScopeNativeCallWrapperEntry()
static void LinkNativeCall(Dart_NativeArguments args)
static uword AutoScopeNativeCallWrapperEntry()
static uword LinkNativeCallEntry()
static uword BootstrapNativeCallWrapperEntry()
static constexpr intptr_t kNumCallWrapperArguments
static const uint8_t * ResolveSymbolInLibrary(const Library &library, uword pc)
bool IsDartInstance() const
intptr_t GetClassId() const
virtual const char * ToCString() const
static uword RedirectExternalReference(uword function, CallKind call_kind, int argument_count)
@ kNoCrossThreadIteration
CodePtr LookupDartCode() const
static StringPtr NewFormatted(const char *format,...) PRINTF_ATTRIBUTE(1
static const char * ToCString(Thread *thread, StringPtr ptr)
void UnwindScopes(uword stack_marker)
static Thread * Current()
uword top_exit_frame_info() const
ExecutionState execution_state() const
Isolate * isolate() const
IsolateGroup * isolate_group() const
static TypedDataPtr New(intptr_t class_id, intptr_t len, Heap::Space space=Heap::kNew)
#define THR_Print(format,...)
struct _Dart_Handle * Dart_Handle
Dart_NativeFunction(* Dart_NativeEntryResolver)(Dart_Handle name, int num_of_arguments, bool *auto_setup_scope)
const uint8_t *(* Dart_NativeEntrySymbol)(Dart_NativeFunction nf)
struct _Dart_NativeArguments * Dart_NativeArguments
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
#define MSAN_UNPOISON(ptr, len)
void(* NativeFunctionWrapper)(Dart_NativeArguments args, Dart_NativeFunction func)
bool IsErrorClassId(intptr_t index)
void DartNativeThrowArgumentException(const Instance &instance)
ObjectPtr(* BootstrapNativeFunction)(Thread *thread, Zone *zone, NativeArguments *arguments)
static NativeFunction ResolveNativeFunction(Zone *zone, const Function &func, bool *is_bootstrap_native, bool *is_auto_scope)
void DartNativeThrowTypeArgumentCountException(int num_type_args, int num_type_args_expected)
const char *const function_name
static int8_t data[kExtLength]
void(* NativeFunction)(NativeArguments *arguments)
#define CHECK_STACK_ALIGNMENT
#define TRACE_NATIVE_CALL(format, name)
#define REUSABLE_GROWABLE_OBJECT_ARRAY_HANDLESCOPE(thread)
#define REUSABLE_LIBRARY_HANDLESCOPE(thread)