From 359fb6e5183f781dd0f76c0e0e85ac35de08e43c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 8 Nov 2008 20:32:23 -0600 Subject: [PATCH] VM fixes for Win64 calling convention --- vm/cpu-x86.32.S | 4 ++++ vm/cpu-x86.64.S | 6 ++++++ vm/cpu-x86.S | 17 +++++++++-------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/vm/cpu-x86.32.S b/vm/cpu-x86.32.S index e0e674a7e2..eec850dc9e 100755 --- a/vm/cpu-x86.32.S +++ b/vm/cpu-x86.32.S @@ -10,14 +10,18 @@ and the callstack top is passed in EDX */ #define DS_REG %esi #define RETURN_REG %eax +#define NV_TEMP_REG %rbx + #define CELL_SIZE 4 #define STACK_PADDING 12 #define PUSH_NONVOLATILE \ push %ebx ; \ + push %ebp ; \ push %ebp #define POP_NONVOLATILE \ + pop %ebp ; \ pop %ebp ; \ pop %ebx diff --git a/vm/cpu-x86.64.S b/vm/cpu-x86.64.S index 15a4eb8da3..c981095d62 100644 --- a/vm/cpu-x86.64.S +++ b/vm/cpu-x86.64.S @@ -7,6 +7,8 @@ #define CELL_SIZE 8 #define STACK_PADDING 56 +#define NV_TEMP_REG %rbp + #ifdef WINDOWS #define ARG0 %rcx @@ -20,9 +22,11 @@ push %rdi ; \ push %rsi ; \ push %rbx ; \ + push %rbp ; \ push %rbp #define POP_NONVOLATILE \ + pop %rbp ; \ pop %rbp ; \ pop %rbx ; \ pop %rsi ; \ @@ -41,9 +45,11 @@ push %rbx ; \ push %rbp ; \ push %r12 ; \ + push %r13 ; \ push %r13 #define POP_NONVOLATILE \ + pop %r13 ; \ pop %r13 ; \ pop %r12 ; \ pop %rbp ; \ diff --git a/vm/cpu-x86.S b/vm/cpu-x86.S index 3d6cacdebd..1857fb0ed8 100755 --- a/vm/cpu-x86.S +++ b/vm/cpu-x86.S @@ -1,20 +1,21 @@ DEF(F_FASTCALL void,c_to_factor,(CELL quot)): PUSH_NONVOLATILE - push ARG0 - - /* Save stack pointer */ - lea -CELL_SIZE(STACK_REG),ARG0 + mov ARG0,NV_TEMP_REG /* Create register shadow area for Win64 */ - sub $32,STACK_REG + sub $32,STACK_REG + + /* Save stack pointer */ + lea -CELL_SIZE(STACK_REG),ARG0 call MANGLE(save_callstack_bottom) - add $32,STACK_REG /* Call quot-xt */ - mov (STACK_REG),ARG0 + mov NV_TEMP_REG,ARG0 call *QUOT_XT_OFFSET(ARG0) - pop ARG0 + /* Tear down register shadow area */ + add $32,STACK_REG + POP_NONVOLATILE ret