@@ -667,98 +667,10 @@ void StubCodeCompiler::GenerateCallAutoScopeNativeStub(Assembler* assembler) {
667667// R2 : address of first argument in argument array.
668668// R1 : argc_tag including number of arguments and function kind.
669669void StubCodeCompiler::GenerateCallBootstrapNativeStub (Assembler* assembler) {
670- const intptr_t thread_offset = target::NativeArguments::thread_offset ();
671- const intptr_t argc_tag_offset = target::NativeArguments::argc_tag_offset ();
672- const intptr_t argv_offset = target::NativeArguments::argv_offset ();
673- const intptr_t retval_offset = target::NativeArguments::retval_offset ();
674-
675- __ EnterStubFrame ();
676-
677- // Save exit frame information to enable stack walking as we are about
678- // to transition to native code.
679- __ StoreToOffset (FP , THR , target::Thread::top_exit_frame_info_offset ());
680-
681- #if defined(DEBUG)
682- {
683- Label ok;
684- // Check that we are always entering from Dart code.
685- __ LoadFromOffset (R6 , THR , target::Thread::vm_tag_offset ());
686- __ CompareImmediate (R6 , VMTag::kDartCompiledTagId );
687- __ b (&ok, EQ );
688- __ Stop (" Not coming from Dart code." );
689- __ Bind (&ok);
690- }
691- #endif
692-
693- // Mark that the thread is executing native code.
694- __ StoreToOffset (R5 , THR , target::Thread::vm_tag_offset ());
695-
696- // Reserve space for the native arguments structure passed on the stack (the
697- // outgoing pointer parameter to the native arguments structure is passed in
698- // R0) and align frame before entering the C++ world.
699- __ ReserveAlignedFrameSpace (target::NativeArguments::StructSize ());
700-
701- // Initialize target::NativeArguments structure and call native function.
702- // Registers R0, R1, R2, and R3 are used.
703-
704- ASSERT (thread_offset == 0 * target::kWordSize );
705- // Set thread in NativeArgs.
706- __ mov (R0 , THR );
707-
708- // There are no native calls to closures, so we do not need to set the tag
709- // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_.
710- ASSERT (argc_tag_offset == 1 * target::kWordSize );
711- // Set argc in target::NativeArguments: R1 already contains argc.
712-
713- ASSERT (argv_offset == 2 * target::kWordSize );
714- // Set argv in target::NativeArguments: R2 already contains argv.
715-
716- // Set retval in NativeArgs.
717- ASSERT (retval_offset == 3 * target::kWordSize );
718- __ AddImmediate (R3 , FP , 2 * target::kWordSize );
719-
720- // Passing the structure by value as in runtime calls would require changing
721- // Dart API for native functions.
722- // For now, space is reserved on the stack and we pass a pointer to it.
723- __ StoreToOffset (R0 , SP , thread_offset);
724- __ StoreToOffset (R1 , SP , argc_tag_offset);
725- __ StoreToOffset (R2 , SP , argv_offset);
726- __ StoreToOffset (R3 , SP , retval_offset);
727- __ mov (R0 , SP ); // Pass the pointer to the target::NativeArguments.
728-
729- // We are entering runtime code, so the C stack pointer must be restored from
730- // the stack limit to the top of the stack. We cache the stack limit address
731- // in the Dart SP register, which is callee-saved in the C ABI.
732- __ mov (R25 , CSP );
733- __ mov (CSP , SP );
734-
735- // Call native function or redirection via simulator.
736- __ blr (R5 );
737-
738- // Restore SP and CSP.
739- __ mov (SP , CSP );
740- __ mov (CSP , R25 );
741-
742- // Refresh write barrier mask.
743- __ ldr (BARRIER_MASK ,
744- Address (THR , target::Thread::write_barrier_mask_offset ()));
745-
746- // Mark that the thread is executing Dart code.
747- __ LoadImmediate (R2 , VMTag::kDartCompiledTagId );
748- __ StoreToOffset (R2 , THR , target::Thread::vm_tag_offset ());
749-
750- // Reset exit frame information in Isolate structure.
751- __ StoreToOffset (ZR , THR , target::Thread::top_exit_frame_info_offset ());
752-
753- // Restore the global object pool after returning from runtime (old space is
754- // moving, so the GOP could have been relocated).
755- if (FLAG_precompiled_mode && FLAG_use_bare_instructions) {
756- __ ldr (PP , Address (THR , target::Thread::global_object_pool_offset ()));
757- __ sub (PP , PP , Operand (kHeapObjectTag )); // Pool in PP is untagged!
758- }
759-
760- __ LeaveStubFrame ();
761- __ ret ();
670+ GenerateCallNativeWithWrapperStub (
671+ assembler,
672+ Address (THR ,
673+ target::Thread::bootstrap_native_wrapper_entry_point_offset ()));
762674}
763675
764676// Input parameters:
0 commit comments