[pypy-svn] r66367 - in pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp: . test

arigo at codespeak.net arigo at codespeak.net
Sat Jul 18 19:07:21 CEST 2009


Author: arigo
Date: Sat Jul 18 19:07:20 2009
New Revision: 66367

Modified:
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizefindnode.py
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizefindnode.py
Log:
test_bridge_simple_known_class.


Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizefindnode.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizefindnode.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizefindnode.py	Sat Jul 18 19:07:20 2009
@@ -243,7 +243,8 @@
         instnode.knownclsbox = self.known_class
         return instnode
     def matches_instance_node(self, exitnode):
-        xxx
+        return (exitnode.knownclsbox is not None and
+                self.known_class.equals(exitnode.knownclsbox))
 
 class __extend__(VirtualInstanceSpecNode):
     def make_instance_node(self):
@@ -260,6 +261,11 @@
 
 class BridgeSpecializationFinder(NodeFinder):
 
+    def find_nodes_bridge(self, bridge, specnodes):
+        if specnodes is not None:
+            self.setup_bridge_input_nodes(specnodes, bridge.inputargs)
+        self.find_nodes(bridge.operations)
+
     def setup_bridge_input_nodes(self, specnodes, inputargs):
         assert len(specnodes) == len(inputargs)
         for i in range(len(inputargs)):

Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizefindnode.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizefindnode.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizefindnode.py	Sat Jul 18 19:07:20 2009
@@ -494,9 +494,7 @@
         outputspecnodes = self.unpack_specnodes(outputspectext)
         bridge = self.parse(ops, boxkinds=boxkinds)
         bridge_specialization_finder = BridgeSpecializationFinder()
-        bridge_specialization_finder.setup_bridge_input_nodes(inputspecnodes,
-                                                              bridge.inputargs)
-        bridge_specialization_finder.find_nodes(bridge.operations)
+        bridge_specialization_finder.find_nodes_bridge(bridge, inputspecnodes)
         matches = bridge_specialization_finder.bridge_matches(
             bridge.operations[-1],
             outputspecnodes)
@@ -514,6 +512,20 @@
         self.find_bridge(ops, 'Not', 'Not')
         self.find_bridge(ops, 'Not', 'Virtual(node_vtable)', mismatch=True)
 
+    def test_bridge_simple_known_class(self):
+        ops = """
+        [p0]
+        setfield_gc(p0, 123, descr=valuedescr)
+        jump(p0)
+        """
+        self.find_bridge(ops, 'Not', 'Not')
+        self.find_bridge(ops, 'Fixed(node_vtable)', 'Not')
+        self.find_bridge(ops, 'Fixed(node_vtable)', 'Fixed(node_vtable)')
+        #
+        self.find_bridge(ops, 'Not', 'Fixed(node_vtable)', mismatch=True)
+        self.find_bridge(ops, 'Fixed(node_vtable)', 'Fixed(node_vtable2)',
+                         mismatch=True)
+
 
 class TestLLtype(BaseTestOptimize, LLtypeMixin):
     pass



More information about the Pypy-commit mailing list