[pypy-commit] pypy stmgc-c7-rewindjmp: Remove some other inevitable transactions
arigo
noreply at buildbot.pypy.org
Sun Aug 17 16:01:36 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7-rewindjmp
Changeset: r72841:9d2407315c43
Date: 2014-08-17 16:01 +0200
http://bitbucket.org/pypy/pypy/changeset/9d2407315c43/
Log: Remove some other inevitable transactions
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -125,21 +125,21 @@
def after_external_call():
if we_are_translated():
# starts a new transaction if we are not atomic already
- llop.stm_start_inevitable_if_not_atomic(lltype.Void)
+ llop.stm_start_if_not_atomic(lltype.Void)
after_external_call._dont_reach_me_in_del_ = True
after_external_call._transaction_break_ = True
@dont_look_inside
-def enter_callback_call():
+def enter_callback_call(rjbuf):
if we_are_translated():
- return llop.stm_enter_callback_call(lltype.Signed)
+ return llop.stm_enter_callback_call(lltype.Signed, rjbuf)
enter_callback_call._dont_reach_me_in_del_ = True
enter_callback_call._transaction_break_ = True
@dont_look_inside
-def leave_callback_call(token):
+def leave_callback_call(rjbuf, token):
if we_are_translated():
- llop.stm_leave_callback_call(lltype.Void, token)
+ llop.stm_leave_callback_call(lltype.Void, rjbuf, token)
leave_callback_call._dont_reach_me_in_del_ = True
leave_callback_call._transaction_break_ = True
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
@@ -430,7 +430,7 @@
'stm_push_root': LLOp(),
'stm_pop_root_into': LLOp(),
'stm_commit_if_not_atomic': LLOp(canmallocgc=True),
- 'stm_start_inevitable_if_not_atomic': LLOp(canmallocgc=True),
+ 'stm_start_if_not_atomic': LLOp(canmallocgc=True),
'stm_abort_and_retry': LLOp(canmallocgc=True),
'stm_enter_callback_call': LLOp(canmallocgc=True),
'stm_leave_callback_call': LLOp(),
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -315,10 +315,10 @@
source = py.code.Source(r"""
def wrapper(%(args)s): # no *args - no GIL for mallocing the tuple
token = 0
+ rjbuf = llop.stm_rewind_jmp_frame(llmemory.Address, 1)
if aroundstate is not None:
if aroundstate.enter_callback is not None:
- token = aroundstate.enter_callback()
- llop.stm_rewind_jmp_frame(lltype.Void, 1)
+ token = aroundstate.enter_callback(rjbuf)
else:
after = aroundstate.after
if after is not None:
@@ -339,8 +339,7 @@
stackcounter.stacks_counter -= 1
if aroundstate is not None:
if aroundstate.leave_callback is not None:
- llop.stm_rewind_jmp_frame(lltype.Void, 2)
- aroundstate.leave_callback(token)
+ aroundstate.leave_callback(rjbuf, token)
else:
before = aroundstate.before
if before is not None:
@@ -355,13 +354,16 @@
miniglobals['os'] = os
miniglobals['we_are_translated'] = we_are_translated
miniglobals['stackcounter'] = stackcounter
+ miniglobals['llmemory'] = llmemory
exec source.compile() in miniglobals
return miniglobals['wrapper']
_make_wrapper_for._annspecialcase_ = 'specialize:memo'
AroundFnPtr = lltype.Ptr(lltype.FuncType([], lltype.Void))
-EnterCallbackFnPtr = lltype.Ptr(lltype.FuncType([], lltype.Signed))
-LeaveCallbackFnPtr = lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Void))
+EnterCallbackFnPtr = lltype.Ptr(lltype.FuncType([llmemory.Address],
+ lltype.Signed))
+LeaveCallbackFnPtr = lltype.Ptr(lltype.FuncType([llmemory.Address,
+ lltype.Signed], lltype.Void))
class AroundState:
_alloc_flavor_ = "raw"
diff --git a/rpython/translator/stm/breakfinder.py b/rpython/translator/stm/breakfinder.py
--- a/rpython/translator/stm/breakfinder.py
+++ b/rpython/translator/stm/breakfinder.py
@@ -4,8 +4,7 @@
TRANSACTION_BREAK = set([
'stm_commit_if_not_atomic',
- 'stm_start_inevitable_if_not_atomic',
- #'stm_perform_transaction',
+ 'stm_start_if_not_atomic',
#'stm_partial_commit_and_resume_other_threads', # new priv_revision
#'jit_assembler_call',
#'jit_stm_transaction_break_point',
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
@@ -156,16 +156,18 @@
def stm_commit_if_not_atomic(funcgen, op):
return 'pypy_stm_commit_if_not_atomic();'
-def stm_start_inevitable_if_not_atomic(funcgen, op):
- return 'pypy_stm_start_inevitable_if_not_atomic();'
+def stm_start_if_not_atomic(funcgen, op):
+ return 'pypy_stm_start_if_not_atomic();'
def stm_enter_callback_call(funcgen, op):
+ arg0 = funcgen.expr(op.args[0])
result = funcgen.expr(op.result)
- return '%s = pypy_stm_enter_callback_call();' % (result,)
+ return '%s = pypy_stm_enter_callback_call(%s);' % (result, arg0)
def stm_leave_callback_call(funcgen, op):
arg0 = funcgen.expr(op.args[0])
- return 'pypy_stm_leave_callback_call(%s);' % (arg0,)
+ arg1 = funcgen.expr(op.args[1])
+ return 'pypy_stm_leave_callback_call(%s, %s);' % (arg0, arg1)
def stm_should_break_transaction(funcgen, op):
result = funcgen.expr(op.result)
@@ -259,8 +261,10 @@
def stm_rewind_jmp_frame(funcgen, op):
if len(op.args) == 0:
+ assert op.result.concretetype is lltype.Void
return '/* automatic stm_rewind_jmp_frame */'
elif op.args[0].value == 1:
- return 'stm_rewind_jmp_enterframe(&stm_thread_local, &rjbuf1);'
+ assert op.result.concretetype is llmemory.Address
+ return '%s = &rjbuf1;' % (funcgen.expr(op.result),)
else:
- return 'stm_rewind_jmp_leaveframe(&stm_thread_local, &rjbuf1);'
+ assert False, op.args[0].value
diff --git a/rpython/translator/stm/src_stm/stmgcintf.c b/rpython/translator/stm/src_stm/stmgcintf.c
--- a/rpython/translator/stm/src_stm/stmgcintf.c
+++ b/rpython/translator/stm/src_stm/stmgcintf.c
@@ -89,41 +89,45 @@
/* stm_teardown() not called here for now; it's mostly for tests */
}
-long pypy_stm_enter_callback_call(void)
+long pypy_stm_enter_callback_call(void *rjbuf)
{
if (pypy_stm_ready_atomic == 0) {
/* first time we see this thread */
assert(pypy_transaction_length >= 0);
int e = errno;
pypy_stm_register_thread_local();
+ stm_rewind_jmp_enterframe(&stm_thread_local, (rewind_jmp_buf *)rjbuf);
errno = e;
pypy_stm_ready_atomic = 1;
- pypy_stm_start_inevitable_if_not_atomic();
+ pypy_stm_start_if_not_atomic();
return 1;
}
else {
/* callback from C code, itself called from Python code */
- pypy_stm_start_inevitable_if_not_atomic();
+ stm_rewind_jmp_enterframe(&stm_thread_local, (rewind_jmp_buf *)rjbuf);
+ pypy_stm_start_if_not_atomic();
return 0;
}
}
-void pypy_stm_leave_callback_call(long token)
+void pypy_stm_leave_callback_call(void *rjbuf, long token)
{
+ int e = errno;
if (token == 1) {
/* if we're returning into foreign C code that was not itself
called from Python code, then we're ignoring the atomic
status and committing anyway. */
- int e = errno;
pypy_stm_ready_atomic = 1;
stm_commit_transaction();
pypy_stm_ready_atomic = 0;
+ stm_rewind_jmp_leaveframe(&stm_thread_local, (rewind_jmp_buf *)rjbuf);
pypy_stm_unregister_thread_local();
- errno = e;
}
else {
pypy_stm_commit_if_not_atomic();
+ stm_rewind_jmp_leaveframe(&stm_thread_local, (rewind_jmp_buf *)rjbuf);
}
+ errno = e;
}
void _pypy_stm_initialize_nursery_low_fill_mark(long v_counter)
diff --git a/rpython/translator/stm/src_stm/stmgcintf.h b/rpython/translator/stm/src_stm/stmgcintf.h
--- a/rpython/translator/stm/src_stm/stmgcintf.h
+++ b/rpython/translator/stm/src_stm/stmgcintf.h
@@ -53,6 +53,15 @@
}
errno = e;
}
+static inline void pypy_stm_start_if_not_atomic(void) {
+ if (pypy_stm_ready_atomic == 1) {
+ int e = errno;
+ stm_start_transaction(&stm_thread_local);
+ _pypy_stm_initialize_nursery_low_fill_mark(0);
+ _pypy_stm_inev_state();
+ errno = e;
+ }
+}
static inline void pypy_stm_start_inevitable_if_not_atomic(void) {
if (pypy_stm_ready_atomic == 1) {
int e = errno;
@@ -89,8 +98,8 @@
static inline long pypy_stm_get_atomic(void) {
return pypy_stm_ready_atomic - 1;
}
-long pypy_stm_enter_callback_call(void);
-void pypy_stm_leave_callback_call(long);
+long pypy_stm_enter_callback_call(void *);
+void pypy_stm_leave_callback_call(void *, long);
void pypy_stm_set_transaction_length(double);
void pypy_stm_transaction_break(void);
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
@@ -73,7 +73,7 @@
rthread.start_new_thread(threadfn, ())
while glob.seen is None:
llop.stm_commit_if_not_atomic(lltype.Void)
- llop.stm_start_inevitable_if_not_atomic(lltype.Void)
+ llop.stm_start_if_not_atomic(lltype.Void)
return glob.seen.value
#
t, cbuilder = self.compile(entry_point)
@@ -470,7 +470,7 @@
lst[42] = 43
lst2[999] = lst
llop.stm_commit_if_not_atomic(lltype.Void)
- llop.stm_start_inevitable_if_not_atomic(lltype.Void)
+ llop.stm_start_if_not_atomic(lltype.Void)
print 'did not crash', lst2[999][42]
return 0
More information about the pypy-commit
mailing list