Author: Armin Rigo <ar...@tunes.org> Branch: stmgc-c7 Changeset: r71047:5971a915100c Date: 2014-04-28 19:05 +0200 http://bitbucket.org/pypy/pypy/changeset/5971a915100c/
Log: Test and implementation of a way to grab the longest_abort_info from RPython diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py --- a/rpython/rlib/rstm.py +++ b/rpython/rlib/rstm.py @@ -132,6 +132,16 @@ def pop_marker(): llop.stm_pop_marker(lltype.Void) +def longest_abort_info(): + state = llop.stm_longest_marker_state(lltype.Signed) + time = llop.stm_longest_marker_time(lltype.Float) + cself = llop.stm_longest_marker_self(rffi.CCHARP) + cother = llop.stm_longest_marker_other(rffi.CCHARP) + return (state, time, rffi.charp2str(cself), rffi.charp2str(cother)) + +def reset_longest_abort_info(): + llop.stm_reset_longest_marker_state(lltype.Void) + # ____________________________________________________________ def make_perform_transaction(func, CONTAINERP): diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py --- a/rpython/rtyper/lltypesystem/lloperation.py +++ b/rpython/rtyper/lltypesystem/lloperation.py @@ -457,22 +457,11 @@ 'stm_expand_marker': LLOp(), 'stm_setup_expand_marker_for_pypy': LLOp(), -## 'stm_allocate_nonmovable_int_adr': LLOp(sideeffects=False, canmallocgc=True), -## 'stm_become_inevitable': LLOp(canmallocgc=True), -## 'stm_stop_all_other_threads': LLOp(canmallocgc=True), -## 'stm_partial_commit_and_resume_other_threads': LLOp(canmallocgc=True), -## 'stm_minor_collect': LLOp(canmallocgc=True), -## 'stm_major_collect': LLOp(canmallocgc=True), -## 'stm_get_tid': LLOp(canfold=True), -## 'stm_ptr_eq': LLOp(canfold=True), - -## 'stm_weakref_allocate': LLOp(sideeffects=False, canmallocgc=True), - -## 'stm_get_adr_of_private_rev_num':LLOp(), -## 'stm_get_adr_of_read_barrier_cache':LLOp(), -## 'stm_get_adr_of_nursery_current': LLOp(), -## 'stm_get_adr_of_nursery_nextlimit': LLOp(), -## 'stm_get_adr_of_active': LLOp(), + 'stm_longest_marker_state': LLOp(), + 'stm_longest_marker_time': LLOp(), + 'stm_longest_marker_self': LLOp(), + 'stm_longest_marker_other': LLOp(), + 'stm_reset_longest_marker_state': LLOp(), # __________ address operations __________ diff --git a/rpython/translator/stm/funcgen.py b/rpython/translator/stm/funcgen.py --- a/rpython/translator/stm/funcgen.py +++ b/rpython/translator/stm/funcgen.py @@ -239,3 +239,25 @@ assert len(offsets) == 4 return 'pypy_stm_setup_expand_marker(%s, %s, %s, %s);' % ( offsets[0], offsets[1], offsets[2], offsets[3]) + +def stm_longest_marker_state(funcgen, op): + result = funcgen.expr(op.result) + return '%s = (Signed)stm_thread_local.longest_marker_state;' % (result,) + +def stm_longest_marker_time(funcgen, op): + result = funcgen.expr(op.result) + return '%s = stm_thread_local.longest_marker_time;' % (result,) + +def stm_longest_marker_self(funcgen, op): + result = funcgen.expr(op.result) + return '%s = stm_thread_local.longest_marker_self;' % (result,) + +def stm_longest_marker_other(funcgen, op): + result = funcgen.expr(op.result) + return '%s = stm_thread_local.longest_marker_other;' % (result,) + +def stm_reset_longest_marker_state(funcgen, op): + return ('stm_thread_local.longest_marker_state = 0;\n' + 'stm_thread_local.longest_marker_time = 0.0;\n' + 'stm_thread_local.longest_marker_self[0] = 0;\n' + 'stm_thread_local.longest_marker_other[0] = 0;') diff --git a/rpython/translator/stm/test/test_ztranslated.py b/rpython/translator/stm/test/test_ztranslated.py --- a/rpython/translator/stm/test/test_ztranslated.py +++ b/rpython/translator/stm/test/test_ztranslated.py @@ -237,7 +237,6 @@ assert 'ok\n' in data def test_abort_info(self): - py.test.skip("goes away") class Parent(object): pass class Foobar(Parent): @@ -249,19 +248,12 @@ globf.xy = 100 + retry_counter def check(_, retry_counter): - rstm.abort_info_push(globf, ('[', 'xy', ']', 'yx')) setxy(globf, retry_counter) if retry_counter < 3: rstm.abort_and_retry() - # - last = rstm.charp_inspect_abort_info() - if last: - print rffi.charp2str(last) - else: - print 'got abort_info=NULL!' - print int(bool(rstm.charp_inspect_abort_info())) - # - rstm.abort_info_pop(2) + print rstm.longest_abort_info() + rstm.reset_longest_abort_info() + print rstm.longest_abort_info() return 0 PS = lltype.Ptr(lltype.GcStruct('S', ('got_exception', OBJECTPTR))) @@ -275,7 +267,10 @@ return 0 t, cbuilder = self.compile(main) data = cbuilder.cmdexec('a b') - assert 'li102ee10:hi there 3e\n0\n' in data + # + # 6 == STM_TIME_RUN_ABORTED_OTHER + import re; r = re.compile(r'\(6, 0.00\d+, , \)\n\(0, 0.00+, , \)\n$') + assert r.match(data) def test_weakref(self): import weakref _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit