diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/data.s | 60 | ||||
| -rw-r--r-- | include/gc.s | 6 | ||||
| -rw-r--r-- | include/intops.s | 6 | ||||
| -rw-r--r-- | include/io.s | 3 | ||||
| -rw-r--r-- | include/uskel.s | 4 |
5 files changed, 68 insertions, 11 deletions
diff --git a/include/data.s b/include/data.s index 4a827e2..35c4c8d 100644 --- a/include/data.s +++ b/include/data.s @@ -1,7 +1,7 @@ .ifndef _data_s_file _data_s_file: - nop + nop # avoid confusing gdb # Format of the info tables: # - code @@ -64,6 +64,62 @@ IND_info: IND_code: enter 010(%rbp) +# Blackhole (contains the original thunkptr for debugging purposes) +# | ptr | orig_thunkptr | +BLE_evacuate: + jmp _gc_evacuate_ret +BLE_scavenge: + jmp _gc_scavenge_ret + +BLE_info_table: + cell BLE_evacuate + cell BLE_scavenge + cell 0 +BLE_code: + # if we hit this, we've got a pure loop in a program, and it is never + # going to actually progress. So let's just shoot it down with a + # helpful message or so. + mov 010(%rbp), %r15 + + mov $1, %rdi #stdout + + mov $14, %rdx + mov $BLE_msg, %rsi + mov $1, %rax #write + syscall + + mov $1, %rdx + BLE_loop: + mov %r15, %rcx + and $0xf, %rcx + mov $BLE_hex, %rsi + add %rcx, %rsi + mov $1, %rax + syscall + shr $4, %r15 + jnz BLE_loop + + mov $BLE_nl, %rsi + mov $1, %rax + syscall + + # shot self down (and retry if it doesn't succeed) + BLE_retry_sigkill: + mov $39, %rax + syscall # getpid + mov %rax, %rdi + mov $6, %rsi # SIGABRT + mov $62, %rax # kill + syscall + jmp BLE_retry_sigkill + +BLE_msg: + .ascii "diverged at 0x" +BLE_hex: + .ascii "0123456789abcdef" +BLE_nl: + .ascii "\n" + # List # | ptr | 0 | # [] case # | ptr | 1 | a | b | # (a:b) case @@ -86,7 +142,7 @@ LIST_scavenge: cmpq $0, 010(%rbp) je LIST_scavenge_nil mov %rbp, %r15 - + mov $LIST_scavenge1, %rsi mov 020(%r15), %rbp jmp _gc_evacuate diff --git a/include/gc.s b/include/gc.s index ae71d5c..b40ac95 100644 --- a/include/gc.s +++ b/include/gc.s @@ -96,7 +96,7 @@ _uskel_alloc: _uskel_gc_init: mov %rsi, %r13 - movq $0x100, _gc_min_alloc # must be higher than 2x the biggest thunk possible + movq $0x100000, _gc_min_alloc # must be higher than 2x the biggest thunk possible movq $0x180, _gc_grow_ratio movq $0x40, _gc_shrink_ratio mov $0, %rsp # fake original rsp for first alloc run @@ -124,7 +124,7 @@ _uskel_gc: # point the writer to the new memory area mov _write_region_end, %rsp mov %rsp, %r8 # % r8 is the "last thing that was scavenged" - + # start by evacuating the thunk and cont mov _gc_backup_thunk, %rbp mov $_uskel_gc_evacuate_cont_thunk, %rsi @@ -167,7 +167,7 @@ _uskel_gc: mov _gc_region_start, %rdi # addr = gc start sub %rdi, %rsi # len = gc end - gc start syscall - + # recalculate the gc trigger point mov %rsp, %rax sub _write_region_start, %rax diff --git a/include/intops.s b/include/intops.s index dbadb37..08b3300 100644 --- a/include/intops.s +++ b/include/intops.s @@ -5,13 +5,13 @@ _intops_s_file: .include "include/primops.s" .primop2 plus - mov 010(%rsi), %rax # arg 2 + mov 010(%rsi), %rax # arg 2 mov 020(%rbp), %rsi # location of arg1 add 010(%rsi), %rax # arg 1 primop2_ret_int %rax .primop2 mul - mov 010(%rsi), %rax # arg 2 + mov 010(%rsi), %rax # arg 2 mov 020(%rbp), %rsi # location of arg1 mulq 010(%rsi) # arg 1 (goes to %rax and %rdx) primop2_ret_int %rax @@ -19,7 +19,7 @@ _intops_s_file: .primop2 sub mov 020(%rbp), %rdi # location of arg1 mov 010(%rdx), %rax # arg 1 - sub 010(%rsi), %rax # arg 2 + sub 010(%rsi), %rax # arg 2 primop2_ret_int %rax .endif # _intops_s_file diff --git a/include/io.s b/include/io.s index 0431dd0..29a63c9 100644 --- a/include/io.s +++ b/include/io.s @@ -10,6 +10,7 @@ _io_s_file: # arg -> | ret | cont | .thunkcode print_fini + needs_alloc $0110 #64 bit characters + 8 backup mov 010(%rsi), %rax # make a string @@ -25,7 +26,7 @@ _io_s_file: shr $1, %rax jnz print_fini_loop - mov $0, %rdi #stdin + mov $1, %rdi #stdout mov %rsp, %rdx sub %r15, %rdx #size mov %r15, %rsi #buf diff --git a/include/uskel.s b/include/uskel.s index f59a1f7..0a21217 100644 --- a/include/uskel.s +++ b/include/uskel.s @@ -32,10 +32,10 @@ _uskel_start: pushq $0 pushq $main - mov $0, %rsi # set continuation to exit + # loop the continuation to itself (prevents gc trouble, should never be reached) + mov %rsp, %rsi enter %rsp # run the program # Q: are there gonna be functions that have both the argument AND the cont? - # # A: No, stuff is either entered as return-continuation (takes res, # cont has to be saved) or as forward call (takes cont) # |
