[pypy-svn] r61873 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
fijal at codespeak.net
fijal at codespeak.net
Sat Feb 14 12:44:10 CET 2009
Author: fijal
Date: Sat Feb 14 12:44:08 2009
New Revision: 61873
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_vlist.py
Log:
Introduce a special SpecNode for FixedClassList (unnecessary I think though),
make sure that we reuse instance node when calling new_with_vtable or
newlist
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 12:44:08 2009
@@ -4,6 +4,7 @@
operations_without_side_effects,
operation_never_raises)
from pypy.jit.metainterp.specnode import (FixedClassSpecNode,
+ FixedListSpecNode,
VirtualInstanceSpecNode,
VirtualizableSpecNode,
NotSpecNode,
@@ -130,6 +131,8 @@
not self.expanded_fields):
if self.cls is None:
return NotSpecNode()
+ if isinstance(known_class, ListDescr):
+ return FixedListSpecNode(known_class)
return FixedClassSpecNode(known_class)
if not other.escaped:
fields = []
@@ -304,6 +307,8 @@
box = op.results[0]
self.find_nodes_getfield(instnode, field, box)
continue
+ else:
+ instnode.escaped = True
elif opname == 'setitem':
instnode = self.getnode(op.args[1])
fieldbox = op.args[2]
@@ -312,6 +317,8 @@
self.find_nodes_setfield(instnode, field,
self.getnode(op.args[3]))
continue
+ else:
+ instnode.escaped = True
elif opname == 'guard_class':
instnode = self.getnode(op.args[0])
if instnode.cls is None:
@@ -536,13 +543,18 @@
size = op.args[0].getint()
key = instnode.cls.source.getint()
type_cache.class_size[key] = size
- continue
+ op = self.replace_arguments(op)
+ newoperations.append(op)
+ continue
elif opname == 'newlist':
instnode = self.nodes[op.results[0]]
+ assert isinstance(instnode.cls.source, ListDescr)
if not instnode.escaped:
instnode.virtual = True
assert isinstance(instnode.cls.source, ListDescr)
- continue
+ op = self.replace_arguments(op)
+ newoperations.append(op)
+ continue
elif opname == 'setfield_gc':
instnode = self.nodes[op.args[0]]
valuenode = self.nodes[op.args[2]]
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 12:44:08 2009
@@ -58,6 +58,15 @@
return False
return instnode.cls.source.equals(self.known_class)
+class FixedListSpecNode(FixedClassSpecNode):
+
+ def equals(self, other):
+ if type(other) is not FixedListSpecNode:
+ return False
+ else:
+ assert isinstance(other, FixedListSpecNode) # make annotator happy
+ return self.known_class.equals(other.known_class)
+
class SpecNodeWithFields(FixedClassSpecNode):
def __init__(self, known_class, fields):
FixedClassSpecNode.__init__(self, known_class)
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py Sat Feb 14 12:44:08 2009
@@ -41,6 +41,25 @@
assert res == f(10)
self.check_all_virtualized()
+ def test_cannot_be_virtual(self):
+ jitdriver = JitDriver(greens = [], reds = ['n', 'l'])
+ def f(n):
+ l = [3] * 100
+ while n > 0:
+ jitdriver.can_enter_jit(n=n, l=l)
+ jitdriver.jit_merge_point(n=n, l=l)
+ x = l[n]
+ l = [3] * 100
+ l[3] = x
+ l[3] = x + 1
+ n -= 1
+ return l[0]
+
+ res = self.meta_interp(f, [10])
+ assert res == f(10)
+ # one setitem should be gone by now
+ self.check_loops(newlist=1, setitem=1, getitem=1)
+
def test_append_pop(self):
py.test.skip("XXX")
def f(n):
More information about the Pypy-commit
mailing list