diff options
author | Andy Wingo <wingo@pobox.com> | 2010-05-01 00:31:18 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-05-01 00:31:18 +0200 |
commit | 9a974fd38438eee10a2e5389c14129193c833860 (patch) | |
tree | 7c81a896c61ef67e417d9dabe9fba215d1a6ccb0 /libguile/struct.c | |
parent | 52272fc764d0ca3eee00dcf7f1f51734198ad777 (diff) |
optimize and bugfix make-struct VM opcode
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump for make-struct
change.
* libguile/struct.c (scm_i_alloc_struct): Use scm_words instead of
scm_gc_malloc to simplify the code and inline the call to GC_MALLOC.
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Compile
make-struct/no-tail to make-struct.
* module/language/tree-il/primitives.scm (define-primitive-expander):
Allow a conditional branch of #f to aboirt inlining.
(make-struct): Expand into make-struct/no-tail in the case that
tail-size is 0.
* libguile/vm-i-scheme.c (make-struct): Adapt to always assume tail-size
is 0. Inline allocation if possible. Don't decrement the SP past live
objects on the stack, which could cause GC to miss references. Use the
NULLSTACK macro.
Diffstat (limited to 'libguile/struct.c')
-rw-r--r-- | libguile/struct.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/libguile/struct.c b/libguile/struct.c index c28a76d48..5b1213cb2 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -391,11 +391,10 @@ struct_finalizer_trampoline (GC_PTR ptr, GC_PTR unused_data) SCM scm_i_alloc_struct (scm_t_bits *vtable_data, int n_words) { - scm_t_bits ret; - ret = (scm_t_bits)scm_gc_malloc (sizeof (scm_t_bits) * (n_words + 2), "struct"); - SCM_SET_CELL_WORD_0 (SCM_PACK (ret), (scm_t_bits)vtable_data | scm_tc3_struct); - SCM_SET_CELL_WORD_1 (SCM_PACK (ret), - (scm_t_bits)SCM_CELL_OBJECT_LOC (SCM_PACK (ret), 2)); + SCM ret; + + ret = scm_words ((scm_t_bits)vtable_data | scm_tc3_struct, n_words + 2); + SCM_SET_CELL_WORD_1 (ret, (scm_t_bits)SCM_CELL_OBJECT_LOC (ret, 2)); /* vtable_data can be null when making a vtable vtable */ if (vtable_data && vtable_data[scm_vtable_index_instance_finalize]) @@ -403,14 +402,14 @@ scm_i_alloc_struct (scm_t_bits *vtable_data, int n_words) /* Register a finalizer for the newly created instance. */ GC_finalization_proc prev_finalizer; GC_PTR prev_finalizer_data; - GC_REGISTER_FINALIZER_NO_ORDER ((void*)ret, + GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (ret), struct_finalizer_trampoline, NULL, &prev_finalizer, &prev_finalizer_data); } - return SCM_PACK (ret); + return ret; } |