From a38834bf62cdcb270b54ef979a46b5f92a45c1fd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 20 Dec 2005 08:22:01 +0000 Subject: [PATCH] fixing a calling convention issue I don't fully understand --- TODO.FACTOR.txt | 5 +++-- library/compiler/amd64/architecture.factor | 4 ++++ library/compiler/ppc/generator.factor | 2 +- library/compiler/x86/architecture.factor | 4 ++++ library/compiler/x86/generator.factor | 11 ++++++----- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index fac7d71870..e261e35039 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -18,9 +18,10 @@ - on win64: to_cell will break - .h .b .o for ratios and floats is broken - amd64 to do: - - overflow checks + - fixnum<< overflow check - alien calls - - relocation info + - relocation problem + - compiling sheet runs out of memory word help sections: - synopsis diff --git a/library/compiler/amd64/architecture.factor b/library/compiler/amd64/architecture.factor index 973046996f..6faae65601 100644 --- a/library/compiler/amd64/architecture.factor +++ b/library/compiler/amd64/architecture.factor @@ -44,3 +44,7 @@ M: float-regs fastcall-regs drop 0 ; : fixnum>slot@ drop ; inline : prepare-division CQO ; inline + +: compile-prologue RSP 8 SUB ; inline + +: compile-epilogue RSP 8 ADD ; inline diff --git a/library/compiler/ppc/generator.factor b/library/compiler/ppc/generator.factor index 2b4946a410..dadbdb6d89 100644 --- a/library/compiler/ppc/generator.factor +++ b/library/compiler/ppc/generator.factor @@ -54,7 +54,7 @@ M: %call generate-node ( vop -- ) dup primitive? [ word-addr 3 MTCTR BCTR ] [ B ] if ; M: %jump generate-node ( vop -- ) - drop label compile-epilogue compile-jump ; + drop compile-epilogue label compile-jump ; M: %jump-label generate-node ( vop -- ) drop label B ; diff --git a/library/compiler/x86/architecture.factor b/library/compiler/x86/architecture.factor index 4df4b8239b..78eababc1b 100644 --- a/library/compiler/x86/architecture.factor +++ b/library/compiler/x86/architecture.factor @@ -41,3 +41,7 @@ M: float-regs fastcall-regs drop 0 ; : fixnum>slot@ 1 SHR ; inline : prepare-division CDQ ; inline + +: compile-prologue ; inline + +: compile-epilogue ; inline diff --git a/library/compiler/x86/generator.factor b/library/compiler/x86/generator.factor index 9211310b33..1e73bb3b93 100644 --- a/library/compiler/x86/generator.factor +++ b/library/compiler/x86/generator.factor @@ -5,7 +5,8 @@ USING: alien arrays assembler compiler inference kernel kernel-internals lists math memory namespaces sequences words ; ! Not used on x86 -M: %prologue generate-node drop ; +M: %prologue generate-node ( vop -- ) + drop compile-prologue ; : (call-label) label dup postpone-word @@ -18,10 +19,10 @@ M: %call-label generate-node ( vop -- ) drop label CALL ; M: %jump generate-node ( vop -- ) - drop (call-label) JMP ; + drop compile-epilogue (call-label) JMP ; M: %jump-label generate-node ( vop -- ) - drop label JMP ; + drop compile-epilogue label JMP ; M: %jump-t generate-node ( vop -- ) drop @@ -31,10 +32,10 @@ M: %jump-t generate-node ( vop -- ) label JNE ; M: %return-to generate-node ( vop -- ) - drop label address-operand PUSH ; + drop label address-operand PUSH compile-prologue ; M: %return generate-node ( vop -- ) - drop RET ; + drop compile-epilogue RET ; M: %dispatch generate-node ( vop -- ) #! Compile a piece of code that jumps to an offset in a