[pypy-svn] r12845 - pypy/dist/pypy/rpython

arigo at codespeak.net arigo at codespeak.net
Fri May 27 16:58:12 CEST 2005


Author: arigo
Date: Fri May 27 16:58:12 2005
New Revision: 12845

Modified:
   pypy/dist/pypy/rpython/rpbc.py
   pypy/dist/pypy/rpython/rtyper.py
Log:
Produce functionptrs with both a _callable and a graph attribute.
It makes more sense for code generators should depend on 'graph' rather
than '_callable'.



Modified: pypy/dist/pypy/rpython/rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/rpbc.py	(original)
+++ pypy/dist/pypy/rpython/rpbc.py	Fri May 27 16:58:12 2005
@@ -1,7 +1,7 @@
 import types
 from pypy.annotation.pairtype import pair, pairtype
 from pypy.annotation.model import SomePBC
-from pypy.rpython.lltype import Void, FuncType, functionptr
+from pypy.rpython.lltype import Void, FuncType, functionptr, NonGcPtr
 from pypy.rpython.rtyper import TLS, receive, receiveconst, direct_op
 from pypy.rpython.rtyper import peek_at_result_annotation
 
@@ -32,7 +32,7 @@
         else:
             lloutput = s_output.lowleveltype()
         FT = FuncType(llinputs, lloutput)
-        f = functionptr(FT, func.func_name, _callable=func)
+        f = functionptr(FT, func.func_name, graph = graph, _callable = func)
         args_v = [receive(llinputs[i], arg=i+1) for i in range(len(args_s))]
-        c = receiveconst(FT, f)
+        c = receiveconst(NonGcPtr(FT), f)
         return direct_op('direct_call', [c] + args_v, resulttype=lloutput)

Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py	(original)
+++ pypy/dist/pypy/rpython/rtyper.py	Fri May 27 16:58:12 2005
@@ -2,7 +2,7 @@
 from pypy.annotation import model as annmodel
 from pypy.objspace.flow.model import Variable, Constant, Block, Link
 from pypy.objspace.flow.model import SpaceOperation
-from pypy.rpython.lltype import Void, LowLevelType, NonGcPtr
+from pypy.rpython.lltype import Void, LowLevelType, NonGcPtr, ContainerType
 from pypy.rpython.lltype import FuncType, functionptr
 from pypy.tool.tls import tlsobject
 from pypy.tool.sourcetools import func_with_new_name, valid_identifier
@@ -217,6 +217,9 @@
         lowleveltype = s_requested
     else:
         lowleveltype = s_requested.lowleveltype()
+    assert not isinstance(lowleveltype, ContainerType), (
+        "missing a GcPtr or NonGcPtr in the type specification of %r" %
+        (lowleveltype,))
     c = Constant(value)
     c.concretetype = lowleveltype
     return c
@@ -272,24 +275,26 @@
         spec_name.append(valid_identifier(getattr(key, '__name__', key))+suffix)
     spec_key = tuple(spec_key)
     try:
-        spec_function, resulttype = (
+        spec_function, spec_graph, resulttype = (
             TLS.rtyper.specialized_ll_functions[spec_key])
     except KeyError:
         name = '_'.join(spec_name)
         spec_function = func_with_new_name(ll_function, name)
         # flow and annotate (the copy of) the low-level function
+        spec_graph = annotator.translator.getflowgraph(spec_function)
         s_returnvalue = annotator.build_types(spec_function, args_s)
         resulttype = annmodel.annotation_to_lltype(s_returnvalue,
                                            "%s: " % ll_function.func_name)
         # cache the result
         TLS.rtyper.specialized_ll_functions[spec_key] = (
-            spec_function, resulttype)
+            spec_function, spec_graph, resulttype)
 
     # build the 'direct_call' operation
     lltypes = [v.concretetype for v in args_v]
     FT = FuncType(lltypes, resulttype)
-    c = Constant(functionptr(FT, ll_function.func_name, _callable=spec_function))
-    c.concretetype = NonGcPtr(FT)
+    f = functionptr(FT, ll_function.func_name, graph = spec_graph,
+                                           _callable = spec_function)
+    c = receiveconst(NonGcPtr(FT), f)
     return direct_op('direct_call', [c]+list(args_v), resulttype=resulttype)
 
 



More information about the Pypy-commit mailing list