~ chicken-core (chicken-5) eb13513be6fe2a5b20ef1006708bdf4ed00af188
commit eb13513be6fe2a5b20ef1006708bdf4ed00af188
Author: Peter Bex <peter@more-magic.net>
AuthorDate: Sat Aug 22 18:15:00 2015 +0200
Commit: Peter Bex <peter@more-magic.net>
CommitDate: Sat Aug 22 19:37:26 2015 +0200
restore temp-stack after use, and use av where appropriate
Conflicts:
runtime.c
diff --git a/runtime.c b/runtime.c
index ebccddc7..449ad24d 100644
--- a/runtime.c
+++ b/runtime.c
@@ -1498,8 +1498,12 @@ C_word CHICKEN_run(void *toplevel)
serious_signal_occurred = 0;
- if(!return_to_host)
- ((C_proc)C_restart_trampoline)(C_restart_c, C_temporary_stack);
+ if(!return_to_host) {
+ C_word *p = C_temporary_stack;
+
+ C_temporary_stack = C_temporary_stack_bottom;
+ ((C_proc)C_restart_trampoline)(C_restart_c, p);
+ }
chicken_is_running = 0;
return C_restore;
@@ -9835,7 +9839,7 @@ void C_ccall C_gc(C_word c, C_word *av)
k = av[ 1 ];
int f;
C_word
- arg,
+ arg, *p,
size = 0;
if(c == 3) {
@@ -9846,6 +9850,7 @@ void C_ccall C_gc(C_word c, C_word *av)
else f = 1;
C_save(k);
+ p = C_temporary_stack;
if(c == 3) {
if((arg & C_FIXNUM_BIT) != 0) size = C_unfix(arg);
@@ -9854,7 +9859,8 @@ void C_ccall C_gc(C_word c, C_word *av)
if(size && !C_heap_size_is_fixed) {
C_rereclaim2(size, 0);
- gc_2(0, NULL);
+ C_temporary_stack = C_temporary_stack_bottom;
+ gc_2(0, p);
}
else if(f) C_fromspace_top = C_fromspace_limit;
@@ -9864,7 +9870,7 @@ void C_ccall C_gc(C_word c, C_word *av)
void C_ccall gc_2(C_word c, C_word *av)
{
- C_word k = C_restore;
+ C_word k = av[ 0 ];
C_kontinue(k, C_fix((C_uword)C_fromspace_limit - (C_uword)C_fromspace_top));
}
@@ -9922,7 +9928,7 @@ void C_ccall C_allocate_vector(C_word c, C_word *av)
k = av[ 1 ],
size, bvecf, init, align8,
bytes,
- n;
+ n, *p;
if(c != 6) C_bad_argc(c, 6);
@@ -9957,20 +9963,22 @@ void C_ccall C_allocate_vector(C_word c, C_word *av)
}
C_save(C_SCHEME_FALSE);
- allocate_vector_2(0, NULL);
+ p = C_temporary_stack;
+ C_temporary_stack = C_temporary_stack_bottom;
+ allocate_vector_2(0, p);
}
void C_ccall allocate_vector_2(C_word c, C_word *av)
{
C_word
- mode = C_restore,
- bytes = C_unfix(C_restore),
- align8 = C_restore,
- bvecf = C_restore,
- init = C_restore,
- size = C_unfix(C_restore),
- k = C_restore,
+ mode = av[ 0 ],
+ bytes = C_unfix(av[ 1 ]),
+ align8 = av[ 2 ],
+ bvecf = av[ 3 ],
+ init = av[ 4 ],
+ size = C_unfix(av[ 5 ]),
+ k = av[ 6 ],
*v0, v;
if(C_truep(mode)) {
@@ -11344,7 +11352,8 @@ void C_ccall C_make_structure(C_word c, C_word *av)
C_word
/* closure = av[ 0 ] */
k = av[ 1 ],
- type = av[ 2 ];
+ type = av[ 2 ],
+ *p;
int i;
av += 2;
@@ -11357,15 +11366,17 @@ void C_ccall C_make_structure(C_word c, C_word *av)
if(!C_demand(c - 1))
C_reclaim((void *)make_structure_2, c);
- make_structure_2(0, NULL);
+ p = C_temporary_stack;
+ C_temporary_stack = C_temporary_stack_bottom;
+ make_structure_2(0, p);
}
void C_ccall make_structure_2(C_word c, C_word *av)
{
C_word
- k = C_restore,
- type = C_restore,
+ k = av[ 0 ],
+ type = av[ 1 ],
size = c - 2,
*a = C_alloc(C_SIZEOF_STRUCTURE(size+1)),
*s = a,
@@ -11374,9 +11385,10 @@ void C_ccall make_structure_2(C_word c, C_word *av)
*(s++) = C_STRUCTURE_TYPE | (size + 1);
*(s++) = type;
s += size;
+ av += 2;
while(size--)
- *(--s) = C_restore;
+ *(--s) = *(av++);
C_kontinue(k, s0);
}
@@ -11434,20 +11446,23 @@ void C_ccall C_ensure_heap_reserve(C_word c, C_word *av)
C_word
/* closure = av[ 0 ] */
k = av[ 1 ],
- n = av[ 2 ];
+ n = av[ 2 ],
+ *p;
C_save(k);
if(!C_demand(C_bytestowords(C_unfix(n))))
C_reclaim((void *)generic_trampoline, c);
- generic_trampoline(0, NULL);
+ p = C_temporary_stack;
+ C_temporary_stack = C_temporary_stack_bottom;
+ generic_trampoline(0, p);
}
void C_ccall generic_trampoline(C_word c, C_word *av)
{
- C_word k = C_restore;
+ C_word k = av[ 0 ];
C_kontinue(k, C_SCHEME_UNDEFINED);
}
@@ -11825,9 +11840,9 @@ void C_ccall dload_2(C_word c, C_word *av0)
{
void *handle, *p;
C_word
- entry = C_restore,
- name = C_restore,
- k = C_restore,
+ entry = av0[ 0 ],
+ name = av0[ 1 ],
+ k = av0[ 2 ],,
av[ 2 ];
C_char *mname = (C_char *)C_data_pointer(name);
@@ -11877,9 +11892,9 @@ void C_ccall dload_2(C_word c, C_word *av0)
{
void *handle, *p, *p2;
C_word
- entry = C_restore,
- name = C_restore,
- k = C_restore,
+ entry = av0[ 0 ],
+ name = av0[ 1 ],
+ k = av0[ 2 ],
av[ 2 ];
C_char *topname = (C_char *)C_data_pointer(entry);
C_char *mname = (C_char *)C_data_pointer(name);
@@ -11931,9 +11946,9 @@ void C_ccall dload_2(C_word c, C_word *av0)
HINSTANCE handle;
FARPROC p = NULL, p2;
C_word
- entry = C_restore,
- name = C_restore,
- k = C_restore,
+ entry = av0[ 0 ],
+ name = av0[ 1 ],
+ k = av0[ 2 ],
av[ 2 ];
C_char *topname = (C_char *)C_data_pointer(entry);
C_char *mname = (C_char *)C_data_pointer(name);
@@ -12008,7 +12023,7 @@ void C_ccall C_become(C_word c, C_word *av)
void C_ccall become_2(C_word c, C_word *av)
{
- C_word k = C_restore;
+ C_word k = av[ 0 ];
*forwarding_table = 0;
C_kontinue(k, C_SCHEME_UNDEFINED);
@@ -12341,7 +12356,8 @@ void C_ccall C_copy_closure(C_word c, C_word *av)
C_word
/* closure = av[ 0 ] */
k = av[ 1 ],
- proc = av[ 2 ];
+ proc = av[ 2 ],
+ *p;
int n = C_header_size(proc);
if(!C_demand(n + 1))
@@ -12349,7 +12365,9 @@ void C_ccall C_copy_closure(C_word c, C_word *av)
else {
C_save(proc);
C_save(k);
- copy_closure_2(0, NULL);
+ p = C_temporary_stack;
+ C_temporary_stack = C_temporary_stack_bottom;
+ copy_closure_2(0, p);
}
}
@@ -12357,8 +12375,8 @@ void C_ccall C_copy_closure(C_word c, C_word *av)
static void C_ccall copy_closure_2(C_word c, C_word *av)
{
C_word
- k = C_restore,
- proc = C_restore;
+ k = av[ 0 ],
+ proc = av[ 1 ];
int cells = C_header_size(proc);
C_word
*ptr = C_alloc(C_SIZEOF_CLOSURE(cells)),
@@ -12982,7 +13000,7 @@ hdump_count(C_word key, int n, int t)
static void C_ccall dump_heap_state_2(C_word c, C_word *av)
{
- C_word k = C_restore;
+ C_word k = av[ 0 ];
HDUMP_BUCKET *b, *b2, **bp;
int n, bytes;
C_byte *scan;
@@ -13106,10 +13124,11 @@ static void C_ccall dump_heap_state_2(C_word c, C_word *av)
static void C_ccall filter_heap_objects_2(C_word c, C_word *av)
{
- void *func = C_pointer_address(C_restore);
- C_word userarg = C_restore;
- C_word vector = C_restore;
- C_word k = C_restore;
+ void *func = C_pointer_address(av[ 0 ]);
+ C_word
+ userarg = av[ 1 ],
+ vector = av[ 2 ],
+ k = av[ 3 ];
int n, bytes;
C_byte *scan;
C_SCHEME_BLOCK *sbp;
Trap