[pypy-svn] r77090 - pypy/branch/gen2-gc/pypy/rpython/lltypesystem

arigo at codespeak.net arigo at codespeak.net
Wed Sep 15 15:34:34 CEST 2010


Author: arigo
Date: Wed Sep 15 15:34:32 2010
New Revision: 77090

Modified:
   pypy/branch/gen2-gc/pypy/rpython/lltypesystem/llarena.py
Log:
Add some comments and __repr__s.


Modified: pypy/branch/gen2-gc/pypy/rpython/lltypesystem/llarena.py
==============================================================================
--- pypy/branch/gen2-gc/pypy/rpython/lltypesystem/llarena.py	(original)
+++ pypy/branch/gen2-gc/pypy/rpython/lltypesystem/llarena.py	Wed Sep 15 15:34:32 2010
@@ -16,8 +16,11 @@
 class Arena(object):
     object_arena_location = {}     # {container: (arena, offset)}
     old_object_arena_location = weakref.WeakKeyDictionary()
+    _count_arenas = 0
 
     def __init__(self, nbytes, zero):
+        Arena._count_arenas += 1
+        self._arena_index = Arena._count_arenas
         self.nbytes = nbytes
         self.usagemap = array.array('c')
         self.objectptrs = {}        # {offset: ptr-to-container}
@@ -25,6 +28,9 @@
         self.freed = False
         self.reset(zero)
 
+    def __repr__(self):
+        return '<Arena #%d [%d bytes]>' % (self._arena_index, self.nbytes)
+
     def reset(self, zero, start=0, size=None):
         self.check()
         if size is None:
@@ -357,6 +363,11 @@
     # This only works with linux's madvise(), which is really not a memory
     # usage hint but a real command.  It guarantees that after MADV_DONTNEED
     # the pages are cleared again.
+
+    # Note that the trick of the general 'posix' section below, i.e.
+    # reading /dev/zero, does not seem to have the correct effect of
+    # lazily-allocating pages on all Linux systems.
+
     from pypy.rpython.tool import rffi_platform
     from pypy.translator.tool.cbuild import ExternalCompilationInfo
     _eci = ExternalCompilationInfo(includes=['sys/mman.h'])



More information about the Pypy-commit mailing list