JIT-inline allocation of location for mutated local bindings

This commit is contained in:
Matthew Flatt 2010-08-25 18:22:09 -06:00
parent 8c16b825de
commit f13dcc2915
3 changed files with 51 additions and 8 deletions

View File

@ -1230,6 +1230,23 @@ long GC_initial_word(int request_size)
return w;
}
long GC_array_initial_word(int request_size)
{
long w = 0;
objhead info;
const size_t allocate_size = COMPUTE_ALLOC_SIZE_FOR_OBJECT_SIZE(request_size);
memset(&info, 0, sizeof(objhead));
info.type = PAGE_ARRAY;
info.size = BYTES_MULTIPLE_OF_WORD_TO_WORDS(allocate_size); /* ALIGN_BYTES_SIZE bumped us up to the next word boundary */
memcpy(&w, &info, sizeof(objhead));
return w;
}
long GC_alloc_alignment()
{
return APAGE_SIZE;

View File

@ -1574,6 +1574,7 @@ static void _jit_prolog_again(mz_jit_state *jitter, int n, int ret_addr_reg)
#ifdef CAN_INLINE_ALLOC
THREAD_LOCAL_DECL(extern unsigned long GC_gen0_alloc_page_ptr);
long GC_initial_word(int sizeb);
long GC_array_initial_word(int sizeb);
long GC_compute_alloc_size(long sizeb);
static void *retry_alloc_code;
@ -1673,14 +1674,21 @@ static int inline_alloc(mz_jit_state *jitter, int amt, Scheme_Type ty, int immut
(void)mz_tl_sti_l(tl_GC_gen0_alloc_page_ptr, JIT_R2, JIT_R0);
/* GC header: */
a_word = GC_initial_word(amt);
jit_movi_l(JIT_R2, a_word);
jit_str_l(JIT_V1, JIT_R2);
/* Scheme_Object header: */
a_word = initial_tag_word(ty, immut);
jit_movi_l(JIT_R2, a_word);
jit_stxi_l(sizeof(long), JIT_V1, JIT_R2);
if (ty >= 0) {
a_word = GC_initial_word(amt);
jit_movi_l(JIT_R2, a_word);
jit_str_l(JIT_V1, JIT_R2);
/* Scheme_Object header: */
a_word = initial_tag_word(ty, immut);
jit_movi_l(JIT_R2, a_word);
jit_stxi_l(sizeof(long), JIT_V1, JIT_R2);
} else {
/* an array of pointers */
a_word = GC_array_initial_word(amt);
jit_movi_l(JIT_R2, a_word);
jit_str_l(JIT_V1, JIT_R2);
}
CHECK_LIMIT();
__END_TINY_JUMPS__(1);
@ -9995,11 +10003,19 @@ static int generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int w
pos = mz_remap(SCHEME_INT_VAL(v));
p = SCHEME_CDR(p);
#ifdef CAN_INLINE_ALLOC
inline_alloc(jitter, sizeof(Scheme_Object*), -1, 0, 0, 0, 0);
CHECK_LIMIT();
jit_addi_p(JIT_R0, JIT_V1, OBJHEAD_SIZE);
jit_ldxi_p(JIT_R2, JIT_RUNSTACK, WORDS_TO_BYTES(pos));
jit_str_p(JIT_R0, JIT_R2);
#else
jit_ldxi_p(JIT_R2, JIT_RUNSTACK, WORDS_TO_BYTES(pos));
mz_prepare(1);
jit_pusharg_p(JIT_R2);
(void)mz_finish(ts_scheme_make_envunbox);
jit_retval(JIT_R0);
#endif
jit_stxi_p(WORDS_TO_BYTES(pos), JIT_RUNSTACK, JIT_R0);
CHECK_LIMIT();
@ -10315,11 +10331,19 @@ static int generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int w
JIT_UPDATE_THREAD_RSPTR_IF_NEEDED();
for (i = 0; i < c; i++) {
CHECK_LIMIT();
#ifdef CAN_INLINE_ALLOC
inline_alloc(jitter, sizeof(Scheme_Object*), -1, 0, 0, 0, 0);
CHECK_LIMIT();
jit_addi_p(JIT_R0, JIT_V1, OBJHEAD_SIZE);
(void)jit_movi_p(JIT_R1, scheme_undefined);
jit_str_p(JIT_R0, JIT_R1);
#else
(void)jit_movi_p(JIT_R0, scheme_undefined);
mz_prepare(1);
jit_pusharg_p(JIT_R0);
(void)mz_finish(ts_scheme_make_envunbox);
jit_retval(JIT_R0);
#endif
jit_stxi_p(WORDS_TO_BYTES(i), JIT_RUNSTACK, JIT_R0);
}
}

View File

@ -43,7 +43,9 @@ define_ts_z_p(GC_malloc_one_small_tagged, FSRC_OTHER)
define_ts_n_s(scheme_make_native_closure, FSRC_OTHER)
define_ts_n_s(scheme_make_native_case_closure, FSRC_OTHER)
define_ts_bsi_v(call_set_global_bucket, FSRC_MARKS)
#ifndef CAN_INLINE_ALLOC
define_ts_s_s(scheme_make_envunbox, FSRC_OTHER)
#endif
define_ts_s_s(make_global_ref, FSRC_OTHER)
define_ts_iiS_v(lexical_binding_wrong_return_arity, FSRC_MARKS)
define_ts_iiS_v(call_wrong_return_arity, FSRC_MARKS)