From: <zy...@us...> - 2009-03-07 16:00:46
|
Revision: 6082 http://jython.svn.sourceforge.net/jython/?rev=6082&view=rev Author: zyasoft Date: 2009-03-07 16:00:32 +0000 (Sat, 07 Mar 2009) Log Message: ----------- Use a PyList instead to store the block stack for the PBC-VM. Modified Paths: -------------- trunk/jython/src/org/python/core/PyBytecode.java Modified: trunk/jython/src/org/python/core/PyBytecode.java =================================================================== --- trunk/jython/src/org/python/core/PyBytecode.java 2009-03-07 15:57:43 UTC (rev 6081) +++ trunk/jython/src/org/python/core/PyBytecode.java 2009-03-07 16:00:32 UTC (rev 6082) @@ -230,26 +230,24 @@ } } - // the following code exploits the fact that f_exits and f_lineno are only used by code compiled to Java bytecode; + // the following code exploits the fact that f_exits is only used by code compiled to Java bytecode; // in their place we implement the block stack for PBC-VM, as mapped below in the comments of pushBlock private static PyTryBlock popBlock(PyFrame f) { - PyTryBlock block = (PyTryBlock) (f.f_exits[--f.f_lineno]); - f.f_exits[f.f_lineno] = null; // ensure eventual GC of this reference - return block; + return (PyTryBlock)(((PyList)f.f_exits[0]).pop()); } private static void pushBlock(PyFrame f, PyTryBlock block) { if (f.f_exits == null) { // allocate in the frame where they can fit! TODO consider supporting directly in the frame - f.f_exits = new PyObject[CO_MAXBLOCKS]; // f_blockstack in CPython - a simple ArrayList might be best - f.f_lineno = 0; // f_iblock in CPython + f.f_exits = new PyObject[1]; // f_blockstack in CPython - a simple ArrayList might be best + f.f_exits[0] = new PyList(); } - f.f_exits[f.f_lineno++] = block; + ((PyList)f.f_exits[0]).append(block); } private boolean blocksLeft(PyFrame f) { if (f.f_exits != null) { - return f.f_lineno > 0; + return ((PyList)f.f_exits[0]).__nonzero__(); } else { return false; } @@ -1579,6 +1577,7 @@ return lines.get(lo); } + @Override public String toString() { return addr_breakpoints.toString() + ";" + lines.toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |