[pypy-commit] pypy stm: Progress
arigo
noreply at buildbot.pypy.org
Fri Oct 28 12:16:26 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r48559:346f0c8a0ed7
Date: 2011-10-28 12:16 +0200
http://bitbucket.org/pypy/pypy/changeset/346f0c8a0ed7/
Log: Progress
diff --git a/pypy/translator/stm/_rffi_stm.py b/pypy/translator/stm/_rffi_stm.py
--- a/pypy/translator/stm/_rffi_stm.py
+++ b/pypy/translator/stm/_rffi_stm.py
@@ -11,9 +11,9 @@
eci = ExternalCompilationInfo(
include_dirs = [cdir, cdir2],
- includes = ['src_stm/et.h'],
+ includes = ['src_stm/et.h', 'src_stm/et.c'],
pre_include_bits = ['#define PYPY_LONG_BIT %d' % LONG_BIT],
- separate_module_sources = ['#include "src_stm/et.c"\n'],
+ separate_module_sources = ['\n'], # hack for test_rffi_stm
)
def llexternal(name, args, result, **kwds):
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
@@ -1,11 +1,14 @@
/* -*- c-basic-offset: 2 -*- */
+#ifndef PYPY_NOT_MAIN_FILE
+
/* XXX assumes that time never wraps around (in a 'long'), which may be
* correct on 64-bit machines but not on 32-bit machines if the process
* runs for long enough.
*
* XXX measure the overhead of the global_timestamp
*/
+
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
@@ -74,6 +77,9 @@
owner_version_t my_lock_word;
unsigned init_counter;
struct RedoLog redolog; /* last item, because it's the biggest one */
+#ifdef RPY_ASSERT
+ int transaction_active;
+#endif
};
/* global_timestamp contains in its lowest bit a flag equal to 1
@@ -235,6 +241,10 @@
{
d->reads.size = 0;
redolog_clear(&d->redolog);
+#ifdef RPY_ASSERT
+ assert(d->transaction_active);
+ d->transaction_active = 0;
+#endif
}
static void tx_cleanup(struct tx_descriptor *d)
@@ -597,6 +607,10 @@
void stm_begin_transaction(jmp_buf* buf)
{
struct tx_descriptor *d = thread_descriptor;
+#ifdef RPY_ASSERT
+ assert(!d->transaction_active);
+ d->transaction_active = 1;
+#endif
d->setjmp_buf = buf;
d->start_time = d->last_known_global_timestamp & ~1;
}
@@ -852,3 +866,5 @@
stm_write_partial_word(4, (char *)addr, 0, ii); /* 64 bits, aligned */
#endif
}
+
+#endif /* PYPY_NOT_MAIN_FILE */
diff --git a/pypy/translator/stm/test/test_transform.py b/pypy/translator/stm/test/test_transform.py
--- a/pypy/translator/stm/test/test_transform.py
+++ b/pypy/translator/stm/test/test_transform.py
@@ -39,7 +39,7 @@
from pypy.config.pypyoption import get_pypy_config
self.config = get_pypy_config(translating=True)
self.config.translation.stm = True
- return StandaloneTests.compile(self, entry_point)
+ return StandaloneTests.compile(self, entry_point, debug=True)
def test_no_pointer_operations(self):
def simplefunc(argv):
@@ -54,3 +54,21 @@
dataout, dataerr = cbuilder.cmdexec('', err=True)
assert dataout == ''
assert '102' in dataerr.splitlines()
+
+ def test_fails_when_nonbalanced_begin(self):
+ def g():
+ rstm.begin_transaction()
+ g._dont_inline_ = True
+ def simplefunc(argv):
+ rstm.begin_transaction()
+ g()
+ return 0
+ t, cbuilder = self.compile(simplefunc)
+ cbuilder.cmdexec('', expect_crash=True)
+
+ def test_fails_when_nonbalanced_commit(self):
+ def simplefunc(argv):
+ rstm.commit_transaction()
+ return 0
+ t, cbuilder = self.compile(simplefunc)
+ cbuilder.cmdexec('', expect_crash=True)
More information about the pypy-commit
mailing list