[Python-checkins] python/dist/src/Python ceval.c, 2.314.2.3,
2.314.2.4 newcompile.c, 1.1.2.86, 1.1.2.87
nascheme at users.sourceforge.net
nascheme at users.sourceforge.net
Fri Mar 26 13:17:34 EST 2004
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22531/Python
Modified Files:
Tag: ast-branch
ceval.c newcompile.c
Log Message:
Change the behavior of the MAKE_CLOSURE opcode. Instead of building a
tuple of free variables internally, the compiler now generates an explict
BUILD_TUPLE instruction.
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.314.2.3
retrieving revision 2.314.2.4
diff -C2 -d -r2.314.2.3 -r2.314.2.4
*** ceval.c 28 Apr 2003 17:17:05 -0000 2.314.2.3
--- ceval.c 26 Mar 2004 18:17:31 -0000 2.314.2.4
***************
*** 2167,2187 ****
case MAKE_CLOSURE:
{
- int nfree;
v = POP(); /* code object */
x = PyFunction_New(v, f->f_globals);
- nfree = PyCode_GetNumFree((PyCodeObject *)v);
Py_DECREF(v);
! /* XXX Maybe this should be a separate opcode? */
! if (x != NULL && nfree > 0) {
! v = PyTuple_New(nfree);
! if (v == NULL) {
! Py_DECREF(x);
! x = NULL;
! break;
! }
! while (--nfree >= 0) {
! w = POP();
! PyTuple_SET_ITEM(v, nfree, w);
! }
err = PyFunction_SetClosure(x, v);
Py_DECREF(v);
--- 2167,2175 ----
case MAKE_CLOSURE:
{
v = POP(); /* code object */
x = PyFunction_New(v, f->f_globals);
Py_DECREF(v);
! if (x != NULL) {
! v = POP();
err = PyFunction_SetClosure(x, v);
Py_DECREF(v);
Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.86
retrieving revision 1.1.2.87
diff -C2 -d -r1.1.2.86 -r1.1.2.87
*** newcompile.c 26 Mar 2004 15:34:10 -0000 1.1.2.86
--- newcompile.c 26 Mar 2004 18:17:31 -0000 1.1.2.87
***************
*** 48,54 ****
opcode_stack_effect() function should be reviewed since stack depth bugs
! could be really hard to find later. Also, the stack effect of
! MAKE_CLOSURE is not accurate. One idea is to have the compiler generate
! an explict BUILD_TUPLE opcode before MAKE_CLOSURE.
Dead code is being generated (i.e. after unconditional jumps).
--- 48,52 ----
opcode_stack_effect() function should be reviewed since stack depth bugs
! could be really hard to find later.
Dead code is being generated (i.e. after unconditional jumps).
***************
*** 773,777 ****
return 0;
case END_FINALLY:
! return -1; /* XXX or -2 or -3 */
case BUILD_CLASS:
return -2;
--- 771,775 ----
return 0;
case END_FINALLY:
! return -1; /* or -2 or -3 if exception occurred */
case BUILD_CLASS:
return -2;
***************
*** 829,833 ****
case SETUP_EXCEPT:
case SETUP_FINALLY:
! return 3; /* XXX isn't this 0? */
case LOAD_FAST:
--- 827,831 ----
case SETUP_EXCEPT:
case SETUP_FINALLY:
! return 3; /* actually pushed by an exception */
case LOAD_FAST:
***************
*** 858,862 ****
case MAKE_CLOSURE:
- /* XXX Also pops free variables to creates a tuple. */
return -oparg;
case LOAD_CLOSURE:
--- 856,859 ----
***************
*** 1181,1184 ****
--- 1178,1182 ----
ADDOP_I(c, LOAD_CLOSURE, arg);
}
+ ADDOP_I(c, BUILD_TUPLE, free);
ADDOP_O(c, LOAD_CONST, (PyObject*)co, consts);
ADDOP_I(c, MAKE_CLOSURE, args);
***************
*** 2679,2682 ****
--- 2677,2681 ----
b->b_seen = 1;
b->b_startdepth = depth;
+ fprintf("block %d\n", block);
for (i = 0; i < b->b_iused; i++) {
instr = &b->b_instr[i];
***************
*** 2685,2688 ****
--- 2684,2688 ----
if (depth > maxdepth)
maxdepth = depth;
+ fprintf(" %s %d\n", opnames[instr->i_opcode], depth);
if (instr->i_jrel || instr->i_jabs) {
maxdepth = stackdepth_walk(c, instr->i_target,
More information about the Python-checkins
mailing list