[pypy-svn] r45000 - in pypy/dist/pypy: rpython/memory/gctransform translator/llvm

mwh at codespeak.net mwh at codespeak.net
Fri Jul 13 09:51:05 CEST 2007


Author: mwh
Date: Fri Jul 13 09:51:03 2007
New Revision: 45000

Modified:
   pypy/dist/pypy/rpython/memory/gctransform/boehm.py
   pypy/dist/pypy/translator/llvm/gc.py
   pypy/dist/pypy/translator/llvm/opwriter.py
Log:
usual putting-llvm-back-together-with-sellotape, but pleasingly this 
mostly involves deleting code.


Modified: pypy/dist/pypy/rpython/memory/gctransform/boehm.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform/boehm.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform/boehm.py	Fri Jul 13 09:51:03 2007
@@ -55,6 +55,7 @@
             self.malloc_varsize_ptr = self.inittime_helper(
                 ll_malloc_varsize, [lltype.Signed]*4, llmemory.Address, inline=False)
             self.mixlevelannotator.finish()   # for now
+            self.mixlevelannotator.backend_optimize()
 
     def push_alive_nopyobj(self, var, llops):
         pass

Modified: pypy/dist/pypy/translator/llvm/gc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/gc.py	(original)
+++ pypy/dist/pypy/translator/llvm/gc.py	Fri Jul 13 09:51:03 2007
@@ -36,67 +36,6 @@
                     exc_flag=False):
         raise NotImplementedError, 'GcPolicy should not be used directly'
 
-    def zeromalloc(self, codewriter, targetvar, type_, size=1, atomic=False,
-                   exc_flag=False):
-        uword = self.db.get_machine_uword()
-        malloc_ptr = '%malloc_ptr' + self.get_count(True)
-        malloc_size = '%malloc_size' + self.get_count()
-        malloc_sizeu = '%malloc_sizeu' + self.get_count()
-        
-        codewriter.getelementptr(malloc_size, type_, 'null',
-                                 [(uword, size)], getptr=False)
-        codewriter.cast(malloc_sizeu, type_, malloc_size, uword)
-        self._zeromalloc(codewriter, malloc_ptr, malloc_sizeu, atomic, exc_flag)
-        codewriter.cast(targetvar, 'sbyte*', malloc_ptr, type_)            
-
-    def var_zeromalloc(self, codewriter, targetvar,
-                       type_, node, len, atomic=False):
-
-        word = lentype = self.db.get_machine_word()
-        uword = self.db.get_machine_uword()
-        malloc_ptr = '%malloc_ptr' + self.get_count(True)
-        malloc_size = '%malloc_size' + self.get_count()
-        malloc_sizeu = '%malloc_sizeu' + self.get_count()
-        actuallen = '%actuallen' + self.get_count()
-        arraylength = '%arraylength' + self.get_count()
-        
-        ARRAY, indices_to_array = node.var_malloc_info()
-        
-        #varsized arrays and structs look like this: 
-        #Array: {int length , elemtype*}
-        #Struct: {...., Array}
-        
-        # the following indices access the last element in the array
-        elemtype = self.db.repr_type(ARRAY.OF)
-        word = lentype = self.db.get_machine_word()
-        uword = self.db.get_machine_uword()
-        
-        # need room for NUL terminator
-        if ARRAY is STR.chars:
-            codewriter.binaryop('add', actuallen, lentype, len, 1)
-        else:
-            codewriter.cast(actuallen, lentype, len, lentype)
-            
-        elemindices = list(indices_to_array)
-        elemindices += [('uint', 1), (lentype, actuallen)]
-        codewriter.getelementptr(malloc_size, type_, 'null', elemindices) 
-        codewriter.cast(malloc_sizeu, elemtype + '*', malloc_size, uword)
-        
-        self._zeromalloc(codewriter, malloc_ptr, malloc_sizeu, atomic=atomic)
-
-        indices_to_arraylength = tuple(indices_to_array) + (('uint', 0),)
-
-        codewriter.cast(targetvar, 'sbyte*', malloc_ptr, type_)
-
-        #XXX ctypes Arrays have no length field
-        #XXXif not VARPART._hints.get('nolength', False):
-
-        # the following accesses the length field of the array 
-        codewriter.getelementptr(arraylength, type_, 
-                                 targetvar,  indices_to_arraylength)
-        codewriter.store(lentype, len, arraylength)
-
-
     def op_call_rtti_destructor(self, codewriter, opr):
         raise Exception, 'GcPolicy should not be used directly'
      
@@ -201,14 +140,14 @@
 ##            atomic = False 
 
         # malloc_size is unsigned right now
-        sizei = '%malloc_sizei' + self.get_count()        
-        codewriter.cast(sizei, uword, size, word)
-        codewriter.call(targetvar, 'sbyte*', fnname, [word], [sizei])
+        sizeu = '%malloc_sizeu' + self.get_count()        
+        codewriter.cast(sizeu, word, size, uword)
+        codewriter.call(targetvar, 'sbyte*', fnname, [word], [size])
 
         if atomic:
             codewriter.call(None, 'void', '%llvm.memset' + postfix(),
                             ['sbyte*', 'ubyte', uword, uword],
-                            [targetvar, 0, size, boundary_size],
+                            [targetvar, 0, sizeu, boundary_size],
                             cconv='ccc')        
 
 

Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py	(original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py	Fri Jul 13 09:51:03 2007
@@ -279,36 +279,15 @@
     # is of type Void, which is removed by direct_call
     indirect_call = direct_call
 
-    def malloc(self, opr):
-        arg_type = opr.op.args[0].value
+    def boehm_malloc(self, opr):
+        self.db.gcpolicy._zeromalloc(self.codewriter, opr.retref, opr.argrefs[0], atomic=False)
 
-        # XXX hack better to look at the actual structure
-        name = str(opr.op.args[0])
-        exc = False
-        if 'Exception' in name or 'Error' in name:
-            exc = True
-
-        self.db.gcpolicy.zeromalloc(self.codewriter, opr.retref, opr.rettype,
-                                    atomic=arg_type._is_atomic(), exc_flag=exc)
-
-    zero_malloc = malloc
-
-    def malloc_varsize(self, opr):
-
-        # XXX transformation perhaps?
-        arg_type = opr.op.args[0].value
-        if isinstance(arg_type, lltype.Array) and arg_type.OF is lltype.Void:
-            # This is a backend decision to NOT represent a void array with
-            # anything and save space - therefore not varsized anymore
-            self.malloc(opr)
-            return
-
-        node = self.db.obj2node[arg_type]
-        self.db.gcpolicy.var_zeromalloc(self.codewriter, opr.retref,
-                                        opr.rettype, node, opr.argrefs[1],
-                                        atomic=arg_type._is_atomic())
+    def boehm_malloc_atomic(self, opr):
+        self.db.gcpolicy._zeromalloc(self.codewriter, opr.retref, opr.argrefs[0], atomic=True)
 
-    zero_malloc_varsize = malloc_varsize
+    def boehm_register_finalizer(self, opr):
+        # ha, ha
+        pass
 
     def flavored_malloc(self, opr):
         flavor = opr.op.args[0].value



More information about the Pypy-commit mailing list