[pypy-commit] pypy gc_no_cleanup_nursery: implement the arena debugging and fix for asmgcc

fijal noreply at buildbot.pypy.org
Sat Sep 6 21:15:46 CEST 2014


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: gc_no_cleanup_nursery
Changeset: r73343:3fc11182cb52
Date: 2014-09-06 13:15 -0600
http://bitbucket.org/pypy/pypy/changeset/3fc11182cb52/

Log:	implement the arena debugging and fix for asmgcc

diff --git a/rpython/jit/backend/llsupport/jitframe.py b/rpython/jit/backend/llsupport/jitframe.py
--- a/rpython/jit/backend/llsupport/jitframe.py
+++ b/rpython/jit/backend/llsupport/jitframe.py
@@ -47,6 +47,7 @@
 def jitframe_allocate(frame_info):
     frame = lltype.malloc(JITFRAME, frame_info.jfi_frame_depth)
     frame.jf_frame_info = frame_info
+    frame.jf_extra_stack_depth = 0
     return frame
 
 def jitframe_resolve(frame):
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -6,9 +6,8 @@
                          '4M'.  Small values
                          (like 1 or 1KB) are useful for debugging.
 
- PYPY_GC_NURSERY_CLEANUP The interval at which nursery is cleaned up. Must
-                         be smaller than the nursery size and bigger than the
-                         biggest object we can allotate in the nursery.
+ PYPY_GC_NURSERY_DEBUG   If set to non-zero, will fill nursery with garbage,
+                         to help debugging.
 
  PYPY_GC_INCREMENT_STEP  The size of memory marked during the marking step.
                          Default is size of nursery * 2. If you mark it too high
@@ -358,6 +357,7 @@
         if not self.read_from_env:
             self.allocate_nursery()
             self.gc_increment_step = self.nursery_size * 4
+            self.gc_nursery_debug = False
         else:
             #
             defaultsize = self.nursery_size
@@ -414,6 +414,9 @@
             else:
                 self.gc_increment_step = newsize * 4
             #
+            nursery_debug = env.read_uint_from_env('PYPY_GC_NURSERY_DEBUG')
+            if nursery_debug > 0:
+                self.gc_nursery_debug = True
             self.minor_collection()    # to empty the nursery
             llarena.arena_free(self.nursery)
             self.nursery_size = newsize
@@ -1390,7 +1393,10 @@
         #
         # All live nursery objects are out, and the rest dies.  Fill
         # the nursery up to the cleanup point with zeros
-        llarena.arena_reset(self.nursery, self.nursery_size, 0)
+        if self.gc_nursery_debug:
+            llarena.arena_reset(self.nursery, self.nursery_size, 3)
+        else:
+            llarena.arena_reset(self.nursery, self.nursery_size, 0)
         self.debug_rotate_nursery()
         self.nursery_free = self.nursery
         self.nursery_top = self.nursery + self.nursery_size
diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py
--- a/rpython/rtyper/llinterp.py
+++ b/rpython/rtyper/llinterp.py
@@ -953,6 +953,9 @@
         checkadr(toaddr)
         llmemory.raw_memcopy(fromaddr, toaddr, size)
 
+    def op_raw_memset(self, addr, byte, size):
+        raise NotImplementedError
+
     op_raw_memmove = op_raw_memcopy # this is essentially the same here
 
     def op_raw_load(self, RESTYPE, addr, offset):
diff --git a/rpython/rtyper/lltypesystem/llarena.py b/rpython/rtyper/lltypesystem/llarena.py
--- a/rpython/rtyper/lltypesystem/llarena.py
+++ b/rpython/rtyper/lltypesystem/llarena.py
@@ -1,6 +1,7 @@
 import array, weakref
 from rpython.rtyper.lltypesystem import llmemory
 from rpython.rlib.rarithmetic import is_valid_int
+from rpython.rtyper.lltypesystem.lloperation import llop
 
 
 # An "arena" is a large area of memory which can hold a number of
@@ -53,7 +54,7 @@
                 del self.objectptrs[offset]
                 del self.objectsizes[offset]
                 obj._free()
-        if zero:
+        if zero and zero != 3:
             initialbyte = "0"
         else:
             initialbyte = "#"
@@ -346,6 +347,7 @@
       * 0: don't fill the area with zeroes
       * 1: clear, optimized for a very large area of memory
       * 2: clear, optimized for a small or medium area of memory
+      * 3: fill with garbage
     """
     arena_addr = getfakearenaaddress(arena_addr)
     arena_addr.arena.reset(zero, arena_addr.offset, size)
@@ -518,6 +520,8 @@
     if zero:
         if zero == 1:
             clear_large_memory_chunk(arena_addr, size)
+        elif zero == 3:
+            llop.raw_memset(lltype.Void, arena_addr, ord('#'), size)
         else:
             llmemory.raw_memclear(arena_addr, size)
 llimpl_arena_reset._always_inline_ = True
diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -406,6 +406,7 @@
     'raw_malloc_usage':     LLOp(sideeffects=False),
     'raw_free':             LLOp(),
     'raw_memclear':         LLOp(),
+    'raw_memset':           LLOp(),
     'raw_memcopy':          LLOp(),
     'raw_memmove':          LLOp(),
     'raw_load':             LLOp(sideeffects=False, canrun=True),
diff --git a/rpython/translator/c/src/mem.h b/rpython/translator/c/src/mem.h
--- a/rpython/translator/c/src/mem.h
+++ b/rpython/translator/c/src/mem.h
@@ -18,6 +18,7 @@
 #define OP_RAW_FREE(p, r) PyObject_Free(p); COUNT_FREE;
 
 #define OP_RAW_MEMCLEAR(p, size, r) memset((void*)p, 0, size)
+#define OP_RAW_MEMSET(p, byte, size, r) memset((void*)p, byte, size)
 
 #define OP_RAW_MALLOC_USAGE(size, r) r = size
 


More information about the pypy-commit mailing list