~ chicken-core (chicken-5) e358c8861ef943c26771ae0a8137e6fc02b14a77
commit e358c8861ef943c26771ae0a8137e6fc02b14a77
Author: Peter Bex <peter@more-magic.net>
AuthorDate: Thu Oct 1 17:03:21 2015 +0200
Commit: Evan Hanson <evhan@foldling.org>
CommitDate: Mon Oct 5 09:54:59 2015 +1300
Simplify C_make_structure by using standard save_and_reclaim
This gets rid of the extra make_structure_2 function which doesn't
really add anything except make the code less clear & more confusing.
Signed-off-by: Evan Hanson <evhan@foldling.org>
diff --git a/runtime.c b/runtime.c
index 22648fef..9a8e6b4f 100644
--- a/runtime.c
+++ b/runtime.c
@@ -551,7 +551,6 @@ static C_cpsproc(call_cc_wrapper) C_noret;
static C_cpsproc(call_cc_values_wrapper) C_noret;
static C_cpsproc(gc_2) C_noret;
static C_cpsproc(allocate_vector_2) C_noret;
-static C_cpsproc(make_structure_2) C_noret;
static C_cpsproc(generic_trampoline) C_noret;
static void handle_interrupt(void *trampoline) C_noret;
static C_cpsproc(callback_return_continuation) C_noret;
@@ -11362,31 +11361,22 @@ static void bignum_to_str_2(C_word c, C_word *av)
void C_ccall C_make_structure(C_word c, C_word *av)
-{
- if(!C_demand(c - 1)) {
- assert(C_temporary_stack == C_temporary_stack_bottom);
- C_temporary_stack = C_temporary_stack_bottom - (c - 1);
- C_memmove(C_temporary_stack, av + 1, (c - 1) * sizeof(C_word));
- C_reclaim((void *)make_structure_2, c - 1);
- }
-
- make_structure_2(c - 1, av + 1);
-}
-
-
-void C_ccall make_structure_2(C_word c, C_word *av)
{
C_word
- k = av[ 0 ],
- type = av[ 1 ],
- size = c - 2,
- *a = C_alloc(C_SIZEOF_STRUCTURE(size+1)),
- *s = a,
- s0 = (C_word)s;
+ /* closure = av[ 0 ] */
+ k = av[ 1 ],
+ type = av[ 2 ],
+ size = c - 3,
+ *s, s0;
+ if(!C_demand(size + 2))
+ C_save_and_reclaim((void *)C_make_structure, c, av);
+
+ s = C_alloc(C_SIZEOF_STRUCTURE(size + 1)),
+ s0 = (C_word)s;
*(s++) = C_STRUCTURE_TYPE | (size + 1);
*(s++) = type;
- av += 2;
+ av += 3;
while(size--)
*(s++) = *(av++);
Trap