[pypy-svn] r77449 - in pypy/trunk/pypy/rpython: lltypesystem memory/gc

arigo at codespeak.net arigo at codespeak.net
Tue Sep 28 16:14:24 CEST 2010


Author: arigo
Date: Tue Sep 28 16:14:22 2010
New Revision: 77449

Modified:
   pypy/trunk/pypy/rpython/lltypesystem/llarena.py
   pypy/trunk/pypy/rpython/memory/gc/minimark.py
   pypy/trunk/pypy/rpython/memory/gc/minimarkpage.py
Log:
Tweaks and comments.


Modified: pypy/trunk/pypy/rpython/lltypesystem/llarena.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/llarena.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/llarena.py	Tue Sep 28 16:14:22 2010
@@ -479,10 +479,11 @@
 
 def llimpl_arena_malloc(nbytes, zero):
     addr = llimpl_malloc(nbytes)
-    if zero and bool(addr):
-        clear_large_memory_chunk(addr, nbytes)
+    if bool(addr):
+        llimpl_arena_reset(addr, nbytes, zero)
     return addr
-register_external(arena_malloc, [int, bool], llmemory.Address,
+llimpl_arena_malloc._always_inline_ = True
+register_external(arena_malloc, [int, int], llmemory.Address,
                   'll_arena.arena_malloc',
                   llimpl=llimpl_arena_malloc,
                   llfakeimpl=arena_malloc,
@@ -499,6 +500,7 @@
             clear_large_memory_chunk(arena_addr, size)
         else:
             llmemory.raw_memclear(arena_addr, size)
+llimpl_arena_reset._always_inline_ = True
 register_external(arena_reset, [llmemory.Address, int, int], None,
                   'll_arena.arena_reset',
                   llimpl=llimpl_arena_reset,

Modified: pypy/trunk/pypy/rpython/memory/gc/minimark.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/minimark.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gc/minimark.py	Tue Sep 28 16:14:22 2010
@@ -101,9 +101,10 @@
         # fall-back number.
         "nursery_size": 896*1024,
 
-        # The system page size.  Like obmalloc.c, we assume that it is 4K,
-        # which is OK for most systems.
-        "page_size": 4096,
+        # The system page size.  Like obmalloc.c, we assume that it is 4K
+        # for 32-bit systems; unlike obmalloc.c, we assume that it is 8K
+        # for 64-bit systems, for consistent results.
+        "page_size": 1024*WORD,
 
         # The size of an arena.  Arenas are groups of pages allocated
         # together.
@@ -279,7 +280,7 @@
         # in malloc_fixedsize_clear().  The few extra pages are never used
         # anyway so it doesn't even count.
         extra = self.nonlarge_gcptrs_max + 1
-        self.nursery = llarena.arena_malloc(self.nursery_size + extra, True)
+        self.nursery = llarena.arena_malloc(self.nursery_size + extra, 2)
         if not self.nursery:
             raise MemoryError("cannot allocate nursery")
         # the current position in the nursery:
@@ -523,15 +524,11 @@
             # Allocate the object using arena_malloc(), which we assume here
             # is just the same as raw_malloc(), but allows the extra
             # flexibility of saying that we have extra words in the header.
-            arena = llarena.arena_malloc(allocsize, False)
+            # The memory returned is cleared by a raw_memclear().
+            arena = llarena.arena_malloc(allocsize, 2)
             if not arena:
                 raise MemoryError("cannot allocate large object")
             #
-            # Clear it using method 2 of llarena.arena_reset(), which is the
-            # same as just a raw_memclear().  This also clears the card mark
-            # bits, if any.
-            llarena.arena_reset(arena, allocsize, 2)
-            #
             # Reserve the card mark bits as a list of single bytes
             # (the loop is empty in C).
             i = 0

Modified: pypy/trunk/pypy/rpython/memory/gc/minimarkpage.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/minimarkpage.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gc/minimarkpage.py	Tue Sep 28 16:14:22 2010
@@ -39,6 +39,9 @@
     # -- The chained list of free blocks.  If there are none, points to the
     #    first uninitialized block.
     ('freeblock', llmemory.Address),
+    # -- The structure above is 4 words, which is a good value:
+    #    '(1024-4) % N' is zero or very small for various small N's,
+    #    i.e. there is not much wasted space.
     )
 PAGE_PTR.TO.become(PAGE_HEADER)
 PAGE_NULL = lltype.nullptr(PAGE_HEADER)



More information about the Pypy-commit mailing list