Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Functions
native_entry.h File Reference
#include "platform/memory_sanitizer.h"
#include "vm/allocation.h"
#include "vm/exceptions.h"
#include "vm/heap/verifier.h"
#include "vm/log.h"
#include "vm/native_arguments.h"
#include "vm/native_function.h"
#include "vm/runtime_entry.h"

Go to the source code of this file.

Classes

class  dart::NativeEntry
 
class  dart::NativeEntryData
 

Namespaces

namespace  dart
 

Macros

#define TRACE_NATIVE_CALL(format, name)
 
#define DEFINE_NATIVE_ENTRY(name, type_argument_count, argument_count)
 
#define DEFINE_FFI_NATIVE_ENTRY(name, return_type, argument_types)    return_type BootstrapNatives::FN_##name argument_types
 
#define NATIVE_TYPE_ARGUMENT_COUNT(expected)
 
#define GET_NATIVE_TYPE_ARGUMENT(name, value)    AbstractType& name = AbstractType::Handle(value);
 
#define GET_NON_NULL_NATIVE_ARGUMENT(type, name, value)
 
#define GET_NATIVE_ARGUMENT(type, name, value)
 

Typedefs

typedef ObjectPtr(* dart::BootstrapNativeFunction) (Thread *thread, Zone *zone, NativeArguments *arguments)
 

Functions

void dart::DartNativeThrowTypeArgumentCountException (int num_type_args, int num_type_args_expected)
 
void dart::DartNativeThrowArgumentException (const Instance &instance)
 

Macro Definition Documentation

◆ DEFINE_FFI_NATIVE_ENTRY

#define DEFINE_FFI_NATIVE_ENTRY (   name,
  return_type,
  argument_types 
)     return_type BootstrapNatives::FN_##name argument_types

Definition at line 53 of file native_entry.h.

64 { \
65 DartNativeThrowTypeArgumentCountException(__num_type_arguments, expected); \
66 }
67
68#define GET_NATIVE_TYPE_ARGUMENT(name, value) \
69 AbstractType& name = AbstractType::Handle(value);
70
71// Natives should throw an exception if an illegal argument or null is passed.
72// type name = value.
73#define GET_NON_NULL_NATIVE_ARGUMENT(type, name, value) \
74 const Instance& __##name##_instance__ = \
75 Instance::CheckedHandle(zone, value); \
76 if (!__##name##_instance__.Is##type()) { \
77 DartNativeThrowArgumentException(__##name##_instance__); \
78 } \
79 const type& name = type::Cast(__##name##_instance__);
80
81// Natives should throw an exception if an illegal argument is passed.
82// type name = value.
83#define GET_NATIVE_ARGUMENT(type, name, value) \
84 const Instance& __##name##_instance__ = \
85 Instance::CheckedHandle(zone, value); \
86 type& name = type::Handle(zone); \
87 if (!__##name##_instance__.IsNull()) { \
88 if (!__##name##_instance__.Is##type()) { \
89 DartNativeThrowArgumentException(__##name##_instance__); \
90 } \
91 } \
92 name ^= value;
93
94// Helper class for resolving and handling native functions.
95class NativeEntry : public AllStatic {
96 public:
97 static constexpr intptr_t kNumArguments = 1;
98 static constexpr intptr_t kNumCallWrapperArguments = 2;
99
100 // Resolve specified dart native function to the actual native entrypoint.
101 static NativeFunction ResolveNative(const Library& library,
102 const String& function_name,
103 int number_of_arguments,
104 bool* auto_setup_scope);
105 static const uint8_t* ResolveSymbolInLibrary(const Library& library,
106 uword pc);
107 static const uint8_t* ResolveSymbol(uword pc);
108
109 static uword BootstrapNativeCallWrapperEntry();
110 static void BootstrapNativeCallWrapper(Dart_NativeArguments args,
112
113 static uword NoScopeNativeCallWrapperEntry();
114 static void NoScopeNativeCallWrapper(Dart_NativeArguments args,
116
117 static uword AutoScopeNativeCallWrapperEntry();
118 static void AutoScopeNativeCallWrapper(Dart_NativeArguments args,
120
121 static uword LinkNativeCallEntry();
122 static void LinkNativeCall(Dart_NativeArguments args);
123
124 private:
125 static void NoScopeNativeCallWrapperNoStackCheck(Dart_NativeArguments args,
127 static void AutoScopeNativeCallWrapperNoStackCheck(Dart_NativeArguments args,
129
130 static void MaybePropagateError(NativeArguments* arguments);
131};
132
133#if !defined(DART_PRECOMPILED_RUNTIME)
134
135class NativeEntryData : public ValueObject {
136 public:
137 explicit NativeEntryData(const TypedData& data) : data_(data) {}
138
139 MethodRecognizer::Kind kind() const;
140 void set_kind(MethodRecognizer::Kind value) const;
141 static MethodRecognizer::Kind GetKind(TypedDataPtr data);
142
143 NativeFunctionWrapper trampoline() const;
144 void set_trampoline(NativeFunctionWrapper value) const;
145 static NativeFunctionWrapper GetTrampoline(TypedDataPtr data);
146
147 NativeFunction native_function() const;
148 void set_native_function(NativeFunction value) const;
149 static NativeFunction GetNativeFunction(TypedDataPtr data);
150
151 intptr_t argc_tag() const;
152 void set_argc_tag(intptr_t value) const;
153 static intptr_t GetArgcTag(TypedDataPtr data);
154
155 static TypedDataPtr New(MethodRecognizer::Kind kind,
156 NativeFunctionWrapper trampoline,
157 NativeFunction native_function,
158 intptr_t argc_tag);
159
160 private:
161 struct Payload {
162 NativeFunctionWrapper trampoline;
163 NativeFunction native_function;
164 intptr_t argc_tag;
165 MethodRecognizer::Kind kind;
166 };
167
168 static Payload* FromTypedArray(TypedDataPtr data);
169
170 const TypedData& data_;
171
172 friend class ObjectPoolSerializationCluster;
173 DISALLOW_COPY_AND_ASSIGN(NativeEntryData);
174};
175
176#endif // !defined(DART_PRECOMPILED_RUNTIME)
177
178} // namespace dart
179
180#endif // RUNTIME_VM_NATIVE_ENTRY_H_
struct _Dart_NativeArguments * Dart_NativeArguments
Definition dart_api.h:3010
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
Definition dart_api.h:3198
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
void(* NativeFunctionWrapper)(Dart_NativeArguments args, Dart_NativeFunction func)
uintptr_t uword
Definition globals.h:501
void(* NativeFunction)(NativeArguments *arguments)
std::function< void(Dart_NativeArguments)> NativeEntry
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581

◆ DEFINE_NATIVE_ENTRY

#define DEFINE_NATIVE_ENTRY (   name,
  type_argument_count,
  argument_count 
)
Value:
static ObjectPtr DN_Helper##name(Isolate* isolate, Thread* thread, \
Zone* zone, NativeArguments* arguments); \
ObjectPtr BootstrapNatives::DN_##name(Thread* thread, Zone* zone, \
NativeArguments* arguments) { \
TRACE_NATIVE_CALL("%s", "" #name); \
ASSERT(arguments->NativeArgCount() == argument_count); \
/* Note: a longer type arguments vector may be passed */ \
ASSERT(arguments->NativeTypeArgCount() >= type_argument_count); \
return DN_Helper##name(thread->isolate(), thread, zone, arguments); \
} \
static ObjectPtr DN_Helper##name(Isolate* isolate, Thread* thread, \
Zone* zone, NativeArguments* arguments)
const char * name
Definition fuchsia.cc:50
int argument_count
Definition fuchsia.cc:52

Definition at line 39 of file native_entry.h.

43 { \
44 TRACE_NATIVE_CALL("%s", "" #name); \
45 ASSERT(arguments->NativeArgCount() == argument_count); \
46 /* Note: a longer type arguments vector may be passed */ \
47 ASSERT(arguments->NativeTypeArgCount() >= type_argument_count); \
48 return DN_Helper##name(thread->isolate(), thread, zone, arguments); \
49 } \
50 static ObjectPtr DN_Helper##name(Isolate* isolate, Thread* thread, \
51 Zone* zone, NativeArguments* arguments)

◆ GET_NATIVE_ARGUMENT

#define GET_NATIVE_ARGUMENT (   type,
  name,
  value 
)
Value:
const Instance& __##name##_instance__ = \
Instance::CheckedHandle(zone, value); \
type& name = type::Handle(zone); \
if (!__##name##_instance__.IsNull()) { \
if (!__##name##_instance__.Is##type()) { \
DartNativeThrowArgumentException(__##name##_instance__); \
} \
} \
name ^= value;
#define __
uint8_t value

Definition at line 84 of file native_entry.h.

88 { \
89 if (!__##name##_instance__.Is##type()) { \
90 DartNativeThrowArgumentException(__##name##_instance__); \
91 } \
92 } \
93 name ^= value;

◆ GET_NATIVE_TYPE_ARGUMENT

#define GET_NATIVE_TYPE_ARGUMENT (   name,
  value 
)     AbstractType& name = AbstractType::Handle(value);

Definition at line 69 of file native_entry.h.

◆ GET_NON_NULL_NATIVE_ARGUMENT

#define GET_NON_NULL_NATIVE_ARGUMENT (   type,
  name,
  value 
)
Value:
const Instance& __##name##_instance__ = \
Instance::CheckedHandle(zone, value); \
if (!__##name##_instance__.Is##type()) { \
DartNativeThrowArgumentException(__##name##_instance__); \
} \
const type& name = type::Cast(__##name##_instance__);

Definition at line 74 of file native_entry.h.

77 { \
78 DartNativeThrowArgumentException(__##name##_instance__); \
79 } \
80 const type& name = type::Cast(__##name##_instance__);

◆ NATIVE_TYPE_ARGUMENT_COUNT

#define NATIVE_TYPE_ARGUMENT_COUNT (   expected)
Value:
int __num_type_arguments = arguments->NativeTypeArgCount(); \
if (__num_type_arguments != expected) { \
DartNativeThrowTypeArgumentCountException(__num_type_arguments, expected); \
}

Definition at line 63 of file native_entry.h.

65 { \
66 DartNativeThrowTypeArgumentCountException(__num_type_arguments, expected); \
67 }

◆ TRACE_NATIVE_CALL

#define TRACE_NATIVE_CALL (   format,
  name 
)
Value:
do { \
} while (0)

Definition at line 30 of file native_entry.h.

31 { \
32 } while (0)