[pypy-commit] pypy recursion_and_inlining: Use framestack instead of portal_trace_positions.

ltratt noreply at buildbot.pypy.org
Tue Dec 9 17:29:45 CET 2014


Author: Laurence Tratt <laurie at tratt.net>
Branch: recursion_and_inlining
Changeset: r74863:fe3efdc5abfa
Date: 2014-12-08 15:22 +0000
http://bitbucket.org/pypy/pypy/changeset/fe3efdc5abfa/

Log:	Use framestack instead of portal_trace_positions.

	The latter does not, despite first appearences, model the frame
	stack: it models all call positions the portal has gone through in
	its history. If I'd looked more carefully, I might have noticed that
	the portal has a semi-hidden framestack attribute, which has a semi-
	hidden greenkey attribute. This records exactly what we want, and
	also solves the problem that we're no longer tied to being the main
	jitcode.

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
@@ -958,27 +958,29 @@
                 # loop.
                 portal_code = targetjitdriver_sd.mainjitcode
                 inline = True
-                if self.metainterp.is_main_jitcode(portal_code):
-                    count = 0
-                    for gk, _ in self.metainterp.portal_trace_positions:
-                        if gk is None:
-                            continue
-                        assert len(gk) == len(greenboxes)
-                        i = 0
-                        for i in range(len(gk)):
-                            if not gk[i].same_constant(greenboxes[i]):
-                                break
-                        else:
-                            count += 1
-                    memmgr = self.metainterp.staticdata.warmrunnerdesc.memory_manager
-                    if count >= memmgr.max_unroll_recursion:
-                        # This function is recursive and has exceeded the
-                        # maximum number of unrollings we allow. We want to stop
-                        # inlining it further and to make sure that, if it
-                        # hasn't happened already, the function is traced
-                        # separately as soon as possible.
-                        warmrunnerstate.dont_trace_here(greenboxes)
-                        inline = False
+                count = 0
+                for f in self.metainterp.framestack:
+                    if f.jitcode is not portal_code:
+                        continue
+                    gk = f.greenkey
+                    if gk is None:
+                        continue
+                    assert len(gk) == len(greenboxes)
+                    i = 0
+                    for i in range(len(gk)):
+                        if not gk[i].same_constant(greenboxes[i]):
+                            break
+                    else:
+                        count += 1
+                memmgr = self.metainterp.staticdata.warmrunnerdesc.memory_manager
+                if count >= memmgr.max_unroll_recursion:
+                    # This function is recursive and has exceeded the
+                    # maximum number of unrollings we allow. We want to stop
+                    # inlining it further and to make sure that, if it
+                    # hasn't happened already, the function is traced
+                    # separately as soon as possible.
+                    warmrunnerstate.dont_trace_here(greenboxes)
+                    inline = False
                 if inline:
                     return self.metainterp.perform_call(portal_code, allboxes,
                                 greenkey=greenboxes)


More information about the pypy-commit mailing list