[pypy-svn] r78509 - in pypy/branch/jit-unroll-loops/pypy/jit/metainterp: optimizeopt test
hakanardo at codespeak.net
hakanardo at codespeak.net
Sat Oct 30 12:30:37 CEST 2010
Author: hakanardo
Date: Sat Oct 30 12:30:35 2010
New Revision: 78509
Modified:
pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/heap.py
pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/optimizer.py
pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py
pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
(hakanardo, cfbolz) force lazy setfileds at end of preamble
Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/heap.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/heap.py (original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/heap.py Sat Oct 30 12:30:35 2010
@@ -148,6 +148,10 @@
self.clean_caches()
+ def force_at_end_of_preamble(self):
+ self.force_all_lazy_setfields()
+ self.next_optimization.force_at_end_of_preamble()
+
def force_lazy_setfield(self, descr, before_guard=False):
try:
op = self.lazy_setfields[descr]
Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/optimizer.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/optimizer.py (original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/optimizer.py Sat Oct 30 12:30:35 2010
@@ -150,6 +150,8 @@
oohelper.CVAL_NULLREF = ConstantValue(oohelper.CONST_NULL)
class Optimization(object):
+ next_optimization = None
+
def propagate_forward(self, op):
raise NotImplementedError
@@ -191,6 +193,10 @@
def setup(self, virtuals):
pass
+ def force_at_end_of_preamble(self):
+ if self.next_optimization:
+ self.next_optimization.force_at_end_of_preamble()
+
class Optimizer(Optimization):
def __init__(self, metainterp_sd, loop, optimizations=None, virtuals=True):
Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py (original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py Sat Oct 30 12:30:35 2010
@@ -18,8 +18,9 @@
if not self.enabled:
self.emit_operation(op)
return
-
+
if op.getopnum() == rop.JUMP:
+ self.force_at_end_of_preamble()
loop = self.optimizer.loop
loop.preamble.operations = self.optimizer.newoperations
self.optimizer.newoperations = []
@@ -93,10 +94,13 @@
if not isinstance(a, Const) and a in self.optimizer.values:
v = self.getvalue(a)
if v.fromstart and not v.is_constant():
- a = v.force_box()
- if a not in inputargs:
- inputargs.append(a)
- newval = self.getvalue(argmap[a])
+ b = v.force_box()
+ if b not in inputargs:
+ #boxes = []
+ #v.enum_forced_boxes(boxes, seen_inputargs)
+ #for b in boxes:
+ inputargs.append(b)
+ newval = self.getvalue(argmap[b])
jumpargs.append(newval.force_box())
jmp.initarglist(jumpargs)
Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py (original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py Sat Oct 30 12:30:35 2010
@@ -854,16 +854,20 @@
p3sub = getfield_gc(p3, descr=nextdescr)
i3 = getfield_gc(p3sub, descr=valuedescr)
escape(i3)
- jump(i1, p2)
- """
- expected = """
- [i1, p3]
p2sub = new_with_vtable(ConstClass(node_vtable2))
setfield_gc(p2sub, i1, descr=valuedescr)
- setfield_gc(p3, p2sub, descr=nextdescr)
- escape(i1)
- p4 = new_with_vtable(ConstClass(node_vtable))
- jump(i1, p4)
+ setfield_gc(p2, p2sub, descr=nextdescr)
+ jump(i1, p2, p2sub)
+ """
+ expected = """
+ [i1, p2, p2sub]
+ i3 = getfield_gc(p2sub, descr=valuedescr)
+ escape(i3)
+ p1 = new_with_vtable(ConstClass(node_vtable))
+ p3sub = new_with_vtable(ConstClass(node_vtable2))
+ setfield_gc(p3sub, i1, descr=valuedescr)
+ setfield_gc(p1, p3sub, descr=nextdescr)
+ jump(i1, p1, p3sub)
"""
self.optimize_loop(ops, 'Not, Not, Not', expected, preamble)
More information about the Pypy-commit
mailing list