[pypy-commit] pypy stm-gc: Fix or kill all the remaining tests in translator/stm/test.
arigo
noreply at buildbot.pypy.org
Sun Feb 12 11:54:39 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52387:15f4af2d89e5
Date: 2012-02-12 11:54 +0100
http://bitbucket.org/pypy/pypy/changeset/15f4af2d89e5/
Log: Fix or kill all the remaining tests in translator/stm/test.
diff --git a/pypy/rlib/rstm.py b/pypy/rlib/rstm.py
--- a/pypy/rlib/rstm.py
+++ b/pypy/rlib/rstm.py
@@ -7,7 +7,7 @@
from pypy.rpython.annlowlevel import (cast_base_ptr_to_instance,
cast_instance_to_base_ptr,
llhelper)
-from pypy.translator.stm import _rffi_stm
+from pypy.translator.stm.stmgcintf import StmOperations
_global_lock = thread.allocate_lock()
@@ -46,8 +46,8 @@
lltype.TLS.stm_callback_arg = arg
llarg = lltype.nullptr(rffi.VOIDP.TO)
callback = _get_stm_callback(func, argcls)
- llcallback = llhelper(_rffi_stm.CALLBACK, callback)
- _rffi_stm.stm_perform_transaction(llcallback, llarg)
+ llcallback = llhelper(StmOperations.CALLBACK_TX, callback)
+ StmOperations.perform_transaction(llcallback, llarg)
keepalive_until_here(arg)
if not we_are_translated():
_global_lock.release()
@@ -62,8 +62,8 @@
llop.stm_descriptor_done(lltype.Void)
if not we_are_translated(): _global_lock.release()
-def debug_get_state():
- return _rffi_stm.stm_debug_get_state()
+def _debug_get_state():
+ return StmOperations._debug_get_state()
def thread_id():
- return _rffi_stm.stm_thread_id()
+ return StmOperations.thread_id()
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
@@ -186,7 +186,7 @@
self.merge_eci(db.gcpolicy.compilation_info())
if self.config.translation.stm:
- from pypy.translator.stm._rffi_stm import eci
+ from pypy.translator.stm.stmgcintf import eci
self.merge_eci(eci)
all = []
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
@@ -1,7 +1,5 @@
from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.objspace.flow.model import Constant
from pypy.translator.c.support import cdecl, c_string_constant
-from pypy.translator.stm.llstm import size_of_voidp
def _stm_generic_get(funcgen, op, (expr_type, expr_ptr, expr_field)):
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
@@ -1,3 +1,5 @@
+import py
+py.test.skip("llstminterp disabled")
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.llinterp import LLFrame, LLException
##from pypy.translator.stm import rstm
diff --git a/pypy/translator/stm/test/test_funcgen.py b/pypy/translator/stm/test/test_funcgen.py
deleted file mode 100644
--- a/pypy/translator/stm/test/test_funcgen.py
+++ /dev/null
@@ -1,334 +0,0 @@
-from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.rlib.rarithmetic import r_longlong, r_singlefloat
-from pypy.rlib.objectmodel import compute_identity_hash
-from pypy.translator.stm.test.support import CompiledSTMTests
-from pypy.rlib.debug import debug_print
-from pypy.rpython.annlowlevel import llhelper
-
-
-# ____________________________________________________________
-
-A = lltype.GcStruct('A', ('x', lltype.Signed), ('y', lltype.Signed),
- ('c1', lltype.Char), ('c2', lltype.Char),
- ('c3', lltype.Char), ('l', lltype.SignedLongLong),
- ('f', lltype.Float), ('sa', lltype.SingleFloat),
- ('sb', lltype.SingleFloat))
-rll1 = r_longlong(-10000000000003)
-rll2 = r_longlong(-300400500600700)
-rf1 = -12.38976129
-rf2 = 52.1029
-rs1a = r_singlefloat(-0.598127)
-rs2a = r_singlefloat(0.017634)
-rs1b = r_singlefloat(40.121)
-rs2b = r_singlefloat(-9e9)
-
-NULL = lltype.nullptr(rffi.VOIDP.TO)
-
-def make_a_1():
- a = lltype.malloc(A, immortal=True)
- a.x = -611
- a.c1 = '/'
- a.c2 = '\\'
- a.c3 = '!'
- a.y = 0
- a.l = rll1
- a.f = rf1
- a.sa = rs1a
- a.sb = rs1b
- return a
-a_prebuilt = make_a_1()
-
-def _play_with_getfield(dummy_arg, retry_counter):
- a = a_prebuilt
- assert a.x == -611
- assert a.c1 == '/'
- assert a.c2 == '\\'
- assert a.c3 == '!'
- assert a.y == 0
- assert a.l == rll1
- assert a.f == rf1
- assert float(a.sa) == float(rs1a)
- assert float(a.sb) == float(rs1b)
- return NULL
-
-def _play_with_setfields(dummy_arg, retry_counter):
- a = a_prebuilt
- #
- a.x = 12871981
- a.c1 = '('
- assert a.c1 == '('
- assert a.c2 == '\\'
- assert a.c3 == '!'
- a.c2 = '?'
- assert a.c1 == '('
- assert a.c2 == '?'
- assert a.c3 == '!'
- a.c3 = ')'
- a.l = rll2
- a.f = rf2
- a.sa = rs2a
- a.sb = rs2b
- # read the values which have not been commited yet, but are local to the
- # transaction
- _check_values_of_fields(dummy_arg, retry_counter)
- return NULL
-
-def _check_values_of_fields(dummy_arg, retry_counter):
- a = a_prebuilt
- assert a.x == 12871981
- assert a.c1 == '('
- assert a.c2 == '?'
- assert a.c3 == ')'
- assert a.l == rll2
- assert a.f == rf2
- assert float(a.sa) == float(rs2a)
- assert float(a.sb) == float(rs2b)
- return NULL
-
-
-def make_array(OF):
- a = lltype.malloc(lltype.GcArray(OF), 5, immortal=True)
- for i, value in enumerate([1, 10, -1, -10, 42]):
- a[i] = rffi.cast(OF, value)
- return a
-
-prebuilt_array_signed = make_array(lltype.Signed)
-prebuilt_array_char = make_array(lltype.Char)
-
-def check(array, expected):
- assert len(array) == len(expected)
- for i in range(len(expected)):
- assert array[i] == expected[i]
-check._annspecialcase_ = 'specialize:ll'
-
-def change(array, newvalues):
- assert len(newvalues) <= len(array)
- for i in range(len(newvalues)):
- array[i] = rffi.cast(lltype.typeOf(array).TO.OF, newvalues[i])
-change._annspecialcase_ = 'specialize:ll'
-
-def _play_with_getarrayitem(dummy_arg, retry_counter):
- check(prebuilt_array_signed, [1, 10, -1, -10, 42])
- check(prebuilt_array_char, [chr(1), chr(10), chr(255),
- chr(246), chr(42)])
- return NULL
-
-
-def _play_with_setarrayitem_1(dummy_arg, retry_counter):
- change(prebuilt_array_signed, [500000, -10000000, 3])
- check(prebuilt_array_signed, [500000, -10000000, 3, -10, 42])
- prebuilt_array_char[0] = 'A'
- check(prebuilt_array_char, ['A', chr(10), chr(255), chr(246), chr(42)])
- prebuilt_array_char[3] = 'B'
- check(prebuilt_array_char, ['A', chr(10), chr(255), 'B', chr(42)])
- prebuilt_array_char[4] = 'C'
- check(prebuilt_array_char, ['A', chr(10), chr(255), 'B', 'C'])
- return NULL
-
-def _play_with_setarrayitem_2(dummy_arg, retry_counter):
- check(prebuilt_array_char, ['A', chr(10), chr(255), 'B', 'C'])
- prebuilt_array_char[1] = 'D'
- check(prebuilt_array_char, ['A', 'D', chr(255), 'B', 'C'])
- prebuilt_array_char[2] = 'E'
- check(prebuilt_array_char, ['A', 'D', 'E', 'B', 'C'])
- return NULL
-
-def _play_with_setarrayitem_3(dummy_arg, retry_counter):
- check(prebuilt_array_char, ['A', 'D', 'E', 'B', 'C'])
- return NULL
-
-
-def make_array_of_structs(T1, T2):
- S = lltype.Struct('S', ('x', T1), ('y', T2))
- a = lltype.malloc(lltype.GcArray(S), 3, immortal=True)
- for i, (value1, value2) in enumerate([(1, 10), (-1, 20), (-50, -30)]):
- a[i].x = rffi.cast(T1, value1)
- a[i].y = rffi.cast(T2, value2)
- return a
-
-prebuilt_array_signed_signed = make_array_of_structs(lltype.Signed,
- lltype.Signed)
-prebuilt_array_char_char = make_array_of_structs(lltype.Char,
- lltype.Char)
-
-def check2(array, expected1, expected2):
- assert len(array) == len(expected1) == len(expected2)
- for i in range(len(expected1)):
- assert array[i].x == expected1[i]
- assert array[i].y == expected2[i]
-check2._annspecialcase_ = 'specialize:ll'
-
-def change2(array, newvalues1, newvalues2):
- assert len(newvalues1) <= len(array)
- assert len(newvalues2) <= len(array)
- for i in range(len(newvalues1)):
- array[i].x = rffi.cast(lltype.typeOf(array).TO.OF.x, newvalues1[i])
- for i in range(len(newvalues2)):
- array[i].y = rffi.cast(lltype.typeOf(array).TO.OF.y, newvalues2[i])
-change2._annspecialcase_ = 'specialize:ll'
-
-def _play_with_getinteriorfield(dummy_arg, retry_counter):
- check2(prebuilt_array_signed_signed, [1, -1, -50], [10, 20, -30])
- check2(prebuilt_array_char_char, [chr(1), chr(255), chr(206)],
- [chr(10), chr(20), chr(226)])
- return NULL
-
-
-def _play_with_setinteriorfield_1(dummy_arg, retry_counter):
- change2(prebuilt_array_signed_signed, [500000, -10000000], [102101202])
- check2(prebuilt_array_signed_signed, [500000, -10000000, -50],
- [102101202, 20, -30])
- change2(prebuilt_array_char_char, ['a'], ['b'])
- check2(prebuilt_array_char_char, ['a', chr(255), chr(206)],
- ['b', chr(20), chr(226)])
- return NULL
-
-def _play_with_setinteriorfield_2(dummy_arg, retry_counter):
- check2(prebuilt_array_signed_signed, [500000, -10000000, -50],
- [102101202, 20, -30])
- check2(prebuilt_array_char_char, ['a', chr(255), chr(206)],
- ['b', chr(20), chr(226)])
- return NULL
-
-
-# ____________________________________________________________
-
-
-class TestFuncGen(CompiledSTMTests):
-
- def test_getfield_all_sizes(self):
- def do_stm_getfield(argv):
- _play_with_getfield(None, 0)
- return 0
- t, cbuilder = self.compile(do_stm_getfield)
- cbuilder.cmdexec('')
-
- def test_getfield_all_sizes_inside_transaction(self):
- def do_stm_getfield(argv):
- callback = llhelper(CALLBACK, _play_with_getfield)
- stm_descriptor_init()
- stm_perform_transaction(callback, NULL)
- stm_descriptor_done()
- return 0
- t, cbuilder = self.compile(do_stm_getfield)
- cbuilder.cmdexec('')
-
- def test_getfield_all_sizes_outside_transaction(self):
- def do_stm_getfield(argv):
- stm_descriptor_init()
- # we have a descriptor, but we don't call it in a transaction
- _play_with_getfield(None, 0)
- stm_descriptor_done()
- return 0
- t, cbuilder = self.compile(do_stm_getfield)
- cbuilder.cmdexec('')
-
- def test_setfield_all_sizes(self):
- def do_stm_setfield(argv):
- _play_with_setfields(None, 0)
- return 0
- t, cbuilder = self.compile(do_stm_setfield)
- cbuilder.cmdexec('')
-
- def test_setfield_all_sizes_inside_transaction(self):
- def do_stm_setfield(argv):
- callback1 = llhelper(CALLBACK, _play_with_setfields)
- callback2 = llhelper(CALLBACK, _check_values_of_fields)
- stm_descriptor_init()
- stm_perform_transaction(callback1, NULL)
- # read values which aren't local to the transaction
- stm_perform_transaction(callback2, NULL)
- stm_descriptor_done()
- return 0
- t, cbuilder = self.compile(do_stm_setfield)
- cbuilder.cmdexec('')
-
- def test_setfield_all_sizes_outside_transaction(self):
- def do_stm_setfield(argv):
- stm_descriptor_init()
- _play_with_setfields(None, 0)
- stm_descriptor_done()
- return 0
- t, cbuilder = self.compile(do_stm_setfield)
- cbuilder.cmdexec('')
-
- def test_getarrayitem_all_sizes(self):
- def do_stm_getarrayitem(argv):
- _play_with_getarrayitem(None, 0)
- return 0
- t, cbuilder = self.compile(do_stm_getarrayitem)
- cbuilder.cmdexec('')
-
- def test_getarrayitem_all_sizes_inside_transaction(self):
- def do_stm_getarrayitem(argv):
- callback = llhelper(CALLBACK, _play_with_getarrayitem)
- stm_descriptor_init()
- stm_perform_transaction(callback, NULL)
- stm_descriptor_done()
- return 0
- t, cbuilder = self.compile(do_stm_getarrayitem)
- cbuilder.cmdexec('')
-
-
- def test_setarrayitem_all_sizes(self):
- def do_stm_setarrayitem(argv):
- _play_with_setarrayitem_1(None, 0)
- _play_with_setarrayitem_2(None, 0)
- _play_with_setarrayitem_3(None, 0)
- return 0
- t, cbuilder = self.compile(do_stm_setarrayitem)
- cbuilder.cmdexec('')
-
- def test_setarrayitem_all_sizes_inside_transaction(self):
- def do_stm_setarrayitem(argv):
- callback1 = llhelper(CALLBACK, _play_with_setarrayitem_1)
- callback2 = llhelper(CALLBACK, _play_with_setarrayitem_2)
- callback3 = llhelper(CALLBACK, _play_with_setarrayitem_3)
- #
- stm_descriptor_init()
- stm_perform_transaction(callback1, NULL)
- stm_perform_transaction(callback2, NULL)
- stm_perform_transaction(callback3, NULL)
- stm_descriptor_done()
- return 0
- t, cbuilder = self.compile(do_stm_setarrayitem)
- cbuilder.cmdexec('')
-
- def test_getinteriorfield_all_sizes(self):
- def do_stm_getinteriorfield(argv):
- _play_with_getinteriorfield(None, 0)
- return 0
- t, cbuilder = self.compile(do_stm_getinteriorfield)
- cbuilder.cmdexec('')
-
- def test_getinteriorfield_all_sizes_inside_transaction(self):
- def do_stm_getinteriorfield(argv):
- callback = llhelper(CALLBACK, _play_with_getinteriorfield)
- stm_descriptor_init()
- stm_perform_transaction(callback, NULL)
- stm_descriptor_done()
- return 0
- t, cbuilder = self.compile(do_stm_getinteriorfield)
- cbuilder.cmdexec('')
-
-
- def test_setinteriorfield_all_sizes(self):
- def do_stm_setinteriorfield(argv):
- _play_with_setinteriorfield_1(None, 0)
- _play_with_setinteriorfield_2(None, 0)
- return 0
- t, cbuilder = self.compile(do_stm_setinteriorfield)
- cbuilder.cmdexec('')
-
- def test_setinteriorfield_all_sizes_inside_transaction(self):
- def do_stm_setinteriorfield(argv):
- callback1 = llhelper(CALLBACK, _play_with_setinteriorfield_1)
- callback2 = llhelper(CALLBACK, _play_with_setinteriorfield_2)
- #
- stm_descriptor_init()
- stm_perform_transaction(callback1, NULL)
- stm_perform_transaction(callback2, NULL)
- stm_descriptor_done()
- return 0
- t, cbuilder = self.compile(do_stm_setinteriorfield)
- cbuilder.cmdexec('')
diff --git a/pypy/translator/stm/test/test_llstm.py b/pypy/translator/stm/test/test_llstm.py
deleted file mode 100644
--- a/pypy/translator/stm/test/test_llstm.py
+++ /dev/null
@@ -1,161 +0,0 @@
-import py
-from pypy.translator.stm._rffi_stm import *
-from pypy.translator.stm.llstm import *
-from pypy.rpython.annlowlevel import llhelper
-from pypy.rlib.rarithmetic import r_longlong, r_singlefloat
-
-
-A = lltype.Struct('A', ('x', lltype.Signed), ('y', lltype.Signed),
- ('c1', lltype.Char), ('c2', lltype.Char),
- ('c3', lltype.Char), ('l', lltype.SignedLongLong),
- ('f', lltype.Float), ('sa', lltype.SingleFloat),
- ('sb', lltype.SingleFloat), ('v', lltype.Void))
-rll1 = r_longlong(-10000000000003)
-rll2 = r_longlong(-300400500600700)
-rf1 = -12.38976129
-rf2 = 52.1029
-rs1a = r_singlefloat(-0.598127)
-rs2a = r_singlefloat(0.017634)
-rs1b = r_singlefloat(40.121)
-rs2b = r_singlefloat(-9e9)
-
-def callback1(a, retry_counter):
- a = rffi.cast(lltype.Ptr(A), a)
- assert retry_counter == a.y # non-transactionally
- assert a.x == -611
- assert a.c1 == '/'
- assert a.c2 == '\\'
- assert a.c3 == '!'
- assert a.l == rll1
- assert a.f == rf1
- assert float(a.sa) == float(rs1a)
- assert float(a.sb) == float(rs1b)
- assert a.v == None
- assert stm_getfield(a, 'x') == -611
- assert stm_getfield(a, 'c2') == '\\'
- assert stm_getfield(a, 'c1') == '/'
- assert stm_getfield(a, 'c3') == '!'
- assert stm_getfield(a, 'l') == rll1
- assert stm_getfield(a, 'f') == rf1
- assert float(stm_getfield(a, 'sa')) == float(rs1a)
- assert float(stm_getfield(a, 'sb')) == float(rs1b)
- p = lltype.direct_fieldptr(a, 'x')
- p = rffi.cast(SignedP, p)
- stm_write_word(p, 42 * a.y)
- assert stm_getfield(a, 'x') == 42 * a.y
- assert a.x == -611 # xxx still the old value when reading non-transact.
- if a.y < 10:
- a.y += 1 # non-transactionally
- stm_abort_and_retry()
- return lltype.nullptr(rffi.VOIDP.TO)
-
-def test_stm_getfield():
- a = lltype.malloc(A, flavor='raw')
- a.x = -611
- a.c1 = '/'
- a.c2 = '\\'
- a.c3 = '!'
- a.y = 0
- a.l = rll1
- a.f = rf1
- a.sa = rs1a
- a.sb = rs1b
- a.v = None
- stm_descriptor_init()
- stm_perform_transaction(llhelper(CALLBACK, callback1),
- rffi.cast(rffi.VOIDP, a))
- stm_descriptor_done()
- assert a.x == 420
- assert a.c1 == '/'
- assert a.c2 == '\\'
- assert a.c3 == '!'
- assert a.l == rll1
- assert a.f == rf1
- assert float(a.sa) == float(rs1a)
- assert float(a.sb) == float(rs1b)
- assert a.v == None
- assert a.y == 10
- lltype.free(a, flavor='raw')
-
-def callback2(a, retry_counter):
- a = rffi.cast(lltype.Ptr(A), a)
- assert a.x == -611
- assert a.c1 == '&'
- assert a.c2 == '*'
- assert a.c3 == '#'
- assert a.l == rll1
- assert a.f == rf1
- assert float(a.sa) == float(rs1a)
- assert float(a.sb) == float(rs1b)
- assert a.v == None
- assert stm_getfield(a, 'x') == -611
- assert stm_getfield(a, 'c1') == '&'
- assert stm_getfield(a, 'c2') == '*'
- assert stm_getfield(a, 'c3') == '#'
- assert stm_getfield(a, 'l') == rll1
- assert stm_getfield(a, 'f') == rf1
- assert float(stm_getfield(a, 'sa')) == float(rs1a)
- assert float(stm_getfield(a, 'sb')) == float(rs1b)
- stm_setfield(a, 'x', 42 * a.y)
- stm_setfield(a, 'c1', '(')
- assert stm_getfield(a, 'c1') == '('
- assert stm_getfield(a, 'c2') == '*'
- assert stm_getfield(a, 'c3') == '#'
- stm_setfield(a, 'c2', '?')
- assert stm_getfield(a, 'c1') == '('
- assert stm_getfield(a, 'c2') == '?'
- assert stm_getfield(a, 'c3') == '#'
- stm_setfield(a, 'c3', ')')
- stm_setfield(a, 'l', rll2)
- stm_setfield(a, 'f', rf2)
- stm_setfield(a, 'sa', rs2a)
- stm_setfield(a, 'sb', rs2b)
- assert stm_getfield(a, 'x') == 42 * a.y
- assert stm_getfield(a, 'c1') == '('
- assert stm_getfield(a, 'c2') == '?'
- assert stm_getfield(a, 'c3') == ')'
- assert stm_getfield(a, 'l') == rll2
- assert stm_getfield(a, 'f') == rf2
- assert float(stm_getfield(a, 'sa')) == float(rs2a)
- assert float(stm_getfield(a, 'sb')) == float(rs2b)
- assert a.x == -611 # xxx still the old value when reading non-transact.
- assert a.c1 == '&'
- assert a.c2 == '*'
- assert a.c3 == '#'
- assert a.l == rll1
- assert a.f == rf1
- assert float(a.sa) == float(rs1a)
- assert float(a.sb) == float(rs1b)
- assert a.v == None
- if a.y < 10:
- a.y += 1 # non-transactionally
- stm_abort_and_retry()
- return lltype.nullptr(rffi.VOIDP.TO)
-
-def test_stm_setfield():
- a = lltype.malloc(A, flavor='raw')
- a.x = -611
- a.c1 = '&'
- a.c2 = '*'
- a.c3 = '#'
- a.y = 0
- a.l = rll1
- a.f = rf1
- a.sa = rs1a
- a.sb = rs1b
- a.v = None
- stm_descriptor_init()
- stm_perform_transaction(llhelper(CALLBACK, callback2),
- rffi.cast(rffi.VOIDP, a))
- stm_descriptor_done()
- assert a.x == 420
- assert a.c1 == '('
- assert a.c2 == '?'
- assert a.c3 == ')'
- assert a.l == rll2
- assert a.f == rf2
- assert float(a.sa) == float(rs2a)
- assert float(a.sb) == float(rs2b)
- assert a.v == None
- assert a.y == 10
- lltype.free(a, flavor='raw')
diff --git a/pypy/translator/stm/test/test_llstminterp.py b/pypy/translator/stm/test/test_llstminterp.py
--- a/pypy/translator/stm/test/test_llstminterp.py
+++ b/pypy/translator/stm/test/test_llstminterp.py
@@ -1,4 +1,5 @@
import py
+py.test.skip("llstminterp disabled")
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.test.test_llinterp import get_interpreter
from pypy.translator.stm.llstminterp import eval_stm_graph
More information about the pypy-commit
mailing list