[pypy-svn] r61882 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
fijal at codespeak.net
fijal at codespeak.net
Sat Feb 14 14:50:20 CET 2009
Author: fijal
Date: Sat Feb 14 14:50:17 2009
New Revision: 61882
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/specnode.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py
Log:
A bit break everything. Constant folding happening on earlier level
allows us to detect really constant getitem from list, hence virtualizing
it completely. on the other hand, we explode on some bug
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 Sat Feb 14 14:50:17 2009
@@ -53,7 +53,9 @@
assert isinstance(ld, ListDescr)
alloc_offset = len(self.list_allocations)
malloc_func = ld.malloc_func
- assert instnode.known_length != -1
+ if instnode.known_length == -1:
+ # XXX
+ instnode.known_length = 42
self.list_allocations.append((malloc_func,
instnode.known_length))
res = (alloc_offset + 1) << 16
@@ -92,9 +94,9 @@
self.source = source # a Box
self.escaped = escaped
self.startbox = startbox
- self.const = const
self.virtual = False
self.virtualized = False
+ self.const = const
self.cls = None
self.origfields = {}
self.curfields = {}
@@ -182,11 +184,11 @@
def __repr__(self):
flags = ''
- if self.escaped: flags += 'e'
- if self.startbox: flags += 's'
- if self.const: flags += 'c'
- if self.virtual: flags += 'v'
- if self.virtualized: flags += 'V'
+ if self.escaped: flags += 'e'
+ if self.startbox: flags += 's'
+ if self.const: flags += 'c'
+ if self.virtual: flags += 'v'
+ if self.virtualized: flags += 'V'
return "<InstanceNode %s (%s)>" % (self.source, flags)
@@ -232,7 +234,8 @@
return self.nodes[box]
except KeyError:
assert isinstance(box, Const)
- node = self.nodes[box] = InstanceNode(box, escaped=True)
+ node = self.nodes[box] = InstanceNode(box, escaped=True,
+ const=True)
return node
def getsource(self, box):
@@ -307,8 +310,9 @@
elif opname == 'getitem':
instnode = self.getnode(op.args[1])
fieldbox = op.args[2]
- if isinstance(fieldbox, ConstInt):
- field = fieldbox.getint()
+ if (isinstance(fieldbox, ConstInt) or
+ self.nodes[op.args[2]].const):
+ field = self.getsource(fieldbox).getint()
box = op.results[0]
self.find_nodes_getfield(instnode, field, box)
continue
@@ -318,8 +322,9 @@
elif opname == 'setitem':
instnode = self.getnode(op.args[1])
fieldbox = op.args[2]
- if isinstance(fieldbox, ConstInt):
- field = fieldbox.getint()
+ if (isinstance(fieldbox, ConstInt)
+ or self.nodes[op.args[2]].const):
+ field = self.getsource(fieldbox).getint()
self.find_nodes_setfield(instnode, field,
self.getnode(op.args[3]))
continue
@@ -331,6 +336,11 @@
if instnode.cls is None:
instnode.cls = InstanceNode(op.args[1])
continue
+ elif opname == 'guard_value':
+ instnode = self.getnode(op.args[0])
+ assert isinstance(op.args[1], Const)
+ instnode.const = op.args[1]
+ continue
elif opname == 'guard_nonvirtualized':
instnode = self.getnode(op.args[0])
if instnode.startbox:
@@ -338,8 +348,16 @@
if instnode.cls is None:
instnode.cls = InstanceNode(op.args[1])
continue
- elif (opname not in always_pure_operations and
- opname not in operations_without_side_effects):
+ elif opname in always_pure_operations:
+ for arg in op.args:
+ if not self.getnode(arg).const:
+ break
+ else:
+ for box in op.results:
+ self.nodes[box] = InstanceNode(box, escaped=True,
+ const=True)
+ continue
+ elif opname not in operations_without_side_effects:
# default case
self.first_escaping_op = False
for box in op.args:
@@ -515,9 +533,7 @@
continue
elif opname.startswith('guard_'):
if opname == 'guard_true' or opname == 'guard_false':
- # XXX why we need that?
- if (isinstance(self.nodes[op.args[0]].source, Const) or
- self.nodes[op.args[0]].const):
+ if self.nodes[op.args[0]].const:
continue
if (opname == 'guard_no_exception' or
opname == 'guard_exception'):
@@ -525,8 +541,8 @@
continue
exception_might_have_happened = False
if opname == 'guard_value':
- if (isinstance(self.nodes[op.args[0]].source, Const) and
- isinstance(self.nodes[op.args[1]].source, Const)):
+ if (self.nodes[op.args[0]].const and
+ self.nodes[op.args[1]].const):
continue
op = self.optimize_guard(op)
newoperations.append(op)
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/specnode.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/specnode.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/specnode.py Sat Feb 14 14:50:17 2009
@@ -185,7 +185,7 @@
def extract_runtime_data(self, cpu, valuebox, resultlist):
from pypy.jit.metainterp.codewriter import ListDescr
-
+
resultlist.append(valuebox)
ld = self.known_class
assert isinstance(ld, ListDescr)
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py Sat Feb 14 14:50:17 2009
@@ -77,8 +77,7 @@
return interp_without_call(code, inputarg=inputarg)
res = self.meta_interp(main, [1, 6])
- # we could eventually get away without setitems at all I think
- # we're missing once guard_no_exception at the end I think
+ # eventually this loop should become really virtual
self.check_loops({'merge_point':1, 'guard_value':1, 'getitem':2,
'setitem':4, 'guard_no_exception':2, 'int_mul':1,
'int_sub':1, 'int_is_true':1, 'int_le':1,
More information about the Pypy-commit
mailing list