Index: Corso/Python/ceval.c =================================================================== --- Corso.orig/Python/ceval.c +++ Corso/Python/ceval.c @@ -633,9 +633,19 @@ PyEval_EvalFrameEx(PyFrameObject *f, int /* This macro is used when several opcodes defer to the same implementation (e.g. SETUP_LOOP, SETUP_FINALLY) */ #define TARGET_WITH_IMPL(op, impl) \ - TARGET_##op: goto impl; + TARGET_ ## op: \ + opcode = op; \ + if (HAS_ARG(op)) \ + oparg = NEXTARG(); \ + TARGET_OP_FETCHED_ ## op: \ + goto impl; \ -#define TARGET(op) TARGET_##op: +#define TARGET(op) \ + TARGET_ ## op: \ + opcode = op; \ + if (HAS_ARG(op)) \ + oparg = NEXTARG(); \ + TARGET_OP_FETCHED_ ## op: \ #define DISPATCH() \ { \ @@ -650,13 +660,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int #define FAST_DISPATCH() \ { \ if (!_Py_TracingPossible) { \ - FETCH_NEXT_OPCODE(); \ - goto *opcode_targets[opcode]; \ + f->f_lasti = INSTR_OFFSET(); \ + goto *opcode_targets[*next_instr++]; \ } \ goto fast_next_opcode; \ } -#define SWITCH(op) goto *opcode_targets[op]; +#define SWITCH(op) goto *opcode_op_fetched_targets[op]; #define DEFAULT_TARGET _unknown_opcode #define BREAK() goto on_error Index: Corso/Python/makeopcodetargets.py =================================================================== --- Corso.orig/Python/makeopcodetargets.py +++ Corso/Python/makeopcodetargets.py @@ -18,16 +18,23 @@ def write_contents(f): """Write C code contents to the target file object. """ opcode = find_module("opcode") - targets = ['_unknown_opcode'] * 256 + targets = ['_unknown_opcode'] * 256 + opfetched_targets = ['_unknown_opcode'] * 256 for opname, op in opcode.opmap.items(): if opname == "STOP_CODE": - # XXX opcode not implemented + # This opcode will never appear in the compiler output continue - targets[op] = "TARGET_%s" % opname + targets[op] = "TARGET_%s" % opname + opfetched_targets[op] = "TARGET_OP_FETCHED_%s" % opname + f.write("static void *opcode_targets[256] = {\n") f.write(",\n".join("\t&&%s" % s for s in targets)) f.write("\n};\n") + f.write("static void *opcode_op_fetched_targets[256] = {\n") + f.write(",\n".join("\t&&%s" % s for s in opfetched_targets)) + f.write("\n};\n") + if __name__ == "__main__": import sys