aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2012-01-11 19:55:11 +0200
committerPekka Enberg <penberg@kernel.org>2012-01-11 19:56:19 +0200
commit04dc44c497bee6f589ccba7f709f1cb1be876968 (patch)
tree7aac538044512388605b5fa596db53dd22280ede
parent64029fed3b2288c16dafca17bd47b4b265e15533 (diff)
downloadjato-04dc44c497bee6f589ccba7f709f1cb1be876968.tar.gz
x86-32: Generate better code for static method trampolines
This patch removes a redundant push eax/pop eax pair from static method trampolines. Before: [main] # Trampoline: [main] 0xa739cab0: 55 push %ebp [main] 0xa739cab1: 89 e5 mov %esp,%ebp [main] 0xa739cab3: 68 40 16 b7 08 push $0x8b71640 [main] 0xa739cab8: e8 73 38 d0 60 call 0x00000000080a0330 # jit_magic_trampoline+0 (/home/penberg/src/jato/jit/trampoline.c:95) [main] [main] 0xa739cabd: 83 c4 04 add $0x4,%esp [main] 0xa739cac0: 65 8b 0d f0 b7 ff ff mov %gs:0xffffb7f0,%ecx [main] 0xa739cac7: 85 09 test %ecx,(%ecx) [main] 0xa739cac9: 50 push %eax [main] 0xa739caca: 58 pop %eax [main] 0xa739cacb: 5d pop %ebp [main] 0xa739cacc: ff e0 jmp *%eax After: [unknown] # Trampoline: [unknown] 0xa7399f80: 55 push %ebp [unknown] 0xa7399f81: 89 e5 mov %esp,%ebp [unknown] 0xa7399f83: 68 c0 d8 c2 08 push $0x8c2d8c0 [unknown] 0xa7399f88: e8 a3 63 d0 60 call 0x00000000080a0330 # jit_magic_trampoline+0 (/home/penberg/src/jato/jit/trampoline.c:95) [unknown] [unknown] 0xa7399f8d: 83 c4 04 add $0x4,%esp [unknown] 0xa7399f90: 65 8b 0d f0 b7 ff ff mov %gs:0xffffb7f0,%ecx [unknown] 0xa7399f97: 85 09 test %ecx,(%ecx) [unknown] 0xa7399f99: 5d pop %ebp [unknown] 0xa7399f9a: ff e0 jmp *%eax Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--arch/x86/emit-code.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index 345eca26..878d5819 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -948,18 +948,16 @@ void emit_trampoline(struct compilation_unit *cu,
MACH_REG_ECX);
__emit_test_membase_reg(buf, MACH_REG_ECX, 0, MACH_REG_ECX);
- __emit_push_reg(buf, MACH_REG_EAX);
-
if (method_is_virtual(cu->method)) {
+ __emit_push_reg(buf, MACH_REG_EAX);
__emit_push_membase(buf, MACH_REG_EBP, 0x08);
__emit_push_imm(buf, (unsigned long)cu);
__emit_call(buf, fixup_vtable);
__emit_add_imm_reg(buf, 0x08, MACH_REG_ESP);
+ __emit_pop_reg(buf, MACH_REG_EAX);
}
- __emit_pop_reg(buf, MACH_REG_EAX);
-
__emit_pop_reg(buf, MACH_REG_EBP);
emit_indirect_jump_reg(buf, MACH_REG_EAX);