[pypy-svn] r68505 - pypy/trunk/pypy/doc/jit

benjamin at codespeak.net benjamin at codespeak.net
Thu Oct 15 18:07:02 CEST 2009


Author: benjamin
Date: Thu Oct 15 18:07:01 2009
New Revision: 68505

Modified:
   pypy/trunk/pypy/doc/jit/pyjitpl5.txt
Log:
more about tracing and guards

Modified: pypy/trunk/pypy/doc/jit/pyjitpl5.txt
==============================================================================
--- pypy/trunk/pypy/doc/jit/pyjitpl5.txt	(original)
+++ pypy/trunk/pypy/doc/jit/pyjitpl5.txt	Thu Oct 15 18:07:01 2009
@@ -103,10 +103,27 @@
 trace.  All possible operations generated by tracing are listed in
 metainterp/resoperation.py.  When a (interpreter-level) call to a function the
 JIT has bytecode for occurs in the bytecode, another frame is added to the stack
-and the tracing continues with the same list.  This flattens the list of
-operations.  Interpretation continues until the can_enter_jit hint is seen.  At
-this point, a whole interation of the application level loop has been seen and
-recorded.
+and the tracing continues with the same history.  This flattens the list of
+operations over calls.  Most importantly, it unrolls the opcode dispatch loop.
+Interpretation continues until the can_enter_jit hint is seen.  At this point, a
+whole interation of the application level loop has been seen and recorded.
+
+Because only one iteration has been recorded the JIT only knows about one
+codepath in the loop.  For example, if there's a if statement construct like
+this::
+
+   if x:
+       do_something_exciting()
+   else:
+       do_something_else()
+
+and ``x`` is true when the JIT does tracing, only the codepath
+``do_something_exciting`` will be added to the trace.  In future runs, to ensure
+that it is picking the right path, a special operation called a *guard
+operation* is added to the list.  A guard is a small test that checks if
+assumptions the JIT makes during tracing are still true.  In the example above,
+a GUARD_TRUE guard will be generated for ``x`` before running
+``do_something_exciting``.
 
 
 More resources



More information about the Pypy-commit mailing list