Implement bytecodes for calling functions with 1 and 2 arguments.

This commit is contained in:
jjgarcia 2008-06-19 15:06:57 +00:00
parent a2b260c24d
commit 8bdaba7f11
4 changed files with 44 additions and 0 deletions

View file

@ -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:
/*

View file

@ -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)));

View file

@ -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

View file

@ -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,\