[pypy-commit] pypy stm: Protect debug printing with the RPY_STM_ASSERT define.
arigo
noreply at buildbot.pypy.org
Sun Oct 30 17:16:28 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r48610:43fe948fc6ca
Date: 2011-10-30 17:13 +0100
http://bitbucket.org/pypy/pypy/changeset/43fe948fc6ca/
Log: Protect debug printing with the RPY_STM_ASSERT define. Lets us run
tests.
diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -207,7 +207,8 @@
# use generate_source(defines=DEBUG_DEFINES) to force the #definition
# of the macros that enable debugging assertions
DEBUG_DEFINES = {'RPY_ASSERT': 1,
- 'RPY_LL_ASSERT': 1}
+ 'RPY_LL_ASSERT': 1,
+ 'RPY_STM_ASSERT': 1}
def generate_graphs_for_llinterp(self, db=None):
# prepare the graphs as when the source is generated, but without
@@ -561,7 +562,7 @@
('no_obmalloc', '', '$(MAKE) CFLAGS="-g -O2 -DRPY_ASSERT -DNO_OBMALLOC" $(TARGET)'),
('linuxmemchk', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DLINUXMEMCHK" $(TARGET)'),
('llsafer', '', '$(MAKE) CFLAGS="-O2 -DRPY_LL_ASSERT" $(TARGET)'),
- ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT" $(TARGET)'),
+ ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT -DRPY_STM_ASSERT" $(TARGET)'),
('profile', '', '$(MAKE) CFLAGS="-g -O1 -pg $(CFLAGS) -fno-omit-frame-pointer" LDFLAGS="-pg $(LDFLAGS)" $(TARGET)'),
]
if self.has_profopt():
diff --git a/pypy/translator/stm/llstminterp.py b/pypy/translator/stm/llstminterp.py
--- a/pypy/translator/stm/llstminterp.py
+++ b/pypy/translator/stm/llstminterp.py
@@ -112,6 +112,7 @@
self.llinterpreter.stm_mode = "regular_transaction"
self.llinterpreter.last_transaction_started_in_frame = self
- def opstm_stm_try_inevitable(self):
+ def opstm_stm_try_inevitable(self, why):
self.check_stm_mode(lambda m: m != "not_in_transaction")
self.llinterpreter.stm_mode = "inevitable_transaction"
+ print why
diff --git a/pypy/translator/stm/src_stm/et.c b/pypy/translator/stm/src_stm/et.c
--- a/pypy/translator/stm/src_stm/et.c
+++ b/pypy/translator/stm/src_stm/et.c
@@ -21,7 +21,10 @@
#include "src_stm/et.h"
#include "src_stm/atomic_ops.h"
-#include "src/debug_print.h"
+
+#ifdef RPY_STM_ASSERT
+# include "src/debug_print.h"
+#endif
/************************************************************/
@@ -44,7 +47,7 @@
inline static volatile orec_t* get_orec(void* addr)
{
unsigned long index = (unsigned long)addr;
-#ifdef RPY_ASSERT
+#ifdef RPY_STM_ASSERT
assert(!(index & (sizeof(orec_t)-1)));
#endif
char *p = orecs + (index & ((NUM_STRIPES-1) * sizeof(orec_t)));
@@ -78,7 +81,7 @@
owner_version_t my_lock_word;
unsigned init_counter;
struct RedoLog redolog; /* last item, because it's the biggest one */
-#ifdef RPY_ASSERT
+#ifdef RPY_STM_ASSERT
int transaction_active;
#endif
};
@@ -242,7 +245,7 @@
{
d->reads.size = 0;
redolog_clear(&d->redolog);
-#ifdef RPY_ASSERT
+#ifdef RPY_STM_ASSERT
assert(d->transaction_active);
d->transaction_active = 0;
#endif
@@ -538,7 +541,9 @@
void stm_descriptor_init(void)
{
+#ifdef RPY_STM_ASSERT
PYPY_DEBUG_START("stm-init");
+#endif
if (thread_descriptor != NULL)
thread_descriptor->init_counter++;
else
@@ -556,7 +561,9 @@
thread_descriptor = d;
}
+#ifdef RPY_STM_ASSERT
PYPY_DEBUG_STOP("stm-init");
+#endif
}
void stm_descriptor_done(void)
@@ -566,9 +573,10 @@
if (d->init_counter > 0)
return;
- PYPY_DEBUG_START("stm-done");
thread_descriptor = NULL;
+#ifdef RPY_STM_ASSERT
+ PYPY_DEBUG_START("stm-done");
if (PYPY_HAVE_DEBUG_PRINTS) {
int num_aborts = 0, num_spinloops = 0;
int i, prevchar;
@@ -598,8 +606,10 @@
fprintf(PYPY_DEBUG_FILE, "]\n");
}
+ PYPY_DEBUG_STOP("stm-done");
+#endif
+
free(d);
- PYPY_DEBUG_STOP("stm-done");
}
void* stm_perform_transaction(void*(*callback)(void*), void *arg)
@@ -614,7 +624,7 @@
void stm_begin_transaction(jmp_buf* buf)
{
struct tx_descriptor *d = thread_descriptor;
-#ifdef RPY_ASSERT
+#ifdef RPY_STM_ASSERT
assert(!d->transaction_active);
d->transaction_active = 1;
#endif
@@ -705,7 +715,7 @@
to 1. */
struct tx_descriptor *d = thread_descriptor;
-#ifdef RPY_ASSERT
+#ifdef RPY_STM_ASSERT
PYPY_DEBUG_START("stm-inevitable");
if (PYPY_HAVE_DEBUG_PRINTS)
{
@@ -717,7 +727,7 @@
if (is_inevitable(d))
{
-#ifdef RPY_ASSERT
+#ifdef RPY_STM_ASSERT
PYPY_DEBUG_STOP("stm-inevitable");
#endif
return; /* I am already inevitable */
@@ -758,7 +768,7 @@
CFENCE;
d_inev_checking = 1;
#endif
-#ifdef RPY_ASSERT
+#ifdef RPY_STM_ASSERT
PYPY_DEBUG_STOP("stm-inevitable");
#endif
}
@@ -794,7 +804,7 @@
if (bool_cas(&global_timestamp, curtime, curtime + 1))
break;
}
-#ifdef RPY_ASSERT
+#ifdef RPY_STM_ASSERT
assert(!d->transaction_active);
d->transaction_active = 1;
#endif
@@ -814,14 +824,14 @@
void stm_transaction_boundary(jmp_buf* buf)
{
-#ifdef RPY_ASSERT
- PYPY_DEBUG_START("stm-boundary");
+#ifdef RPY_STM_ASSERT
+ PYPY_DEBUG_START("stm-transaction-boundary");
#endif
stm_commit_transaction();
setjmp(*buf);
stm_begin_transaction(buf);
-#ifdef RPY_ASSERT
- PYPY_DEBUG_STOP("stm-boundary");
+#ifdef RPY_STM_ASSERT
+ PYPY_DEBUG_STOP("stm-transaction-boundary");
#endif
}
diff --git a/pypy/translator/stm/src_stm/et.h b/pypy/translator/stm/src_stm/et.h
--- a/pypy/translator/stm/src_stm/et.h
+++ b/pypy/translator/stm/src_stm/et.h
@@ -11,7 +11,7 @@
#include <setjmp.h>
#include "src/commondefs.h"
-#ifdef RPY_ASSERT
+#ifdef RPY_STM_ASSERT
# define STM_CCHARP(arg) , char* arg
# define STM_CCHARP1(arg) char* arg
# define STM_EXPLAIN(info) , info
More information about the pypy-commit
mailing list