[pypy-svn] r30699 - in pypy/dist/pypy: rpython translator/c/src

fijal at codespeak.net fijal at codespeak.net
Fri Jul 28 17:39:14 CEST 2006


Author: fijal
Date: Fri Jul 28 17:39:11 2006
New Revision: 30699

Modified:
   pypy/dist/pypy/rpython/objectmodel.py
   pypy/dist/pypy/rpython/rlist.py
   pypy/dist/pypy/translator/c/src/mem.h
Log:
Added flag responsible for malloc zeroing memory. If set, malloc is supposed to fill memory with zeroes (null pointers respectively). If not, memory must be malloced always.


Modified: pypy/dist/pypy/rpython/objectmodel.py
==============================================================================
--- pypy/dist/pypy/rpython/objectmodel.py	(original)
+++ pypy/dist/pypy/rpython/objectmodel.py	Fri Jul 28 17:39:11 2006
@@ -22,6 +22,18 @@
     def __hash__(self):
         raise TypeError("Symbolics are not hashable!")
 
+class BackendFlagSymbolic(object):
+    def __init__(self, val):
+        self.val = val
+    
+    def annotation(self):
+        from pypy.annotation import model
+        return model.SomeBoolean()
+    
+    def lltype(self):
+        from pypy.rpython.lltypesystem import lltype
+        return lltype.Bool
+
 class ComputedIntSymbolic(Symbolic):
 
     def __init__(self, compute_fn):
@@ -48,6 +60,7 @@
         from pypy.rpython.lltypesystem import lltype
         return lltype.Signed
 
+malloc_zero_filled = CDefinedIntSymbolic('MALLOC_ZERO_FILLED')
 
 def instantiate(cls):
     "Create an empty instance of 'cls'."

Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py	(original)
+++ pypy/dist/pypy/rpython/rlist.py	Fri Jul 28 17:39:11 2006
@@ -6,6 +6,7 @@
 from pypy.rpython.lltypesystem.lltype import typeOf, Ptr, Void, Signed, Bool
 from pypy.rpython.lltypesystem.lltype import nullptr, Char, UniChar
 from pypy.rpython import robject
+from pypy.rpython.objectmodel import malloc_zero_filled
 
 def dum_checkidx(): pass
 def dum_nocheck(): pass
@@ -371,7 +372,8 @@
         check = ord(item)
     else:
         check = item
-    if check: # as long as malloc it is known to zero the allocated memory avoid zeroing twice
+    if (not malloc_zero_check) or check: # as long as malloc it is known to zero the allocated memory avoid zeroing twice
+    
         i = 0
         while i < count:
             l.ll_setitem_fast(i, item)

Modified: pypy/dist/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/mem.h	(original)
+++ pypy/dist/pypy/translator/c/src/mem.h	Fri Jul 28 17:39:11 2006
@@ -10,6 +10,8 @@
 #define alloca  _alloca
 #endif
 
+#define MALLOC_ZERO_FILLED 1
+
 #define OP_STACK_MALLOC(size,r,restype)                                 \
     r = (restype) alloca(size);                                         \
     if (r == NULL) FAIL_EXCEPTION(PyExc_MemoryError, "out of memory");  \



More information about the Pypy-commit mailing list