[pypy-commit] pypy default: Improve rlib.debug; transposed from stm-gc.
arigo
noreply at buildbot.pypy.org
Mon Apr 30 11:57:20 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r54816:765ff6ef6f80
Date: 2012-04-30 10:11 +0200
http://bitbucket.org/pypy/pypy/changeset/765ff6ef6f80/
Log: Improve rlib.debug; transposed from stm-gc.
diff --git a/pypy/rlib/debug.py b/pypy/rlib/debug.py
--- a/pypy/rlib/debug.py
+++ b/pypy/rlib/debug.py
@@ -1,10 +1,12 @@
import sys, time
from pypy.rpython.extregistry import ExtRegistryEntry
+from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib.rarithmetic import is_valid_int
def ll_assert(x, msg):
"""After translation to C, this becomes an RPyAssert."""
+ assert type(x) is bool, "bad type! got %r" % (type(x),)
assert x, msg
class Entry(ExtRegistryEntry):
@@ -21,8 +23,13 @@
hop.exception_cannot_occur()
hop.genop('debug_assert', vlist)
+class FatalError(Exception):
+ pass
+
def fatalerror(msg):
# print the RPython traceback and abort with a fatal error
+ if not we_are_translated():
+ raise FatalError(msg)
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.lltypesystem.lloperation import llop
llop.debug_print_traceback(lltype.Void)
@@ -33,6 +40,8 @@
def fatalerror_notb(msg):
# a variant of fatalerror() that doesn't print the RPython traceback
+ if not we_are_translated():
+ raise FatalError(msg)
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.lltypesystem.lloperation import llop
llop.debug_fatalerror(lltype.Void, msg)
diff --git a/pypy/rpython/memory/gc/minimark.py b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -916,7 +916,7 @@
ll_assert(not self.is_in_nursery(obj),
"object in nursery after collection")
# similarily, all objects should have this flag:
- ll_assert(self.header(obj).tid & GCFLAG_TRACK_YOUNG_PTRS,
+ ll_assert(self.header(obj).tid & GCFLAG_TRACK_YOUNG_PTRS != 0,
"missing GCFLAG_TRACK_YOUNG_PTRS")
# the GCFLAG_VISITED should not be set between collections
ll_assert(self.header(obj).tid & GCFLAG_VISITED == 0,
diff --git a/pypy/rpython/memory/gc/semispace.py b/pypy/rpython/memory/gc/semispace.py
--- a/pypy/rpython/memory/gc/semispace.py
+++ b/pypy/rpython/memory/gc/semispace.py
@@ -640,7 +640,7 @@
between collections."""
tid = self.header(obj).tid
if tid & GCFLAG_EXTERNAL:
- ll_assert(tid & GCFLAG_FORWARDED, "bug: external+!forwarded")
+ ll_assert(tid & GCFLAG_FORWARDED != 0, "bug: external+!forwarded")
ll_assert(not (self.tospace <= obj < self.free),
"external flag but object inside the semispaces")
else:
diff --git a/pypy/rpython/memory/gctransform/framework.py b/pypy/rpython/memory/gctransform/framework.py
--- a/pypy/rpython/memory/gctransform/framework.py
+++ b/pypy/rpython/memory/gctransform/framework.py
@@ -8,7 +8,6 @@
from pypy.rpython.memory.gcheader import GCHeaderBuilder
from pypy.rlib.rarithmetic import ovfcheck
from pypy.rlib import rgc
-from pypy.rlib.debug import ll_assert
from pypy.rlib.objectmodel import we_are_translated
from pypy.translator.backendopt import graphanalyze
from pypy.translator.backendopt.support import var_needsgc
More information about the pypy-commit
mailing list