[pypy-svn] r64113 - in pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp: . test

antocuni at codespeak.net antocuni at codespeak.net
Wed Apr 15 19:36:29 CEST 2009


Author: antocuni
Date: Wed Apr 15 19:36:27 2009
New Revision: 64113

Added:
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py
      - copied, changed from r61964, pypy/branch/oo-jit/pypy/jit/rainbow/typesystem.py
Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py
Log:
introduce a "typesystem helper" class to smooth the differences between lltype
and ootype.  A bunch of tests now pass again



Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py	Wed Apr 15 19:36:27 2009
@@ -520,12 +520,6 @@
     test_oops_on_nongc = skip
     test_instantiate_classes = skip
 
-    test_loop = skip
-    test_we_are_jitted = skip
-    test_r_uint = skip
-    test_mod_ovf = skip
-    test_bridge_from_interpreter = skip
-
     test_constant_across_mp = skip
     test_stopatxpolicy = skip
     test_print = skip

Copied: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py (from r61964, pypy/branch/oo-jit/pypy/jit/rainbow/typesystem.py)
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/typesystem.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py	Wed Apr 15 19:36:27 2009
@@ -1,6 +1,6 @@
-from pypy.rpython.annlowlevel import base_ptr_lltype, base_obj_ootype
-from pypy.rpython.annlowlevel import cast_instance_to_base_ptr
-from pypy.rpython.annlowlevel import cast_instance_to_base_obj
+#from pypy.rpython.annlowlevel import base_ptr_lltype, base_obj_ootype
+#from pypy.rpython.annlowlevel import cast_instance_to_base_ptr
+#from pypy.rpython.annlowlevel import cast_instance_to_base_obj
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.ootypesystem import ootype
 
@@ -14,9 +14,9 @@
     if isinstance(T, lltype.Struct):
         return getattr(T, name)
     elif isinstance(T, (ootype.Instance, ootype.Record)):
-        if name == '__class__':
-            # XXX hack hack hack
-            return ootype.Class
+##         if name == '__class__':
+##             # XXX hack hack hack
+##             return ootype.Class
         _, FIELD = T._lookup_field(name)
         return FIELD
     else:
@@ -30,73 +30,32 @@
 class LLTypeHelper(TypeSystemHelper):
 
     name = 'lltype'
-    ROOT_TYPE = llmemory.Address
-    BASE_OBJ_TYPE = base_ptr_lltype()
-    NULL_OBJECT = base_ptr_lltype()._defl()
-    cast_instance_to_base_ptr = staticmethod(cast_instance_to_base_ptr)
+    functionptr = staticmethod(lltype.functionptr)
+    #ROOT_TYPE = llmemory.Address
+    #BASE_OBJ_TYPE = base_ptr_lltype()
+    #NULL_OBJECT = base_ptr_lltype()._defl()
+    #cast_instance_to_base_ptr = staticmethod(cast_instance_to_base_ptr)
 
     def get_typeptr(self, obj):
         return obj.typeptr
 
-    def genop_malloc_fixedsize(self, builder, alloctoken):
-        return builder.genop_malloc_fixedsize(alloctoken)
-
-    def genop_ptr_iszero(self, builder, argbox, gv_addr):
-        return builder.genop1("ptr_iszero", gv_addr)
-
-    def genop_ptr_nonzero(self, builder, argbox, gv_addr):
-        return builder.genop1("ptr_nonzero", gv_addr)
-
-    def genop_ptr_eq(self, builder, gv_addr0, gv_addr1):
-        return builder.genop2("ptr_eq", gv_addr0, gv_addr1)
-
-    def genop_ptr_ne(self, builder, gv_addr0, gv_addr1):
-        return builder.genop2("ptr_ne", gv_addr0, gv_addr1)
-
     def get_FuncType(self, ARGS, RESULT):
         FUNCTYPE = lltype.FuncType(ARGS, RESULT)
         FUNCPTRTYPE = lltype.Ptr(FUNCTYPE)
         return FUNCTYPE, FUNCPTRTYPE
 
-    def PromotionPoint(self, flexswitch, incoming_gv, promotion_path):
-        from pypy.jit.timeshifter.rtimeshift import PromotionPointLLType
-        return PromotionPointLLType(flexswitch, incoming_gv, promotion_path)
-
 class OOTypeHelper(TypeSystemHelper):
 
     name = 'ootype'
-    ROOT_TYPE = ootype.Object
-    BASE_OBJ_TYPE = base_obj_ootype()
-    NULL_OBJECT = base_obj_ootype()._defl()
-    cast_instance_to_base_ptr = staticmethod(cast_instance_to_base_obj)
+    functionptr = staticmethod(ootype.static_meth)
+    #ROOT_TYPE = ootype.Object
+    #BASE_OBJ_TYPE = base_obj_ootype()
+    #NULL_OBJECT = base_obj_ootype()._defl()
+    #cast_instance_to_base_ptr = staticmethod(cast_instance_to_base_obj)
 
     def get_typeptr(self, obj):
         return obj.meta
 
-    def genop_malloc_fixedsize(self, builder, alloctoken):
-        return builder.genop_new(alloctoken)
-
-    def genop_ptr_iszero(self, builder, argbox, gv_addr):
-        return builder.genop_ooisnull(gv_addr)
-
-    def genop_ptr_nonzero(self, builder, argbox, gv_addr):
-        return builder.genop_oononnull(gv_addr)
-
-    def genop_ptr_eq(self, builder, gv_addr0, gv_addr1):
-        return builder.genop2("oois", gv_addr0, gv_addr1)
-
-    def genop_ptr_ne(self, builder, gv_addr0, gv_addr1):
-        assert False, 'TODO'
-        #return builder.genop2("ptr_ne", gv_addr0, gv_addr1)
-
     def get_FuncType(self, ARGS, RESULT):
         FUNCTYPE = ootype.StaticMethod(ARGS, RESULT)
         return FUNCTYPE, FUNCTYPE
-
-    def PromotionPoint(self, flexswitch, incoming_gv, promotion_path):
-        from pypy.jit.timeshifter.rtimeshift import PromotionPointOOType
-        return PromotionPointOOType(flexswitch, incoming_gv, promotion_path)
-
-
-llhelper = LLTypeHelper()
-oohelper = OOTypeHelper()

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py	Wed Apr 15 19:36:27 2009
@@ -17,6 +17,7 @@
 from pypy.jit.metainterp import support, history, pyjitpl
 from pypy.jit.metainterp.pyjitpl import MetaInterpStaticData, MetaInterp
 from pypy.jit.metainterp.policy import JitPolicy
+from pypy.jit.metainterp.typesystem import LLTypeHelper, OOTypeHelper
 
 # ____________________________________________________________
 # Bootstrapping
@@ -107,7 +108,7 @@
         pyjitpl._warmrunnerdesc = self   # this is a global for debugging only!
         if policy is None:
             policy = JitPolicy()
-        self.translator = translator
+        self.set_translator(translator)
         self.build_meta_interp(**kwds)
         self.make_args_specification()
         self.rewrite_jit_merge_point()
@@ -124,6 +125,14 @@
     def _freeze_(self):
         return True
 
+    def set_translator(self, translator):
+        self.translator = translator
+        if translator.rtyper.type_system.name == 'lltypesystem':
+            self.ts = LLTypeHelper()
+        else:
+            assert translator.rtyper.type_system.name == 'ootypesystem'
+            self.ts = OOTypeHelper()
+
     def build_meta_interp(self, CPUClass=None, view="auto",
                           translate_support_code=False, optimizer=None,
                           **kwds):
@@ -197,12 +206,15 @@
             if i < len(self.jitdriver.greens):
                 self.green_args_spec.append(TYPE)
         RESTYPE = graph.getreturnvar().concretetype
-        self.JIT_ENTER_FUNCTYPE = lltype.FuncType(ALLARGS, lltype.Void)
-        self.PORTAL_FUNCTYPE = lltype.FuncType(ALLARGS, RESTYPE)
+        (self.JIT_ENTER_FUNCTYPE,
+         self.PTR_JIT_ENTER_FUNCTYPE) = self.ts.get_FuncType(ALLARGS, lltype.Void)
+        (self.PORTAL_FUNCTYPE,
+         self.PTR_PORTAL_FUNCTYPE) = self.ts.get_FuncType(ALLARGS, RESTYPE)
+        
 
     def rewrite_can_enter_jit(self):
         FUNC = self.JIT_ENTER_FUNCTYPE
-        FUNCPTR = lltype.Ptr(FUNC)
+        FUNCPTR = self.PTR_JIT_ENTER_FUNCTYPE
         jit_enter_fnptr = self.helper_func(FUNCPTR, self.maybe_enter_jit_fn)
 
         graphs = self.translator.graphs
@@ -269,8 +281,8 @@
         # ____________________________________________________________
         # Prepare the portal_runner() helper
         #
-        portal_ptr = lltype.functionptr(PORTALFUNC, 'portal',
-                                        graph = portalgraph)
+        portal_ptr = self.ts.functionptr(PORTALFUNC, 'portal',
+                                         graph = portalgraph)
 
         class DoneWithThisFrame(JitException):
             def __init__(self, resultbox):
@@ -323,7 +335,7 @@
                         raise Exception, value
         ll_portal_runner._recursive_portal_call_ = True
 
-        portal_runner_ptr = self.helper_func(lltype.Ptr(PORTALFUNC),
+        portal_runner_ptr = self.helper_func(self.PTR_PORTAL_FUNCTYPE,
                                              ll_portal_runner)
 
         # ____________________________________________________________
@@ -334,7 +346,7 @@
         assert op.opname == 'jit_marker'
         assert op.args[0].value == 'jit_merge_point'
         greens_v, reds_v = decode_hp_hint_args(op)
-        vlist = [Constant(portal_runner_ptr, lltype.Ptr(PORTALFUNC))]
+        vlist = [Constant(portal_runner_ptr, self.PTR_PORTAL_FUNCTYPE)]
         vlist += greens_v
         vlist += reds_v
         v_result = Variable()



More information about the Pypy-commit mailing list