[pypy-svn] r61858 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
fijal at codespeak.net
fijal at codespeak.net
Fri Feb 13 23:15:48 CET 2009
Author: fijal
Date: Fri Feb 13 23:15:48 2009
New Revision: 61858
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/heaptracker.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize.py
Log:
A bunch of trivial fixes. For example to get rid of guard_no_exception
when they're mutliple. Need more tests though
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/heaptracker.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/heaptracker.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/heaptracker.py Fri Feb 13 23:15:48 2009
@@ -74,15 +74,19 @@
always_pure_operations[_opname] = None
if not _opdesc.sideeffects:
operations_without_side_effects[_opname] = None
+ if not _opdesc.canraise:
+ operation_never_raises[_opname] = None
# XXX fish fish fish
operations_without_side_effects['getfield_gc'] = None
operations_without_side_effects = {}
always_pure_operations = {}
+operation_never_raises = {}
for guard in ['guard_no_exception', 'guard_exception', 'guard_true',
'guard_false', 'guard_value', 'guard_class']:
always_pure_operations[guard] = True
+ operation_never_raises[guard] = True
setup()
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 Fri Feb 13 23:15:48 2009
@@ -1,7 +1,8 @@
from pypy.jit.metainterp.history import (Box, Const, ConstInt, BoxInt,
MergePoint, ResOperation, Jump)
from pypy.jit.metainterp.heaptracker import (always_pure_operations,
- operations_without_side_effects)
+ operations_without_side_effects,
+ operation_never_raises)
from pypy.jit.metainterp.specnode import (FixedClassSpecNode,
VirtualInstanceSpecNode,
VirtualizableSpecNode,
@@ -423,6 +424,7 @@
def optimize_loop(self):
newoperations = []
+ exception_might_have_happened = False
mp = self.loop.operations[0]
if mp.opname == 'merge_point':
assert len(mp.args) == len(self.specnodes)
@@ -469,6 +471,15 @@
if opname == 'guard_true' or opname == 'guard_false':
if self.nodes[op.args[0]].const:
continue
+ if (opname == 'guard_no_exception' or
+ opname == 'guard_exception'):
+ if exception_might_have_happened:
+ continue
+ exception_might_have_happened = False
+ if opname == 'guard_value':
+ if (self.nodes[op.args[0]].const and
+ self.nodes[op.args[1]].const):
+ continue
op = self.optimize_guard(op)
newoperations.append(op)
continue
@@ -537,6 +548,8 @@
continue
elif opname not in operations_without_side_effects:
self.cleanup_field_caches(newoperations)
+ if opname not in operation_never_raises:
+ exception_might_have_happened = True
for box in op.results:
instnode = InstanceNode(box)
self.nodes[box] = instnode
@@ -550,7 +563,8 @@
for node in self.nodes.values():
for ofs, valuenode in node.dirtyfields.items():
# XXX move to IntanceNode eventually
- if isinstance(node.cls.source, ListDescr):
+ if (node.cls is not None and
+ isinstance(node.cls.source, ListDescr)):
newoperations.append(ResOperation('setitem',
[node.cls.source.setfunc, node.source,
ConstInt(ofs), valuenode.source], []))
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py Fri Feb 13 23:15:48 2009
@@ -183,8 +183,8 @@
def builtin_func_for_spec(rtyper, oopspec_name, ll_args, ll_res):
args_s = [annmodel.lltype_to_annotation(v) for v in ll_args]
if '.' not in oopspec_name: # 'newxxx' operations
- LIST_OR_DICT = op.result.concretetype
- bk = self.codewriter.rtyper.annotator.bookkeeper
+ LIST_OR_DICT = ll_res
+ bk = rtyper.annotator.bookkeeper
args_s.insert(0, annmodel.SomePBC([bk.getdesc(LIST_OR_DICT.TO)]))
else:
LIST_OR_DICT = ll_args[0]
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize.py Fri Feb 13 23:15:48 2009
@@ -684,3 +684,32 @@
])
+# ____________________________________________________________
+
+class M:
+ locals().update(A.__dict__) # :-)
+ sum3 = BoxInt(3)
+ v3 = BoxInt(4)
+ ops = [
+ MergePoint('merge_point', [sum, n1], []),
+ ResOperation('guard_class', [n1, ConstAddr(node_vtable, cpu)], []),
+ ResOperation('getfield_gc', [n1, ConstInt(ofs_value)], [v]),
+ ResOperation('int_sub', [v, ConstInt(1)], [v2]),
+ ResOperation('int_add', [sum, v], [sum2]),
+ ResOperation('escape', [n1], []),
+ Jump('jump', [sum2, n1], []),
+ ]
+
+def test_M_optimize_loop():
+ spec = PerfectSpecializer(Loop(M.ops))
+ spec.find_nodes()
+ spec.intersect_input_and_output()
+ spec.optimize_loop()
+ equaloplists(spec.loop.operations, [
+ MergePoint('merge_point', [L.sum, L.n1, L.v], []),
+ ResOperation('int_sub', [L.v, ConstInt(1)], [L.v2]),
+ ResOperation('int_add', [L.sum, L.v], [L.sum2]),
+ ResOperation('escape', [L.n1], []),
+ ResOperation('getfield_gc', [L.n1, ConstInt(L.ofs_value)], [ANY]),
+ Jump('jump', [L.sum2, L.n1, ANY], []),
+ ])
More information about the Pypy-commit
mailing list