JIT: fix problem with arity checking with >= 25 arguments

This commit is contained in:
Matthew Flatt 2014-09-07 18:39:49 -06:00
parent f99d6840a6
commit cddfdca835
2 changed files with 16 additions and 5 deletions

View File

@ -112,6 +112,13 @@
(syntax-test #'(lambda (x . 5) x))
(syntax-test #'(lambda (x) x . 5))
;; 25 is a threshold for non-shared arity-handling code:
(module check-wrong-arity-many-arguments racket/base
((lambda (a b c d e f g h i j k l m n o p q r s t u v w x y)
1)))
(err/rt-test (dynamic-require ''check-wrong-arity-many-arguments #f)
exn:fail:contract:arity?)
(err/rt-test (letrec ([not-ready not-ready]) 5)
(lambda (exn)
(and (exn:fail:contract:variable? exn)

View File

@ -3293,7 +3293,7 @@ static int do_generate_closure(mz_jit_state *jitter, void *_data)
{
Generate_Closure_Data *gdata = (Generate_Closure_Data *)_data;
Scheme_Closure_Data *data = gdata->data;
void *start_code, *tail_code, *code_end, *arity_code;
void *start_code, *tail_code, *code_end, *arity_code, *do_arity_code;
#ifdef NEED_RETAIN_CODE_POINTERS
void *retain_code = NULL;
#endif
@ -3340,10 +3340,7 @@ static int do_generate_closure(mz_jit_state *jitter, void *_data)
arity_code = jit_get_ip();
if (!has_rest)
(void)jit_bnei_i(shared_arity_code, JIT_R1, num_params);
else
(void)jit_blti_i(shared_arity_code, JIT_R1, num_params);
do_arity_code = shared_arity_code;
} else {
arity_code = generate_lambda_simple_arity_check(num_params, has_rest, is_method, 0);
#ifdef NEED_RETAIN_CODE_POINTERS
@ -3352,8 +3349,15 @@ static int do_generate_closure(mz_jit_state *jitter, void *_data)
#endif
arity_code = jit_adjust_ip(arity_code);
CHECK_NESTED_GENERATE();
do_arity_code = arity_code;
}
if (!has_rest)
(void)jit_bnei_i(do_arity_code, JIT_R1, num_params);
else
(void)jit_blti_i(do_arity_code, JIT_R1, num_params);
/* A tail call starts here. Caller must ensure that the stack is big
enough, right number of arguments (at start of runstack), closure
is in R0. If the closure has a rest arg, also ensure argc in R1