From 38bbf4323715379caa4089a9abff280e69bbca6e Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Thu, 19 Jun 2008 15:09:12 +0000 Subject: [PATCH] Opcodes for small integers --- src/c/compiler.d | 3 +++ src/c/interpreter.d | 14 ++++++++++++++ src/h/bytecodes.h | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/src/c/compiler.d b/src/c/compiler.d index 049aeef29..211fed814 100644 --- a/src/c/compiler.d +++ b/src/c/compiler.d @@ -1933,8 +1933,11 @@ compile_form(cl_object stmt, int flags) { } else QUOTED: if ((flags & FLAG_USEFUL)) { + cl_fixnum n; if (stmt == Cnil) { asm_op(push? OP_PUSHNIL : OP_NIL); + } else if (FIXNUMP(stmt) && (n = fix(stmt), abs(n)) <= MAX_OPARG) { + asm_op2(push? OP_PINT : OP_INT, n); } else { asm_op2c(push? OP_PUSHQ : OP_QUOTE, stmt); } diff --git a/src/c/interpreter.d b/src/c/interpreter.d index 00be49bc8..18de678b6 100644 --- a/src/c/interpreter.d +++ b/src/c/interpreter.d @@ -593,6 +593,20 @@ ecl_interpret(cl_object frame, cl_object env, cl_object bytecodes, cl_index offs THREAD_NEXT; } + CASE(OP_INT); { + cl_fixnum n; + GET_OPARG(n, vector); + reg0 = MAKE_FIXNUM(n); + THREAD_NEXT; + } + + CASE(OP_PINT); { + cl_fixnum n; + GET_OPARG(n, vector); + STACK_PUSH(the_env, MAKE_FIXNUM(n)); + THREAD_NEXT; + } + /* OP_PUSH Pushes the object in VALUES(0). */ diff --git a/src/h/bytecodes.h b/src/h/bytecodes.h index 82b361a76..6fa7532b1 100644 --- a/src/h/bytecodes.h +++ b/src/h/bytecodes.h @@ -18,6 +18,8 @@ enum { OP_CDR, OP_LIST, OP_LISTA, + OP_INT, + OP_PINT, OP_VAR, OP_VARS, OP_PUSH, @@ -172,6 +174,8 @@ typedef int16_t cl_oparg; &&LBL_OP_CDR - &&LBL_OP_NOP,\ &&LBL_OP_LIST - &&LBL_OP_NOP,\ &&LBL_OP_LISTA - &&LBL_OP_NOP,\ + &&LBL_OP_INT - &&LBL_OP_NOP,\ + &&LBL_OP_PINT - &&LBL_OP_NOP,\ &&LBL_OP_VAR - &&LBL_OP_NOP,\ &&LBL_OP_VARS - &&LBL_OP_NOP,\ &&LBL_OP_PUSH - &&LBL_OP_NOP,\