[pypy-svn] r62544 - pypy/branch/pyjitpl5/pypy/jit/metainterp
fijal at codespeak.net
fijal at codespeak.net
Wed Mar 4 19:36:37 CET 2009
Author: fijal
Date: Wed Mar 4 19:36:35 2009
New Revision: 62544
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/graphpage.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
Log:
Optimization - use _pure versions of operations when possible. optimize.py
gets rid of it if it can prove that args are constant
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/graphpage.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/graphpage.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/graphpage.py Wed Mar 4 19:36:35 2009
@@ -68,10 +68,10 @@
_prev = Box._extended_display
try:
Box._extended_display = False
- #if len(self.graphs) > 1:
- # graphs = self.graphs[1:]
- #else:
- graphs = self.graphs
+ if len(self.graphs) > 1:
+ graphs = self.graphs[1:]
+ else:
+ graphs = self.graphs
for i, graph in enumerate(graphs):
self.gengraph(graph, i)
finally:
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py Wed Mar 4 19:36:35 2009
@@ -304,6 +304,20 @@
if (self.first_escaping_op and instnode.cls):
instnode.expanded_fields[field] = None
+ def find_nodes_getarrayitem(self, op):
+ instnode = self.getnode(op.args[0])
+ if instnode.cls is None:
+ instnode.cls = InstanceNode(FixedList(op.args[1].getint()))
+ fieldbox = op.args[2]
+ if self.getnode(fieldbox).const:
+ item = self.getsource(fieldbox).getint()
+ assert item >= 0 # XXX
+ self.find_nodes_getfield(instnode, item, op.result)
+ else:
+ instnode.escaped = True
+ self.nodes[op.result] = InstanceNode(op.result,
+ escaped=True)
+
## def find_nodes_insert(self, instnode, field, fieldnode):
## for ofs, node in instnode.curfields.items():
## if ofs >= field:
@@ -369,19 +383,13 @@
## instnode.origsize = size
## continue
elif opnum == rop.GETARRAYITEM_GC:
- instnode = self.getnode(op.args[0])
- if instnode.cls is None:
- instnode.cls = InstanceNode(FixedList(op.args[1].getint()))
- fieldbox = op.args[2]
- if self.getnode(fieldbox).const:
- item = self.getsource(fieldbox).getint()
- assert item >= 0 # XXX
- self.find_nodes_getfield(instnode, item, op.result)
- else:
- instnode.escaped = True
- self.nodes[op.result] = InstanceNode(op.result,
- escaped=True)
+ self.find_nodes_getarrayitem(op)
continue
+ elif opnum == rop.GETARRAYITEM_GC_PURE:
+ instnode = self.getnode(op.args[0])
+ if not instnode.const or not self.getnode(op.args[2]).const:
+ self.find_nodes_getarrayitem(op)
+ continue
elif opnum == rop.SETARRAYITEM_GC:
instnode = self.getnode(op.args[0])
if instnode.cls is None:
@@ -413,6 +421,15 @@
box = op.result
self.find_nodes_getfield(instnode, field, box)
continue
+ elif opnum == rop.GETFIELD_GC_PURE:
+ instnode = self.getnode(op.args[0])
+ fieldbox = op.args[1]
+ assert isinstance(fieldbox, ConstInt)
+ field = fieldbox.getint()
+ if not instnode.const:
+ box = op.result
+ self.find_nodes_getfield(instnode, field, box)
+ continue
## elif opname == 'getitem':
## instnode = self.getnode(op.args[1])
## fieldbox = op.args[2]
@@ -767,6 +784,12 @@
continue
# otherwise we need this getfield, but it does not
# invalidate caches
+ elif opnum == rop.GETFIELD_GC_PURE:
+ instnode = self.nodes[op.args[0]]
+ if not instnode.const:
+ ofs = op.args[1].getint()
+ if self.optimize_getfield(instnode, ofs, op.result):
+ continue
elif opnum == rop.GETARRAYITEM_GC:
instnode = self.nodes[op.args[0]]
ofsbox = self.getsource(op.args[2])
@@ -774,6 +797,15 @@
ofs = ofsbox.getint()
if self.optimize_getfield(instnode, ofs, op.result):
continue
+ elif opnum == rop.GETARRAYITEM_GC_PURE:
+ instnode = self.nodes[op.args[0]]
+ ofsbox = self.getsource(op.args[2])
+ if not instnode.const:
+ if isinstance(ofsbox, ConstInt):
+ ofs = ofsbox.getint()
+ if self.optimize_getfield(instnode, ofs, op.result):
+ continue
+
## elif opname == 'getitem':
## instnode = self.nodes[op.args[1]]
## ofsbox = self.getsource(op.args[2])
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py Wed Mar 4 19:36:35 2009
@@ -330,8 +330,8 @@
@arguments("box", "constbox", "box")
def opimpl_getarrayitem_foldable_gc(self, arraybox, arraydesc, indexbox):
tp = self.metainterp.cpu.typefor(arraydesc.getint())
- self.execute(rop.GETARRAYITEM_GC, [arraybox, arraydesc, indexbox], tp,
- True)
+ self.execute(rop.GETARRAYITEM_GC_PURE,
+ [arraybox, arraydesc, indexbox], tp, True)
@arguments("box", "constbox", "box", "box")
def opimpl_setarrayitem_gc(self, arraybox, arraydesc, indexbox, itembox):
@@ -379,7 +379,7 @@
@arguments("box", "constbox")
def opimpl_getfield_pure_gc(self, box, fielddesc):
tp = self.metainterp.cpu.typefor(fielddesc.getint())
- self.execute(rop.GETFIELD_GC, [box, fielddesc], tp, True)
+ self.execute(rop.GETFIELD_GC_PURE, [box, fielddesc], tp, True)
@arguments("box", "constbox", "box")
def opimpl_setfield_gc(self, box, fielddesc, valuebox):
self.execute(rop.SETFIELD_GC, [box, fielddesc, valuebox],
More information about the Pypy-commit
mailing list