Author: Armin Rigo <ar...@tunes.org> Branch: stm Changeset: r48710:b27ec3dc59d2 Date: 2011-11-03 19:15 +0100 http://bitbucket.org/pypy/pypy/changeset/b27ec3dc59d2/
Log: Yay! targetdemo is fixed and seems to be working. Added a test for it. diff --git a/pypy/translator/stm/funcgen.py b/pypy/translator/stm/funcgen.py --- a/pypy/translator/stm/funcgen.py +++ b/pypy/translator/stm/funcgen.py @@ -102,15 +102,29 @@ def stm_transaction_boundary(funcgen, op): assert funcgen.exception_policy == 'stm' - lines = ['STM_TRANSACTION_BOUNDARY();'] - TMPVAR = 'ty_%s' + # make code looking like this: + # + # stm_commit_transaction(); + # { + # volatile long tmp_123 = l_123; + # setjmp(jmpbuf); + # l_123 = tmp_123; + # } + # stm_begin_transaction(&jmpbuf); + # + lines = ['\tsetjmp(jmpbuf);'] + TMPVAR = 'tmp_%s' for v in op.args: tmpname = TMPVAR % v.name cdeclname = cdecl(funcgen.lltypename(v), 'volatile ' + tmpname) realname = funcgen.expr(v) - lines.insert(0, '%s = %s;' % (cdeclname, realname)) - lines.append('%s = %s;' % (realname, tmpname)) - return '{\n\t' + '\n\t'.join(lines) + '\n}' + lines.insert(0, '\t%s = %s;' % (cdeclname, realname)) + lines.append('\t%s = %s;' % (realname, tmpname)) + lines.insert(0, '{') + lines.insert(0, 'stm_commit_transaction();') + lines.append('}') + lines.append('stm_begin_transaction(&jmpbuf);') + return '\n'.join(lines) def stm_try_inevitable(funcgen, op): info = op.args[0].value 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 @@ -47,11 +47,6 @@ #define STM_DECLARE_VARIABLE() ; jmp_buf jmpbuf #define STM_MAKE_INEVITABLE() stm_try_inevitable_if(&jmpbuf \ STM_EXPLAIN("return")) -#define STM_TRANSACTION_BOUNDARY() \ - stm_commit_transaction(); \ - setjmp(jmpbuf); \ - stm_begin_transaction(&jmpbuf); - // XXX little-endian only! #define STM_read_partial_word(T, base, offset) \ 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 @@ -108,12 +108,13 @@ # ____________________________________________________________ -class TestTransformSingleThread(StandaloneTests): +class CompiledSTMTests(StandaloneTests): def compile(self, entry_point): from pypy.config.pypyoption import get_pypy_config self.config = get_pypy_config(translating=True) self.config.translation.stm = True + self.config.translation.gc = "none" # # Prevent the RaiseAnalyzer from just emitting "WARNING: Unknown # operation". We want instead it to crash. @@ -125,6 +126,9 @@ del RaiseAnalyzer.fail_on_unknown_operation return res + +class TestTransformSingleThread(CompiledSTMTests): + def test_no_pointer_operations(self): def simplefunc(argv): i = 0 diff --git a/pypy/translator/stm/test/test_ztranslated.py b/pypy/translator/stm/test/test_ztranslated.py new file mode 100644 --- /dev/null +++ b/pypy/translator/stm/test/test_ztranslated.py @@ -0,0 +1,11 @@ +from pypy.translator.stm.test.test_transform import CompiledSTMTests +from pypy.translator.stm.test import targetdemo + + +class TestSTMTranslated(CompiledSTMTests): + + def test_hello_world(self): + t, cbuilder = self.compile(targetdemo.entry_point) + data = cbuilder.cmdexec('') + assert 'done sleeping.' in data + assert 'check ok!' in data _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit