From 2d974ffc2badec265acb0fb8d2ac3c2f4530d4a9 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Tue, 15 Feb 2011 23:39:24 +0000 Subject: [PATCH] The interpreter optimizes FUNCALL acting on known core functions. --- src/c/compiler.d | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/c/compiler.d b/src/c/compiler.d index 596d24910..6aa665b81 100644 --- a/src/c/compiler.d +++ b/src/c/compiler.d @@ -916,6 +916,26 @@ c_call(cl_env_ptr env, cl_object args, int flags) { cl_index nargs; name = pop(&args); + if (name >= (cl_object)cl_symbols + && name < (cl_object)(cl_symbols + cl_num_symbols_in_core)) + { + cl_object f = SYM_FUN(name); + cl_type t = (f == OBJNULL)? t_other : type_of(f); + if (t == t_cfunfixed) { + cl_index n = ecl_length(args); + if (f->cfun.narg == 1 && n == 1) { + compile_form(env, ECL_CONS_CAR(args), FLAG_REG0); + asm_op2c(env, OP_CALLG1, name); + return FLAG_VALUES; + } else if (f->cfun.narg == 2 && n == 2) { + compile_form(env, ECL_CONS_CAR(args), FLAG_PUSH); + args = ECL_CONS_CDR(args); + compile_form(env, ECL_CONS_CAR(args), FLAG_REG0); + asm_op2c(env, OP_CALLG2, name); + return FLAG_VALUES; + } + } + } nargs = c_arguments(env, args); if (env->c_env->stepping) { /* When stepping, we only have one opcode to do function @@ -2177,30 +2197,9 @@ for special form ~S.", 1, function); */ if (c_env->stepping) asm_op2c(env, OP_STEPIN, stmt); - if (function >= (cl_object)cl_symbols - && function < (cl_object)(cl_symbols + cl_num_symbols_in_core)) - { - cl_object f = SYM_FUN(function); - cl_type t = (f == OBJNULL)? t_other : type_of(f); - if (t == t_cfunfixed) { - cl_object args = ECL_CONS_CDR(stmt); - cl_index n = ecl_length(args); - if (f->cfun.narg == 1 && n == 1) { - compile_form(env, ECL_CONS_CAR(args), FLAG_REG0); - asm_op2c(env, OP_CALLG1, function); - new_flags = FLAG_VALUES; - goto OUTPUT; - } else if (f->cfun.narg == 2 && n == 2) { - compile_form(env, ECL_CONS_CAR(args), FLAG_PUSH); - args = ECL_CONS_CDR(args); - compile_form(env, ECL_CONS_CAR(args), FLAG_REG0); - asm_op2c(env, OP_CALLG2, function); - new_flags = FLAG_VALUES; - goto OUTPUT; - } - } - } + c_env->lexical_level++; new_flags = c_call(env, stmt, flags); + c_env->lexical_level--; OUTPUT: /* flags new_flags action