[pypy-commit] pypy guard-value-limit: (arigo, remi) a branch to experiment with limiting the length of the chain of guard_values

Raemi pypy.commits at gmail.com
Sat Mar 24 11:53:51 EDT 2018


Author: Remi Meier <remi.meier at gmail.com>
Branch: guard-value-limit
Changeset: r94129:c72f96e9c08b
Date: 2018-03-24 15:22 +0100
http://bitbucket.org/pypy/pypy/changeset/c72f96e9c08b/

Log:	(arigo,remi) a branch to experiment with limiting the length of the
	chain of guard_values

	quick hack to tell pyjitpl.opimpl_guard_value that it is the x-th in
	a chain of guard_values. Then simply do not promote the result and
	do not emit a guard_value.

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
@@ -862,12 +862,14 @@
 
 class ResumeGuardDescr(AbstractResumeGuardDescr):
     _attrs_ = ('rd_numb', 'rd_consts', 'rd_virtuals',
-               'rd_pendingfields', 'status')
+               'rd_pendingfields', 'status', 'guard_value_counter')
     rd_numb = lltype.nullptr(NUMBERING)
     rd_consts = None
     rd_virtuals = None
     rd_pendingfields = lltype.nullptr(PENDINGFIELDSP.TO)
 
+    guard_value_counter = 0
+
     def copy_all_attributes_from(self, other):
         other = other.get_resumestorage()
         assert isinstance(other, ResumeGuardDescr)
@@ -881,6 +883,17 @@
         else:
             other.rd_vector_info = None
 
+    def compile_and_attach(self, metainterp, new_loop, orig_inputargs):
+        for op in new_loop.operations:
+            if op.is_guard():
+                if op.getopnum() == rop.GUARD_VALUE:
+                    descr = op.getdescr()
+                    if isinstance(descr, ResumeGuardDescr):
+                        descr.guard_value_counter = self.guard_value_counter + 1
+                break
+
+        AbstractResumeGuardDescr.compile_and_attach(self, metainterp, new_loop, orig_inputargs)
+
     def store_final_boxes(self, guard_op, boxes, metainterp_sd):
         guard_op.setfailargs(boxes)
         self.store_hash(metainterp_sd)
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
@@ -1215,7 +1215,9 @@
 
     @arguments("box", "orgpc")
     def _opimpl_guard_value(self, box, orgpc):
-        self.implement_guard_value(box, orgpc)
+        if self.metainterp.guard_value_counter <= 4:
+            return self.implement_guard_value(box, orgpc)
+        return box
 
     @arguments("box", "box", "descr", "orgpc")
     def opimpl_str_guard_value(self, box, funcbox, descr, orgpc):
@@ -1551,6 +1553,7 @@
                 pc = self.pc
                 op = ord(self.bytecode[pc])
                 staticdata.opcode_implementations[op](self, pc)
+                self.metainterp.guard_value_counter = 0
         except ChangeFrame:
             pass
 
@@ -2428,6 +2431,7 @@
         # is also available as 'self.jitdriver_sd', because we need to
         # specialize this function and a few other ones for the '*args'.
         debug_start('jit-tracing')
+        self.guard_value_counter = 0
         self.staticdata._setup_once()
         self.staticdata.profiler.start_tracing()
         assert jitdriver_sd is self.jitdriver_sd
@@ -2460,6 +2464,7 @@
         self.staticdata.profiler.start_tracing()
         key = resumedescr.get_resumestorage()
         assert isinstance(key, compile.ResumeGuardDescr)
+        self.guard_value_counter = key.guard_value_counter + 1
         # store the resumekey.wref_original_loop_token() on 'self' to make
         # sure that it stays alive as long as this MetaInterp
         self.resumekey_original_loop_token = resumedescr.rd_loop_token.loop_token_wref()


More information about the pypy-commit mailing list