[pypy-commit] pypy disable-unroll-for-short-loops: try to attack the problem differently, a bit unclear how to test the beast
fijal
noreply at buildbot.pypy.org
Fri Jun 5 21:20:43 CEST 2015
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: disable-unroll-for-short-loops
Changeset: r77925:655b7c16bafd
Date: 2015-06-05 21:20 +0200
http://bitbucket.org/pypy/pypy/changeset/655b7c16bafd/
Log: try to attack the problem differently, a bit unclear how to test the
beast
diff --git a/rpython/jit/metainterp/compile.py b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -104,34 +104,6 @@
# ____________________________________________________________
-def disable_unrolling_if_loop_too_long(loop, metainterp):
- threshold = metainterp.jitdriver_sd.warmstate.disable_unrolling_threshold
- if len(loop.operations) < threshold:
- return False
- # now we need to patch label, like in simplify.py
- last_op = loop.operations[-1]
- descr = last_op.getdescr()
- assert isinstance(descr, TargetToken)
- descr = descr.targeting_jitcell_token
- assert isinstance (descr, JitCellToken)
- last_op = last_op.copy_and_change(rop.JUMP)
- if not descr.target_tokens:
- # fish the first label
- for op in loop.operations:
- if op.getopnum() == rop.LABEL:
- target_token = op.getdescr()
- break
- else:
- assert False, "can't find a label"
- assert isinstance(target_token, TargetToken)
- assert target_token.targeting_jitcell_token is descr
- last_op.setdescr(target_token)
- else:
- assert len(descr.target_tokens) == 1
- last_op.setdescr(descr.target_tokens[0])
- loop.operations[-1] = last_op
- return True
-
def compile_loop(metainterp, greenkey, start,
inputargs, jumpargs,
full_preamble_needed=True,
@@ -177,7 +149,7 @@
if part.quasi_immutable_deps:
loop.quasi_immutable_deps.update(part.quasi_immutable_deps)
if part.operations[-1].getopnum() == rop.LABEL:
- if not disable_unrolling_if_loop_too_long(part, metainterp):
+ if start_state is not None:
inliner = Inliner(inputargs, jumpargs)
part.quasi_immutable_deps = None
part.operations = [part.operations[-1]] + \
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
@@ -154,6 +154,19 @@
loop.operations = self.optimizer.get_newoperations()
if export_state:
+ jd_sd = self.optimizer.jitdriver_sd
+ threshold = jd_sd.warmstate.disable_unrolling_threshold
+ if 1 or len(loop.operations) > threshold:
+ if loop.operations[0].getopnum() == rop.LABEL:
+ # abandoning unrolling, too long
+ new_descr = stop_label.getdescr()
+ if loop.operations[0].getopnum() == rop.LABEL:
+ new_descr = loop.operations[0].getdescr()
+ stop_label = stop_label.copy_and_change(rop.JUMP,
+ descr=new_descr)
+ self.optimizer.send_extra_operation(stop_label)
+ loop.operations = self.optimizer.get_newoperations()
+ return None
final_state = self.export_state(stop_label)
else:
final_state = None
More information about the pypy-commit
mailing list