[pypy-svn] r69000 - in pypy/branch/gc-dump-malloc/pypy/rpython/memory: . gc
arigo at codespeak.net
arigo at codespeak.net
Thu Nov 5 19:18:21 CET 2009
Author: arigo
Date: Thu Nov 5 19:18:21 2009
New Revision: 69000
Modified:
pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/base.py
pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/semispace.py
pypy/branch/gc-dump-malloc/pypy/rpython/memory/gctypelayout.py
Log:
Add a counter on all allocations, by typeid.
What is left: find a way to display that information
when the process exits...
Modified: pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/base.py
==============================================================================
--- pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/base.py (original)
+++ pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/base.py Thu Nov 5 19:18:21 2009
@@ -48,7 +48,8 @@
varsize_offset_to_variable_part,
varsize_offset_to_length,
varsize_offsets_to_gcpointers_in_var_part,
- weakpointer_offset):
+ weakpointer_offset,
+ count_allocation):
self.getfinalizer = getfinalizer
self.is_varsize = is_varsize
self.has_gcptr_in_varsize = has_gcptr_in_varsize
@@ -60,6 +61,7 @@
self.varsize_offset_to_length = varsize_offset_to_length
self.varsize_offsets_to_gcpointers_in_var_part = varsize_offsets_to_gcpointers_in_var_part
self.weakpointer_offset = weakpointer_offset
+ self.count_allocation = count_allocation
def set_root_walker(self, root_walker):
self.root_walker = root_walker
Modified: pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/semispace.py
==============================================================================
--- pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/semispace.py (original)
+++ pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/semispace.py Thu Nov 5 19:18:21 2009
@@ -428,6 +428,7 @@
def init_gc_object(self, addr, typeid16, flags=0):
hdr = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(self.HDR))
hdr.tid = self.combine(typeid16, flags)
+ self.count_allocation(typeid16)
def init_gc_object_immortal(self, addr, typeid16, flags=0):
hdr = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(self.HDR))
Modified: pypy/branch/gc-dump-malloc/pypy/rpython/memory/gctypelayout.py
==============================================================================
--- pypy/branch/gc-dump-malloc/pypy/rpython/memory/gctypelayout.py (original)
+++ pypy/branch/gc-dump-malloc/pypy/rpython/memory/gctypelayout.py Thu Nov 5 19:18:21 2009
@@ -24,6 +24,7 @@
("finalizer", FINALIZERTYPE),
("fixedsize", lltype.Signed),
("ofstoptrs", lltype.Ptr(OFFSETS_TO_GC_PTR)),
+ ("counter", lltype.Signed),
hints={'immutable': True},
)
VARSIZE_TYPE_INFO = lltype.Struct("varsize_type_info",
@@ -93,6 +94,9 @@
return weakptr_offset
return -1
+ def q_count_allocation(self, typeid):
+ self.get(typeid).counter += 1
+
def set_query_functions(self, gc):
gc.set_query_functions(
self.q_is_varsize,
@@ -105,7 +109,8 @@
self.q_varsize_offset_to_variable_part,
self.q_varsize_offset_to_length,
self.q_varsize_offsets_to_gcpointers_in_var_part,
- self.q_weakpointer_offset)
+ self.q_weakpointer_offset,
+ self.q_count_allocation)
T_IS_VARSIZE = 0x01
@@ -160,6 +165,7 @@
if TYPE == WEAKREF:
infobits |= T_IS_WEAKREF
info.infobits = infobits
+ info.counter = 0
# ____________________________________________________________
More information about the Pypy-commit
mailing list