[pypy-svn] r17718 - in pypy/dist/pypy: annotation rpython

pedronis at codespeak.net pedronis at codespeak.net
Wed Sep 21 15:26:52 CEST 2005


Author: pedronis
Date: Wed Sep 21 15:26:51 2005
New Revision: 17718

Modified:
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/annotation/builtin.py
   pypy/dist/pypy/rpython/normalizecalls.py
   pypy/dist/pypy/rpython/rbuiltin.py
Log:
don't generate ununsed my instantiate



Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Wed Sep 21 15:26:51 2005
@@ -197,6 +197,8 @@
 
         self.needs_hash_support = {}
 
+        self.needs_generic_instantiate = {}
+
         self.memo_tables = []
 
         self.stats = Stats(self)

Modified: pypy/dist/pypy/annotation/builtin.py
==============================================================================
--- pypy/dist/pypy/annotation/builtin.py	(original)
+++ pypy/dist/pypy/annotation/builtin.py	Wed Sep 21 15:26:51 2005
@@ -234,6 +234,9 @@
             clsdef = getbookkeeper().getclassdef(cls)
         else:
             clsdef = clsdef.commonbase(getbookkeeper().getclassdef(cls))
+    if len(s_clspbc.prebuiltinstances) > 1:
+        for cls in s_clspbc.prebuiltinstances:
+            getbookkeeper().needs_generic_instantiate[cls] = True
     return SomeInstance(clsdef)
 
 def robjmodel_we_are_translated():

Modified: pypy/dist/pypy/rpython/normalizecalls.py
==============================================================================
--- pypy/dist/pypy/rpython/normalizecalls.py	(original)
+++ pypy/dist/pypy/rpython/normalizecalls.py	Wed Sep 21 15:26:51 2005
@@ -324,8 +324,12 @@
 
 def create_instantiate_functions(annotator):
     # build the 'instantiate() -> instance of C' functions for the vtables
+
+    needs_generic_instantiate = annotator.bookkeeper.needs_generic_instantiate
+    
     for cls, classdef in annotator.getuserclasses().items():
-        if needsgc(classdef): # only gc-case
+        if cls in needs_generic_instantiate:
+            assert needsgc(classdef) # only gc-case            
             create_instantiate_function(annotator, cls, classdef)
 
 def create_instantiate_function(annotator, cls, classdef):

Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/rbuiltin.py	Wed Sep 21 15:26:51 2005
@@ -212,9 +212,9 @@
         v_errno = hop.inputarg(lltype.Signed, arg=1)
         r_self.setfield(v_self, 'errno', v_errno, hop.llops)
 
-def ll_instantiate(typeptr, RESULT):
+def ll_instantiate(typeptr):
     my_instantiate = typeptr.instantiate
-    return lltype.cast_pointer(RESULT, my_instantiate())
+    return my_instantiate()
 
 def rtype_instantiate(hop):
     s_class = hop.args_s[0]
@@ -222,8 +222,10 @@
     if len(s_class.prebuiltinstances) != 1:
         # instantiate() on a variable class
         vtypeptr, = hop.inputargs(rclass.get_type_repr(hop.rtyper))
-        cresult = hop.inputconst(lltype.Void, hop.r_result.lowleveltype)
-        return hop.gendirectcall(ll_instantiate, vtypeptr, cresult)
+        v_inst = hop.gendirectcall(ll_instantiate, vtypeptr)
+        return hop.genop('cast_pointer', [v_inst],    # v_type implicit in r_result
+                         resulttype = hop.r_result.lowleveltype)
+
 
     klass = s_class.const
     return rclass.rtype_new_instance(hop.rtyper, klass, hop.llops)



More information about the Pypy-commit mailing list