Commit f9d0275b authored by Ivo Anjo's avatar Ivo Anjo

Add hacky workaround to make abort(value) work again

I have no idea why the workaround works. See the comments for more details.
parent 92b9cacc
......@@ -130,9 +130,16 @@ JNIEXPORT void JNICALL Java_javartm_Transaction_abort__(JNIEnv *env, jclass cls)
}
}
JNIEXPORT void JNICALL Java_javartm_Transaction_abort__J(JNIEnv *env, jclass cls, jlong reason) {
// I don't know why (register clobbering? bug?), but if reason is 32bits, then the returned
// result after _xabort is always 0. Having reason as a long seems to work, don't know why.
// FIXME: I'm completely lost here. I suspect abort(status) seems to have some kind of alignment issue or
// something else, because if you comment out the following never-used code you get something like the
// following on javartm.Test:
// abort(0 -> 255) results: 41 correct status codes; 214 times status == 0; 0 may retry; 0 capacity aborts
// enabling it normally yields:
// abort(0 -> 255) results: 255 correct status codes; 0 times status == 0; 0 may retry; 0 capacity aborts
// Why? I don't have the faintest clue. Feel free to poke around for yourself.
void FIXME_HACK() { printf("."); }
JNIEXPORT void JNICALL Java_javartm_Transaction_abort__I(JNIEnv *env, jclass cls, jint reason) {
if (_xtest()) {
// Supposedly the argument to _xabort must be encoded into the instruction.
// To allow the user to specify his reason we must have an xabort for each value.
......
......@@ -134,7 +134,7 @@ public final class Transaction {
* Abort and set returned status code.
* Note that reason MUST FIT as unsigned 8bits [0,255], otherwise it will be set to 0.
**/
public native static void abort(long reason);
public native static void abort(int reason);
public static <V> V doTransactionally(AtomicRunnable<V> r) {
return doTransactionally(r, false);
......@@ -143,6 +143,7 @@ public final class Transaction {
private native static <V> V doTransactionally(AtomicRunnable<V> r, boolean warmup);
public static short getAbortReason(int txStatus) {
if ((txStatus & ABORT_EXPLICIT) == 0) return -1;
return (short) (txStatus >>> 24);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment