This commit is contained in:
danyabeerzun 2019-04-24 17:34:53 +03:00
parent 23697829b9
commit 49d86298a1
7 changed files with 73 additions and 1041 deletions

Binary file not shown.

View file

@ -1,394 +0,0 @@
Bsexp: allocate 16!
alloc: current: f7fe9000 16;new current: f7fe9040
Bsexp: allocate 16!
alloc: current: f7fe9040 16;new current: f7fe9080
Bsexp: allocate 16!
alloc: current: f7fe9080 16;new current: f7fe90c0
Bsexp: allocate 16!
alloc: current: f7fe90c0 16;new current: f7fe9100
Bsexp: allocate 16!
alloc: current: f7fe9100 16;new current: f7fe9140
Bsexp: allocate 16!
alloc: current: f7fe9140 16;new current: f7fe9180
Bsexp: allocate 16!
alloc: current: f7fe9180 16;new current: f7fe91c0
Bsexp: allocate 16!
alloc: call gc: 16
HEAP SNAPSHOT
===================
f_begin = 0xf7fe9000, f_end = 0xf7fe9200,
data at 0xf7fe9000(=>0xf7fe9008): SEXP
tag(cons) 4 0
len = 4, new cur = 0xf7fe9040
data at 0xf7fe9040(=>0xf7fe9048): SEXP
tag(cons) 3 0xf7fe9008
len = 4, new cur = 0xf7fe9080
data at 0xf7fe9080(=>0xf7fe9088): SEXP
tag(cons) 2 0xf7fe9048
len = 4, new cur = 0xf7fe90c0
data at 0xf7fe90c0(=>0xf7fe90c8): SEXP
tag(cons) 1 0xf7fe9088
len = 4, new cur = 0xf7fe9100
data at 0xf7fe9100(=>0xf7fe9108): SEXP
tag(cons) 1 0
len = 4, new cur = 0xf7fe9140
data at 0xf7fe9140(=>0xf7fe9148): SEXP
tag(cons) 3 0
len = 4, new cur = 0xf7fe9180
data at 0xf7fe9180(=>0xf7fe9188): SEXP
tag(cons) 2 0xf7fe9148
len = 4, new cur = 0xf7fe91c0
gc: current: f7fbc000; to_space.b = f7fbc000; to_space.e = f7fbc200; f_space.b = f7fe9000; f_space.e = f7fe9200
gc: data is scanned
gc_test_and_copy_root: root ff98e3a0 f7fe9108
gc_copy: f7fe9108 cur = f7fbc000 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9108 (f7fe9100) -> f7fbc008 (f7fbc000); new-current = f7fbc040
gc_test_and_copy_root: root ff98e3a4 f7fe90c8
gc_copy: f7fe90c8 cur = f7fbc040 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9088 cur = f7fbc080 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9048 cur = f7fbc0c0 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9008 cur = f7fbc100 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9008 (f7fe9000) -> f7fbc108 (f7fbc100); new-current = f7fbc140
copy_elements: fix f7fe9048: f7fbc108
gc_copy: f7fe9048 (f7fe9040) -> f7fbc0c8 (f7fbc0c0); new-current = f7fbc140
copy_elements: fix f7fe9088: f7fbc0c8
gc_copy: f7fe9088 (f7fe9080) -> f7fbc088 (f7fbc080); new-current = f7fbc140
copy_elements: fix f7fe90c8: f7fbc088
gc_copy: f7fe90c8 (f7fe90c0) -> f7fbc048 (f7fbc040); new-current = f7fbc140
gc: end: (allocate!) return f7fbc140; from_space.current f7fbc180; from_space.end
gc END
HEAP SNAPSHOT
===================
f_begin = 0xf7fbc000, f_end = 0xf7fbc200,
data at 0xf7fbc000(=>0xf7fbc008): SEXP
tag(cons) 1 0
len = 4, new cur = 0xf7fbc040
data at 0xf7fbc040(=>0xf7fbc048): SEXP
tag(cons) 1 0xf7fbc088
len = 4, new cur = 0xf7fbc080
data at 0xf7fbc080(=>0xf7fbc088): SEXP
tag(cons) 2 0xf7fbc0c8
len = 4, new cur = 0xf7fbc0c0
data at 0xf7fbc0c0(=>0xf7fbc0c8): SEXP
tag(cons) 3 0xf7fbc108
len = 4, new cur = 0xf7fbc100
data at 0xf7fbc100(=>0xf7fbc108): SEXP
tag(cons) 4 0
len = 4, new cur = 0xf7fbc140
data at 0xf7fbc140
printFromSpace: end!
===================
Bsexp: allocate 16!
alloc: current: f7fbc180 16;new current: f7fbc1c0
Bsexp: allocate 16!
alloc: call gc: 16
HEAP SNAPSHOT
===================
f_begin = 0xf7fbc000, f_end = 0xf7fbc200,
data at 0xf7fbc000(=>0xf7fbc008): SEXP
tag(cons) 1 0
len = 4, new cur = 0xf7fbc040
data at 0xf7fbc040(=>0xf7fbc048): SEXP
tag(cons) 1 0xf7fbc088
len = 4, new cur = 0xf7fbc080
data at 0xf7fbc080(=>0xf7fbc088): SEXP
tag(cons) 2 0xf7fbc0c8
len = 4, new cur = 0xf7fbc0c0
data at 0xf7fbc0c0(=>0xf7fbc0c8): SEXP
tag(cons) 3 0xf7fbc108
len = 4, new cur = 0xf7fbc100
data at 0xf7fbc100(=>0xf7fbc108): SEXP
tag(cons) 4 0
len = 4, new cur = 0xf7fbc140
data at 0xf7fbc140(=>0xf7fbc148): SEXP
tag(cons) 6 0
len = 4, new cur = 0xf7fbc180
data at 0xf7fbc180(=>0xf7fbc188): SEXP
tag(cons) 5 0xf7fbc148
len = 4, new cur = 0xf7fbc1c0
gc: current: f7fe9000; to_space.b = f7fe9000; to_space.e = f7fe9200; f_space.b = f7fbc000; f_space.e = f7fbc200
gc: data is scanned
gc_test_and_copy_root: root ff98e394 f7fbc188
gc_copy: f7fbc188 cur = f7fe9000 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fbc148 cur = f7fe9040 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fbc148 (f7fbc140) -> f7fe9048 (f7fe9040); new-current = f7fe9080
copy_elements: fix f7fbc188: f7fe9048
gc_copy: f7fbc188 (f7fbc180) -> f7fe9008 (f7fe9000); new-current = f7fe9080
gc_test_and_copy_root: root ff98e3a0 f7fbc008
gc_copy: f7fbc008 cur = f7fe9080 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fbc008 (f7fbc000) -> f7fe9088 (f7fe9080); new-current = f7fe90c0
gc_test_and_copy_root: root ff98e3a4 f7fbc048
gc_copy: f7fbc048 cur = f7fe90c0 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fbc088 cur = f7fe9100 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fbc0c8 cur = f7fe9140 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fbc108 cur = f7fe9180 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fbc108 (f7fbc100) -> f7fe9188 (f7fe9180); new-current = f7fe91c0
copy_elements: fix f7fbc0c8: f7fe9188
gc_copy: f7fbc0c8 (f7fbc0c0) -> f7fe9148 (f7fe9140); new-current = f7fe91c0
copy_elements: fix f7fbc088: f7fe9148
gc_copy: f7fbc088 (f7fbc080) -> f7fe9108 (f7fe9100); new-current = f7fe91c0
copy_elements: fix f7fbc048: f7fe9108
gc_copy: f7fbc048 (f7fbc040) -> f7fe90c8 (f7fe90c0); new-current = f7fe91c0
gc pre-extend_spaces : f7fe91c0 10 f7fe9200
extend: 0xf7fbc000 0xf7fe9000 0xf7fbc000 0xf7fe9000
extend: 0xf7fbc200 0xf7fe9200 0xf7fe91c0
gc post-extend_spaces: f7fe91c0 10 f7fe9400
gc: end: (allocate!) return f7fe91c0; from_space.current f7fe9200; from_space.end
gc END
HEAP SNAPSHOT
===================
f_begin = 0xf7fe9000, f_end = 0xf7fe9400,
data at 0xf7fe9000(=>0xf7fe9008): SEXP
tag(cons) 5 0xf7fe9048
len = 4, new cur = 0xf7fe9040
data at 0xf7fe9040(=>0xf7fe9048): SEXP
tag(cons) 6 0
len = 4, new cur = 0xf7fe9080
data at 0xf7fe9080(=>0xf7fe9088): SEXP
tag(cons) 1 0
len = 4, new cur = 0xf7fe90c0
data at 0xf7fe90c0(=>0xf7fe90c8): SEXP
tag(cons) 1 0xf7fe9108
len = 4, new cur = 0xf7fe9100
data at 0xf7fe9100(=>0xf7fe9108): SEXP
tag(cons) 2 0xf7fe9148
len = 4, new cur = 0xf7fe9140
data at 0xf7fe9140(=>0xf7fe9148): SEXP
tag(cons) 3 0xf7fe9188
len = 4, new cur = 0xf7fe9180
data at 0xf7fe9180(=>0xf7fe9188): SEXP
tag(cons) 4 0
len = 4, new cur = 0xf7fe91c0
data at 0xf7fe91c0
printFromSpace: end!
===================
Bsexp: allocate 16!
alloc: current: f7fe9200 16;new current: f7fe9240
Bsexp: allocate 16!
alloc: current: f7fe9240 16;new current: f7fe9280
Bsexp: allocate 16!
alloc: current: f7fe9280 16;new current: f7fe92c0
Bsexp: allocate 16!
alloc: current: f7fe92c0 16;new current: f7fe9300
Bsexp: allocate 16!
alloc: current: f7fe9300 16;new current: f7fe9340
Bsexp: allocate 16!
alloc: current: f7fe9340 16;new current: f7fe9380
Bsexp: allocate 16!
alloc: current: f7fe9380 16;new current: f7fe93c0
Bsexp: allocate 16!
alloc: call gc: 16
HEAP SNAPSHOT
===================
f_begin = 0xf7fe9000, f_end = 0xf7fe9400,
data at 0xf7fe9000(=>0xf7fe9008): SEXP
tag(cons) 5 0xf7fe9048
len = 4, new cur = 0xf7fe9040
data at 0xf7fe9040(=>0xf7fe9048): SEXP
tag(cons) 6 0
len = 4, new cur = 0xf7fe9080
data at 0xf7fe9080(=>0xf7fe9088): SEXP
tag(cons) 1 0
len = 4, new cur = 0xf7fe90c0
data at 0xf7fe90c0(=>0xf7fe90c8): SEXP
tag(cons) 1 0xf7fe9108
len = 4, new cur = 0xf7fe9100
data at 0xf7fe9100(=>0xf7fe9108): SEXP
tag(cons) 2 0xf7fe9148
len = 4, new cur = 0xf7fe9140
data at 0xf7fe9140(=>0xf7fe9148): SEXP
tag(cons) 3 0xf7fe9188
len = 4, new cur = 0xf7fe9180
data at 0xf7fe9180(=>0xf7fe9188): SEXP
tag(cons) 4 0
len = 4, new cur = 0xf7fe91c0
data at 0xf7fe91c0(=>0xf7fe91c8): SEXP
tag(cons) 0xf7fe9008 0
len = 4, new cur = 0xf7fe9200
data at 0xf7fe9200(=>0xf7fe9208): SEXP
tag(cons) 4 0xf7fe91c8
len = 4, new cur = 0xf7fe9240
data at 0xf7fe9240(=>0xf7fe9248): SEXP
tag(cons) 0xf7fe9208 0
len = 4, new cur = 0xf7fe9280
data at 0xf7fe9280(=>0xf7fe9288): SEXP
tag(cons) 0xf7fe9188 0xf7fe9248
len = 4, new cur = 0xf7fe92c0
data at 0xf7fe92c0(=>0xf7fe92c8): SEXP
tag(cons) 0xf7fe9088 0xf7fe9288
len = 4, new cur = 0xf7fe9300
data at 0xf7fe9300(=>0xf7fe9308): SEXP
tag(cons) 4 0
len = 4, new cur = 0xf7fe9340
data at 0xf7fe9340(=>0xf7fe9348): SEXP
tag(cons) 3 0xf7fe9308
len = 4, new cur = 0xf7fe9380
data at 0xf7fe9380(=>0xf7fe9388): SEXP
tag(cons) 2 0xf7fe9348
len = 4, new cur = 0xf7fe93c0
gc: current: f7fbc000; to_space.b = f7fbc000; to_space.e = f7fbc400; f_space.b = f7fe9000; f_space.e = f7fe9400
gc: data is scanned
gc_test_and_copy_root: root ff98e398 f7fe9388
gc_copy: f7fe9388 cur = f7fbc000 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9348 cur = f7fbc040 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9308 cur = f7fbc080 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9308 (f7fe9300) -> f7fbc088 (f7fbc080); new-current = f7fbc0c0
copy_elements: fix f7fe9348: f7fbc088
gc_copy: f7fe9348 (f7fe9340) -> f7fbc048 (f7fbc040); new-current = f7fbc0c0
copy_elements: fix f7fe9388: f7fbc048
gc_copy: f7fe9388 (f7fe9380) -> f7fbc008 (f7fbc000); new-current = f7fbc0c0
gc_test_and_copy_root: root ff98e3a0 f7fe92c8
gc_copy: f7fe92c8 cur = f7fbc0c0 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9088 cur = f7fbc100 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9088 (f7fe9080) -> f7fbc108 (f7fbc100); new-current = f7fbc140
copy_elements: fix f7fe92c8: f7fbc108
gc_copy: f7fe9288 cur = f7fbc140 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9188 cur = f7fbc180 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9188 (f7fe9180) -> f7fbc188 (f7fbc180); new-current = f7fbc1c0
copy_elements: fix f7fe9288: f7fbc188
gc_copy: f7fe9248 cur = f7fbc1c0 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9208 cur = f7fbc200 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe91c8 cur = f7fbc240 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9008 cur = f7fbc280 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9048 cur = f7fbc2c0 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9048 (f7fe9040) -> f7fbc2c8 (f7fbc2c0); new-current = f7fbc300
copy_elements: fix f7fe9008: f7fbc2c8
gc_copy: f7fe9008 (f7fe9000) -> f7fbc288 (f7fbc280); new-current = f7fbc300
copy_elements: fix f7fe91c8: f7fbc288
gc_copy: f7fe91c8 (f7fe91c0) -> f7fbc248 (f7fbc240); new-current = f7fbc300
copy_elements: fix f7fe9208: f7fbc248
gc_copy: f7fe9208 (f7fe9200) -> f7fbc208 (f7fbc200); new-current = f7fbc300
copy_elements: fix f7fe9248: f7fbc208
gc_copy: f7fe9248 (f7fe9240) -> f7fbc1c8 (f7fbc1c0); new-current = f7fbc300
copy_elements: fix f7fe9288: f7fbc1c8
gc_copy: f7fe9288 (f7fe9280) -> f7fbc148 (f7fbc140); new-current = f7fbc300
copy_elements: fix f7fe92c8: f7fbc148
gc_copy: f7fe92c8 (f7fe92c0) -> f7fbc0c8 (f7fbc0c0); new-current = f7fbc300
gc_test_and_copy_root: root ff98e3a4 f7fe90c8
gc_copy: f7fe90c8 cur = f7fbc300 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9108 cur = f7fbc340 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9148 cur = f7fbc380 starts
len1 = 2, len2=848787, len3 = 2
gc_copy: f7fe9188 cur = f7fbc3c0 starts
gc_copy: IS_FORWARD_PTR: return! f7fbc188
copy_elements: fix f7fe9148: f7fbc188
gc_copy: f7fe9148 (f7fe9140) -> f7fbc388 (f7fbc380); new-current = f7fbc3c0
copy_elements: fix f7fe9108: f7fbc388
gc_copy: f7fe9108 (f7fe9100) -> f7fbc348 (f7fbc340); new-current = f7fbc3c0
copy_elements: fix f7fe90c8: f7fbc348
gc_copy: f7fe90c8 (f7fe90c0) -> f7fbc308 (f7fbc300); new-current = f7fbc3c0
gc pre-extend_spaces : f7fbc3c0 10 f7fbc400
extend: 0xf7fe9000 0xf7fbc000 0xf7fe9000 0xf7fbc000
extend: 0xf7fe9400 0xf7fbc400 0xf7fbc3c0
gc post-extend_spaces: f7fbc3c0 10 f7fbc800
gc: end: (allocate!) return f7fbc3c0; from_space.current f7fbc400; from_space.end
gc END
HEAP SNAPSHOT
===================
f_begin = 0xf7fbc000, f_end = 0xf7fbc800,
data at 0xf7fbc000(=>0xf7fbc008): SEXP
tag(cons) 2 0xf7fbc048
len = 4, new cur = 0xf7fbc040
data at 0xf7fbc040(=>0xf7fbc048): SEXP
tag(cons) 3 0xf7fbc088
len = 4, new cur = 0xf7fbc080
data at 0xf7fbc080(=>0xf7fbc088): SEXP
tag(cons) 4 0
len = 4, new cur = 0xf7fbc0c0
data at 0xf7fbc0c0(=>0xf7fbc0c8): SEXP
tag(cons) 0xf7fbc108 0xf7fbc148
len = 4, new cur = 0xf7fbc100
data at 0xf7fbc100(=>0xf7fbc108): SEXP
tag(cons) 1 0
len = 4, new cur = 0xf7fbc140
data at 0xf7fbc140(=>0xf7fbc148): SEXP
tag(cons) 0xf7fbc188 0xf7fbc1c8
len = 4, new cur = 0xf7fbc180
data at 0xf7fbc180(=>0xf7fbc188): SEXP
tag(cons) 4 0
len = 4, new cur = 0xf7fbc1c0
data at 0xf7fbc1c0(=>0xf7fbc1c8): SEXP
tag(cons) 0xf7fbc208 0
len = 4, new cur = 0xf7fbc200
data at 0xf7fbc200(=>0xf7fbc208): SEXP
tag(cons) 4 0xf7fbc248
len = 4, new cur = 0xf7fbc240
data at 0xf7fbc240(=>0xf7fbc248): SEXP
tag(cons) 0xf7fbc288 0
len = 4, new cur = 0xf7fbc280
data at 0xf7fbc280(=>0xf7fbc288): SEXP
tag(cons) 5 0xf7fbc2c8
len = 4, new cur = 0xf7fbc2c0
data at 0xf7fbc2c0(=>0xf7fbc2c8): SEXP
tag(cons) 6 0
len = 4, new cur = 0xf7fbc300
data at 0xf7fbc300(=>0xf7fbc308): SEXP
tag(cons) 1 0xf7fbc348
len = 4, new cur = 0xf7fbc340
data at 0xf7fbc340(=>0xf7fbc348): SEXP
tag(cons) 2 0xf7fbc388
len = 4, new cur = 0xf7fbc380
data at 0xf7fbc380(=>0xf7fbc388): SEXP
tag(cons) 3 0xf7fbc188
len = 4, new cur = 0xf7fbc3c0
data at 0xf7fbc3c0
printFromSpace: end!
===================
Barray: create n = 4
alloc: current: f7fbc400 20;new current: f7fbc450
alloc: current: f7fbc450 8;new current: f7fbc470
alloc: current: f7fbc470 6;new current: f7fbc488
0
alloc: current: f7fbc488 8;new current: f7fbc4a8
alloc: current: f7fbc4a8 17;new current: f7fbc4ec
{1, 2, 3, 4}
alloc: current: f7fbc4ec 8;new current: f7fbc50c
alloc: current: f7fbc50c 28;new current: f7fbc57c
{{1}, {4}, {4, {5, 6}}}
alloc: current: f7fbc57c 8;new current: f7fbc59c
alloc: current: f7fbc59c 17;new current: f7fbc5e0
{1, 2, 3, 4}

View file

@ -1,578 +0,0 @@
.data
filler: .fill 6, 4, 1
.globl __gc_data_start
.globl __gc_data_end
__gc_data_start:
global_i: .int 1
global_lists: .int 1
__gc_data_end:
string_0: .string "%s\n"
.text
.globl main
# LABEL ("main") / []
main:
# BEGIN ("main", [], []) / []
pushl %ebp
movl %esp, %ebp
subl $Lmain_SIZE, %esp
movl %esp, %edi
movl $filler, %esi
movl $LSmain_SIZE, %ecx
rep movsl
# CALL ("L__gc_init", 0) / []
call L__gc_init
addl $0, %esp
movl %eax, %ebx
# DROP / [R (0)]
# LDA ("lists") / []
leal global_lists, %ebx
# CONST (0) / [R (0)]
movl $1, %ecx
# CONST (1) / [R (1); R (0)]
movl $3, %esi
# CONST (2) / [R (2); R (1); R (0)]
movl $5, %edi
# CONST (3) / [R (3); R (2); R (1); R (0)]
movl $7, -4(%ebp)
# CONST (4) / [S (0); R (3); R (2); R (1); R (0)]
movl $9, -8(%ebp)
# CONST (0) / [S (1); S (0); R (3); R (2); R (1); R (0)]
movl $1, -12(%ebp)
# SEXP ("cons", 2) / [S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -16(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -16(%ebp)
pushl -12(%ebp)
pushl -8(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -8(%ebp)
# SEXP ("cons", 2) / [S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -12(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -12(%ebp)
pushl -8(%ebp)
pushl -4(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -4(%ebp)
# SEXP ("cons", 2) / [S (0); R (3); R (2); R (1); R (0)]
movl $848787, -8(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl -8(%ebp)
pushl -4(%ebp)
pushl %edi
pushl $3
call Bsexp
addl $16, %esp
popl %esi
popl %ecx
popl %ebx
movl %eax, %edi
# SEXP ("cons", 2) / [R (3); R (2); R (1); R (0)]
movl $848787, -4(%ebp)
pushl %ebx
pushl %ecx
pushl -4(%ebp)
pushl %edi
pushl %esi
pushl $3
call Bsexp
addl $16, %esp
popl %ecx
popl %ebx
movl %eax, %esi
# CONST (1) / [R (2); R (1); R (0)]
movl $3, %edi
# CONST (0) / [R (3); R (2); R (1); R (0)]
movl $1, -4(%ebp)
# SEXP ("cons", 2) / [S (0); R (3); R (2); R (1); R (0)]
movl $848787, -8(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl -8(%ebp)
pushl -4(%ebp)
pushl %edi
pushl $3
call Bsexp
addl $16, %esp
popl %esi
popl %ecx
popl %ebx
movl %eax, %edi
# CONST (2) / [R (3); R (2); R (1); R (0)]
movl $5, -4(%ebp)
# CONST (3) / [S (0); R (3); R (2); R (1); R (0)]
movl $7, -8(%ebp)
# CONST (0) / [S (1); S (0); R (3); R (2); R (1); R (0)]
movl $1, -12(%ebp)
# SEXP ("cons", 2) / [S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -16(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -16(%ebp)
pushl -12(%ebp)
pushl -8(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -8(%ebp)
# SEXP ("cons", 2) / [S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -12(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -12(%ebp)
pushl -8(%ebp)
pushl -4(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -4(%ebp)
# CONST (4) / [S (0); R (3); R (2); R (1); R (0)]
movl $9, -8(%ebp)
# CONST (5) / [S (1); S (0); R (3); R (2); R (1); R (0)]
movl $11, -12(%ebp)
# CONST (6) / [S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $13, -16(%ebp)
# CONST (0) / [S (3); S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $1, -20(%ebp)
# SEXP ("cons", 2) / [S (4); S (3); S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -24(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -24(%ebp)
pushl -20(%ebp)
pushl -16(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -16(%ebp)
# SEXP ("cons", 2) / [S (3); S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -20(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -20(%ebp)
pushl -16(%ebp)
pushl -12(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -12(%ebp)
# CONST (0) / [S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $1, -16(%ebp)
# SEXP ("cons", 2) / [S (3); S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -20(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -20(%ebp)
pushl -16(%ebp)
pushl -12(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -12(%ebp)
# SEXP ("cons", 2) / [S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -16(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -16(%ebp)
pushl -12(%ebp)
pushl -8(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -8(%ebp)
# CONST (0) / [S (1); S (0); R (3); R (2); R (1); R (0)]
movl $1, -12(%ebp)
# SEXP ("cons", 2) / [S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -16(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -16(%ebp)
pushl -12(%ebp)
pushl -8(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -8(%ebp)
# SEXP ("cons", 2) / [S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -12(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -12(%ebp)
pushl -8(%ebp)
pushl -4(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -4(%ebp)
# SEXP ("cons", 2) / [S (0); R (3); R (2); R (1); R (0)]
movl $848787, -8(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl -8(%ebp)
pushl -4(%ebp)
pushl %edi
pushl $3
call Bsexp
addl $16, %esp
popl %esi
popl %ecx
popl %ebx
movl %eax, %edi
# CONST (1) / [R (3); R (2); R (1); R (0)]
movl $3, -4(%ebp)
# CONST (2) / [S (0); R (3); R (2); R (1); R (0)]
movl $5, -8(%ebp)
# CONST (3) / [S (1); S (0); R (3); R (2); R (1); R (0)]
movl $7, -12(%ebp)
# CONST (4) / [S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $9, -16(%ebp)
# CONST (0) / [S (3); S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $1, -20(%ebp)
# SEXP ("cons", 2) / [S (4); S (3); S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -24(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -24(%ebp)
pushl -20(%ebp)
pushl -16(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -16(%ebp)
# SEXP ("cons", 2) / [S (3); S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -20(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -20(%ebp)
pushl -16(%ebp)
pushl -12(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -12(%ebp)
# SEXP ("cons", 2) / [S (2); S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -16(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -16(%ebp)
pushl -12(%ebp)
pushl -8(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -8(%ebp)
# SEXP ("cons", 2) / [S (1); S (0); R (3); R (2); R (1); R (0)]
movl $848787, -12(%ebp)
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
pushl -12(%ebp)
pushl -8(%ebp)
pushl -4(%ebp)
pushl $3
call Bsexp
addl $16, %esp
popl %edi
popl %esi
popl %ecx
popl %ebx
movl %eax, -4(%ebp)
# CALL (".array", 4) / [S (0); R (3); R (2); R (1); R (0)]
pushl %ebx
pushl -4(%ebp)
pushl %edi
pushl %esi
pushl %ecx
pushl $4
call Barray
addl $20, %esp
popl %ebx
movl %eax, %ecx
# STI / [R (1); R (0)]
movl %ecx, %eax
movl %eax, (%ebx)
movl %eax, %ebx
# DROP / [R (0)]
# LDA ("i") / []
leal global_i, %ebx
# CONST (0) / [R (0)]
movl $1, %ecx
# STI / [R (1); R (0)]
movl %ecx, %eax
movl %eax, (%ebx)
movl %eax, %ebx
# DROP / [R (0)]
# JMP ("L55") / []
jmp L55
# LABEL ("L54") / []
L54:
# STRING ("%s\\n") / []
movl $string_0, %ebx
pushl %ebx
call Bstring
addl $4, %esp
movl %eax, %ebx
# LD ("lists") / [R (0)]
movl global_lists, %ecx
# LD ("i") / [R (1); R (0)]
movl global_i, %esi
# CALL (".elem", 2) / [R (2); R (1); R (0)]
pushl %ebx
pushl %esi
pushl %ecx
call Belem
addl $8, %esp
popl %ebx
movl %eax, %ecx
# CALL (".stringval", 1) / [R (1); R (0)]
pushl %ebx
pushl %ecx
call Bstringval
addl $4, %esp
popl %ebx
movl %eax, %ecx
# CALL ("Lprintf", 2) / [R (1); R (0)]
pushl %ecx
pushl %ebx
call Lprintf
addl $8, %esp
movl %eax, %ebx
# DROP / [R (0)]
# LDA ("i") / []
leal global_i, %ebx
# LD ("i") / [R (0)]
movl global_i, %ecx
# CONST (1) / [R (1); R (0)]
movl $3, %esi
# BINOP ("+") / [R (2); R (1); R (0)]
addl %esi, %ecx
decl %ecx
# STI / [R (1); R (0)]
movl %ecx, %eax
movl %eax, (%ebx)
movl %eax, %ebx
# DROP / [R (0)]
# LABEL ("L55") / []
L55:
# LD ("i") / []
movl global_i, %ebx
# LD ("lists") / [R (0)]
movl global_lists, %ecx
# CALL (".length", 1) / [R (1); R (0)]
pushl %ebx
pushl %ecx
call Blength
addl $4, %esp
popl %ebx
movl %eax, %ecx
# BINOP ("<") / [R (1); R (0)]
xorl %eax, %eax
cmpl %ecx, %ebx
setl %al
sall %eax
orl $0x0001, %eax
movl %eax, %ebx
# CJMP ("nz", "L54") / [R (0)]
sarl %ebx
cmpl $0, %ebx
jnz L54
# CONST (0) / []
movl $1, %ebx
# CALL ("Lraw", 1) / [R (0)]
pushl %ebx
call Lraw
addl $4, %esp
movl %eax, %ebx
# RET / [R (0)]
movl %ebx, %eax
jmp Lmain_epilogue
# END / []
Lmain_epilogue:
movl %ebp, %esp
popl %ebp
ret
.set Lmain_SIZE, 24
.set LSmain_SIZE, 6

Binary file not shown.

View file

@ -23,7 +23,7 @@ size_t *current;
/* end */ /* end */
/* GC extern invariant for built-in functions */ /* GC extern invariant for built-in functions */
extern void __pre_gc (); extern void __pre_gc ();
extern void __post_gc (); extern void __post_gc ();
/* end */ /* end */
@ -32,16 +32,16 @@ extern void __post_gc ();
# define SEXP_TAG 0x00000005 # define SEXP_TAG 0x00000005
# define LEN(x) ((x & 0xFFFFFFF8) >> 3) # define LEN(x) ((x & 0xFFFFFFF8) >> 3)
# define TAG(x) (x & 0x00000007) # define TAG(x) (x & 0x00000007)
# define TO_DATA(x) ((data*)((char*)(x)-sizeof(int))) # define TO_DATA(x) ((data*)((char*)(x)-sizeof(int)))
# define TO_SEXP(x) ((sexp*)((char*)(x)-2*sizeof(int))) # define TO_SEXP(x) ((sexp*)((char*)(x)-2*sizeof(int)))
#ifdef DEBUG_PRINT // GET_SEXP_TAG is necessary for printing from space
# define GET_SEXP_TAG(x) (LEN(x))
#endif
//new # define UNBOXED(x) (((int) (x)) & 0x0001)
# define GET_TAG_FROM_SEXP(x) (LEN(x)) # define UNBOX(x) (((int) (x)) >> 1)
# define UNBOXED(x) (((int) (x)) & 0x0001)
# define UNBOX(x) (((int) (x)) >> 1)
# define BOX(x) ((((int) (x)) << 1) | 0x0001) # define BOX(x) ((((int) (x)) << 1) | 0x0001)
typedef struct { typedef struct {
@ -57,7 +57,7 @@ typedef struct {
extern void* alloc (size_t); extern void* alloc (size_t);
extern int Blength (void *p) { extern int Blength (void *p) {
data *a = (char*) BOX (NULL); data *a = (data*) BOX (NULL);
a = TO_DATA(p); a = TO_DATA(p);
return BOX(LEN(a->tag)); return BOX(LEN(a->tag));
} }
@ -65,13 +65,20 @@ extern int Blength (void *p) {
char* de_hash (int n) { char* de_hash (int n) {
static char *chars = (char*) BOX (NULL); static char *chars = (char*) BOX (NULL);
static char buf[6] = {0,0,0,0,0,0}; static char buf[6] = {0,0,0,0,0,0};
char *p = (char*) BOX (NULL); char *p = (char *) BOX (NULL);
chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNJPQRSTUVWXYZ"; chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNJPQRSTUVWXYZ";
p = &buf[5]; p = &buf[5];
#ifdef DEBUG_PRINT
printf ("de_hash: tag: %d\n", n); fflush (stdout);
#endif
*p-- = 0; *p-- = 0;
while (n != 0) { while (n != 0) {
#ifdef DEBUG_PRINT
printf ("char: %c\n", chars [n & 0x003F]); fflush (stdout);
#endif
*p-- = chars [n & 0x003F]; *p-- = chars [n & 0x003F];
n = n >> 6; n = n >> 6;
} }
@ -148,8 +155,11 @@ static void printValue (void *p) {
break; break;
case SEXP_TAG: { case SEXP_TAG: {
// char * tag = de_hash (TO_SEXP(p)->tag); #ifndef DEBUG_PRINT
char * tag = de_hash (GET_TAG_FROM_SEXP(TO_SEXP(p)->tag)); char * tag = de_hash (TO_SEXP(p)->tag);
#else
char * tag = de_hash (GET_SEXP_TAG(TO_SEXP(p)->tag));
#endif
if (strcmp (tag, "cons") == 0) { if (strcmp (tag, "cons") == 0) {
data *b = a; data *b = a;
@ -181,7 +191,7 @@ static void printValue (void *p) {
} }
} }
break; break;
default: default:
printStringBuf ("*** invalid tag: %x ***", TAG(a->tag)); printStringBuf ("*** invalid tag: %x ***", TAG(a->tag));
} }
@ -218,7 +228,7 @@ extern void* Bstring (void *p) {
} }
extern void* Bstringval (void *p) { extern void* Bstringval (void *p) {
void *s = BOX(NULL); void *s = (void *) BOX (NULL);
__pre_gc () ; __pre_gc () ;
@ -243,8 +253,7 @@ extern void* Barray (int n, ...) {
__pre_gc (); __pre_gc ();
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("Barray: create n = %d\n", n); printf ("Barray: create n = %d\n", n); fflush(stdout);
fflush(stdout);
#endif #endif
r = (data*) alloc (sizeof(int) * (n+1)); r = (data*) alloc (sizeof(int) * (n+1));
@ -270,12 +279,12 @@ extern void* Bsexp (int n, ...) {
int ai = BOX(0); int ai = BOX(0);
size_t * p = NULL; size_t * p = NULL;
sexp *r = (sexp*) BOX (NULL); sexp *r = (sexp*) BOX (NULL);
data *d = (sexp*) BOX (NULL); data *d = (data *) BOX (NULL);
__pre_gc () ; __pre_gc () ;
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf("Bsexp: allocate %zu!\n",sizeof(int) * (n+1)); printf("Bsexp: allocate %zu!\n",sizeof(int) * (n+1)); fflush (stdout);
#endif #endif
r = (sexp*) alloc (sizeof(int) * (n+1)); r = (sexp*) alloc (sizeof(int) * (n+1));
d = &(r->contents); d = &(r->contents);
@ -294,9 +303,10 @@ extern void* Bsexp (int n, ...) {
r->tag = va_arg(args, int); r->tag = va_arg(args, int);
// new line (next) #ifdef DEBUG_PRINT
r->tag = SEXP_TAG | ((r->tag) << 3); r->tag = SEXP_TAG | ((r->tag) << 3);
#endif
va_end(args); va_end(args);
__post_gc(); __post_gc();
@ -305,10 +315,14 @@ extern void* Bsexp (int n, ...) {
} }
extern int Btag (void *d, int t, int n) { extern int Btag (void *d, int t, int n) {
data *r = (data*) BOX (NULL); data *r = (data *) BOX (NULL);
r = TO_DATA(d); r = TO_DATA(d);
#ifndef DEBUG_PRINT
return BOX(TAG(r->tag) == SEXP_TAG && TO_SEXP(d)->tag == t && LEN(r->tag) == n);
#else
return BOX(TAG(r->tag) == SEXP_TAG && return BOX(TAG(r->tag) == SEXP_TAG &&
GET_TAG_FROM_SEXP(TO_SEXP(d)->tag) == t && LEN(r->tag) == n); GET_SEXP_TAG(TO_SEXP(d)->tag) == t && LEN(r->tag) == n);
#endif
} }
extern int Barray_patt (void *d, int n) { extern int Barray_patt (void *d, int n) {
@ -490,7 +504,7 @@ static void copy_elements (size_t *where, size_t *from, int len) {
p = gc_copy ((size_t*) elem); p = gc_copy ((size_t*) elem);
*where = p; *where = p;
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("copy_elements: fix %x: %x\n", from, *where); printf ("copy_elements: fix %p: %p\n", from, *where); fflush (stdout);
#endif #endif
where ++; where ++;
} }
@ -528,19 +542,20 @@ extern size_t * gc_copy (size_t *obj) {
int len1, len2, len3; int len1, len2, len3;
void * objj; void * objj;
void * newobjj = (void*)current; void * newobjj = (void*)current;
printf("gc_copy: %x cur = %x starts\n", obj, current); printf ("gc_copy: %p cur = %p starts\n", obj, current);
fflush (stdout);
#endif #endif
if (!IS_VALID_HEAP_POINTER(obj)) { if (!IS_VALID_HEAP_POINTER(obj)) {
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("gc_copy: invalid ptr: %x\n", obj); printf ("gc_copy: invalid ptr: %p\n", obj); fflush (stdout);
#endif #endif
return obj; return obj;
} }
if (!IN_PASSIVE_SPACE(current) && current != to_space.end) { if (!IN_PASSIVE_SPACE(current) && current != to_space.end) {
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf("ERROR: gc_copy: out-of-space %x %x %x\n", current, to_space.begin, to_space.end); printf("ERROR: gc_copy: out-of-space %p %p %p\n", current, to_space.begin, to_space.end);
fflush(stdout); fflush(stdout);
#endif #endif
perror("ERROR: gc_copy: out-of-space\n"); perror("ERROR: gc_copy: out-of-space\n");
@ -549,7 +564,7 @@ extern size_t * gc_copy (size_t *obj) {
if (IS_FORWARD_PTR(d->tag)) { if (IS_FORWARD_PTR(d->tag)) {
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("gc_copy: IS_FORWARD_PTR: return! %x\n", (size_t *) d->tag); printf ("gc_copy: IS_FORWARD_PTR: return! %p\n", (size_t *) d->tag);
fflush(stdout); fflush(stdout);
#endif #endif
return (size_t *) d->tag; return (size_t *) d->tag;
@ -562,8 +577,7 @@ extern size_t * gc_copy (size_t *obj) {
switch (TAG(d->tag)) { switch (TAG(d->tag)) {
case ARRAY_TAG: case ARRAY_TAG:
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("gc_copy:array_tag; len = %zu\n", LEN(d->tag)); printf ("gc_copy:array_tag; len = %zu\n", LEN(d->tag)); fflush (stdout);
fflush(stdout);
#endif #endif
current += (LEN(d->tag) + 1) * sizeof (int); current += (LEN(d->tag) + 1) * sizeof (int);
*copy = d->tag; *copy = d->tag;
@ -575,8 +589,7 @@ extern size_t * gc_copy (size_t *obj) {
case STRING_TAG: case STRING_TAG:
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("gc_copy:string_tag; len = %d\n", LEN(d->tag) + 1); printf ("gc_copy:string_tag; len = %d\n", LEN(d->tag) + 1); fflush (stdout);
fflush(stdout);
#endif #endif
current += LEN(d->tag) * sizeof(char) + sizeof (int); current += LEN(d->tag) * sizeof(char) + sizeof (int);
*copy = d->tag; *copy = d->tag;
@ -592,7 +605,8 @@ extern size_t * gc_copy (size_t *obj) {
len1 = LEN(s->contents.tag); len1 = LEN(s->contents.tag);
len2 = LEN(s->tag); len2 = LEN(s->tag);
len3 = LEN(d->tag); len3 = LEN(d->tag);
printf("len1 = %li, len2=%li, len3 = %li\n",len1,len2,len3); printf ("len1 = %li, len2=%li, len3 = %li\n", len1, len2, len3);
fflush (stdout);
#endif #endif
current += (LEN(s->contents.tag) + 2) * sizeof (int); current += (LEN(s->contents.tag) + 2) * sizeof (int);
*copy = s->tag; *copy = s->tag;
@ -606,14 +620,13 @@ extern size_t * gc_copy (size_t *obj) {
default: default:
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("ERROR: gc_copy: weird tag: %x", TAG(d->tag)); printf ("ERROR: gc_copy: weird tag: %p", TAG(d->tag)); fflush (stdout);
fflush (stdout);
#endif #endif
perror ("ERROR: gc_copy: weird tag"); perror ("ERROR: gc_copy: weird tag");
exit (1); exit (1);
} }
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("gc_copy: %x (%x) -> %x (%x); new-current = %x\n", obj, objj, copy, newobjj, current); printf ("gc_copy: %p(%p) -> %p (%p); new-current = %p\n", obj, objj, copy, newobjj, current);
fflush (stdout); fflush (stdout);
#endif #endif
return copy; return copy;
@ -622,14 +635,10 @@ extern size_t * gc_copy (size_t *obj) {
extern void gc_test_and_copy_root (size_t ** root) { extern void gc_test_and_copy_root (size_t ** root) {
if (IS_VALID_HEAP_POINTER(*root)) { if (IS_VALID_HEAP_POINTER(*root)) {
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("gc_test_and_copy_root: root %p %p\n", root, *root); printf ("gc_test_and_copy_root: root %p %p\n", root, *root); fflush (stdout);
fflush (stdout);
#endif #endif
*root = gc_copy (*root); *root = gc_copy (*root);
} }
/* #ifdef DEBUG_PRINT */
/* else { printf ("gc_test_and_copy_root: NOT A PTR %p %p\n", root, *root); fflush (stdout); } */
/* #endif */
} }
extern void gc_root_scan_data (void) { extern void gc_root_scan_data (void) {
@ -665,27 +674,29 @@ static int free_pool (pool * p) {
static void * gc (size_t size) { static void * gc (size_t size) {
current = to_space.begin; current = to_space.begin;
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf("\ngc: current: %x; to_space.b = %x; to_space.e = %x; f_space.b = %x; f_space.e = %x\n", printf ("\ngc: current:%p; to_space.b =%p; to_space.e =%p; f_space.b = %p; f_space.e = %p\n",
current, to_space.begin, to_space.end, from_space.begin, from_space.end); current, to_space.begin, to_space.end, from_space.begin, from_space.end);
fflush (stdout);
#endif #endif
gc_root_scan_data (); gc_root_scan_data ();
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf("gc: data is scanned\n"); printf ("gc: data is scanned\n"); fflush (stdout);
#endif #endif
__gc_trace_registers ();
__gc_root_scan_stack (); __gc_root_scan_stack ();
if (!IN_PASSIVE_SPACE(current)) { if (!IN_PASSIVE_SPACE(current)) {
perror ("ASSERT: !IN_PASSIVE_SPACE(current)\n"); perror ("ASSERT: !IN_PASSIVE_SPACE(current)\n");
exit (1); exit (1);
} }
while (current + size >= to_space.end) { while (current + size >= to_space.end) {
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("gc pre-extend_spaces : %x %x %x \n", current, size, to_space.end); printf ("gc pre-extend_spaces : %p %zu %p \n", current, size, to_space.end);
fflush (stdout);
#endif #endif
extend_spaces (); extend_spaces ();
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("gc post-extend_spaces: %x %x %x \n", current, size, to_space.end); printf ("gc post-extend_spaces: %p %zu %p \n", current, size, to_space.end);
fflush (stdout);
#endif #endif
} }
assert (IN_PASSIVE_SPACE(current)); assert (IN_PASSIVE_SPACE(current));
@ -694,18 +705,20 @@ static void * gc (size_t size) {
gc_swap_spaces (); gc_swap_spaces ();
from_space.current = current + size; from_space.current = current + size;
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf ("gc: end: (allocate!) return %x; from_space.current %x; from_space.end \n\n", printf ("gc: end: (allocate!) return %p; from_space.current %p; from_space.end %p \n\n",
current, from_space.current, from_space.end); current, from_space.current, from_space.end);
fflush (stdout);
#endif #endif
return (void *) current; return (void *) current;
} }
#ifdef DEBUG_PRINT
static void printFromSpace (void) { static void printFromSpace (void) {
size_t * cur = from_space.begin, *tmp = NULL; size_t * cur = from_space.begin, *tmp = NULL;
data * d = NULL; data * d = NULL;
sexp * s = NULL; sexp * s = NULL;
size_t len = 0; size_t len = 0;
#ifdef DEBUG_PRINT
printf ("\nHEAP SNAPSHOT\n===================\n"); printf ("\nHEAP SNAPSHOT\n===================\n");
printf ("f_begin = %p, f_end = %p,\n", from_space.begin, from_space.end); printf ("f_begin = %p, f_end = %p,\n", from_space.begin, from_space.end);
while (cur < from_space.current) { while (cur < from_space.current) {
@ -736,7 +749,7 @@ static void printFromSpace (void) {
case SEXP_TAG: case SEXP_TAG:
s = (sexp *) d; s = (sexp *) d;
d = (data *) &(s->contents); d = (data *) &(s->contents);
char * tag = de_hash (GET_TAG_FROM_SEXP(s->tag)); char * tag = de_hash (GET_SEXP_TAG(s->tag));
printf ("(=>%p): SEXP\n\ttag(%s) ", s->contents.contents, tag); printf ("(=>%p): SEXP\n\ttag(%s) ", s->contents.contents, tag);
len = LEN(d->tag); len = LEN(d->tag);
tmp = (s->contents.contents); tmp = (s->contents.contents);
@ -762,31 +775,30 @@ static void printFromSpace (void) {
cur += len * sizeof(int); cur += len * sizeof(int);
printf ("len = %zu, new cur = %p\n", len, cur); printf ("len = %zu, new cur = %p\n", len, cur);
} }
#endif
} }
#endif
extern void * alloc (size_t size) { extern void * alloc (size_t size) {
void * p = (void*)BOX(NULL); void * p = (void*)BOX(NULL);
if (from_space.current + size < from_space.end) { if (from_space.current + size < from_space.end) {
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf("alloc: current: %x %zu", from_space.current, size); printf ("alloc: current: %p %zu", from_space.current, size); fflush (stdout);
#endif #endif
p = (void*) from_space.current; p = (void*) from_space.current;
from_space.current += size; from_space.current += size;
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf(";new current: %x \n", from_space.current); printf (";new current: %p \n", from_space.current); fflush (stdout);
#endif #endif
return p; return p;
} }
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf("alloc: call gc: %zu\n", size); printf ("alloc: call gc: %zu\n", size); fflush (stdout);
fflush (stdout); printFromSpace(); fflush (stdout);
#endif #endif
printFromSpace();
p = gc (size); p = gc (size);
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
printf("gc END\n\n"); printf("gc END\n\n"); fflush (stdout);
printFromSpace(); fflush (stdout);
#endif #endif
printFromSpace(); return gc (size);
return p;
} }

View file

@ -1,8 +0,0 @@
Driver.cmo : X86.cmo SM.cmo Language.cmo
Driver.cmx : X86.cmx SM.cmx Language.cmx
Language.cmo :
Language.cmx :
SM.cmo : Language.cmo
SM.cmx : Language.cmx
X86.cmo : SM.cmo Language.cmo
X86.cmx : SM.cmx Language.cmx

Binary file not shown.