256 {
258 NativeArguments* arguments =
reinterpret_cast<NativeArguments*
>(
args);
259
262
264 bool is_bootstrap_native = false;
265 bool is_auto_scope = true;
266
267 {
268 TransitionGeneratedToVM transition(arguments->thread());
269 StackZone stack_zone(arguments->thread());
270 Zone* zone = stack_zone.GetZone();
271
272 DartFrameIterator iterator(arguments->thread(),
274 StackFrame* caller_frame = iterator.NextFrame();
275
278
279 if (FLAG_trace_natives) {
280 THR_Print(
"Resolving native target for %s\n", func.ToCString());
281 }
282
283 target_function =
285 &is_bootstrap_native, &is_auto_scope);
286 ASSERT(target_function !=
nullptr);
287
288#if defined(DEBUG)
290 const Code& current_trampoline =
292 caller_frame->pc(),
code, ¤t_function));
293
294
295 ASSERT(current_function ==
297 current_function == target_function);
298 ASSERT(current_trampoline.ptr() == StubCode::CallBootstrapNative().ptr() ||
299 current_function == target_function);
300#endif
301
304 if (is_bootstrap_native) {
305 trampoline = StubCode::CallBootstrapNative().ptr();
306 } else if (is_auto_scope) {
307 trampoline = StubCode::CallAutoScopeNative().ptr();
308 } else {
309 trampoline = StubCode::CallNoScopeNative().ptr();
310 }
312 patch_target_function, trampoline);
313
314 if (FLAG_trace_natives) {
315 THR_Print(
" -> %p (%s)\n", target_function,
316 is_bootstrap_native ? "bootstrap" : "non-bootstrap");
317 }
318 }
319
320
321 if (is_bootstrap_native) {
324 } else if (is_auto_scope) {
325
326
327 NativeEntry::AutoScopeNativeCallWrapperNoStackCheck(
329 } else {
330
331
332 NativeEntry::NoScopeNativeCallWrapperNoStackCheck(
334 }
335}
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)
@ kNoCrossThreadIteration
#define THR_Print(format,...)
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
static NativeFunction ResolveNativeFunction(Zone *zone, const Function &func, bool *is_bootstrap_native, bool *is_auto_scope)
void(* NativeFunction)(NativeArguments *arguments)
#define TRACE_NATIVE_CALL(format, name)