[pypy-svn] r64481 - in pypy/branch/pyjitpl5-simplify/pypy/jit: backend/llgraph metainterp metainterp/test

antocuni at codespeak.net antocuni at codespeak.net
Mon Apr 20 23:37:30 CEST 2009


Author: antocuni
Date: Mon Apr 20 23:37:29 2009
New Revision: 64481

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py
Log:
implement call to static method in the llgraph oo backend. A new test passes


Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py	Mon Apr 20 23:37:29 2009
@@ -693,6 +693,14 @@
         if isinstance(ootype.typeOf(newvalue), ootype.OOType):
             newvalue = ootype.cast_from_object(T, newvalue)
         setattr(obj, fieldname, newvalue)
+
+    def op_call(self, calldescr, func, *args):
+        sm = ootype.cast_from_object(calldescr.FUNC, func)
+        res = sm(*args)
+        if isinstance(calldescr.FUNC.RESULT, ootype.OOType):
+            return ootype.cast_to_object(res)
+        return res
+
 # ____________________________________________________________
 
 def cast_to_int(x, memocast):

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	Mon Apr 20 23:37:29 2009
@@ -491,6 +491,7 @@
 class StaticMethDescr(OODescr):
 
     def __init__(self, FUNC, ARGS, RESULT):
+        self.FUNC = FUNC
         getargs = make_getargs(ARGS)
         def callfunc(funcbox, argboxes):
             funcobj = ootype.cast_from_object(FUNC, funcbox.getobj())

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py	Mon Apr 20 23:37:29 2009
@@ -47,7 +47,8 @@
         values = []
         for graph in graphs:
             fnptr = codewriter.rtyper.getcallable(graph)
-            keys.append(llmemory.cast_ptr_to_adr(fnptr))
+            fnaddress = codewriter.ts.cast_fnptr_to_root(fnptr)
+            keys.append(fnaddress)
             values.append(codewriter.get_jitcode(graph))
 
         def bytecode_for_address(fnaddress):
@@ -78,7 +79,7 @@
 class CodeWriter(object):
     portal_graph = None
 
-    def __init__(self, metainterp_sd, policy):
+    def __init__(self, metainterp_sd, policy, ts):
         self.all_prebuilt_values = {}
         self.all_graphs = {}
         self.all_indirectcallsets = {}
@@ -88,6 +89,7 @@
         self.rtyper = metainterp_sd.cpu.rtyper
         self.cpu = metainterp_sd.cpu
         self.policy = policy
+        self.ts = ts
 
     def make_portal_bytecode(self, graph):
         log.info("making JitCodes...")

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py	Mon Apr 20 23:37:29 2009
@@ -282,8 +282,10 @@
         return ootype.ooidentityhash(self.value) # XXX: check me
 
     def getaddr(self, cpu):
-        assert False
-        #return llmemory.cast_ptr_to_adr(self.value)
+        # so far this is used only when calling
+        # CodeWriter.IndirectCallset.bytecode_for_address.  We don't need a
+        # real addr, but just a key for the dictionary
+        return self.value
 
     def equals(self, other):
         assert False

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py	Mon Apr 20 23:37:29 2009
@@ -789,8 +789,8 @@
                 cs[key] = value
             self.cpu.class_sizes = cs
 
-    def generate_bytecode(self, policy):
-        self._codewriter = codewriter.CodeWriter(self, policy)
+    def generate_bytecode(self, policy, ts):
+        self._codewriter = codewriter.CodeWriter(self, policy, ts)
         self.portal_code = self._codewriter.make_portal_bytecode(
             self.portal_graph)
 

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	Mon Apr 20 23:37:29 2009
@@ -518,7 +518,6 @@
     test_oops_on_nongc = skip
     test_instantiate_classes = skip
 
-    test_stopatxpolicy = skip
     test_print = skip
     test_bridge_from_interpreter_2 = skip
     test_bridge_from_interpreter_3 = skip

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py	Mon Apr 20 23:37:29 2009
@@ -44,6 +44,9 @@
         FUNCPTRTYPE = lltype.Ptr(FUNCTYPE)
         return FUNCTYPE, FUNCPTRTYPE
 
+    def cast_fnptr_to_root(self, fnptr):
+        return llmemory.cast_ptr_to_adr(fnptr)
+
 class OOTypeHelper(TypeSystemHelper):
 
     name = 'ootype'
@@ -59,3 +62,6 @@
     def get_FuncType(self, ARGS, RESULT):
         FUNCTYPE = ootype.StaticMethod(ARGS, RESULT)
         return FUNCTYPE, FUNCTYPE
+
+    def cast_fnptr_to_root(self, fnptr):
+        return ootype.cast_to_object(fnptr)

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	Mon Apr 20 23:37:29 2009
@@ -115,7 +115,7 @@
         self.build_meta_interp(**kwds)
         self.make_args_specification()
         self.rewrite_jit_merge_point()
-        self.metainterp_sd.generate_bytecode(policy)
+        self.metainterp_sd.generate_bytecode(policy, self.ts)
         self.make_enter_function()
         self.rewrite_can_enter_jit()
         self.metainterp_sd.num_green_args = self.num_green_args



More information about the Pypy-commit mailing list