From 8d274971d679e40e298356daad01cff96b59384a Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 2 Jan 2019 06:10:52 +0000 Subject: [PATCH] Load the fallback into rax so caller needs no conditional branch. WARNING: This changes the amd64 compiled code interface so that new compiled code requires a new microcode. (However, a new microcode should handle old compiled code without trouble, since old compiled code treats rax as garbage at this point, and LEA does not affect flags.) --- src/compiler/machines/x86-64/rules3.scm | 5 +---- src/microcode/cmpauxmd/x86-64.m4 | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/compiler/machines/x86-64/rules3.scm b/src/compiler/machines/x86-64/rules3.scm index 787efe41c..3193f00e6 100644 --- a/src/compiler/machines/x86-64/rules3.scm +++ b/src/compiler/machines/x86-64/rules3.scm @@ -110,10 +110,7 @@ USA. (else (LAP (MOV Q (R ,rdx) (&U ,frame-size)) ,@(invoke-hook/subroutine entry:compiler-apply-setup)))) - (JNE (@PCR ,generic)) - (JMP (R ,rax)) - (LABEL ,generic) - ,@(invoke-hook entry:compiler-shortcircuit-apply)))) + (JMP (R ,rax))))) (define-rule statement (INVOCATION:JUMP (? frame-size) (? continuation) (? label)) diff --git a/src/microcode/cmpauxmd/x86-64.m4 b/src/microcode/cmpauxmd/x86-64.m4 index f98d8426c..38dbabaf6 100644 --- a/src/microcode/cmpauxmd/x86-64.m4 +++ b/src/microcode/cmpauxmd/x86-64.m4 @@ -613,6 +613,9 @@ define_hook_label(apply_setup) ret asm_apply_setup_fail: + # Load the fallback address into rax, where compiled code will + # jump. + OP(lea,q) TW(ABS(EVR(asm_sc_apply_generic)),REG(rax)) ret define(define_apply_setup_fixed_size, @@ -631,6 +634,7 @@ define_hook_label(apply_setup_size_$1) ret asm_apply_setup_size_$1_fail: + OP(lea,q) TW(ABS(EVR(asm_sc_apply_generic)),REG(rax)) OP(mov,q) TW(IMM(HEX($1)),REG(rdx)) ret') -- 2.25.1