Flutter Engine
The Flutter Engine
bootstrap_natives.h
Go to the documentation of this file.
1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_BOOTSTRAP_NATIVES_H_
6#define RUNTIME_VM_BOOTSTRAP_NATIVES_H_
7
8#include "vm/native_entry.h"
9
10// bootstrap dart natives used in the core dart library.
11
12namespace dart {
13
14// List of bootstrap native entry points used in the core dart library.
15// V(function_name, argument_count)
16#define BOOTSTRAP_NATIVE_LIST(V) \
17 V(AsyncStarMoveNext_debuggerStepCheck, 1) \
18 V(DartAsync_fatal, 1) \
19 V(Object_equals, 2) \
20 V(Object_getHash, 1) \
21 V(Object_toString, 1) \
22 V(Object_runtimeType, 1) \
23 V(Object_haveSameRuntimeType, 2) \
24 V(Object_instanceOf, 4) \
25 V(Object_simpleInstanceOf, 2) \
26 V(Function_apply, 2) \
27 V(Closure_equals, 2) \
28 V(Closure_computeHash, 1) \
29 V(AbstractType_equality, 2) \
30 V(AbstractType_getHashCode, 1) \
31 V(AbstractType_toString, 1) \
32 V(Type_equality, 2) \
33 V(LibraryPrefix_isLoaded, 1) \
34 V(LibraryPrefix_setLoaded, 1) \
35 V(LibraryPrefix_loadingUnit, 1) \
36 V(LibraryPrefix_issueLoad, 1) \
37 V(Identical_comparison, 2) \
38 V(Integer_bitAndFromInteger, 2) \
39 V(Integer_bitOrFromInteger, 2) \
40 V(Integer_bitXorFromInteger, 2) \
41 V(Integer_addFromInteger, 2) \
42 V(Integer_subFromInteger, 2) \
43 V(Integer_mulFromInteger, 2) \
44 V(Integer_truncDivFromInteger, 2) \
45 V(Integer_moduloFromInteger, 2) \
46 V(Integer_greaterThanFromInteger, 2) \
47 V(Integer_equalToInteger, 2) \
48 V(Integer_fromEnvironment, 3) \
49 V(Integer_parse, 1) \
50 V(Integer_shlFromInteger, 2) \
51 V(Integer_shrFromInteger, 2) \
52 V(Integer_ushrFromInteger, 2) \
53 V(Bool_fromEnvironment, 3) \
54 V(Bool_hasEnvironment, 2) \
55 V(Capability_factory, 1) \
56 V(Capability_equals, 2) \
57 V(Capability_get_hashcode, 1) \
58 V(RawReceivePort_factory, 2) \
59 V(RawReceivePort_get_id, 1) \
60 V(RawReceivePort_closeInternal, 1) \
61 V(RawReceivePort_setActive, 2) \
62 V(RawReceivePort_getActive, 1) \
63 V(SendPort_get_id, 1) \
64 V(SendPort_get_hashcode, 1) \
65 V(SendPort_sendInternal_, 2) \
66 V(Smi_bitNegate, 1) \
67 V(Smi_bitLength, 1) \
68 V(SuspendState_instantiateClosureWithFutureTypeArgument, 2) \
69 V(Mint_bitNegate, 1) \
70 V(Mint_bitLength, 1) \
71 V(Developer_debugger, 2) \
72 V(Developer_getIsolateIdFromSendPort, 1) \
73 V(Developer_getObjectId, 1) \
74 V(Developer_getServerInfo, 1) \
75 V(Developer_getServiceMajorVersion, 0) \
76 V(Developer_getServiceMinorVersion, 0) \
77 V(Developer_inspect, 1) \
78 V(Developer_lookupExtension, 1) \
79 V(Developer_registerExtension, 2) \
80 V(Developer_log, 8) \
81 V(Developer_postEvent, 2) \
82 V(Developer_webServerControl, 3) \
83 V(Developer_NativeRuntime_buildId, 0) \
84 V(Developer_NativeRuntime_writeHeapSnapshotToFile, 1) \
85 V(Developer_reachability_barrier, 0) \
86 V(Double_getIsNegative, 1) \
87 V(Double_getIsInfinite, 1) \
88 V(Double_getIsNaN, 1) \
89 V(Double_add, 2) \
90 V(Double_sub, 2) \
91 V(Double_mul, 2) \
92 V(Double_div, 2) \
93 V(Double_greaterThanFromInteger, 2) \
94 V(Double_equalToInteger, 2) \
95 V(Double_greaterThan, 2) \
96 V(Double_equal, 2) \
97 V(Double_doubleFromInteger, 2) \
98 V(Double_parse, 3) \
99 V(Double_toString, 1) \
100 V(Double_toStringAsFixed, 2) \
101 V(Double_toStringAsExponential, 2) \
102 V(Double_toStringAsPrecision, 2) \
103 V(Double_flipSignBit, 1) \
104 V(RegExp_factory, 6) \
105 V(RegExp_getPattern, 1) \
106 V(RegExp_getIsMultiLine, 1) \
107 V(RegExp_getIsCaseSensitive, 1) \
108 V(RegExp_getIsUnicode, 1) \
109 V(RegExp_getIsDotAll, 1) \
110 V(RegExp_getGroupCount, 1) \
111 V(RegExp_getGroupNameMap, 1) \
112 V(RegExp_ExecuteMatch, 3) \
113 V(RegExp_ExecuteMatchSticky, 3) \
114 V(List_allocate, 2) \
115 V(List_setIndexed, 3) \
116 V(List_getLength, 1) \
117 V(List_slice, 4) \
118 V(ImmutableList_from, 4) \
119 V(StringBase_createFromCodePoints, 3) \
120 V(StringBase_substringUnchecked, 3) \
121 V(StringBase_joinReplaceAllResult, 4) \
122 V(StringBase_intern, 1) \
123 V(StringBuffer_createStringFromUint16Array, 3) \
124 V(OneByteString_substringUnchecked, 3) \
125 V(OneByteString_allocateFromOneByteList, 3) \
126 V(TwoByteString_allocateFromTwoByteList, 3) \
127 V(String_getHashCode, 1) \
128 V(String_getLength, 1) \
129 V(String_charAt, 2) \
130 V(String_concat, 2) \
131 V(String_fromEnvironment, 3) \
132 V(String_toLowerCase, 1) \
133 V(String_toUpperCase, 1) \
134 V(String_concatRange, 3) \
135 V(Random_initialSeed, 0) \
136 V(SecureRandom_getBytes, 1) \
137 V(DateTime_currentTimeMicros, 0) \
138 V(DateTime_timeZoneName, 1) \
139 V(DateTime_timeZoneOffsetInSeconds, 1) \
140 V(AssertionError_throwNew, 3) \
141 V(AssertionError_throwNewSource, 5) \
142 V(Error_throwWithStackTrace, 2) \
143 V(StackTrace_current, 0) \
144 V(TypeError_throwNew, 4) \
145 V(Stopwatch_now, 0) \
146 V(Stopwatch_frequency, 0) \
147 V(Timeline_getNextTaskId, 0) \
148 V(Timeline_getTraceClock, 0) \
149 V(Timeline_isDartStreamEnabled, 0) \
150 V(Timeline_reportTaskEvent, 5) \
151 V(TypedDataBase_length, 1) \
152 V(TypedDataBase_setClampedRange, 5) \
153 V(TypedData_GetFloat32, 2) \
154 V(TypedData_SetFloat32, 3) \
155 V(TypedData_GetFloat64, 2) \
156 V(TypedData_SetFloat64, 3) \
157 V(TypedData_GetFloat32x4, 2) \
158 V(TypedData_SetFloat32x4, 3) \
159 V(TypedData_GetInt32x4, 2) \
160 V(TypedData_SetInt32x4, 3) \
161 V(TypedData_GetFloat64x2, 2) \
162 V(TypedData_SetFloat64x2, 3) \
163 V(TypedDataView_offsetInBytes, 1) \
164 V(TypedDataView_typedData, 1) \
165 V(Float32x4_fromDoubles, 4) \
166 V(Float32x4_splat, 1) \
167 V(Float32x4_fromInt32x4Bits, 2) \
168 V(Float32x4_fromFloat64x2, 2) \
169 V(Float32x4_zero, 1) \
170 V(Float32x4_add, 2) \
171 V(Float32x4_negate, 1) \
172 V(Float32x4_sub, 2) \
173 V(Float32x4_mul, 2) \
174 V(Float32x4_div, 2) \
175 V(Float32x4_cmplt, 2) \
176 V(Float32x4_cmplte, 2) \
177 V(Float32x4_cmpgt, 2) \
178 V(Float32x4_cmpgte, 2) \
179 V(Float32x4_cmpequal, 2) \
180 V(Float32x4_cmpnequal, 2) \
181 V(Float32x4_scale, 2) \
182 V(Float32x4_abs, 1) \
183 V(Float32x4_clamp, 3) \
184 V(Float32x4_getX, 1) \
185 V(Float32x4_getY, 1) \
186 V(Float32x4_getZ, 1) \
187 V(Float32x4_getW, 1) \
188 V(Float32x4_getSignMask, 1) \
189 V(Float32x4_shuffle, 2) \
190 V(Float32x4_shuffleMix, 3) \
191 V(Float32x4_setX, 2) \
192 V(Float32x4_setY, 2) \
193 V(Float32x4_setZ, 2) \
194 V(Float32x4_setW, 2) \
195 V(Float32x4_min, 2) \
196 V(Float32x4_max, 2) \
197 V(Float32x4_sqrt, 1) \
198 V(Float32x4_reciprocal, 1) \
199 V(Float32x4_reciprocalSqrt, 1) \
200 V(Float64x2_fromDoubles, 2) \
201 V(Float64x2_splat, 1) \
202 V(Float64x2_zero, 1) \
203 V(Float64x2_fromFloat32x4, 2) \
204 V(Float64x2_add, 2) \
205 V(Float64x2_negate, 1) \
206 V(Float64x2_sub, 2) \
207 V(Float64x2_mul, 2) \
208 V(Float64x2_div, 2) \
209 V(Float64x2_scale, 2) \
210 V(Float64x2_abs, 1) \
211 V(Float64x2_clamp, 3) \
212 V(Float64x2_getX, 1) \
213 V(Float64x2_getY, 1) \
214 V(Float64x2_getSignMask, 1) \
215 V(Float64x2_setX, 2) \
216 V(Float64x2_setY, 2) \
217 V(Float64x2_min, 2) \
218 V(Float64x2_max, 2) \
219 V(Float64x2_sqrt, 1) \
220 V(Int32x4_fromInts, 4) \
221 V(Int32x4_fromBools, 4) \
222 V(Int32x4_fromFloat32x4Bits, 2) \
223 V(Int32x4_or, 2) \
224 V(Int32x4_and, 2) \
225 V(Int32x4_xor, 2) \
226 V(Int32x4_add, 2) \
227 V(Int32x4_sub, 2) \
228 V(Int32x4_getX, 1) \
229 V(Int32x4_getY, 1) \
230 V(Int32x4_getZ, 1) \
231 V(Int32x4_getW, 1) \
232 V(Int32x4_setX, 2) \
233 V(Int32x4_setY, 2) \
234 V(Int32x4_setZ, 2) \
235 V(Int32x4_setW, 2) \
236 V(Int32x4_getSignMask, 1) \
237 V(Int32x4_shuffle, 2) \
238 V(Int32x4_shuffleMix, 3) \
239 V(Int32x4_getFlagX, 1) \
240 V(Int32x4_getFlagY, 1) \
241 V(Int32x4_getFlagZ, 1) \
242 V(Int32x4_getFlagW, 1) \
243 V(Int32x4_setFlagX, 2) \
244 V(Int32x4_setFlagY, 2) \
245 V(Int32x4_setFlagZ, 2) \
246 V(Int32x4_setFlagW, 2) \
247 V(Int32x4_select, 3) \
248 V(Isolate_exit_, 2) \
249 V(Isolate_getCurrentRootUriStr, 0) \
250 V(Isolate_getDebugName, 1) \
251 V(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) \
252 V(Isolate_registerKernelBlob, 1) \
253 V(Isolate_unregisterKernelBlob, 1) \
254 V(Isolate_sendOOB, 2) \
255 V(Isolate_spawnFunction, 10) \
256 V(Isolate_spawnUri, 12) \
257 V(GrowableList_allocate, 2) \
258 V(GrowableList_setIndexed, 3) \
259 V(GrowableList_getLength, 1) \
260 V(GrowableList_getCapacity, 1) \
261 V(GrowableList_setLength, 2) \
262 V(GrowableList_setData, 2) \
263 V(Internal_unsafeCast, 1) \
264 V(Internal_nativeEffect, 1) \
265 V(Internal_collectAllGarbage, 0) \
266 V(Internal_makeListFixedLength, 1) \
267 V(Internal_makeFixedListUnmodifiable, 1) \
268 V(Internal_extractTypeArguments, 2) \
269 V(Internal_prependTypeArguments, 4) \
270 V(Internal_boundsCheckForPartialInstantiation, 2) \
271 V(Internal_allocateOneByteString, 1) \
272 V(Internal_allocateTwoByteString, 1) \
273 V(Internal_writeIntoOneByteString, 3) \
274 V(Internal_writeIntoTwoByteString, 3) \
275 V(Internal_deoptimizeFunctionsOnStack, 0) \
276 V(Internal_allocateObjectInstructionsStart, 0) \
277 V(Internal_allocateObjectInstructionsEnd, 0) \
278 V(InvocationMirror_unpackTypeArguments, 2) \
279 V(NoSuchMethodError_existingMethodSignature, 3) \
280 V(Uri_isWindowsPlatform, 0) \
281 V(UserTag_new, 2) \
282 V(UserTag_label, 1) \
283 V(UserTag_defaultTag, 0) \
284 V(UserTag_makeCurrent, 1) \
285 V(Profiler_getCurrentTag, 0) \
286 V(VMService_SendIsolateServiceMessage, 2) \
287 V(VMService_SendRootServiceMessage, 1) \
288 V(VMService_SendObjectRootServiceMessage, 1) \
289 V(VMService_OnStart, 0) \
290 V(VMService_OnExit, 0) \
291 V(VMService_OnServerAddressChange, 1) \
292 V(VMService_ListenStream, 2) \
293 V(VMService_CancelStream, 1) \
294 V(VMService_RequestAssets, 0) \
295 V(VMService_DecodeAssets, 1) \
296 V(VMService_AddUserTagsToStreamableSampleList, 1) \
297 V(VMService_RemoveUserTagsFromStreamableSampleList, 1) \
298 V(Ffi_createNativeCallableListener, 2) \
299 V(Ffi_createNativeCallableIsolateLocal, 3) \
300 V(Ffi_deleteNativeCallable, 1) \
301 V(Ffi_updateNativeCallableKeepIsolateAliveCounter, 1) \
302 V(Ffi_dl_open, 1) \
303 V(Ffi_dl_close, 1) \
304 V(Ffi_dl_lookup, 2) \
305 V(Ffi_dl_getHandle, 1) \
306 V(Ffi_dl_providesSymbol, 2) \
307 V(Ffi_dl_processLibrary, 0) \
308 V(Ffi_dl_executableLibrary, 0) \
309 V(Ffi_GetFfiNativeResolver, 0) \
310 V(DartApiDLInitializeData, 0) \
311 V(DartApiDLMajorVersion, 0) \
312 V(DartApiDLMinorVersion, 0) \
313 V(DartNativeApiFunctionPointer, 1) \
314 V(TransferableTypedData_factory, 2) \
315 V(TransferableTypedData_materialize, 1)
316
317// List of bootstrap native entry points used in the dart:mirror library.
318#define MIRRORS_BOOTSTRAP_NATIVE_LIST(V) \
319 V(Mirrors_makeLocalClassMirror, 1) \
320 V(Mirrors_makeLocalTypeMirror, 1) \
321 V(Mirrors_instantiateGenericType, 2) \
322 V(Mirrors_mangleName, 2) \
323 V(MirrorReference_equals, 2) \
324 V(MirrorSystem_libraries, 0) \
325 V(MirrorSystem_isolate, 0) \
326 V(IsolateMirror_loadUri, 1) \
327 V(InstanceMirror_invoke, 5) \
328 V(InstanceMirror_invokeGetter, 3) \
329 V(InstanceMirror_invokeSetter, 4) \
330 V(InstanceMirror_computeType, 1) \
331 V(ClosureMirror_function, 1) \
332 V(TypeMirror_subtypeTest, 2) \
333 V(ClassMirror_libraryUri, 1) \
334 V(ClassMirror_supertype, 1) \
335 V(ClassMirror_supertype_instantiated, 1) \
336 V(ClassMirror_interfaces, 1) \
337 V(ClassMirror_interfaces_instantiated, 1) \
338 V(ClassMirror_mixin, 1) \
339 V(ClassMirror_mixin_instantiated, 2) \
340 V(ClassMirror_members, 3) \
341 V(ClassMirror_constructors, 3) \
342 V(LibraryMirror_members, 2) \
343 V(LibraryMirror_libraryDependencies, 2) \
344 V(ClassMirror_invoke, 5) \
345 V(ClassMirror_invokeGetter, 3) \
346 V(ClassMirror_invokeSetter, 4) \
347 V(ClassMirror_invokeConstructor, 5) \
348 V(ClassMirror_type_variables, 1) \
349 V(ClassMirror_type_arguments, 1) \
350 V(LibraryMirror_fromPrefix, 1) \
351 V(LibraryMirror_invoke, 5) \
352 V(LibraryMirror_invokeGetter, 3) \
353 V(LibraryMirror_invokeSetter, 4) \
354 V(TypeVariableMirror_owner, 1) \
355 V(TypeVariableMirror_upper_bound, 1) \
356 V(DeclarationMirror_location, 1) \
357 V(DeclarationMirror_metadata, 1) \
358 V(FunctionTypeMirror_call_method, 2) \
359 V(FunctionTypeMirror_parameters, 2) \
360 V(FunctionTypeMirror_return_type, 1) \
361 V(MethodMirror_owner, 2) \
362 V(MethodMirror_parameters, 2) \
363 V(MethodMirror_return_type, 2) \
364 V(MethodMirror_source, 1) \
365 V(ParameterMirror_type, 3) \
366 V(VariableMirror_type, 2)
367
368#define BOOTSTRAP_FFI_NATIVE_LIST(V) \
369 V(FinalizerEntry_SetExternalSize, void, (Dart_Handle, intptr_t)) \
370 V(Pointer_asTypedListFinalizerAllocateData, void*, ()) \
371 V(Pointer_asTypedListFinalizerCallbackPointer, void*, ())
372
374 public:
376 int argument_count,
377 bool* auto_setup_scope);
378
379 // For use with @Native.
380 static void* LookupFfiNative(const char* name, uintptr_t argument_count);
381
382 static const uint8_t* Symbol(Dart_NativeFunction nf);
383
384#define DECLARE_BOOTSTRAP_NATIVE(name, ignored) \
385 static ObjectPtr DN_##name(Thread* thread, Zone* zone, \
386 NativeArguments* arguments);
387
389#if !defined(DART_PRECOMPILED_RUNTIME)
391#endif
392#undef DECLARE_BOOTSTRAP_NATIVE
393
394#define DECLARE_BOOTSTRAP_FFI_NATIVE(name, return_type, argument_types) \
395 static return_type FN_##name argument_types;
397#undef DECLARE_BOOTSTRAP_FFI_NATIVE
398};
399
400} // namespace dart
401
402#endif // RUNTIME_VM_BOOTSTRAP_NATIVES_H_
#define DECLARE_BOOTSTRAP_FFI_NATIVE(name, return_type, argument_types)
#define BOOTSTRAP_FFI_NATIVE_LIST(V)
#define MIRRORS_BOOTSTRAP_NATIVE_LIST(V)
#define BOOTSTRAP_NATIVE_LIST(V)
#define DECLARE_BOOTSTRAP_NATIVE(name, ignored)
static Dart_NativeFunction Lookup(Dart_Handle name, int argument_count, bool *auto_setup_scope)
static void * LookupFfiNative(const char *name, uintptr_t argument_count)
static const uint8_t * Symbol(Dart_NativeFunction nf)
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
Definition: dart_api.h:3207
int argument_count
Definition: fuchsia.cc:52
Definition: dart_vm.cc:33
const char *const name