[pypy-svn] r69003 - in pypy/branch/gc-dump-malloc/pypy: rpython/memory rpython/memory/gc translator/c/src
arigo at codespeak.net
arigo at codespeak.net
Thu Nov 5 20:32:19 CET 2009
Author: arigo
Date: Thu Nov 5 20:32:18 2009
New Revision: 69003
Modified:
pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/generation.py
pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/hybrid.py
pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/semispace.py
pypy/branch/gc-dump-malloc/pypy/rpython/memory/gctypelayout.py
pypy/branch/gc-dump-malloc/pypy/translator/c/src/main.h
Log:
Following tradition pioneered by fijal, also record
the total size of objects, not just the count.
Modified: pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/generation.py (original)
+++ pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/generation.py Thu Nov 5 20:32:18 2009
@@ -215,8 +215,8 @@
result = self.collect_nursery()
llarena.arena_reserve(result, totalsize)
# GCFLAG_NO_YOUNG_PTRS is never set on young objs
- self.init_gc_object(result, typeid, flags=0)
(result + size_gc_header + offset_to_length).signed[0] = length
+ self.init_gc_object(result, typeid, flags=0)
self.nursery_free = result + llarena.round_up_for_allocation(totalsize)
return llmemory.cast_adr_to_ptr(result+size_gc_header, llmemory.GCREF)
Modified: pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/hybrid.py
==============================================================================
--- pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/hybrid.py (original)
+++ pypy/branch/gc-dump-malloc/pypy/rpython/memory/gc/hybrid.py Thu Nov 5 20:32:18 2009
@@ -168,8 +168,8 @@
if raw_malloc_usage(totalsize) <= self.nursery_top - result:
llarena.arena_reserve(result, totalsize)
# GCFLAG_NO_YOUNG_PTRS is never set on young objs
- self.init_gc_object(result, typeid, flags=0)
(result + size_gc_header + offset_to_length).signed[0] = length
+ self.init_gc_object(result, typeid, flags=0)
self.nursery_free = result + llarena.round_up_for_allocation(
totalsize)
return llmemory.cast_adr_to_ptr(result+size_gc_header,
@@ -201,8 +201,8 @@
else:
result = self.malloc_varsize_collecting_nursery(totalsize)
flags = self.GCFLAGS_FOR_NEW_YOUNG_OBJECTS
- self.init_gc_object(result, typeid, flags)
(result + size_gc_header + offset_to_length).signed[0] = length
+ self.init_gc_object(result, typeid, flags)
return llmemory.cast_adr_to_ptr(result+size_gc_header, llmemory.GCREF)
malloc_varsize_slowpath._dont_inline_ = True
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 20:32:18 2009
@@ -114,8 +114,8 @@
raise memoryError
result = self.obtain_free_space(totalsize)
llarena.arena_reserve(result, totalsize)
- self.init_gc_object(result, typeid16)
(result + size_gc_header + offset_to_length).signed[0] = length
+ self.init_gc_object(result, typeid16)
self.free = result + llarena.round_up_for_allocation(totalsize)
return llmemory.cast_adr_to_ptr(result+size_gc_header, llmemory.GCREF)
@@ -428,7 +428,10 @@
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)
+ #
+ size_gc_header = self.gcheaderbuilder.size_gc_header
+ size = self.get_size(addr + size_gc_header)
+ self.count_allocation(typeid16, size)
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 20:32:18 2009
@@ -21,6 +21,7 @@
# structure describing the layout of a typeid
TYPE_INFO = lltype.Struct("type_info",
("counter", lltype.Signed),
+ ("counter_size", lltype.Signed),
("infobits", lltype.Signed), # combination of the T_xxx consts
("finalizer", FINALIZERTYPE),
("fixedsize", lltype.Signed),
@@ -94,8 +95,10 @@
return weakptr_offset
return -1
- def q_count_allocation(self, typeid):
- self.get(typeid).counter += 1
+ def q_count_allocation(self, typeid, size):
+ p = self.get(typeid)
+ p.counter += 1
+ p.counter_size += llmemory.raw_malloc_usage(size)
def set_query_functions(self, gc):
gc.set_query_functions(
Modified: pypy/branch/gc-dump-malloc/pypy/translator/c/src/main.h
==============================================================================
--- pypy/branch/gc-dump-malloc/pypy/translator/c/src/main.h (original)
+++ pypy/branch/gc-dump-malloc/pypy/translator/c/src/main.h Thu Nov 5 20:32:18 2009
@@ -17,8 +17,11 @@
void dump_group_info(const char *typename, long *counter)
{
- if (*counter)
- fprintf(stderr, "|%12lu %s\n", (unsigned long)*counter, typename);
+ if (counter[0])
+ fprintf(stderr, "|%12lu %12lu %s\n",
+ (unsigned long)counter[0],
+ (unsigned long)counter[1],
+ typename);
}
int main(int argc, char *argv[])
More information about the Pypy-commit
mailing list