[pypy-svn] r51870 - in pypy/dist/pypy: rpython/memory rpython/memory/gc rpython/memory/gctransform translator/c translator/c/src

arigo at codespeak.net arigo at codespeak.net
Tue Feb 26 10:07:05 CET 2008


Author: arigo
Date: Tue Feb 26 10:07:04 2008
New Revision: 51870

Modified:
   pypy/dist/pypy/rpython/memory/gc/base.py
   pypy/dist/pypy/rpython/memory/gc/semispace.py
   pypy/dist/pypy/rpython/memory/gctransform/boehm.py
   pypy/dist/pypy/rpython/memory/gctransform/framework.py
   pypy/dist/pypy/rpython/memory/gctransform/refcounting.py
   pypy/dist/pypy/rpython/memory/gcwrapper.py
   pypy/dist/pypy/translator/c/gc.py
   pypy/dist/pypy/translator/c/src/mem.h
Log:
Define MALLOC_ZERO_FILLED to a sensible value provided by
the gc transformer.  This allows the semispace and generation
GCs to set it to 1.


Modified: pypy/dist/pypy/rpython/memory/gc/base.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc/base.py	(original)
+++ pypy/dist/pypy/rpython/memory/gc/base.py	Tue Feb 26 10:07:04 2008
@@ -5,7 +5,7 @@
     _alloc_flavor_ = "raw"
     moving_gc = False
     needs_write_barrier = False
-    needs_zero_gc_pointers = True
+    malloc_zero_filled = False
     prebuilt_gc_objects_are_static_roots = True
 
     def set_query_functions(self, is_varsize, has_gcptr_in_varsize,

Modified: pypy/dist/pypy/rpython/memory/gc/semispace.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc/semispace.py	(original)
+++ pypy/dist/pypy/rpython/memory/gc/semispace.py	Tue Feb 26 10:07:04 2008
@@ -26,7 +26,7 @@
     _alloc_flavor_ = "raw"
     inline_simple_malloc = True
     inline_simple_malloc_varsize = True
-    needs_zero_gc_pointers = False
+    malloc_zero_filled = True
     first_unused_gcflag = first_gcflag << 3
     total_collection_time = 0.0
     total_collection_count = 0

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	Tue Feb 26 10:07:04 2008
@@ -6,6 +6,7 @@
 from pypy.rpython.lltypesystem.lloperation import llop
 
 class BoehmGCTransformer(GCTransformer):
+    malloc_zero_filled = True
     FINALIZER_PTR = lltype.Ptr(lltype.FuncType([llmemory.Address], lltype.Void))
 
     def __init__(self, translator, inline=False):

Modified: pypy/dist/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform/framework.py	Tue Feb 26 10:07:04 2008
@@ -330,7 +330,7 @@
         s_gc = self.translator.annotator.bookkeeper.valueoftype(GCClass)
         r_gc = self.translator.rtyper.getrepr(s_gc)
         self.c_const_gc = rmodel.inputconst(r_gc, self.gcdata.gc)
-        self.needs_zero_gc_pointers = GCClass.needs_zero_gc_pointers
+        self.malloc_zero_filled = GCClass.malloc_zero_filled
 
         HDR = self._gc_HDR = self.gcdata.gc.gcheaderbuilder.HDR
         self._gc_fields = fields = []
@@ -550,7 +550,7 @@
                   resultvar=op.result)
 
     def gct_zero_gc_pointers_inside(self, hop):
-        if self.needs_zero_gc_pointers:
+        if not self.malloc_zero_filled:
             v_ob = hop.spaceop.args[0]
             TYPE = v_ob.concretetype.TO
             gen_zero_gc_pointers(TYPE, v_ob, hop.llops)

Modified: pypy/dist/pypy/rpython/memory/gctransform/refcounting.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform/refcounting.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform/refcounting.py	Tue Feb 26 10:07:04 2008
@@ -32,6 +32,7 @@
 ADDRESS_VOID_FUNC = lltype.FuncType([llmemory.Address], lltype.Void)
 
 class RefcountingGCTransformer(GCTransformer):
+    malloc_zero_filled = True
 
     HDR = lltype.Struct("header", ("refcount", lltype.Signed))
 

Modified: pypy/dist/pypy/rpython/memory/gcwrapper.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gcwrapper.py	(original)
+++ pypy/dist/pypy/rpython/memory/gcwrapper.py	Tue Feb 26 10:07:04 2008
@@ -36,7 +36,7 @@
             typeid = self.get_type_id(TYPE)
             addr = self.gc.malloc(typeid, n, zero=zero)
             result = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(TYPE))
-            if self.gc.needs_zero_gc_pointers:
+            if not self.gc.malloc_zero_filled:
                 gctypelayout.zero_gc_pointers(result)
             return result
         else:
@@ -52,7 +52,7 @@
             addr = self.gc.malloc(typeid, size, zero=zero,
                                   coallocator=coallocator)
             result = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(TYPE))
-            if self.gc.needs_zero_gc_pointers:
+            if not self.gc.malloc_zero_filled:
                 gctypelayout.zero_gc_pointers(result)
             return result
         return self.malloc(TYPE, size, 'gc', zero)

Modified: pypy/dist/pypy/translator/c/gc.py
==============================================================================
--- pypy/dist/pypy/translator/c/gc.py	(original)
+++ pypy/dist/pypy/translator/c/gc.py	Tue Feb 26 10:07:04 2008
@@ -40,7 +40,9 @@
         return []
 
     def pre_pre_gc_code(self): # code that goes before include g_prerequisite.h
-        return []
+        gct = self.db.gctransformer
+        yield '/* using %s */' % (gct.__class__.__name__,)
+        yield '#define MALLOC_ZERO_FILLED %d' % (gct.malloc_zero_filled,)
 
     def pre_gc_code(self):
         return ['typedef void *GC_hidden_pointer;']
@@ -182,6 +184,8 @@
         return ['gc']
 
     def pre_pre_gc_code(self):
+        for line in BasicGcPolicy.pre_pre_gc_code(self):
+            yield line
         if sys.platform == "linux2":
             yield "#define _REENTRANT 1"
             yield "#define GC_LINUX_THREADS 1"
@@ -247,9 +251,6 @@
     gc_libraries = RefcountingGcPolicy.gc_libraries.im_func
     gc_startup_code = RefcountingGcPolicy.gc_startup_code.im_func
 
-    def pre_pre_gc_code(self):
-        yield '#define USING_NO_GC'
-
 
 class FrameworkGcPolicy(BasicGcPolicy):
     transformerclass = framework.FrameworkGCTransformer
@@ -277,9 +278,6 @@
     def rtti_node_factory(self):
         return FrameworkGcRuntimeTypeInfo_OpaqueNode
 
-    def pre_pre_gc_code(self):
-        yield '#define USING_FRAMEWORK_GC'
-
     def gc_startup_code(self):
         fnptr = self.db.gctransformer.frameworkgc_setup_ptr.value
         yield '%s();' % (self.db.get(fnptr),)

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	Tue Feb 26 10:07:04 2008
@@ -64,12 +64,6 @@
 #define alloca  _alloca
 #endif
 
-#ifdef USING_FRAMEWORK_GC
-#define MALLOC_ZERO_FILLED 0
-#else
-#define MALLOC_ZERO_FILLED 1
-#endif
-
 #define OP_STACK_MALLOC(size,r,restype)                                 \
     r = (restype) alloca(size);                                         \
     if (r != NULL) memset((void*) r, 0, size);



More information about the Pypy-commit mailing list