[pypy-commit] pypy inline-virtualref: hacks so this test will run, it sitll doesn't run

alex_gaynor noreply at buildbot.pypy.org
Sat Jan 19 22:46:30 CET 2013


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: inline-virtualref
Changeset: r60220:12e302fb1c07
Date: 2013-01-19 13:46 -0800
http://bitbucket.org/pypy/pypy/changeset/12e302fb1c07/

Log:	hacks so this test will run, it sitll doesn't run

diff --git a/pypy/jit/metainterp/test/support.py b/pypy/jit/metainterp/test/support.py
--- a/pypy/jit/metainterp/test/support.py
+++ b/pypy/jit/metainterp/test/support.py
@@ -1,5 +1,7 @@
+import sys
 
-import py, sys
+import py
+
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.ootypesystem import ootype
 from pypy.jit.backend.llgraph import runner
@@ -13,10 +15,16 @@
 from pypy.translator.backendopt.all import backend_optimizations
 
 
-def _get_jitcodes(testself, CPUClass, func, values, type_system,
-                  supports_longlong=False, translationoptions={}, **kwds):
+def _get_rtyper(func, values, type_system, translationoptions={}):
     from pypy.jit.codewriter import support
 
+    func._jit_unroll_safe_ = True
+    return support.annotate(func, values, type_system=type_system,
+                            translationoptions=translationoptions)
+
+
+def _get_jitcodes(testself, CPUClass, rtyper, supports_longlong=False,
+                  make_jitcodes=True, **kwds):
     class FakeJitCell(object):
         __product_token = None
         def get_procedure_token(self):
@@ -47,11 +55,7 @@
     if kwds.pop('disable_optimizations', False):
         FakeWarmRunnerState.enable_opts = {}
 
-    func._jit_unroll_safe_ = True
-    rtyper = support.annotate(func, values, type_system=type_system,
-                              translationoptions=translationoptions)
     graphs = rtyper.annotator.translator.graphs
-    testself.all_graphs = graphs
     result_kind = history.getkind(graphs[0].getreturnvar().concretetype)[0]
 
     class FakeJitDriverSD:
@@ -79,8 +83,9 @@
     FakeJitDriverSD.warmstate = testself.warmrunnerstate
     if hasattr(testself, 'finish_setup_for_interp_operations'):
         testself.finish_setup_for_interp_operations()
-    #
-    cw.make_jitcodes(verbose=True)
+
+    if make_jitcodes:
+        cw.make_jitcodes(verbose=True)
 
 def _run_with_blackhole(testself, args):
     from pypy.jit.metainterp.blackhole import BlackholeInterpBuilder
@@ -209,7 +214,8 @@
 
     def interp_operations(self, f, args, **kwds):
         # get the JitCodes for the function f
-        _get_jitcodes(self, self.CPUClass, f, args, self.type_system, **kwds)
+        rtyper = _get_rtyper(f, args, self.type_system)
+        _get_jitcodes(self, self.CPUClass, rtyper, **kwds)
         # try to run it with blackhole.py
         result1 = _run_with_blackhole(self, args)
         # try to run it with pyjitpl.py
diff --git a/pypy/jit/metainterp/test/test_virtualref.py b/pypy/jit/metainterp/test/test_virtualref.py
--- a/pypy/jit/metainterp/test/test_virtualref.py
+++ b/pypy/jit/metainterp/test/test_virtualref.py
@@ -1,11 +1,11 @@
 import py
-from pypy.rpython.lltypesystem import lltype, llmemory, lloperation
+from pypy.rpython.lltypesystem import lltype, lloperation
 from pypy.rpython.exceptiondata import UnknownException
 from pypy.rlib.jit import JitDriver, dont_look_inside, vref_None
 from pypy.rlib.jit import virtual_ref, virtual_ref_finish, InvalidVirtualRef
 from pypy.rlib.jit import non_virtual_ref
 from pypy.rlib.objectmodel import compute_unique_id
-from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin, _get_jitcodes
+from pypy.jit.metainterp.test.support import LLJitMixin, _get_jitcodes, _get_rtyper
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.metainterp.virtualref import VirtualRefInfo
 
@@ -21,21 +21,23 @@
     def test_rewrite_graphs(self):
         class X:
             pass
+
         def fn():
             x = X()
             vref = virtual_ref(x)
             x1 = vref()                  # jit_force_virtual
             virtual_ref_finish(vref, x)
         #
-        _get_jitcodes(self, self.CPUClass, fn, [], self.type_system)
-        graph = self.all_graphs[0]
+        rtyper = _get_rtyper(fn, [], self.type_system)
+        graph = rtyper.annotator.translator.graphs[0]
+        _get_jitcodes(self, self.CPUClass, rtyper, make_jitcodes=False)
+        self.vrefinfo.replace_force_virtual_with_call([graph])
         assert graph.name == 'fn'
-        self.vrefinfo.replace_force_virtual_with_call([graph])
-        #
+
         def check_call(op, fname):
             assert op.opname == 'direct_call'
             assert op.args[0].value._obj._name == fname
-        #
+
         ops = [op for block, op in graph.iterblockops()]
         check_call(ops[-3], 'virtual_ref')
         check_call(ops[-2], 'force_virtual_if_necessary')
diff --git a/pypy/jit/metainterp/virtualref.py b/pypy/jit/metainterp/virtualref.py
--- a/pypy/jit/metainterp/virtualref.py
+++ b/pypy/jit/metainterp/virtualref.py
@@ -1,14 +1,14 @@
 from pypy.annotation import model as annmodel
 from pypy.jit.codewriter import heaptracker
 from pypy.jit.metainterp import history
+from pypy.objspace.flow.model import Constant
 from pypy.rlib.jit import InvalidVirtualRef
 from pypy.rpython.annlowlevel import MixLevelHelperAnnotator
 from pypy.rpython.lltypesystem import lltype, llmemory, rclass
 from pypy.rpython.rmodel import inputconst, log
 
 
-class VirtualRefInfo:
-
+class VirtualRefInfo(object):
     def __init__(self, warmrunnerdesc):
         self.warmrunnerdesc = warmrunnerdesc
         self.cpu = warmrunnerdesc.cpu


More information about the pypy-commit mailing list