From f7c506471b48dbae676ed149ecb4630426d437e1 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 13 Dec 2011 15:32:22 -0700 Subject: [PATCH] remove redundant arity checking calling JIT-generated code JIT-generated code has arity checking built in, but the interpreter-to-JIT path unnecessarily checked arity before jumping to JITted code. --- src/racket/src/eval.c | 6 ------ src/racket/src/jit.c | 17 ++++++----------- src/racket/src/jitcall.c | 3 ++- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/racket/src/eval.c b/src/racket/src/eval.c index 54b99e9206..71964beb21 100644 --- a/src/racket/src/eval.c +++ b/src/racket/src/eval.c @@ -2763,12 +2763,6 @@ scheme_do_eval(Scheme_Object *obj, int num_rands, Scheme_Object **rands, DO_CHECK_FOR_BREAK(p, ); - if (!scheme_native_arity_check(obj, num_rands)) { - scheme_wrong_count_m((const char *)obj, -1, -1, - num_rands, rands, 0); - return NULL; - } - data = ((Scheme_Native_Closure *)obj)->code; /* Enlarge the runstack? This max_let_depth is in bytes instead of words. */ diff --git a/src/racket/src/jit.c b/src/racket/src/jit.c index 8a9b0e5993..23844c6347 100644 --- a/src/racket/src/jit.c +++ b/src/racket/src/jit.c @@ -3678,14 +3678,11 @@ static int generate_case_lambda_dispatch(mz_jit_state *jitter, Scheme_Case_Lambd if (has_rest && num_params) --num_params; - /* Check for arity match - not needed in getarg mode if this - is the last case, since the arity check as already done. */ - if (!do_getarg || (i < cnt - 1)) { - if (!has_rest) - ref = jit_bnei_i(jit_forward(), JIT_R1, num_params); - else - ref = jit_blti_i(jit_forward(), JIT_R1, num_params); - } + /* Check for arity match. */ + if (!has_rest) + ref = jit_bnei_i(jit_forward(), JIT_R1, num_params); + else + ref = jit_blti_i(jit_forward(), JIT_R1, num_params); /* Function-argument handling for this case: */ if (do_getarg) { @@ -3701,9 +3698,7 @@ static int generate_case_lambda_dispatch(mz_jit_state *jitter, Scheme_Case_Lambd jit_jmpr(JIT_V1); CHECK_LIMIT(); - if (!do_getarg || (i < cnt - 1)) { - mz_patch_branch(ref); - } + mz_patch_branch(ref); /* Try the next one... */ } diff --git a/src/racket/src/jitcall.c b/src/racket/src/jitcall.c index 7f3e475d80..b1b5320308 100644 --- a/src/racket/src/jitcall.c +++ b/src/racket/src/jitcall.c @@ -78,7 +78,8 @@ static jit_insn *generate_proc_struct_retry(mz_jit_state *jitter, int num_rands, CHECK_LIMIT(); /* It's a native closure, but we can't just jump to it, in case - the arity is wrong. */ + the arity is wrong and an error needs to be reported using + the original wrapper. */ mz_prepare(2); jit_movi_i(JIT_R0, num_rands); jit_pusharg_i(JIT_R0); /* argc */