Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r71334:21e636ca9f67
Date: 2014-05-06 18:55 +0200
http://bitbucket.org/pypy/pypy/changeset/21e636ca9f67/
Log: Record a flag "did I do any allocation?"
diff --git a/rpython/jit/backend/llsupport/rewrite.py
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -36,7 +36,7 @@
_previous_size = -1
_op_malloc_nursery = None
_v_last_malloced_nursery = None
- c_zero = ConstInt(0)
+ does_any_allocation = False
def __init__(self, gc_ll_descr, cpu):
self.gc_ll_descr = gc_ll_descr
@@ -89,6 +89,7 @@
# ----------
def handle_malloc_operation(self, op):
+ self.does_any_allocation = True
opnum = op.getopnum()
if opnum == rop.NEW:
self.handle_new_fixedsize(op.getdescr(), op)
@@ -161,6 +162,7 @@
raise NotImplementedError(op.getopname())
def gen_malloc_frame(self, frame_info, frame):
+ self.does_any_allocation = True
descrs = self.gc_ll_descr.getframedescrs(self.cpu)
if self.gc_ll_descr.kind == 'boehm':
size_box = history.BoxInt()
diff --git a/rpython/jit/backend/llsupport/stmrewrite.py
b/rpython/jit/backend/llsupport/stmrewrite.py
--- a/rpython/jit/backend/llsupport/stmrewrite.py
+++ b/rpython/jit/backend/llsupport/stmrewrite.py
@@ -26,7 +26,7 @@
return
# ---------- transaction breaks ----------
if opnum == rop.STM_SHOULD_BREAK_TRANSACTION:
- self.newops.append(op)
+ self.handle_should_break_transaction()
return
if opnum == rop.STM_TRANSACTION_BREAK:
self.emitting_an_operation_that_can_collect()
@@ -120,6 +120,12 @@
self.newops.append(op1)
self.read_barrier_applied[v_ptr] = None
+ def handle_should_break_transaction(self):
+ op1 = ResOperation(rop.STM_SHOULD_BREAK_TRANSACTION,
+ [ConstInt(not self.does_any_allocation)], None)
+ self.newops.append(op1)
+ self.does_any_allocation = True
+
def must_apply_write_barrier(self, val, v=None):
return val not in self.write_barrier_applied
diff --git a/rpython/jit/backend/llsupport/test/test_stmrewrite.py
b/rpython/jit/backend/llsupport/test/test_stmrewrite.py
--- a/rpython/jit/backend/llsupport/test/test_stmrewrite.py
+++ b/rpython/jit/backend/llsupport/test/test_stmrewrite.py
@@ -1229,3 +1229,35 @@
i3 = call_assembler(p1, descr=casmdescr) {54}
guard_not_forced() [] {55}
""")
+
+ def test_stm_should_break_transaction_no_malloc(self):
+ self.check_rewrite("""
+ []
+ stm_should_break_transaction(0)
+ """, """
+ []
+ stm_should_break_transaction(1)
+ """)
+
+ def test_stm_should_break_transaction_with_malloc(self):
+ self.check_rewrite("""
+ []
+ p2 = new(descr=tdescr)
+ stm_should_break_transaction(0)
+ """, """
+ []
+ p2 = call_malloc_nursery(%(tdescr.size)d)
+ setfield_gc(p2, %(tdescr.tid)d, descr=tiddescr)
+ stm_should_break_transaction(0)
+ """)
+
+ def test_double_stm_should_break_allocation(self):
+ self.check_rewrite("""
+ []
+ stm_should_break_transaction(0)
+ stm_should_break_transaction(0)
+ """, """
+ []
+ stm_should_break_transaction(1)
+ stm_should_break_transaction(0)
+ """)
diff --git a/rpython/jit/metainterp/pyjitpl.py
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -207,7 +207,8 @@
if val:
# app-level loop: only one of these per loop is really needed
resbox = history.BoxInt(0)
- mi.history.record(rop.STM_SHOULD_BREAK_TRANSACTION, [], resbox)
+ mi.history.record(rop.STM_SHOULD_BREAK_TRANSACTION,
+ [history.CONST_FALSE], resbox)
self.metainterp.heapcache.stm_break_done()
return resbox
else:
diff --git a/rpython/jit/metainterp/resoperation.py
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -493,7 +493,7 @@
'FORCE_TOKEN/0',
'VIRTUAL_REF/2', # removed before it's passed to the backend
'READ_TIMESTAMP/0',
- 'STM_SHOULD_BREAK_TRANSACTION/0',
+ 'STM_SHOULD_BREAK_TRANSACTION/1', # flag: increase nursery_current?
'MARK_OPAQUE_PTR/1b',
# this one has no *visible* side effect, since the virtualizable
# must be forced, however we need to execute it anyway
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit