[pypy-svn] r69092 - in pypy/branch/gc-dump-heap/pypy: rpython rpython/lltypesystem rpython/memory/gc rpython/memory/gctransform rpython/memory/test translator/c/test
fijal at codespeak.net
fijal at codespeak.net
Mon Nov 9 14:36:31 CET 2009
Author: fijal
Date: Mon Nov 9 14:36:30 2009
New Revision: 69092
Modified:
pypy/branch/gc-dump-heap/pypy/rpython/llinterp.py
pypy/branch/gc-dump-heap/pypy/rpython/lltypesystem/lloperation.py
pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/generation.py
pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/semispace.py
pypy/branch/gc-dump-heap/pypy/rpython/memory/gctransform/framework.py
pypy/branch/gc-dump-heap/pypy/rpython/memory/gctransform/transform.py
pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_gc.py
pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_transformed_gc.py
pypy/branch/gc-dump-heap/pypy/translator/c/test/test_boehm.py
pypy/branch/gc-dump-heap/pypy/translator/c/test/test_newgc.py
Log:
(arigo, fijal)
* Rename dump_heap to heap_stats
* Implement something for the basic gctransform class (so it does not
explode horribly on ie boehm)
Modified: pypy/branch/gc-dump-heap/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/llinterp.py (original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/llinterp.py Mon Nov 9 14:36:30 2009
@@ -824,7 +824,7 @@
def op_gc_assume_young_pointers(self, addr):
raise NotImplementedError
- def op_gc_dump_heap(self):
+ def op_gc_heap_stats(self):
raise NotImplementedError
def op_gc_obtain_free_space(self, size):
Modified: pypy/branch/gc-dump-heap/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/lltypesystem/lloperation.py (original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/lltypesystem/lloperation.py Mon Nov 9 14:36:30 2009
@@ -460,7 +460,7 @@
'gc_thread_run' : LLOp(),
'gc_thread_die' : LLOp(),
'gc_assume_young_pointers': LLOp(),
- 'gc_dump_heap' : LLOp(canunwindgc=True),
+ 'gc_heap_stats' : LLOp(canunwindgc=True),
# ------- JIT & GC interaction, only for some GCs ----------
Modified: pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/generation.py (original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/generation.py Mon Nov 9 14:36:30 2009
@@ -517,7 +517,7 @@
def _id_grow_older(self, obj, id, ignored):
self.objects_with_id.setitem(obj, id)
- def dump_heap_walk_roots(self):
+ def heap_stats_walk_roots(self):
self.last_generation_root_objects.foreach(
self._track_heap_ext, None)
self.root_walker.walk_roots(
Modified: pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/semispace.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/semispace.py (original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/semispace.py Mon Nov 9 14:36:30 2009
@@ -658,13 +658,13 @@
def _track_heap_root(self, root):
self.track_heap(root.address[0])
- def dump_heap_walk_roots(self):
+ def heap_stats_walk_roots(self):
self.root_walker.walk_roots(
SemiSpaceGC._track_heap_root,
SemiSpaceGC._track_heap_root,
SemiSpaceGC._track_heap_root)
- def dump_heap(self):
+ def heap_stats(self):
self._tracked_dict = self.AddressDict()
max_tid = self.root_walker.gcdata.max_type_id
ll_typeid_map = lltype.malloc(ARRAY_TYPEID_MAP, max_tid, zero=True)
@@ -676,7 +676,7 @@
while i < max_tid:
self._tracked_dict.add(llmemory.cast_ptr_to_adr(ll_typeid_map[i]))
i += 1
- self.dump_heap_walk_roots()
+ self.heap_stats_walk_roots()
self._ll_typeid_map = lltype.nullptr(ARRAY_TYPEID_MAP)
self._tracked_dict.delete()
return ll_typeid_map
Modified: pypy/branch/gc-dump-heap/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/memory/gctransform/framework.py (original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/memory/gctransform/framework.py Mon Nov 9 14:36:30 2009
@@ -271,8 +271,8 @@
[s_gc, annmodel.SomeAddress()],
annmodel.s_None)
- if hasattr(GCClass, 'dump_heap'):
- self.dump_heap_ptr = getfn(GCClass.dump_heap.im_func,
+ if hasattr(GCClass, 'heap_stats'):
+ self.heap_stats_ptr = getfn(GCClass.heap_stats.im_func,
[s_gc], annmodel.SomePtr(lltype.Ptr(ARRAY_TYPEID_MAP)),
minimal_transform=False)
self.get_member_index_ptr = getfn(
@@ -648,10 +648,12 @@
hop.genop("direct_call", [self.assume_young_pointers_ptr,
self.c_const_gc, v_addr])
- def gct_gc_dump_heap(self, hop):
+ def gct_gc_heap_stats(self, hop):
+ if not hasattr(self, 'heap_stats_ptr'):
+ return GCTransformer.gct_gc_heap_stats(self, hop)
op = hop.spaceop
livevars = self.push_roots(hop)
- hop.genop("direct_call", [self.dump_heap_ptr, self.c_const_gc],
+ hop.genop("direct_call", [self.heap_stats_ptr, self.c_const_gc],
resultvar=op.result)
self.pop_roots(hop, livevars)
Modified: pypy/branch/gc-dump-heap/pypy/rpython/memory/gctransform/transform.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/memory/gctransform/transform.py (original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/memory/gctransform/transform.py Mon Nov 9 14:36:30 2009
@@ -388,6 +388,11 @@
# this assumes a non-moving GC. Moving GCs need to override this
hop.rename('cast_ptr_to_int')
+ def gct_gc_heap_stats(self, hop):
+ from pypy.rpython.memory.gc.base import ARRAY_TYPEID_MAP
+
+ return hop.cast_result(rmodel.inputconst(lltype.Ptr(ARRAY_TYPEID_MAP),
+ lltype.nullptr(ARRAY_TYPEID_MAP)))
class MinimalGCTransformer(BaseGCTransformer):
def __init__(self, parenttransformer):
Modified: pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_gc.py (original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_gc.py Mon Nov 9 14:36:30 2009
@@ -551,28 +551,6 @@
res = self.interpret(fn, [-1000], taggedpointers=True)
assert res == 111
-
- def test_gc_dump_heap(self):
- if getattr(self.GCClass, 'dump_heap', None) is None:
- py.test.skip("unsupported gc")
- S = lltype.GcStruct('S', ('x', lltype.Signed))
-
- def fun(fd):
- l = []
- for i in range(10):
- l.append(lltype.malloc(S))
- rgc.dump_heap(fd)
- keepalive_until_here(l)
- return 0
-
- from pypy.tool.udir import udir
- f = udir.join("gcdump_direct.log")
- handle = open(str(f), "w")
- run = self.interpret(fun, [handle.fileno()])
- handle.close()
- assert f.read() == 'xxx'
-
-
from pypy.rlib.objectmodel import UnboxedValue
class TaggedBase(object):
Modified: pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_transformed_gc.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_transformed_gc.py (original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_transformed_gc.py Mon Nov 9 14:36:30 2009
@@ -797,7 +797,7 @@
run = self.runner("do_malloc_operations_in_call")
run([])
- def define_gc_dump_heap(cls):
+ def define_gc_heap_stats(cls):
S = lltype.GcStruct('S', ('x', lltype.Signed))
l1 = []
l2 = []
@@ -815,7 +815,7 @@
# We cheat here and only read the table which we later on
# process ourselves, otherwise this test takes ages
llop.gc__collect(lltype.Void)
- tb = rgc._dump_heap()
+ tb = rgc._heap_stats()
a = 0
nr = 0
b = 0
@@ -836,8 +836,8 @@
return d * 1000 + c * 100 + b * 10 + a
return f
- def test_gc_dump_heap(self):
- run = self.runner("gc_dump_heap")
+ def test_gc_heap_stats(self):
+ run = self.runner("gc_heap_stats")
res = run([])
assert res % 10000 == 2611
totsize = (res / 10000)
Modified: pypy/branch/gc-dump-heap/pypy/translator/c/test/test_boehm.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/translator/c/test/test_boehm.py (original)
+++ pypy/branch/gc-dump-heap/pypy/translator/c/test/test_boehm.py Mon Nov 9 14:36:30 2009
@@ -380,6 +380,15 @@
c_fn = self.getcompiled(fn, [])
assert c_fn() == False
+ def test_heap_stats(self):
+ from pypy.rlib import rgc
+
+ def fn():
+ return bool(rgc._heap_stats())
+
+ c_fn = self.getcompiled(fn, [])
+ assert not c_fn()
+
def test_malloc_nonmovable(self):
TP = lltype.GcArray(lltype.Char)
def func():
Modified: pypy/branch/gc-dump-heap/pypy/translator/c/test/test_newgc.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/translator/c/test/test_newgc.py (original)
+++ pypy/branch/gc-dump-heap/pypy/translator/c/test/test_newgc.py Mon Nov 9 14:36:30 2009
@@ -900,7 +900,7 @@
res = self.run('gc_set_max_heap_size')
assert res == 2
- def define_gc_dump_heap(cls):
+ def define_gc_heap_stats(cls):
S = lltype.GcStruct('S', ('x', lltype.Signed))
l1 = []
l2 = []
@@ -912,7 +912,7 @@
l1.append(s)
l2.append(s)
l3.append(s)
- tb = rgc._dump_heap()
+ tb = rgc._heap_stats()
a = 0
nr = 0
b = 0
@@ -930,8 +930,8 @@
return c * 100 + b * 10 + a
return f
- def test_gc_dump_heap(self):
- res = self.run("gc_dump_heap")
+ def test_gc_heap_stats(self):
+ res = self.run("gc_heap_stats")
assert res == 3011
def definestr_string_builder(cls):
More information about the Pypy-commit
mailing list