[pypy-svn] r69305 - in pypy/trunk/pypy: jit/metainterp jit/metainterp/test rpython rpython/ootypesystem translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Sun Nov 15 20:26:09 CET 2009


Author: antocuni
Date: Sun Nov 15 20:26:06 2009
New Revision: 69305

Modified:
   pypy/trunk/pypy/jit/metainterp/codewriter.py
   pypy/trunk/pypy/jit/metainterp/pyjitpl.py
   pypy/trunk/pypy/jit/metainterp/test/test_basic.py
   pypy/trunk/pypy/rpython/llinterp.py
   pypy/trunk/pypy/rpython/ootypesystem/rdict.py
   pypy/trunk/pypy/translator/cli/function.py
Log:
put all oonewcustomdict operations into its own function and mark it as
dont_look_inside, so that the jit does not need to know about custom dicts



Modified: pypy/trunk/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/codewriter.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/codewriter.py	Sun Nov 15 20:26:06 2009
@@ -924,8 +924,7 @@
         self.register_var(op.result)
 
     def serialize_op_oonewcustomdict(self, op):
-        self.emit('not_implemented')
-        self.register_var(op.result)
+        assert False, 'should not be seen by the jit'
 
     def serialize_op_instanceof(self, op):
         v, c_TYPE = op.args

Modified: pypy/trunk/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/pyjitpl.py	Sun Nov 15 20:26:06 2009
@@ -885,10 +885,6 @@
         return self.metainterp.finishframe_exception(self.exception_box,
                                                      self.exc_value_box)
 
-    @arguments()
-    def opimpl_not_implemented(self):
-        raise NotImplementedError
-
     # ------------------------------
 
     def setup_call(self, argboxes):

Modified: pypy/trunk/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_basic.py	Sun Nov 15 20:26:06 2009
@@ -1242,10 +1242,6 @@
         res = self.interp_operations(f, [0])
         assert res == ord('A') + ord('B')
 
-    def test_r_dict(self):
-        py.test.skip('in-progress')
-
-
     def test_subclassof(self):
         A = ootype.Instance("A", ootype.ROOT)
         B = ootype.Instance("B", A)

Modified: pypy/trunk/pypy/rpython/llinterp.py
==============================================================================
--- pypy/trunk/pypy/rpython/llinterp.py	(original)
+++ pypy/trunk/pypy/rpython/llinterp.py	Sun Nov 15 20:26:06 2009
@@ -1336,7 +1336,7 @@
         # obj is an instance, we want to call 'method_name' on it
         assert fn is None        
         self_arg = [obj]
-        func_graph = obj._TYPE._methods[method_name].graph
+        func_graph = obj._TYPE._methods[method_name._str].graph
 
     return wrap_graph(llinterpreter, func_graph, self_arg)
 

Modified: pypy/trunk/pypy/rpython/ootypesystem/rdict.py
==============================================================================
--- pypy/trunk/pypy/rpython/ootypesystem/rdict.py	(original)
+++ pypy/trunk/pypy/rpython/ootypesystem/rdict.py	Sun Nov 15 20:26:06 2009
@@ -229,26 +229,28 @@
         hop.exception_is_here()
         return r_dict.send_message(hop, 'll_contains', v_args=vlist)
 
-def _get_call_vars(hop, r_func, arg, params_annotation):
+def dum_ignore_me(): pass
+
+def _get_call_args(hop, r_func, arg, params_annotation):
     if isinstance(r_func, AbstractFunctionsPBCRepr):
-        v_fn = r_func.get_unique_llfn()
+        fn = r_func.get_unique_llfn().value
         v_obj = hop.inputconst(ootype.Void, None)
-        c_method_name = hop.inputconst(ootype.Void, None)
+        methodname = None
     elif isinstance(r_func, AbstractMethodsPBCRepr):
+        fn = None
+        v_obj = hop.inputarg(r_func, arg=arg)
         s_pbc_fn = hop.args_s[arg]
         methodname = r_func._get_method_name("simple_call", s_pbc_fn, params_annotation)
-        v_fn = hop.inputconst(ootype.Void, None)
-        v_obj = hop.inputarg(r_func, arg=arg)
-        c_method_name = hop.inputconst(ootype.Void, methodname)
     elif isinstance(r_func, MethodOfFrozenPBCRepr):
         r_impl, nimplicitarg = r_func.get_r_implfunc()
-        v_fn = r_impl.get_unique_llfn()
-        v_obj = hop.inputarg(r_func, arg=arg)
-        c_method_name = hop.inputconst(ootype.Void, None)
-
-    return v_fn, v_obj, c_method_name
+        fn = r_impl.get_unique_llfn().value
+        v_obj = hop.inputconst(ootype.Void, dum_ignore_me)
+        methodname = None
+    return fn, v_obj, methodname
 
 def rtype_r_dict(hop):
+    from pypy.rlib import jit
+
     r_dict = hop.r_result
     if not r_dict.custom_eq_hash:
         raise TyperError("r_dict() call does not return an r_dict instance")
@@ -258,24 +260,29 @@
     # the signature of oonewcustomdict is a bit complicated because we
     # can have three different ways to pass the equal (and hash)
     # callables:    
-    #   1. pass a plain function: v_eqfn is a StaticMethod, v_eqobj
-    #      and c_eq_method_name are None
-    #   2. pass a bound method: v_eqfn is None, v_eqobj is the
-    #      instance, c_method_name is the name of the method,
-    #   3. pass a method of a frozen PBC: v_eqfn is a StaticMethod,
-    #      v_eqobj is the PBC to be pushed in front of the StaticMethod,
-    #      c_eq_method_name is None
+    #   1. pass a plain function: eqfn is a StaticMethod, v_eqobj
+    #      and eq_method_name are None
+    #   2. pass a bound method: eqfn is None, v_eqobj is the
+    #      instance, eq_method_name is the name of the method,
+    #   3. pass a method of a frozen PBC: eqfn is a StaticMethod, v_eqobj is a
+    #      non-None Void value (to be ignored by all the backends except the
+    #      llinterp), eq_method_name is None
 
     s_key = r_dict.dictkey.s_value
-    v_eqfn, v_eqobj, c_eq_method_name =\
-             _get_call_vars(hop, r_dict.r_rdict_eqfn, 0, [s_key, s_key])
-    v_hashfn, v_hashobj, c_hash_method_name =\
-               _get_call_vars(hop, r_dict.r_rdict_hashfn, 1, [s_key])
-
-    return hop.genop("oonewcustomdict", [cDICT,
-                                         v_eqfn, v_eqobj, c_eq_method_name,
-                                         v_hashfn, v_hashobj, c_hash_method_name],
-                     resulttype=hop.r_result.lowleveltype)
+    eqfn, v_eqobj, eq_method_name =\
+             _get_call_args(hop, r_dict.r_rdict_eqfn, 0, [s_key, s_key])
+    hashfn, v_hashobj, hash_method_name =\
+               _get_call_args(hop, r_dict.r_rdict_hashfn, 1, [s_key])
+
+    @jit.dont_look_inside
+    def ll_newcustomdict(DICT, v_eqobj, v_hashobj):
+        from pypy.rpython.lltypesystem.lloperation import llop
+        return llop.oonewcustomdict(DICT, DICT,
+                                    eqfn, v_eqobj, eq_method_name,
+                                    hashfn, v_hashobj, hash_method_name)
+    ll_newcustomdict._dont_inline_ = True
+
+    return hop.gendirectcall(ll_newcustomdict, cDICT, v_eqobj, v_hashobj)
 
 def ll_newdict(DICT):
     return ootype.new(DICT)

Modified: pypy/trunk/pypy/translator/cli/function.py
==============================================================================
--- pypy/trunk/pypy/translator/cli/function.py	(original)
+++ pypy/trunk/pypy/translator/cli/function.py	Sun Nov 15 20:26:06 2009
@@ -1,4 +1,5 @@
 from pypy.objspace.flow import model as flowmodel
+from pypy.rlib.objectmodel import CDefinedIntSymbolic
 from pypy.rpython.lltypesystem.lltype import Void
 from pypy.rpython.ootypesystem import ootype
 from pypy.translator.oosupport.treebuilder import SubOperation
@@ -148,7 +149,7 @@
         from pypy.translator.cli.dotnet import NativeInstance
         if isinstance(to_load, flowmodel.Constant):
             value = to_load.value
-            is_null = not value
+            is_null = (not isinstance(value, CDefinedIntSymbolic)) and (not value)
             T = ootype.typeOf(to_load.value)
             if isinstance(T, NativeInstance) and T._is_value_type and is_null:
                 return True



More information about the Pypy-commit mailing list