Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r69796:b1e070ba9ae9
Date: 2014-03-08 12:01 +0100
http://bitbucket.org/pypy/pypy/changeset/b1e070ba9ae9/
Log: in-progress
diff --git a/rpython/memory/gc/stmgc.py b/rpython/memory/gc/stmgc.py
--- a/rpython/memory/gc/stmgc.py
+++ b/rpython/memory/gc/stmgc.py
@@ -27,9 +27,6 @@
#gcflag_extra = GCFLAG_EXTRA
HDR = stmgcintf.GCPTR.TO
- H_TID = 0
- H_REVISION = WORD
- H_ORIGINAL = WORD * 2
typeid_is_in_field = None
VISIT_FPTR = lltype.Ptr(lltype.FuncType([llmemory.Address], lltype.Void))
@@ -40,7 +37,7 @@
}
def get_type_id(self, obj):
- return llop.stm_get_tid(llgroup.HALFWORD, obj)
+ return llop.stm_addr_get_tid(llgroup.HALFWORD, obj)
def setup(self):
# Hack: MovingGCBase.setup() sets up stuff related to id(), which
@@ -48,6 +45,7 @@
GCBase.setup(self)
#
llop.stm_setup(lltype.Void)
+ llop.stm_register_thread_local(lltype.Void)
def init_gc_object_immortal(self, addr, typeid16, flags=0):
assert flags == 0
@@ -69,19 +67,21 @@
#ll_assert(not needs_finalizer, 'XXX needs_finalizer')
#ll_assert(not is_finalizer_light, 'XXX is_finalizer_light')
ll_assert(not contains_weakptr, 'contains_weakptr: use malloc_weakref')
- # XXX call optimized versions, e.g. if size < GC_NURSERY_SECTION
- return llop.stm_allocate(llmemory.GCREF, size, typeid16)
+ if size < 16:
+ size = 16 # minimum size (test usually constant-folded)
+ return llop.stm_allocate_tid(llmemory.GCREF, size, typeid16)
def malloc_varsize_clear(self, typeid16, length, size, itemsize,
offset_to_length):
- # XXX be careful about overflows, and call optimized versions
+ # XXX be careful here about overflows
totalsize = size + itemsize * length
totalsize = llarena.round_up_for_allocation(totalsize)
- obj = llop.stm_allocate(llmemory.Address, totalsize, typeid16)
- (obj + offset_to_length).signed[0] = length
- return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
+ result = llop.stm_allocate_tid(llmemory.GCREF, totalsize, typeid16)
+ llop.stm_set_into_obj(lltype.Void, result, offset_to_length, length)
+ return result
def malloc_weakref(self, typeid16, size, obj):
+ raise NotImplementedError # XXX
return llop.stm_weakref_allocate(llmemory.GCREF, size,
typeid16, obj)
@@ -102,18 +102,15 @@
def collect(self, gen=1):
"""Do a minor (gen=0) or major (gen>0) collection."""
- if gen > 0:
- llop.stm_major_collect(lltype.Void)
- else:
- llop.stm_minor_collect(lltype.Void)
+ llop.stm_collect(lltype.Void, gen)
def writebarrier_before_copy(self, source_addr, dest_addr,
source_start, dest_start, length):
ll_assert(False, 'XXX')
return False
-
+
def id(self, gcobj):
return llop.stm_id(lltype.Signed, gcobj)
def identityhash(self, gcobj):
- return llop.stm_hash(lltype.Signed, gcobj)
+ return llop.stm_identityhash(lltype.Signed, gcobj)
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
@@ -412,54 +412,62 @@
# (some ops like stm_commit_transaction don't need it because there
# must be no gc-var access afterwards anyway)
'stm_setup': LLOp(),
- 'stm_finalize': LLOp(canmallocgc=True),
- 'stm_barrier': LLOp(sideeffects=False),
- 'stm_allocate': LLOp(sideeffects=False, canmallocgc=True),
- 'stm_allocate_nonmovable_int_adr': LLOp(sideeffects=False,
canmallocgc=True),
+ 'stm_register_thread_local': LLOp(),
+ 'stm_unregister_thread_local': LLOp(),
+ 'stm_can_move': LLOp(),
+ 'stm_allocate_tid': LLOp(sideeffects=False, canmallocgc=True),
+ 'stm_get_from_obj': LLOp(sideeffects=False),
+ 'stm_get_from_obj_const': LLOp(canfold=True),
+ 'stm_set_into_obj': LLOp(),
+ 'stm_collect': LLOp(canmallocgc=True),
+ 'stm_id': LLOp(sideeffects=False),
+ 'stm_identityhash': LLOp(canfold=True),
+ 'stm_addr_get_tid': LLOp(canfold=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_id': LLOp(sideeffects=False),
- 'stm_hash': LLOp(sideeffects=False),
'stm_push_root': LLOp(),
'stm_pop_root_into': LLOp(),
- 'stm_commit_transaction': LLOp(canmallocgc=True),
- 'stm_begin_inevitable_transaction': LLOp(canmallocgc=True),
- 'stm_should_break_transaction': LLOp(sideeffects=False),
- 'stm_set_transaction_length': LLOp(canmallocgc=True),
- 'stm_change_atomic': LLOp(),
- 'stm_get_atomic': LLOp(sideeffects=False),
- 'stm_perform_transaction':LLOp(canmallocgc=True),
- 'stm_enter_callback_call':LLOp(canmallocgc=True),
- 'stm_leave_callback_call':LLOp(canmallocgc=True),
- 'stm_abort_and_retry': LLOp(canmallocgc=True),
- 'stm_weakref_allocate': LLOp(sideeffects=False, canmallocgc=True),
+## '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_id': LLOp(sideeffects=False),
+## 'stm_hash': LLOp(sideeffects=False),
+## 'stm_commit_transaction': LLOp(canmallocgc=True),
+## 'stm_begin_inevitable_transaction': LLOp(canmallocgc=True),
+## 'stm_should_break_transaction': LLOp(sideeffects=False),
+## 'stm_set_transaction_length': LLOp(canmallocgc=True),
+## 'stm_change_atomic': LLOp(),
+## 'stm_get_atomic': LLOp(sideeffects=False),
+## 'stm_perform_transaction':LLOp(canmallocgc=True),
+## 'stm_enter_callback_call':LLOp(canmallocgc=True),
+## 'stm_leave_callback_call':LLOp(canmallocgc=True),
+## 'stm_abort_and_retry': LLOp(canmallocgc=True),
+
+## 'stm_weakref_allocate': LLOp(sideeffects=False, canmallocgc=True),
- 'stm_threadlocalref_get': LLOp(sideeffects=False),
- 'stm_threadlocalref_set': LLOp(canmallocgc=True), # may allocate new array,
- # see threadlocalref.py
- 'stm_threadlocal_get': LLOp(sideeffects=False),
- 'stm_threadlocal_set': LLOp(),
+## 'stm_threadlocalref_get': LLOp(sideeffects=False),
+## 'stm_threadlocalref_set': LLOp(canmallocgc=True), # may allocate new
array,
+## # see threadlocalref.py
+## 'stm_threadlocal_get': LLOp(sideeffects=False),
+## 'stm_threadlocal_set': LLOp(),
- 'stm_abort_info_push': LLOp(),
- 'stm_abort_info_pop': LLOp(),
- 'stm_inspect_abort_info': LLOp(sideeffects=False, canmallocgc=True),
+## 'stm_abort_info_push': LLOp(),
+## 'stm_abort_info_pop': LLOp(),
+## 'stm_inspect_abort_info': 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_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_ignored_start': LLOp(canrun=True),
- 'stm_ignored_stop': LLOp(canrun=True),
-
- 'stm_can_move': LLOp(),
+## 'stm_ignored_start': LLOp(canrun=True),
+## 'stm_ignored_stop': LLOp(canrun=True),
# __________ address operations __________
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -296,6 +296,9 @@
label += '_back'
yield 'goto %s;' % label
+ def _is_stm(self):
+ return getattr(self.db.translator, 'stm_transformation_applied', False)
+
def gen_op(self, op):
macro = 'OP_%s' % op.opname.upper()
line = None
@@ -303,6 +306,13 @@
meth = getattr(self.gcpolicy, macro, None)
if meth:
line = meth(self, op)
+ elif op.opname.startswith('stm_'):
+ if not self._is_stm():
+ raise AssertionError("STM transformation not applied. "
+ "You need '--stm'")
+ from rpython.translator.stm import funcgen
+ func = getattr(funcgen, op.opname)
+ line = func(self, op)
else:
meth = getattr(self, macro, None)
if meth:
@@ -571,69 +581,6 @@
assert isinstance(ARRAY, Array)
return '%s = %s.length;'%(self.expr(op.result), expr)
-
- def _is_stm(self):
- return getattr(self.db.translator, 'stm_transformation_applied', False)
-
- def _OP_STM(self, op):
- if not hasattr(self, 'op_stm'):
- if not self._is_stm():
- raise AssertionError("STM transformation not applied. "
- "You need '--stm'")
- from rpython.translator.stm.funcgen import op_stm
- self.__class__.op_stm = op_stm
- return self.op_stm(op)
- OP_STM_INITIALIZE = _OP_STM
- OP_STM_FINALIZE = _OP_STM
- OP_STM_BECOME_INEVITABLE = _OP_STM
- OP_STM_STOP_ALL_OTHER_THREADS = _OP_STM
- OP_STM_PARTIAL_COMMIT_AND_RESUME_OTHER_THREADS = _OP_STM
- OP_STM_BARRIER = _OP_STM
- OP_STM_PTR_EQ = _OP_STM
- OP_STM_PUSH_ROOT = _OP_STM
- OP_STM_POP_ROOT_INTO = _OP_STM
- OP_STM_GET_ADR_OF_NURSERY_CURRENT = _OP_STM
- OP_STM_GET_ADR_OF_NURSERY_NEXTLIMIT = _OP_STM
- OP_STM_GET_ADR_OF_ACTIVE = _OP_STM
- OP_STM_GET_ROOT_STACK_TOP = _OP_STM
- OP_STM_GET_ADR_OF_PRIVATE_REV_NUM = _OP_STM
- OP_STM_GET_ADR_OF_READ_BARRIER_CACHE= _OP_STM
- OP_STM_ALLOCATE = _OP_STM
- OP_STM_WEAKREF_ALLOCATE = _OP_STM
- OP_STM_GET_TID = _OP_STM
- OP_STM_HASH = _OP_STM
- OP_STM_ID = _OP_STM
- OP_STM_COMMIT_TRANSACTION = _OP_STM
- OP_STM_BEGIN_INEVITABLE_TRANSACTION = _OP_STM
- OP_STM_SHOULD_BREAK_TRANSACTION = _OP_STM
- OP_STM_SET_TRANSACTION_LENGTH = _OP_STM
- OP_STM_CHANGE_ATOMIC = _OP_STM
- OP_STM_GET_ATOMIC = _OP_STM
- OP_STM_THREADLOCAL_GET = _OP_STM
- OP_STM_THREADLOCAL_SET = _OP_STM
- OP_STM_PERFORM_TRANSACTION = _OP_STM
- OP_STM_ENTER_CALLBACK_CALL = _OP_STM
- OP_STM_LEAVE_CALLBACK_CALL = _OP_STM
- OP_STM_ABORT_AND_RETRY = _OP_STM
- OP_STM_ABORT_INFO_PUSH = _OP_STM
- OP_STM_ABORT_INFO_POP = _OP_STM
- OP_STM_INSPECT_ABORT_INFO = _OP_STM
- OP_STM_MAJOR_COLLECT = _OP_STM
- OP_STM_MINOR_COLLECT = _OP_STM
- OP_STM_CLEAR_EXCEPTION_DATA_ON_ABORT= _OP_STM
- OP_STM_ALLOCATE_NONMOVABLE_INT_ADR = _OP_STM
- OP_JIT_STM_TRANSACTION_BREAK_POINT = _OP_STM
- OP_JIT_STM_SHOULD_BREAK_TRANSACTION = _OP_STM
-
- OP_STM_CAN_MOVE = _OP_STM
-
- def OP_STM_IGNORED_START(self, op):
- return '/* stm_ignored_start */'
-
- def OP_STM_IGNORED_STOP(self, op):
- return '/* stm_ignored_stop */'
-
-
def OP_PTR_NONZERO(self, op):
return '%s = (%s != NULL);' % (self.expr(op.result),
self.expr(op.args[0]))
diff --git a/rpython/translator/c/primitive.py
b/rpython/translator/c/primitive.py
--- a/rpython/translator/c/primitive.py
+++ b/rpython/translator/c/primitive.py
@@ -237,7 +237,7 @@
Bool: 'bool_t @',
Void: 'void @',
Address: 'void* @',
- GCREF: 'void* @',
+ GCREF: 'rpy_gc_char *@',
}
def define_c_primitive(ll_type, c_name, suffix=''):
diff --git a/rpython/translator/c/src/mem.h b/rpython/translator/c/src/mem.h
--- a/rpython/translator/c/src/mem.h
+++ b/rpython/translator/c/src/mem.h
@@ -12,6 +12,13 @@
#ifdef RPY_STM
+typedef stm_char rpy_gc_char;
+#else
+typedef char rpy_gc_char;
+#endif
+
+
+#ifdef RPY_STM
void _pypy_stm_free(void *);
#define _OP_RAW_MALLOCED(r) stm_call_on_abort(r, _pypy_stm_free)
#define _OP_RAW_STM_UNREGISTER(r) stm_call_on_abort(r, NULL)
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
@@ -2,6 +2,7 @@
from rpython.translator.c.support import c_string_constant, cdecl
from rpython.translator.c.node import Node, ContainerNode
from rpython.translator.c.primitive import name_small_integer
+from rpython.rtyper.lltypesystem import llmemory
class StmHeaderOpaqueDefNode(Node):
@@ -42,72 +43,61 @@
# self.obj.prebuilt_hash
-def stm_initialize(funcgen, op):
- return '''stm_initialize();
- stm_clear_on_abort(&pypy_g_ExcData.ed_exc_type,
- sizeof(struct pypy_object0 *));
- '''
+def stm_setup(funcgen, op):
+ return 'stm_setup();'
-def jit_stm_transaction_break_point(funcgen, op):
- return '/* jit_stm_transaction_break_point */'
+def stm_register_thread_local(funcgen, op):
+ return 'stm_register_thread_local(&stm_thread_local);'
-def jit_stm_should_break_transaction(funcgen, op):
+def stm_unregister_thread_local(funcgen, op):
+ return 'stm_unregister_thread_local(&stm_thread_local);'
+
+def stm_can_move(funcop, op):
+ arg0 = funcgen.expr(op.args[0])
result = funcgen.expr(op.result)
- return '%s = 0; /* jit_stm_should_break_transaction */' % (result, )
-
-def stm_finalize(funcgen, op):
- return 'stm_finalize();'
+ return '%s = stm_can_move(%s);' % (result, arg0)
-def stm_barrier(funcgen, op):
- category_change = op.args[0].value
- # XXX: how to unify the stm_barrier llop generation in
- # writebarrier.py and threadlocalref.py?
- if isinstance(category_change, str):
- frm, middle, to = category_change
- else: # rstr
- frm, middle, to = (category_change.chars[0],
- category_change.chars[1],
- category_change.chars[2])
- assert middle == '2'
- assert frm < to
- if to == 'W':
- if frm >= 'V':
- funcname = 'stm_repeat_write_barrier'
- else:
- funcname = 'stm_write_barrier'
- elif to == 'V':
- funcname = 'stm_write_barrier_noptr'
- elif to == 'R':
- if frm >= 'Q':
- funcname = 'stm_repeat_read_barrier'
- else:
- funcname = 'stm_read_barrier'
- elif to == 'I':
- funcname = 'stm_immut_read_barrier'
- else:
- raise AssertionError(category_change)
- assert op.args[1].concretetype == op.result.concretetype
- arg = funcgen.expr(op.args[1])
+def stm_allocate_tid(funcgen, op):
+ arg_size = funcgen.expr(op.args[0])
+ arg_type_id = funcgen.expr(op.args[1])
+ result = funcgen.expr(op.result)
+ return ('%s = stm_allocate(%s); ' % (result, arg_size) +
+ '((rpyobj_t *)%s)->type_id = %s;' % (result, arg_type_id))
+
+def stm_get_from_obj(funcgen, op):
+ assert op.args[0].concretetype == llmemory.GCREF
+ arg_obj = funcgen.expr(op.args[0])
+ arg_ofs = funcgen.expr(op.args[1])
+ result = funcgen.expr(op.result)
+ resulttype = cdecl(funcgen.lltypename(op.result), '')
+ return '%s = *(%s *)(%s + %s);' % (result, resulttype, arg_obj, arg_ofs)
+
+stm_get_from_obj_const = stm_get_from_obj
+
+def stm_set_into_obj(funcgen, op):
+ assert op.args[0].concretetype == llmemory.GCREF
+ arg_obj = funcgen.expr(op.args[0])
+ arg_ofs = funcgen.expr(op.args[1])
+ arg_val = funcgen.expr(op.args[2])
+ valtype = cdecl(funcgen.lltypename(op.args[2]), '')
+ return '*(%s *)(%s + %s) = %s;' % (valtype, arg_obj, arg_ofs, arg_val)
+
+def stm_collect(funcgen, op):
+ arg0 = funcgen.expr(op.args[0])
+ return 'stm_collect(%s);' % (arg0,)
+
+def stm_id(funcgen, op):
+ arg0 = funcgen.expr(op.args[0])
+ return 'stm_id((object_t *)%s);' % (arg0,)
+
+def stm_identityhash(funcgen, op):
+ arg0 = funcgen.expr(op.args[0])
+ return 'stm_identityhash((object_t *)%s);' % (arg0,)
+
+def stm_addr_get_tid(funcgen, op):
+ arg0 = funcgen.expr(op.args[0])
result = funcgen.expr(op.result)
- return '%s = (%s)%s((gcptr)%s);' % (
- result, cdecl(funcgen.lltypename(op.result), ''),
- funcname, arg)
-
-def stm_ptr_eq(funcgen, op):
- args = [funcgen.expr(v) for v in op.args]
- result = funcgen.expr(op.result)
- # check for prebuilt arguments
- for i, j in [(0, 1), (1, 0)]:
- if isinstance(op.args[j], Constant):
- if op.args[j].value: # non-NULL
- return ('%s = stm_pointer_equal_prebuilt((gcptr)%s,
(gcptr)%s);'
- % (result, args[i], args[j]))
- else:
- # this case might be unreachable, but better safe than sorry
- return '%s = (%s == NULL);' % (result, args[i])
- #
- return '%s = stm_pointer_equal((gcptr)%s, (gcptr)%s);' % (
- result, args[0], args[1])
+ return '%s = ((struct rpyobj_s *)%s)->type_id;' % (result, arg0)
def stm_become_inevitable(funcgen, op):
try:
@@ -117,160 +107,218 @@
string_literal = c_string_constant(info)
return 'stm_become_inevitable(%s);' % (string_literal,)
-def stm_stop_all_other_threads(funcgen, op):
- return 'stm_stop_all_other_threads();'
-
-def stm_partial_commit_and_resume_other_threads(funcgen, op):
- return 'stm_partial_commit_and_resume_other_threads();'
-
def stm_push_root(funcgen, op):
arg0 = funcgen.expr(op.args[0])
- return 'stm_push_root((gcptr)%s);' % (arg0,)
+ return 'STM_PUSH_ROOT(stm_thread_local, %s);' % (arg0,)
def stm_pop_root_into(funcgen, op):
arg0 = funcgen.expr(op.args[0])
if isinstance(op.args[0], Constant):
- return '/* %s = */ stm_pop_root();' % (arg0,)
- return '%s = (%s)stm_pop_root();' % (
- arg0, cdecl(funcgen.lltypename(op.args[0]), ''))
+ return '/* %s = */ STM_POP_ROOT_RET(stm_thread_local);' % (arg0,)
+ return 'STM_POP_ROOT(stm_thread_local, %s);' % (arg0,)
-def stm_get_adr_of_nursery_current(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = (%s)&stm_nursery_current;' % (
- result, cdecl(funcgen.lltypename(op.result), ''))
-def stm_get_adr_of_nursery_nextlimit(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = (%s)&stm_nursery_nextlimit;' % (
- result, cdecl(funcgen.lltypename(op.result), ''))
+##def stm_initialize(funcgen, op):
+## return '''stm_initialize();
+## stm_clear_on_abort(&pypy_g_ExcData, sizeof(pypy_g_ExcData));
+## '''
-def stm_get_adr_of_active(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = (%s)&stm_active;' % (
- result, cdecl(funcgen.lltypename(op.result), ''))
+##def jit_stm_transaction_break_point(funcgen, op):
+## return '/* jit_stm_transaction_break_point */'
+
+##def jit_stm_should_break_transaction(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = 0; /* jit_stm_should_break_transaction */' % (result, )
-def stm_get_root_stack_top(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = (%s)&stm_shadowstack;' % (
- result, cdecl(funcgen.lltypename(op.result), ''))
+##def stm_finalize(funcgen, op):
+## return 'stm_finalize();'
-def stm_get_adr_of_private_rev_num(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = (%s)&stm_private_rev_num;' % (
- result, cdecl(funcgen.lltypename(op.result), ''))
+##def stm_barrier(funcgen, op):
+## category_change = op.args[0].value
+## # XXX: how to unify the stm_barrier llop generation in
+## # writebarrier.py and threadlocalref.py?
+## if isinstance(category_change, str):
+## frm, middle, to = category_change
+## else: # rstr
+## frm, middle, to = (category_change.chars[0],
+## category_change.chars[1],
+## category_change.chars[2])
+## assert middle == '2'
+## assert frm < to
+## if to == 'W':
+## if frm >= 'V':
+## funcname = 'stm_repeat_write_barrier'
+## else:
+## funcname = 'stm_write_barrier'
+## elif to == 'V':
+## funcname = 'stm_write_barrier_noptr'
+## elif to == 'R':
+## if frm >= 'Q':
+## funcname = 'stm_repeat_read_barrier'
+## else:
+## funcname = 'stm_read_barrier'
+## elif to == 'I':
+## funcname = 'stm_immut_read_barrier'
+## else:
+## raise AssertionError(category_change)
+## assert op.args[1].concretetype == op.result.concretetype
+## arg = funcgen.expr(op.args[1])
+## result = funcgen.expr(op.result)
+## return '%s = (%s)%s((gcptr)%s);' % (
+## result, cdecl(funcgen.lltypename(op.result), ''),
+## funcname, arg)
-def stm_get_adr_of_read_barrier_cache(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = (%s)&stm_read_barrier_cache;' % (
- result, cdecl(funcgen.lltypename(op.result), ''))
+##def stm_ptr_eq(funcgen, op):
+## args = [funcgen.expr(v) for v in op.args]
+## result = funcgen.expr(op.result)
+## # check for prebuilt arguments
+## for i, j in [(0, 1), (1, 0)]:
+## if isinstance(op.args[j], Constant):
+## if op.args[j].value: # non-NULL
+## return ('%s = stm_pointer_equal_prebuilt((gcptr)%s,
(gcptr)%s);'
+## % (result, args[i], args[j]))
+## else:
+## # this case might be unreachable, but better safe than sorry
+## return '%s = (%s == NULL);' % (result, args[i])
+## #
+## return '%s = stm_pointer_equal((gcptr)%s, (gcptr)%s);' % (
+## result, args[0], args[1])
+
+##def stm_become_inevitable(funcgen, op):
+## try:
+## info = op.args[0].value
+## except IndexError:
+## info = "rstm.become_inevitable" # cannot insert it in 'llop'
+## string_literal = c_string_constant(info)
+## return 'stm_become_inevitable(%s);' % (string_literal,)
+
+##def stm_stop_all_other_threads(funcgen, op):
+## return 'stm_stop_all_other_threads();'
+
+##def stm_partial_commit_and_resume_other_threads(funcgen, op):
+## return 'stm_partial_commit_and_resume_other_threads();'
+
+##def stm_get_adr_of_nursery_current(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = (%s)&stm_nursery_current;' % (
+## result, cdecl(funcgen.lltypename(op.result), ''))
+
+##def stm_get_adr_of_nursery_nextlimit(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = (%s)&stm_nursery_nextlimit;' % (
+## result, cdecl(funcgen.lltypename(op.result), ''))
+
+##def stm_get_adr_of_active(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = (%s)&stm_active;' % (
+## result, cdecl(funcgen.lltypename(op.result), ''))
+##def stm_get_root_stack_top(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = (%s)&stm_shadowstack;' % (
+## result, cdecl(funcgen.lltypename(op.result), ''))
+
+##def stm_get_adr_of_private_rev_num(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = (%s)&stm_private_rev_num;' % (
+## result, cdecl(funcgen.lltypename(op.result), ''))
+
+##def stm_get_adr_of_read_barrier_cache(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = (%s)&stm_read_barrier_cache;' % (
+## result, cdecl(funcgen.lltypename(op.result), ''))
-def stm_weakref_allocate(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- arg1 = funcgen.expr(op.args[1])
- arg2 = funcgen.expr(op.args[2])
- result = funcgen.expr(op.result)
- return '%s = stm_weakref_allocate(%s, %s, %s);' % (result, arg0,
- arg1, arg2)
+
+##def stm_weakref_allocate(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## arg1 = funcgen.expr(op.args[1])
+## arg2 = funcgen.expr(op.args[2])
+## result = funcgen.expr(op.result)
+## return '%s = stm_weakref_allocate(%s, %s, %s);' % (result, arg0,
+## arg1, arg2)
-def stm_allocate_nonmovable_int_adr(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- result = funcgen.expr(op.result)
- return '%s = stm_allocate_public_integer_address(%s);' % (result, arg0)
-
-def stm_allocate(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- arg1 = funcgen.expr(op.args[1])
- result = funcgen.expr(op.result)
- return '%s = stm_allocate(%s, %s);' % (result, arg0, arg1)
+##def stm_allocate_nonmovable_int_adr(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## result = funcgen.expr(op.result)
+## return '%s = stm_allocate_public_integer_address(%s);' % (result, arg0)
-def stm_get_tid(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- result = funcgen.expr(op.result)
- return '%s = ((struct rpyobj_s*)%s)->tid;' % (result, arg0)
+##def stm_get_tid(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## result = funcgen.expr(op.result)
+## return '%s = ((struct rpyobj_s*)%s)->tid;' % (result, arg0)
-def stm_hash(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- result = funcgen.expr(op.result)
- return '%s = stm_hash((gcptr)%s);' % (result, arg0)
+##def stm_hash(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## result = funcgen.expr(op.result)
+## return '%s = stm_hash((gcptr)%s);' % (result, arg0)
-def stm_id(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- result = funcgen.expr(op.result)
- return '%s = stm_id((gcptr)%s);' % (result, arg0)
+##def stm_id(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## result = funcgen.expr(op.result)
+## return '%s = stm_id((gcptr)%s);' % (result, arg0)
-def stm_commit_transaction(funcgen, op):
- return '{ int e = errno; stm_commit_transaction(); errno = e; }'
+##def stm_commit_transaction(funcgen, op):
+## return '{ int e = errno; stm_commit_transaction(); errno = e; }'
-def stm_begin_inevitable_transaction(funcgen, op):
- return '{ int e = errno; stm_begin_inevitable_transaction(); errno = e; }'
+##def stm_begin_inevitable_transaction(funcgen, op):
+## return '{ int e = errno; stm_begin_inevitable_transaction(); errno = e;
}'
-def stm_should_break_transaction(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = stm_should_break_transaction();' % (result,)
+##def stm_should_break_transaction(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = stm_should_break_transaction();' % (result,)
-def stm_set_transaction_length(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- return 'stm_set_transaction_length(%s);' % (arg0,)
+##def stm_set_transaction_length(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## return 'stm_set_transaction_length(%s);' % (arg0,)
-def stm_change_atomic(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- return 'stm_atomic(%s);' % (arg0,)
+##def stm_change_atomic(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## return 'stm_atomic(%s);' % (arg0,)
-def stm_get_atomic(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = stm_atomic(0);' % (result,)
+##def stm_get_atomic(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = stm_atomic(0);' % (result,)
-def stm_threadlocal_get(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = (%s)stm_thread_local_obj;' % (
- result, cdecl(funcgen.lltypename(op.result), ''))
+##def stm_threadlocal_get(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = (%s)stm_thread_local_obj;' % (
+## result, cdecl(funcgen.lltypename(op.result), ''))
-def stm_threadlocal_set(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- return 'stm_thread_local_obj = (gcptr)%s;' % (arg0,)
+##def stm_threadlocal_set(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## return 'stm_thread_local_obj = (gcptr)%s;' % (arg0,)
-def stm_perform_transaction(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- arg1 = funcgen.expr(op.args[1])
- return 'stm_perform_transaction((gcptr)%s, %s);' % (arg0, arg1)
+##def stm_perform_transaction(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## arg1 = funcgen.expr(op.args[1])
+## return 'stm_perform_transaction((gcptr)%s, %s);' % (arg0, arg1)
-def stm_enter_callback_call(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = stm_enter_callback_call();' % (result,)
+##def stm_enter_callback_call(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = stm_enter_callback_call();' % (result,)
-def stm_leave_callback_call(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- return 'stm_leave_callback_call(%s);' % (arg0,)
+##def stm_leave_callback_call(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## return 'stm_leave_callback_call(%s);' % (arg0,)
-def stm_abort_and_retry(funcgen, op):
- return 'stm_abort_and_retry();'
+##def stm_abort_and_retry(funcgen, op):
+## return 'stm_abort_and_retry();'
-def stm_abort_info_push(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- arg1 = funcgen.expr(op.args[1])
- return 'stm_abort_info_push((gcptr)%s, %s);' % (arg0, arg1)
+##def stm_abort_info_push(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## arg1 = funcgen.expr(op.args[1])
+## return 'stm_abort_info_push((gcptr)%s, %s);' % (arg0, arg1)
-def stm_abort_info_pop(funcgen, op):
- arg0 = funcgen.expr(op.args[0])
- return 'stm_abort_info_pop(%s);' % (arg0,)
+##def stm_abort_info_pop(funcgen, op):
+## arg0 = funcgen.expr(op.args[0])
+## return 'stm_abort_info_pop(%s);' % (arg0,)
-def stm_inspect_abort_info(funcgen, op):
- result = funcgen.expr(op.result)
- return '%s = stm_inspect_abort_info();' % (result,)
+##def stm_inspect_abort_info(funcgen, op):
+## result = funcgen.expr(op.result)
+## return '%s = stm_inspect_abort_info();' % (result,)
-def stm_minor_collect(funcgen, op):
- return 'stm_minor_collect();'
+##def stm_minor_collect(funcgen, op):
+## return 'stm_minor_collect();'
-def stm_major_collect(funcgen, op):
- return 'stm_major_collect();'
-
-def stm_can_move(funcop, op):
- arg0 = funcgen.expr(op.args[0])
- result = funcgen.expr(op.result)
- return '%s = stm_can_move(%s);' % (result, arg0)
-
-
-def op_stm(funcgen, op):
- func = globals()[op.opname]
- return func(funcgen, op)
+##def stm_major_collect(funcgen, op):
+## return 'stm_major_collect();'
diff --git a/rpython/translator/stm/stmgcintf.py
b/rpython/translator/stm/stmgcintf.py
--- a/rpython/translator/stm/stmgcintf.py
+++ b/rpython/translator/stm/stmgcintf.py
@@ -11,6 +11,8 @@
#include "src_stm/stmgc.h"
+__thread struct stm_thread_local_s stm_thread_local;
+
extern Signed pypy_stmcb_size(void*);
extern void pypy_stmcb_trace(void*, void(*)(void*));
@@ -29,6 +31,8 @@
include_dirs = [cdir, cdir2],
includes = ['src_stm/stmgc.h'],
pre_include_bits = ['#define RPY_STM 1'],
+ post_include_bits = [
+ 'extern __thread struct stm_thread_local_s stm_thread_local;'],
separate_module_sources = [separate_source],
)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit