[pypy-commit] stmgc default: fixes
Remi Meier
noreply at buildbot.pypy.org
Wed Mar 26 18:44:07 CET 2014
Author: Remi Meier
Branch:
Changeset: r1098:80e72e01e2b8
Date: 2014-03-26 18:44 +0100
http://bitbucket.org/pypy/stmgc/changeset/80e72e01e2b8/
Log: fixes
diff --git a/htm-c7/htm.h b/htm-c7/htm.h
--- a/htm-c7/htm.h
+++ b/htm-c7/htm.h
@@ -18,7 +18,7 @@
#define XBEGIN_XABORT_ARG(x) (((x) >> 24) & 0xFF)
static __thread char buf[128];
-char* xbegin_status(int status)
+static char* xbegin_status(int status)
{
if (status == XBEGIN_OK)
snprintf(buf, 128, "OK");
@@ -36,6 +36,9 @@
snprintf(buf, 128, "DEBUG");
else if (status & XBEGIN_NESTED_ABORT)
snprintf(buf, 128, "NESTED_ABORT");
+ else
+ snprintf(buf, 128, "WAT.");
+
return buf;
}
@@ -53,8 +56,6 @@
#define xabort(argument) do { asm volatile(".byte 0xC6, 0xF8, %P0" :: "i" (argument) : "memory"); } while (0);
-
-
static __attribute__((__always_inline__)) inline int xtest()
{
unsigned char result;
diff --git a/htm-c7/stmgc.c b/htm-c7/stmgc.c
--- a/htm-c7/stmgc.c
+++ b/htm-c7/stmgc.c
@@ -24,20 +24,26 @@
return;
}
- int status;
+ volatile int status;
transaction_retry:
- if ((status = xbegin()) == XBEGIN_OK) {
+
+ status = xbegin();
+ if (status == XBEGIN_OK) {
if (mutex_locked(&_stm_gil))
xabort(0);
/* transaction OK */
}
else {
- if (mutex_locked(&_stm_gil))
+ if (status & (XBEGIN_MAYBE_RETRY | XBEGIN_NORMAL_CONFLICT | XBEGIN_XABORT)) {
+ goto transaction_retry;
+ } else if (mutex_locked(&_stm_gil)) {
acquire_gil(tl);
- else if (status & (XBEGIN_MAYBE_RETRY | XBEGIN_NORMAL_CONFLICT))
- goto transaction_retry;
- else
+ }
+ else {
acquire_gil(tl);
+ }
+
+ fprintf(stderr, "failed HTM: %s\n", xbegin_status(status));
}
_stm_tloc = tl;
@@ -49,8 +55,10 @@
if (mutex_locked(&_stm_gil)) {
assert(!xtest());
if (pthread_mutex_unlock(&_stm_gil) != 0) abort();
+ //fprintf(stderr, "G");
} else {
xend();
+ fprintf(stderr, "==== Committed HTM ====\n");
}
}
More information about the pypy-commit
mailing list