[pypy-commit] pypy inline-virtualref: Begin hacking, doesn't work at all.

alex_gaynor noreply at buildbot.pypy.org
Sat Jan 19 21:26:05 CET 2013


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

Log:	Begin hacking, doesn't work at all.

diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -1745,13 +1745,6 @@
             assert False, 'unsupported oopspec: %s' % oopspec_name
         return self._handle_oopspec_call(op, args, oopspecindex, extraeffect)
 
-    def rewrite_op_jit_force_virtual(self, op):
-        return self._do_builtin_call(op)
-
-    def rewrite_op_jit_is_virtual(self, op):
-        raise Exception, (
-            "'vref.virtual' should not be used from jit-visible code")
-
     def rewrite_op_jit_force_virtualizable(self, op):
         # this one is for virtualizables
         vinfo = self.get_vinfo(op.args[0])
diff --git a/pypy/jit/codewriter/support.py b/pypy/jit/codewriter/support.py
--- a/pypy/jit/codewriter/support.py
+++ b/pypy/jit/codewriter/support.py
@@ -224,9 +224,6 @@
 def _ll_1_gc_id(ptr):
     return llop.gc_id(lltype.Signed, ptr)
 
-def _ll_1_jit_force_virtual(inst):
-    return llop.jit_force_virtual(lltype.typeOf(inst), inst)
-
 
 def _ll_2_int_floordiv_ovf_zer(x, y):
     if y == 0:
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,8 +1,11 @@
+from pypy.annotation import model as annmodel
+from pypy.jit.codewriter import heaptracker
+from pypy.jit.metainterp import history
+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
-from pypy.rpython.lltypesystem import lltype, llmemory, rclass
-from pypy.jit.metainterp import history
-from pypy.jit.codewriter import heaptracker
-from pypy.rlib.jit import InvalidVirtualRef
+
 
 class VirtualRefInfo:
 
@@ -125,30 +128,32 @@
     # ____________________________________________________________
 
     def get_force_virtual_fnptr(self):
-        #
         def force_virtual_if_necessary(inst):
             if not inst or inst.typeptr != self.jit_virtual_ref_vtable:
                 return inst    # common, fast case
             return self.force_virtual(inst)
-        #
+
         FUNC = lltype.FuncType([rclass.OBJECTPTR], rclass.OBJECTPTR)
-        funcptr = self.warmrunnerdesc.helper_func(
-            lltype.Ptr(FUNC),
-            force_virtual_if_necessary)
-        return inputconst(lltype.typeOf(funcptr), funcptr)
+        args_s = [annmodel.lltype_to_annotation(v) for v in FUNC.ARGS]
+        s_result = annmodel.lltype_to_annotation(FUNC.RESULT)
+        mixlevelann = MixLevelHelperAnnotator(self.warmrunnerdesc.rtyper)
+        c_func = mixlevelann.constfunc(force_virtual_if_necessary, args_s, s_result)
+        mixlevelann.finish()
+        return inputconst(lltype.typeOf(c_func.value), c_func.value)
 
     def get_is_virtual_fnptr(self):
-        #
         def is_virtual(inst):
             if not inst:
                 return False
             return inst.typeptr == self.jit_virtual_ref_vtable
-        #
+
         FUNC = lltype.FuncType([rclass.OBJECTPTR], lltype.Bool)
         funcptr = self.warmrunnerdesc.helper_func(lltype.Ptr(FUNC), is_virtual)
         return inputconst(lltype.typeOf(funcptr), funcptr)
 
     def force_virtual(self, inst):
+        from pypy.jit.metainterp.compile import ResumeGuardForcedDescr
+
         vref = lltype.cast_pointer(lltype.Ptr(self.JIT_VIRTUAL_REF), inst)
         token = vref.virtual_token
         if token != self.TOKEN_NONE:
@@ -161,7 +166,6 @@
                 vref.virtual_token = self.TOKEN_NONE
             else:
                 assert not vref.forced
-                from pypy.jit.metainterp.compile import ResumeGuardForcedDescr
                 ResumeGuardForcedDescr.force_now(self.cpu, token)
                 assert vref.virtual_token == self.TOKEN_NONE
                 assert vref.forced
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -218,10 +218,10 @@
 
         verbose = False # not self.cpu.translate_support_code
         self.rewrite_access_helpers()
+        self.rewrite_force_virtual(vrefinfo)
         self.codewriter.make_jitcodes(verbose=verbose)
         self.rewrite_can_enter_jits()
         self.rewrite_set_param_and_get_stats()
-        self.rewrite_force_virtual(vrefinfo)
         self.rewrite_force_quasi_immutable()
         self.add_finish()
         self.metainterp_sd.finish_setup(self.codewriter)


More information about the pypy-commit mailing list