[pypy-commit] pypy clean-exported-state: Perform sanity checks when compiled with debugging
sbauman
pypy.commits at gmail.com
Fri Oct 14 13:02:32 EDT 2016
Author: Spenser Bauman <sabauma at gmail.com>
Branch: clean-exported-state
Changeset: r87796:a200785ab631
Date: 2016-10-14 12:51 -0400
http://bitbucket.org/pypy/pypy/changeset/a200785ab631/
Log: Perform sanity checks when compiled with debugging
diff --git a/rpython/jit/metainterp/optimizeopt/heap.py b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -12,7 +12,7 @@
from rpython.jit.metainterp.optimize import InvalidLoop
from rpython.jit.metainterp.resoperation import rop, ResOperation, OpHelpers,\
AbstractResOp, GuardResOp
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import we_are_translated, we_are_lldebug
from rpython.jit.metainterp.optimizeopt import info
@@ -172,7 +172,7 @@
def _getfield(self, opinfo, descr, optheap, true_force=True):
res = opinfo.getfield(descr, optheap)
- if not we_are_translated() and res:
+ if we_are_debug() and res:
if isinstance(opinfo, info.AbstractStructPtrInfo):
assert opinfo in self.cached_infos
if isinstance(res, PreambleOp):
@@ -202,7 +202,7 @@
def _getfield(self, opinfo, descr, optheap, true_force=True):
res = opinfo.getitem(descr, self.index, optheap)
- if not we_are_translated() and res:
+ if we_are_debug() and res:
if isinstance(opinfo, info.ArrayPtrInfo):
assert opinfo in self.cached_infos
if (isinstance(res, PreambleOp) and
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -288,10 +288,15 @@
malloc_zero_filled = CDefinedIntSymbolic('MALLOC_ZERO_FILLED', default=0)
_translated_to_c = CDefinedIntSymbolic('1 /*_translated_to_c*/', default=0)
+_rpy_assert_value = CDefinedIntSymbolic('RPY_ASSERT_VALUE', default=1)
def we_are_translated_to_c():
return we_are_translated() and _translated_to_c
+def we_are_debug():
+ """ Returns True when not translated or translated with debugging enabled. """
+ return not we_are_translated() or (_translated_to_c and _rpy_assert_value)
+
# ____________________________________________________________
def instantiate(cls, nonmovable=False):
diff --git a/rpython/translator/c/src/support.h b/rpython/translator/c/src/support.h
--- a/rpython/translator/c/src/support.h
+++ b/rpython/translator/c/src/support.h
@@ -31,8 +31,10 @@
RPY_EXTERN
void RPyAssertFailed(const char* filename, long lineno,
const char* function, const char *msg);
+# define RPY_ASSERT_VALUE 1
#else
# define RPyAssert(x, msg) /* nothing */
+# define RPY_ASSERT_VALUE 0
#endif
RPY_EXTERN
More information about the pypy-commit
mailing list