[pypy-svn] r66306 - in pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp: . test
arigo at codespeak.net
arigo at codespeak.net
Fri Jul 17 15:45:06 CEST 2009
Author: arigo
Date: Fri Jul 17 15:45:05 2009
New Revision: 66306
Modified:
pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimize.py
pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimize.py
Log:
Track GUARD_CLASS again.
Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimize.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimize.py (original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimize.py Fri Jul 17 15:45:05 2009
@@ -31,6 +31,8 @@
origfields = None # optimization; equivalent to an empty dict
curfields = None # optimization; equivalent to an empty dict
dependencies = None
+ origclass = False
+ curclass = None
def __init__(self, escaped, fromstart=False):
self.escaped = escaped
@@ -92,7 +94,9 @@
self.getnode(box).mark_escaped()
def find_nodes_NEW_WITH_VTABLE(self, op):
- self.nodes[op.result] = InstanceNode(escaped=False)
+ instnode = InstanceNode(escaped=False)
+ instnode.curclass = op.args[0]
+ self.nodes[op.result] = instnode
def find_nodes_SETFIELD_GC(self, op):
instnode = self.getnode(op.args[0])
@@ -129,7 +133,15 @@
self.find_nodes_GETFIELD_GC(op)
def find_nodes_GUARD_CLASS(self, op):
- pass # prevent the default handling
+ instbox = op.args[0]
+ try:
+ instnode = self.nodes[instbox]
+ except KeyError:
+ instnode = self.nodes[instbox] = InstanceNode(escaped=True)
+ else:
+ if instnode.fromstart:
+ instnode.origclass = True
+ instnode.curclass = op.args[1]
def find_nodes_JUMP(self, op):
pass # prevent the default handling
Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimize.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimize.py (original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimize.py Fri Jul 17 15:45:05 2009
@@ -168,6 +168,22 @@
assert getnode(boxes.p3).fromstart
assert not getnode(boxes.p4).fromstart
+ def test_find_nodes_guard_class(self):
+ ops = """
+ [p1]
+ p2 = getfield_gc(p1, descr=nextdescr)
+ guard_class(p2, ConstClass(node_vtable))
+ fail()
+ jump(p1)
+ """
+ boxes, getnode = self.find_nodes(ops)
+ boxp1 = getnode(boxes.p1)
+ boxp2 = getnode(boxes.p2)
+ assert not boxp1.origclass
+ assert boxp1.curclass is None
+ assert boxp2.origclass
+ assert boxp2.curclass.value == self.node_vtable_adr
+
def test_find_nodes_new(self):
ops = """
[sum, p1]
@@ -199,6 +215,11 @@
assert boxp1.fromstart
assert not boxp2.fromstart
+ assert boxp1.origclass
+ assert boxp1.curclass.value == self.node_vtable_adr
+ assert not boxp2.origclass
+ assert boxp2.curclass.value == self.node_vtable_adr
+
class TestLLtype(BaseTestOptimize, LLtypeMixin):
pass
More information about the Pypy-commit
mailing list