diff --git a/src/c/compiler.d b/src/c/compiler.d index fde127f2f..14c6a3355 100644 --- a/src/c/compiler.d +++ b/src/c/compiler.d @@ -1986,6 +1986,28 @@ for special form ~S.", 1, function); */ if (ENV->stepping) asm_op2c(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); + if (f != OBJNULL && type_of(f) == t_cfun) { + cl_object args = ECL_CONS_CDR(stmt); + cl_index n = ecl_length(args); + if (f->cfun.narg == 1 && n == 1) { + compile_form(ECL_CONS_CAR(args), FLAG_REG0); + asm_op2c(OP_CALLG1, function); + new_flags = FLAG_VALUES; + goto OUTPUT; + } else if (f->cfun.narg == 2 && n == 2) { + compile_form(ECL_CONS_CAR(args), FLAG_PUSH); + args = ECL_CONS_CDR(args); + compile_form(ECL_CONS_CAR(args), FLAG_REG0); + asm_op2c(OP_CALLG2, function); + new_flags = FLAG_VALUES; + goto OUTPUT; + } + } + } new_flags = c_call(stmt, flags); OUTPUT: /* diff --git a/src/c/disassembler.d b/src/c/disassembler.d index 57cc6ee48..bcb7f1895 100644 --- a/src/c/disassembler.d +++ b/src/c/disassembler.d @@ -641,6 +641,12 @@ disassemble(cl_object bytecodes, cl_opcode *vector) { case OP_LISTA: string = "LIST*\t"; n = GET_OPARG(bytecodes); goto OPARG; + case OP_CALLG1: string = "CALLG1\t"; + o = GET_DATA(vector, bytecodes); + goto ARG; + case OP_CALLG2: string = "CALLG2\t"; + o = GET_DATA(vector, bytecodes); + goto ARG; default: FEerror("Unknown code ~S", 1, MAKE_FIXNUM(*(vector-1))); diff --git a/src/c/interpreter.d b/src/c/interpreter.d index 135944d34..cebf6cb3e 100644 --- a/src/c/interpreter.d +++ b/src/c/interpreter.d @@ -683,6 +683,18 @@ ecl_interpret(cl_object env, cl_object bytecodes, void *pc) THREAD_NEXT; } + CASE(OP_CALLG1); { + cl_object s = GET_DATA(vector, bytecodes); + reg0 = SYM_FUN(s)->cfun.entry(reg0); + THREAD_NEXT; + } + + CASE(OP_CALLG2); { + cl_object s = GET_DATA(vector, bytecodes); + reg0 = SYM_FUN(s)->cfun.entry(STACK_POP(the_env), reg0); + THREAD_NEXT; + } + /* OP_FCALL n{arg} Calls a function in the stack with N arguments which have been also deposited in the stack. The output values diff --git a/src/h/bytecodes.h b/src/h/bytecodes.h index cee6db284..6bd6761a2 100644 --- a/src/h/bytecodes.h +++ b/src/h/bytecodes.h @@ -139,6 +139,8 @@ enum { OP_PUSHVS, OP_PUSHQ, OP_CALLG, + OP_CALLG1, + OP_CALLG2, OP_CALL, OP_FCALL, OP_PCALLG, @@ -267,6 +269,8 @@ typedef int16_t cl_oparg; &&LBL_OP_PUSHVS - &&LBL_OP_NOP,\ &&LBL_OP_PUSHQ - &&LBL_OP_NOP,\ &&LBL_OP_CALLG - &&LBL_OP_NOP,\ + &&LBL_OP_CALLG1 - &&LBL_OP_NOP,\ + &&LBL_OP_CALLG2 - &&LBL_OP_NOP,\ &&LBL_OP_CALL - &&LBL_OP_NOP,\ &&LBL_OP_FCALL - &&LBL_OP_NOP,\ &&LBL_OP_PCALLG - &&LBL_OP_NOP,\