set the base pointer in vmNativeCall to point to the return address per convention, allowing us to safely walk the stack in Process::getStackTrace

This commit is contained in:
Joel Dice 2008-04-23 15:07:14 -06:00
parent 7e1a2ea876
commit f49174da28

View File

@ -17,13 +17,14 @@
.globl vmNativeCall .globl vmNativeCall
vmNativeCall: vmNativeCall:
pushq %rbp pushq %rbp
movq %rsp,%rbp
// %rdi aka 0(%rbp): function // %rdi aka -48(%rbp): function
// %rsi aka 8(%rbp): stack // %rsi aka -40(%rbp): stack
// %rdx aka 16(%rbp): stackSize // %rdx aka -32(%rbp): stackSize
// %rcx aka 24(%rbp): gprTable // %rcx aka -24(%rbp): gprTable
// %r8 aka 32(%rbp): sseTable // %r8 aka -16(%rbp): sseTable
// %r9 aka 40(%rbp): returnType // %r9 aka -8(%rbp): returnType
// save our argument registers so we can clobber them // save our argument registers so we can clobber them
pushq %r9 pushq %r9
@ -33,8 +34,6 @@ vmNativeCall:
pushq %rsi pushq %rsi
pushq %rdi pushq %rdi
movq %rsp,%rbp
// reserve space for arguments passed via memory // reserve space for arguments passed via memory
subq %rdx,%rsp subq %rdx,%rsp
@ -49,21 +48,21 @@ loop:
movq %rcx,%rax movq %rcx,%rax
movq %rcx,%rdx movq %rcx,%rdx
addq %rsp,%rdx addq %rsp,%rdx
addq 8(%rbp),%rax addq -40(%rbp),%rax
movq (%rax),%rax movq (%rax),%rax
movq %rax,(%rdx) movq %rax,(%rdx)
addq $8,%rcx addq $8,%rcx
test: test:
cmpq 16(%rbp),%rcx cmpq -32(%rbp),%rcx
jb loop jb loop
// do we need to load the general-purpose registers? // do we need to load the general-purpose registers?
cmpq $0,24(%rbp) cmpq $0,-24(%rbp)
je sse je sse
// yes, we do // yes, we do
movq 24(%rbp),%rax movq -24(%rbp),%rax
movq 0(%rax),%rdi movq 0(%rax),%rdi
movq 8(%rax),%rsi movq 8(%rax),%rsi
movq 16(%rax),%rdx movq 16(%rax),%rdx
@ -73,11 +72,11 @@ test:
sse: sse:
// do we need to load the SSE registers? // do we need to load the SSE registers?
cmpq $0,32(%rbp) cmpq $0,-16(%rbp)
je call je call
// yes, we do // yes, we do
movq 32(%rbp),%rax movq -16(%rbp),%rax
movq 0(%rax),%xmm0 movq 0(%rax),%xmm0
movq 8(%rax),%xmm1 movq 8(%rax),%xmm1
movq 16(%rax),%xmm2 movq 16(%rax),%xmm2
@ -88,10 +87,10 @@ sse:
movq 64(%rax),%xmm7 movq 64(%rax),%xmm7
call: call:
call *0(%rbp) call *-48(%rbp)
// handle return value based on expected type // handle return value based on expected type
movq 40(%rbp),%rcx movq -8(%rbp),%rcx
void: void:
cmpq $VOID_TYPE,%rcx cmpq $VOID_TYPE,%rcx
@ -109,10 +108,6 @@ copy:
exit: exit:
movq %rbp,%rsp movq %rbp,%rsp
// pop our argument registers
addq $48,%rsp
popq %rbp popq %rbp
ret ret