mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-21 18:10:30 +00:00
Fix regression in _gclongjmp()
This commit is contained in:
parent
da45c7c80b
commit
65f32fad52
12 changed files with 225 additions and 25 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
#define INITIAL_CAPACITY 4
|
||||
|
||||
// Invokes deferred function calls.
|
||||
|
@ -44,19 +45,17 @@ __gc: decq __garbage(%rip)
|
|||
// </LIMBO>
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
sub $0x20,%rsp
|
||||
sub $16,%rsp
|
||||
push %rax
|
||||
push %rdx
|
||||
movdqa %xmm0,-0x20(%rbp)
|
||||
movdqa %xmm1,-0x10(%rbp)
|
||||
movdqa %xmm0,-16(%rbp)
|
||||
call *%r9
|
||||
movdqa -0x10(%rbp),%xmm1
|
||||
movdqa -0x20(%rbp),%xmm0
|
||||
movdqa -16(%rbp),%xmm0
|
||||
pop %rdx
|
||||
pop %rax
|
||||
leave
|
||||
ret
|
||||
9: call abort
|
||||
9: hlt
|
||||
.endfn __gc,globl,hidden
|
||||
.source __FILE__
|
||||
|
||||
|
|
|
@ -30,29 +30,27 @@
|
|||
// @see examples/ctrlc.c
|
||||
// @noreturn
|
||||
_gclongjmp:
|
||||
.leafprologue
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
.weak __garbage
|
||||
lea __garbage(%rip),%r12
|
||||
test %r12,%r12
|
||||
mov (%r12),%r13 # garbage.i
|
||||
test %r13,%r13
|
||||
jnz .L.unwind.destructors
|
||||
0: jmp longjmp
|
||||
.L.unwind.destructors:
|
||||
push %rdi
|
||||
push %rsi
|
||||
mov (%r12),%r13 # garbage.i
|
||||
mov 16(%r12),%r14 # garbage.p
|
||||
mov (%rdi),%r15 # jmp_buf[0] is new %rsp
|
||||
shl $5,%r13
|
||||
1: test %r13,%r13
|
||||
jz 2f
|
||||
sub $32,%r13
|
||||
cmp (%r14,%r13),%r15
|
||||
ja 2f
|
||||
mov 8(%r14,%r13),%rax # garbage.p[𝑖].fn
|
||||
shl $5,%r13 # log2(sizeof(struct Garbage))
|
||||
1: sub $32,%r13 # 𝑖--
|
||||
js 2f
|
||||
cmp (%r14,%r13),%r15 # new %rsp > garbage.p[𝑖].frame
|
||||
jbe 2f
|
||||
mov 16(%r14,%r13),%rdi # garbage.p[𝑖].arg
|
||||
call *%rax
|
||||
decq (%r12)
|
||||
callq *8(%r14,%r13) # garbage.p[𝑖].fn
|
||||
decq (%r12) # garbage.i--
|
||||
jmp 1b
|
||||
2: pop %rsi
|
||||
pop %rdi
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
// @assume system five nexgen32e abi conformant
|
||||
// @note code built w/ microsoft abi compiler can't call this
|
||||
// @see _gclongjmp() unwinds _gc() destructors
|
||||
longjmp:mov %esi,%eax
|
||||
longjmp:
|
||||
mov %esi,%eax
|
||||
test %eax,%eax
|
||||
jnz 1f
|
||||
inc %eax
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue