[pypy-svn] r77184 - in pypy/trunk/pypy: module/gc rlib rpython/lltypesystem rpython/memory/gc rpython/memory/gctransform translator/c/src
arigo at codespeak.net
arigo at codespeak.net
Mon Sep 20 09:37:13 CEST 2010
Author: arigo
Date: Mon Sep 20 09:37:11 2010
New Revision: 77184
Modified:
pypy/trunk/pypy/module/gc/referents.py
pypy/trunk/pypy/rlib/rgc.py
pypy/trunk/pypy/rpython/lltypesystem/lloperation.py
pypy/trunk/pypy/rpython/memory/gc/inspect.py
pypy/trunk/pypy/rpython/memory/gctransform/framework.py
pypy/trunk/pypy/translator/c/src/mem.h
Log:
Boehm translation fix.
Modified: pypy/trunk/pypy/module/gc/referents.py
==============================================================================
--- pypy/trunk/pypy/module/gc/referents.py (original)
+++ pypy/trunk/pypy/module/gc/referents.py Mon Sep 20 09:37:11 2010
@@ -2,7 +2,7 @@
from pypy.interpreter.baseobjspace import W_Root, Wrappable
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.gateway import ObjSpace
-from pypy.interpreter.error import wrap_oserror
+from pypy.interpreter.error import wrap_oserror, OperationError
from pypy.rlib.objectmodel import we_are_translated
@@ -33,8 +33,14 @@
gcref = rgc.cast_instance_to_gcref(w_obj)
return gcref
+def missing_operation(space):
+ return OperationError(space.w_NotImplementedError,
+ space.wrap("operation not implemented by this GC"))
+
def get_rpy_roots(space):
lst = rgc.get_rpy_roots()
+ if lst is None:
+ raise missing_operation(space)
return space.newlist([wrap(space, gcref) for gcref in lst if gcref])
def get_rpy_referents(space, w_obj):
@@ -42,6 +48,8 @@
This is likely to contain a lot of GcRefs."""
gcref = unwrap(space, w_obj)
lst = rgc.get_rpy_referents(gcref)
+ if lst is None:
+ raise missing_operation(space)
return space.newlist([wrap(space, gcref) for gcref in lst])
def get_rpy_memory_usage(space, w_obj):
@@ -49,6 +57,8 @@
This does not include the internal structures of the object."""
gcref = unwrap(space, w_obj)
size = rgc.get_rpy_memory_usage(gcref)
+ if size < 0:
+ raise missing_operation(space)
return space.wrap(size)
def get_rpy_type_index(space, w_obj):
@@ -57,6 +67,8 @@
file typeids.txt produced at translation."""
gcref = unwrap(space, w_obj)
index = rgc.get_rpy_type_index(gcref)
+ if index < 0:
+ raise missing_operation(space)
return space.wrap(index)
def _list_w_obj_referents(gcref, result_w):
@@ -151,7 +163,9 @@
def _dump_rpy_heap(space, fd):
try:
- rgc.dump_rpy_heap(fd)
+ ok = rgc.dump_rpy_heap(fd):
except OSError, e:
raise wrap_oserror(space, e)
+ if not ok:
+ raise missing_operation(space)
_dump_rpy_heap.unwrap_spec = [ObjSpace, int]
Modified: pypy/trunk/pypy/rlib/rgc.py
==============================================================================
--- pypy/trunk/pypy/rlib/rgc.py (original)
+++ pypy/trunk/pypy/rlib/rgc.py Mon Sep 20 09:37:11 2010
@@ -517,8 +517,8 @@
class Entry(ExtRegistryEntry):
_about_ = dump_rpy_heap
def compute_result_annotation(self, s_fd):
- from pypy.annotation.model import s_None
- return s_None
+ from pypy.annotation.model import s_Bool
+ return s_Bool
def specialize_call(self, hop):
vlist = hop.inputargs(lltype.Signed)
hop.exception_is_here()
Modified: pypy/trunk/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/lloperation.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/lloperation.py Mon Sep 20 09:37:11 2010
@@ -467,6 +467,13 @@
'gc_writebarrier_before_copy': LLOp(canrun=True),
'gc_heap_stats' : LLOp(canunwindgc=True),
+ 'gc_get_rpy_roots' : LLOp(),
+ 'gc_get_rpy_referents': LLOp(),
+ 'gc_get_rpy_memory_usage': LLOp(),
+ 'gc_get_rpy_type_index': LLOp(),
+ 'gc_is_rpy_instance' : LLOp(),
+ 'gc_dump_rpy_heap' : LLOp(),
+
# ------- JIT & GC interaction, only for some GCs ----------
'gc_adr_of_nursery_free' : LLOp(),
Modified: pypy/trunk/pypy/rpython/memory/gc/inspect.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/inspect.py (original)
+++ pypy/trunk/pypy/rpython/memory/gc/inspect.py Mon Sep 20 09:37:11 2010
@@ -197,3 +197,4 @@
heapdumper.walk(heapdumper.pending)
heapdumper.flush()
heapdumper.delete()
+ return True
Modified: pypy/trunk/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gctransform/framework.py (original)
+++ pypy/trunk/pypy/rpython/memory/gctransform/framework.py Mon Sep 20 09:37:11 2010
@@ -412,7 +412,7 @@
minimal_transform=False)
self.dump_rpy_heap_ptr = getfn(inspect.dump_rpy_heap,
[s_gc, annmodel.SomeInteger()],
- annmodel.s_None,
+ annmodel.s_Bool,
minimal_transform=False)
self.set_max_heap_size_ptr = getfn(GCClass.set_max_heap_size.im_func,
Modified: pypy/trunk/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/trunk/pypy/translator/c/src/mem.h (original)
+++ pypy/trunk/pypy/translator/c/src/mem.h Mon Sep 20 09:37:11 2010
@@ -224,3 +224,13 @@
#define OP_CAST_PTR_TO_WEAKREFPTR(x, r) r = x
#define OP_CAST_WEAKREFPTR_TO_PTR(x, r) r = x
+
+/************************************************************/
+/* dummy version of these operations, e.g. with Boehm */
+
+#define OP_GC_GET_RPY_ROOTS(r) r = 0
+#define OP_GC_GET_RPY_REFERENTS(x, r) r = 0
+#define OP_GC_GET_RPY_MEMORY_USAGE(x, r) r = -1
+#define OP_GC_GET_RPY_TYPE_INDEX(x, r) r = -1
+#define OP_GC_IS_RPY_INSTANCE(x, r) r = 0
+#define OP_GC_DUMP_RPY_HEAP(r) r = 0
More information about the Pypy-commit
mailing list