From 3031c8da0c5009183f770b005c245f9bf2a4d01b Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 13 Jul 2015 20:11:06 -0700 Subject: [PATCH] ART: Remove art_quick_invoke_interface_trampoline The function has only been used by the IMT conflict resolution trampoline for a while. Merge the two, which saves a branch. Change-Id: I2f8c9204adf839ddc5459cc04e70d98f858110a1 --- runtime/arch/arm/quick_entrypoints_arm.S | 12 +++++++----- runtime/arch/arm64/quick_entrypoints_arm64.S | 11 +++++++---- runtime/arch/mips/quick_entrypoints_mips.S | 11 ++++++----- runtime/arch/mips64/quick_entrypoints_mips64.S | 12 ++++++------ runtime/arch/x86/quick_entrypoints_x86.S | 10 ++++++---- runtime/arch/x86_64/quick_entrypoints_x86_64.S | 10 ++++++---- 6 files changed, 38 insertions(+), 28 deletions(-) diff --git a/runtime/arch/arm/quick_entrypoints_arm.S b/runtime/arch/arm/quick_entrypoints_arm.S index a7826a74d..068f45873 100644 --- a/runtime/arch/arm/quick_entrypoints_arm.S +++ b/runtime/arch/arm/quick_entrypoints_arm.S @@ -325,23 +325,25 @@ ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFr * On success this wrapper will restore arguments and *jump* to the target, leaving the lr * pointing back to the original caller. */ -.macro INVOKE_TRAMPOLINE c_name, cxx_name +.macro INVOKE_TRAMPOLINE_BODY cxx_name .extern \cxx_name -ENTRY \c_name SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME r2, r3 @ save callee saves in case allocation triggers GC mov r2, r9 @ pass Thread::Current mov r3, sp - bl \cxx_name @ (method_idx, this, caller, Thread*, SP) + bl \cxx_name @ (method_idx, this, Thread*, SP) mov r12, r1 @ save Method*->code_ RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME cbz r0, 1f @ did we find the target? if not go to exception delivery bx r12 @ tail call to target 1: DELIVER_PENDING_EXCEPTION +.endm +.macro INVOKE_TRAMPOLINE c_name, cxx_name +ENTRY \c_name + INVOKE_TRAMPOLINE_BODY \cxx_name END \c_name .endm -INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck @@ -894,7 +896,7 @@ END art_quick_proxy_invoke_handler */ ENTRY art_quick_imt_conflict_trampoline mov r0, r12 - b art_quick_invoke_interface_trampoline + INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline END art_quick_imt_conflict_trampoline .extern artQuickResolutionTrampoline diff --git a/runtime/arch/arm64/quick_entrypoints_arm64.S b/runtime/arch/arm64/quick_entrypoints_arm64.S index 614936b93..6d9b44a1d 100644 --- a/runtime/arch/arm64/quick_entrypoints_arm64.S +++ b/runtime/arch/arm64/quick_entrypoints_arm64.S @@ -450,9 +450,8 @@ ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFr * * Clobbers xIP0. */ -.macro INVOKE_TRAMPOLINE c_name, cxx_name +.macro INVOKE_TRAMPOLINE_BODY cxx_name .extern \cxx_name -ENTRY \c_name SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME // save callee saves in case allocation triggers GC // Helper signature is always // (method_idx, *this_object, *caller_method, *self, sp) @@ -466,10 +465,13 @@ ENTRY \c_name br xIP0 // tail call to target 1: DELIVER_PENDING_EXCEPTION +.endm +.macro INVOKE_TRAMPOLINE c_name, cxx_name +ENTRY \c_name + INVOKE_TRAMPOLINE_BODY \cxx_name END \c_name .endm -INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck @@ -1429,9 +1431,10 @@ END art_quick_proxy_invoke_handler * Called to resolve an imt conflict. xIP1 is a hidden argument that holds the target method's * dex method index. */ + .extern artInvokeInterfaceTrampoline ENTRY art_quick_imt_conflict_trampoline mov x0, xIP1 - b art_quick_invoke_interface_trampoline + INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline END art_quick_imt_conflict_trampoline ENTRY art_quick_resolution_trampoline diff --git a/runtime/arch/mips/quick_entrypoints_mips.S b/runtime/arch/mips/quick_entrypoints_mips.S index cc1de4372..2819f92a0 100644 --- a/runtime/arch/mips/quick_entrypoints_mips.S +++ b/runtime/arch/mips/quick_entrypoints_mips.S @@ -459,9 +459,8 @@ END art_quick_throw_no_such_method * On success this wrapper will restore arguments and *jump* to the target, leaving the lr * pointing back to the original caller. */ -.macro INVOKE_TRAMPOLINE c_name, cxx_name +.macro INVOKE_TRAMPOLINE_BODY cxx_name .extern \cxx_name -ENTRY \c_name SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC move $a2, rSELF # pass Thread::Current jal \cxx_name # (method_idx, this, Thread*, $sp) @@ -474,10 +473,13 @@ ENTRY \c_name nop 1: DELIVER_PENDING_EXCEPTION +.endm +.macro INVOKE_TRAMPOLINE c_name, cxx_name +ENTRY \c_name + INVOKE_TRAMPOLINE_BODY \cxx_name END \c_name .endm -INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck @@ -1103,9 +1105,8 @@ END art_quick_proxy_invoke_handler * dex method index. */ ENTRY art_quick_imt_conflict_trampoline - la $t9, art_quick_invoke_interface_trampoline - jalr $zero, $t9 move $a0, $t0 + INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline END art_quick_imt_conflict_trampoline .extern artQuickResolutionTrampoline diff --git a/runtime/arch/mips64/quick_entrypoints_mips64.S b/runtime/arch/mips64/quick_entrypoints_mips64.S index 37c6c5b3f..abca70b36 100644 --- a/runtime/arch/mips64/quick_entrypoints_mips64.S +++ b/runtime/arch/mips64/quick_entrypoints_mips64.S @@ -525,9 +525,8 @@ END art_quick_throw_no_such_method * On success this wrapper will restore arguments and *jump* to the target, leaving the ra * pointing back to the original caller. */ -.macro INVOKE_TRAMPOLINE c_name, cxx_name +.macro INVOKE_TRAMPOLINE_BODY cxx_name .extern \cxx_name -ENTRY \c_name SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC move $a2, rSELF # pass Thread::Current jal \cxx_name # (method_idx, this, Thread*, $sp) @@ -541,10 +540,13 @@ ENTRY \c_name nop 1: DELIVER_PENDING_EXCEPTION +.endm +.macro INVOKE_TRAMPOLINE c_name, cxx_name +ENTRY \c_name + INVOKE_TRAMPOLINE_BODY \cxx_name END \c_name .endm -INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck @@ -1369,10 +1371,8 @@ END art_quick_proxy_invoke_handler * dex method index. */ ENTRY art_quick_imt_conflict_trampoline - dla $t9, art_quick_invoke_interface_trampoline - .cpreturn - jalr $zero, $t9 move $a0, $t0 + INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline END art_quick_imt_conflict_trampoline .extern artQuickResolutionTrampoline diff --git a/runtime/arch/x86/quick_entrypoints_x86.S b/runtime/arch/x86/quick_entrypoints_x86.S index f6c76491c..bde6a0856 100644 --- a/runtime/arch/x86/quick_entrypoints_x86.S +++ b/runtime/arch/x86/quick_entrypoints_x86.S @@ -293,8 +293,7 @@ TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromC * On success this wrapper will restore arguments and *jump* to the target, leaving the lr * pointing back to the original caller. */ -MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) - DEFINE_FUNCTION RAW_VAR(c_name, 0) +MACRO1(INVOKE_TRAMPOLINE_BODY, cxx_name) SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME ebx, ebx movl %esp, %edx // remember SP @@ -334,10 +333,13 @@ MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) addl MACRO_LITERAL(4), %esp // Pop code pointer off stack CFI_ADJUST_CFA_OFFSET(-4) DELIVER_PENDING_EXCEPTION +END_MACRO +MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) + DEFINE_FUNCTION RAW_VAR(c_name, 0) + INVOKE_TRAMPOLINE_BODY(cxx_name) END_FUNCTION RAW_VAR(c_name, 0) END_MACRO -INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck @@ -1415,7 +1417,7 @@ END_FUNCTION art_quick_proxy_invoke_handler */ DEFINE_FUNCTION art_quick_imt_conflict_trampoline movd %xmm7, %eax // get target method index stored in xmm7 - jmp SYMBOL(art_quick_invoke_interface_trampoline) + INVOKE_TRAMPOLINE_BODY(artInvokeInterfaceTrampoline) END_FUNCTION art_quick_imt_conflict_trampoline DEFINE_FUNCTION art_quick_resolution_trampoline diff --git a/runtime/arch/x86_64/quick_entrypoints_x86_64.S b/runtime/arch/x86_64/quick_entrypoints_x86_64.S index 7d86c3acc..a69a4b20b 100644 --- a/runtime/arch/x86_64/quick_entrypoints_x86_64.S +++ b/runtime/arch/x86_64/quick_entrypoints_x86_64.S @@ -353,8 +353,7 @@ TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromC * * Adapted from x86 code. */ -MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) - DEFINE_FUNCTION VAR(c_name, 0) +MACRO1(INVOKE_TRAMPOLINE_BODY, cxx_name) SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME // save callee saves in case allocation triggers GC // Helper signature is always // (method_idx, *this_object, *caller_method, *self, sp) @@ -375,10 +374,13 @@ MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) jmp *%rax 1: DELIVER_PENDING_EXCEPTION +END_MACRO +MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) + DEFINE_FUNCTION VAR(c_name, 0) + INVOKE_TRAMPOLINE_BODY(cxx_name) END_FUNCTION VAR(c_name, 0) END_MACRO -INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck @@ -1352,7 +1354,7 @@ DEFINE_FUNCTION art_quick_imt_conflict_trampoline int3 #else movq %rax, %rdi - jmp art_quick_invoke_interface_trampoline + INVOKE_TRAMPOLINE_BODY(artInvokeInterfaceTrampoline) #endif // __APPLE__ END_FUNCTION art_quick_imt_conflict_trampoline -- 2.11.0