[pypy-svn] r77958 - in pypy/branch/jit-unroll-loops/pypy/jit: metainterp/optimizeopt metainterp/test tl
hakanardo at codespeak.net
hakanardo at codespeak.net
Thu Oct 14 21:49:26 CEST 2010
Author: hakanardo
Date: Thu Oct 14 21:49:24 2010
New Revision: 77958
Modified:
pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py
pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py
pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_child.py
pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_demo.py
Log:
Clear all last_guard_index before inlining, support the reording of operations in force_lazy_setfield and allow new inputargs to be added by operations induced by forcing the boxes of the final jump.
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 Thu Oct 14 21:49:24 2010
@@ -39,6 +39,7 @@
argmap[loop_args[i]] = jump_args[i]
for v in self.optimizer.values.values():
+ v.last_guard_index = -1 # FIXME: Are there any more indexes stored?
if not v.is_constant() and v.box:
v.fromstart = True
@@ -72,10 +73,16 @@
args.extend(self.getvalue(arg).get_forced_boxes())
newop.initarglist(args + inputargs[len(args):])
+ #print 'P: ', newop
current = len(self.optimizer.newoperations)
self.emit_operation(newop)
+ # FIXME: force_lazy_setfield in heap.py may reorder last ops
+ if current > 0:
+ current -= 1
+
for op in self.optimizer.newoperations[current:]:
+ #print 'E: ', op, self.optimizer.newoperations.index(op)
if op.is_guard():
descr = op.getdescr()
assert isinstance(descr, ResumeGuardDescr)
@@ -83,13 +90,18 @@
args = op.getarglist()
if op.is_guard():
args = args + op.getfailargs()
+ #if op.getopnum() == rop.SETFIELD_GC:
+ # import pdb; pdb.set_trace()
for a in args:
if not isinstance(a, Const) and a in self.optimizer.values:
v = self.getvalue(a)
if v.fromstart and a not in inputargs:
inputargs.append(a)
- if op.getopnum() == rop.JUMP:
- op.initarglist(op.getarglist() + [argmap[a]])
+ jmp = self.optimizer.newoperations[-1]
+ if jmp.getopnum() == rop.JUMP:
+ newval = self.getvalue(argmap[a])
+ newarg = newval.get_forced_boxes()
+ jmp.initarglist(jmp.getarglist() + newarg)
return inputargs
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 Thu Oct 14 21:49:24 2010
@@ -8,7 +8,7 @@
import pypy.jit.metainterp.optimizeopt.virtualize as virtualize
from pypy.jit.metainterp.optimizeopt import optimize_loop_1
from pypy.jit.metainterp.optimizeutil import InvalidLoop
-from pypy.jit.metainterp.history import AbstractDescr, ConstInt, BoxInt
+from pypy.jit.metainterp.history import AbstractDescr, ConstInt, BoxInt, TreeLoop
from pypy.jit.metainterp.jitprof import EmptyProfiler
from pypy.jit.metainterp import executor, compile, resume, history
from pypy.jit.metainterp.resoperation import rop, opname, ResOperation
@@ -214,6 +214,8 @@
op.setfailargs(boxes)
def __eq__(self, other):
return type(self) is type(other) # xxx obscure
+ def clone_if_mutable(self):
+ return self
def _sortboxes(boxes):
_kind2count = {history.INT: 1, history.REF: 2, history.FLOAT: 3}
@@ -254,12 +256,15 @@
loop.token.specnodes = self.unpack_specnodes(spectext)
#
self.loop = loop
+ loop.preamble = TreeLoop('preamble')
metainterp_sd = FakeMetaInterpStaticData(self.cpu)
if hasattr(self, 'vrefinfo'):
metainterp_sd.virtualref_info = self.vrefinfo
optimize_loop_1(metainterp_sd, loop)
#
expected = self.parse(optops)
+ print
+ print "Ops: "
print '\n'.join([str(o) for o in loop.operations])
self.assert_equal(loop, expected)
@@ -3559,14 +3564,10 @@
jump(p0, i22)
"""
expected = """
- [p0, i22]
- i1 = getfield_gc(p0, descr=valuedescr)
- i2 = int_gt(i1, i22)
- guard_false(i2) []
- i3 = int_add(i1, 1)
+ [p0, i22, i1]
i331 = force_token()
setfield_gc(p0, i1, descr=valuedescr)
- jump(p0, i22)
+ jump(p0, i22, i1)
"""
self.optimize_loop(ops, 'Not, Not', expected)
Modified: pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_child.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_child.py (original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_child.py Thu Oct 14 21:49:24 2010
@@ -2,7 +2,7 @@
from pypy.rpython.lltypesystem import lltype
from pypy.jit.metainterp import warmspot
from pypy.module.pypyjit.policy import PyPyJitPolicy
-from pypy.rlib.jit import OPTIMIZER_FULL
+from pypy.rlib.jit import OPTIMIZER_FULL, OPTIMIZER_NO_PERFECTSPEC
def run_child(glob, loc):
@@ -35,5 +35,5 @@
warmspot.jittify_and_run(interp, graph, [], policy=policy,
listops=True, CPUClass=CPUClass,
backendopt=True, inline=True,
- optimizer=OPTIMIZER_FULL)
+ optimizer=OPTIMIZER_NO_PERFECTSPEC)
Modified: pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_demo.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_demo.py (original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_demo.py Thu Oct 14 21:49:24 2010
@@ -38,25 +38,45 @@
## print t2 - t1
try:
+## from array import array
+
+## def coords(w,h):
+## y = 0
+## while y < h:
+## x = 0
+## while x < w:
+## yield x,y
+## x += 1
+## y += 1
+
+## def f(img):
+## sa=0
+## for x, y in coords(4,4):
+## sa += x * y
+## return sa
+
+## #img=array('h',(1,2,3,4))
+## print f(3)
from array import array
+ class Circular(array):
+ def __new__(cls):
+ self = array.__new__(cls, 'i', range(16))
+ return self
+ def __getitem__(self, i):
+ assert self.__len__() == 16
+ return array.__getitem__(self, i & 15)
- def coords(w,h):
- y = 0
- while y < h:
- x = 0
- while x < w:
- yield x,y
- x += 1
- y += 1
-
- def f(img):
- sa=0
- for x, y in coords(4,4):
- sa += x * y
+ def main():
+ buf = Circular()
+ i = 10
+ sa = 0
+ while i < 20:
+ sa += buf[i-2] + buf[i-1] + buf[i] + buf[i+1] + buf[i+2]
+ i += 1
return sa
- #img=array('h',(1,2,3,4))
- print f(3)
+ print main()
+
except Exception, e:
print "Exception: ", type(e)
print e
More information about the Pypy-commit
mailing list