[pypy-commit] pypy stmgc-c4: fix placing TB in bridge
Raemi
noreply at buildbot.pypy.org
Mon Jan 13 16:39:58 CET 2014
Author: Remi Meier <remi.meier at gmail.com>
Branch: stmgc-c4
Changeset: r68651:205454cb7542
Date: 2014-01-13 16:02 +0100
http://bitbucket.org/pypy/pypy/changeset/205454cb7542/
Log: fix placing TB in bridge
diff --git a/rpython/jit/backend/x86/regalloc.py b/rpython/jit/backend/x86/regalloc.py
--- a/rpython/jit/backend/x86/regalloc.py
+++ b/rpython/jit/backend/x86/regalloc.py
@@ -1274,6 +1274,7 @@
args = op.getarglist()
base_loc = self.rm.make_sure_var_in_reg(op.getarg(0), args)
self.perform_discard(op, [base_loc, ofs_loc, size_loc])
+
def consider_stm_transaction_break(self, op, guard_op):
#
diff --git a/rpython/jit/metainterp/blackhole.py b/rpython/jit/metainterp/blackhole.py
--- a/rpython/jit/metainterp/blackhole.py
+++ b/rpython/jit/metainterp/blackhole.py
@@ -899,8 +899,8 @@
return False
- @arguments()
- def bhimpl_stm_transaction_break():
+ @arguments("i")
+ def bhimpl_stm_transaction_break(really_wanted):
pass
# ----------
diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -635,6 +635,7 @@
operations = None
call_pure_results = None
stm_info = None
+ is_really_loop = False
logops = None
quasi_immutable_deps = None
resume_at_jump_descr = None
diff --git a/rpython/jit/metainterp/optimizeopt/stm.py b/rpython/jit/metainterp/optimizeopt/stm.py
--- a/rpython/jit/metainterp/optimizeopt/stm.py
+++ b/rpython/jit/metainterp/optimizeopt/stm.py
@@ -20,7 +20,7 @@
dispatch_opt(self, op)
def _break_wanted(self):
- is_loop = self.optimizer.loop.operations[0].getopnum() == rop.LABEL
+ is_loop = self.optimizer.loop.is_really_loop
return self.optimizer.stm_info.get('break_wanted', is_loop)
def _set_break_wanted(self, val):
@@ -36,8 +36,8 @@
def optimize_STM_TRANSACTION_BREAK(self, op):
assert not self.remove_next_gnf
-
- if self._break_wanted():
+ really_wanted = op.getarg(0).getint()
+ if really_wanted or self._break_wanted():
self._set_break_wanted(False)
self.emit_operation(op)
self.keep_but_ignore_gnf = True
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_stm.py b/rpython/jit/metainterp/optimizeopt/test/test_stm.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_stm.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_stm.py
@@ -29,10 +29,41 @@
"""
self.optimize_loop(ops, ops, expected_preamble=ops)
+ def test_really_wanted_tb(self):
+ ops = """
+ []
+ stm_transaction_break(0)
+ guard_not_forced() []
+
+ stm_transaction_break(1)
+ guard_not_forced() []
+
+ jump()
+ """
+ preamble = """
+ []
+ stm_transaction_break(0)
+ guard_not_forced() []
+
+ stm_transaction_break(1)
+ guard_not_forced() []
+
+ jump()
+ """
+ expected = """
+ []
+ stm_transaction_break(1)
+ guard_not_forced() []
+
+ jump()
+ """
+ self.optimize_loop(ops, expected, expected_preamble=preamble)
+
+
def test_unrolled_loop2(self):
ops = """
[]
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
i0 = call(123, descr=sbtdescr)
@@ -42,7 +73,7 @@
"""
preamble = """
[]
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
i0 = call(123, descr=sbtdescr)
@@ -87,11 +118,11 @@
def test_dont_remove_first_tb(self):
ops = """
[]
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
i0 = call(123, descr=sbtdescr)
guard_false(i0) []
@@ -99,7 +130,7 @@
"""
preamble = """
[]
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
i0 = call(123, descr=sbtdescr)
@@ -117,15 +148,15 @@
def test_add_tb_after_guard_not_forced(self):
ops = """
[]
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
escape() # e.g. like a call_release_gil
guard_not_forced() []
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
i0 = call(123, descr=sbtdescr)
guard_false(i0) []
@@ -133,13 +164,13 @@
"""
preamble = """
[]
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
escape()
guard_not_forced() []
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
i0 = call(123, descr=sbtdescr)
@@ -151,7 +182,7 @@
escape()
guard_not_forced() []
- stm_transaction_break()
+ stm_transaction_break(0)
guard_not_forced() []
i0 = call(123, descr=sbtdescr)
diff --git a/rpython/jit/metainterp/optimizeopt/unroll.py b/rpython/jit/metainterp/optimizeopt/unroll.py
--- a/rpython/jit/metainterp/optimizeopt/unroll.py
+++ b/rpython/jit/metainterp/optimizeopt/unroll.py
@@ -74,6 +74,7 @@
start_label = loop.operations[0]
if start_label.getopnum() == rop.LABEL:
+ loop.is_really_loop = True
loop.operations = loop.operations[1:]
# We need to emit the label op before import_state() as emitting it
# will clear heap caches
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
@@ -187,12 +187,13 @@
raise AssertionError("bad result box type")
# ------------------------------
- def _record_stm_transaction_break(self):
+ def _record_stm_transaction_break(self, really_wanted):
# records an unconditional stm_transaction_break
mi = self.metainterp
mi.vable_and_vrefs_before_residual_call()
mi._record_helper_nonpure_varargs(
- rop.STM_TRANSACTION_BREAK, None, None, [])
+ rop.STM_TRANSACTION_BREAK, None, None,
+ [history.ConstInt(really_wanted)])
mi.vrefs_after_residual_call()
mi.vable_after_residual_call()
mi.generate_guard(rop.GUARD_NOT_FORCED, None)
@@ -213,12 +214,12 @@
#
return resbox
else:
- self._record_stm_transaction_break()
+ self._record_stm_transaction_break(False)
return ConstInt(0)
@arguments()
def opimpl_stm_transaction_break(self):
- self._record_stm_transaction_break()
+ self._record_stm_transaction_break(True)
for _opimpl in ['int_add', 'int_sub', 'int_mul', 'int_floordiv', 'int_mod',
'int_lt', 'int_le', 'int_eq',
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
@@ -510,7 +510,7 @@
'QUASIIMMUT_FIELD/1d', # [objptr], descr=SlowMutateDescr
'RECORD_KNOWN_CLASS/2', # [objptr, clsptr]
'KEEPALIVE/1',
- 'STM_TRANSACTION_BREAK/0',
+ 'STM_TRANSACTION_BREAK/1',
'STM_SET_REVISION_GC/1d', # not really GC, writes raw to the header
'_CANRAISE_FIRST', # ----- start of can_raise operations -----
More information about the pypy-commit
mailing list