Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r71260:1d6e499b69ca
Date: 2014-05-04 18:19 +0200
http://bitbucket.org/pypy/pypy/changeset/1d6e499b69ca/

Log:    Do push_marker/pop_marker inside the jit_driver loop inside of
        outside. Previously, during blackhole-interpretation, we would see
        update_marker_num() calls with no corresponding pushed marker, which
        leads to crashes.

diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -210,15 +210,12 @@
                 if next_instr != 0:
                     self.pushvalue(w_inputvalue)
             #
-            rstm.push_marker(intmask(next_instr) * 2 + 1, self.pycode)
             try:
                 w_exitvalue = self.dispatch(self.pycode, next_instr,
                                             executioncontext)
             except Exception:
-                rstm.pop_marker()
                 executioncontext.return_trace(self, self.space.w_None)
                 raise
-            rstm.pop_marker()
             executioncontext.return_trace(self, w_exitvalue)
             # it used to say self.last_exception = None
             # this is now done by the code in pypyjit module
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -65,18 +65,20 @@
         # For the sequel, force 'next_instr' to be unsigned for performance
         next_instr = r_uint(next_instr)
         co_code = pycode.co_code
-        try:
-            while True:
-                if self.space.config.translation.stm:
-                    # only used for no-jit. The jit-jitdriver is
-                    # in interp_jit.py
-                    stmonly_jitdriver.jit_merge_point(
-                        self=self, co_code=co_code,
-                        next_instr=next_instr, ec=ec)
+        while True:
+            if self.space.config.translation.stm:
+                # only used for no-jit. The jit-jitdriver is
+                # in interp_jit.py
+                stmonly_jitdriver.jit_merge_point(
+                    self=self, co_code=co_code,
+                    next_instr=next_instr, ec=ec)
+            rstm.push_marker(intmask(next_instr) * 2 + 1, co_code)
+            try:
                 next_instr = self.handle_bytecode(co_code, next_instr, ec)
-                rstm.update_marker_num(intmask(next_instr) * 2 + 1)
-        except ExitFrame:
-            return self.popvalue()
+            except ExitFrame:
+                return self.popvalue()
+            finally:
+                rstm.pop_marker()
 
     def handle_bytecode(self, co_code, next_instr, ec):
         try:
diff --git a/pypy/module/pypyjit/interp_jit.py 
b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -52,28 +52,29 @@
     def dispatch(self, pycode, next_instr, ec):
         self = hint(self, access_directly=True)
         next_instr = r_uint(next_instr)
-        is_being_profiled = self.is_being_profiled
-        try:
-            while True:
-                pypyjitdriver.jit_merge_point(ec=ec,
-                    frame=self, next_instr=next_instr, pycode=pycode,
-                    is_being_profiled=is_being_profiled)
-                # nothing inbetween!
-                if rstm.jit_stm_should_break_transaction(False):
-                    rstm.jit_stm_transaction_break_point()
-                co_code = pycode.co_code
-                self.valuestackdepth = hint(self.valuestackdepth, promote=True)
+        while True:
+            pypyjitdriver.jit_merge_point(ec=ec,
+                frame=self, next_instr=next_instr, pycode=pycode,
+                is_being_profiled=self.is_being_profiled)
+            # nothing inbetween!
+            if rstm.jit_stm_should_break_transaction(False):
+                rstm.jit_stm_transaction_break_point()
+
+            co_code = pycode.co_code
+            self.valuestackdepth = hint(self.valuestackdepth, promote=True)
+            rstm.push_marker(intmask(next_instr) * 2 + 1, co_code)
+            try:
                 next_instr = self.handle_bytecode(co_code, next_instr, ec)
-                rstm.update_marker_num(intmask(next_instr) * 2 + 1)
-                is_being_profiled = self.is_being_profiled
-        except Yield:
-            self.last_exception = None
-            w_result = self.popvalue()
-            jit.hint(self, force_virtualizable=True)
-            return w_result
-        except ExitFrame:
-            self.last_exception = None
-            return self.popvalue()
+            except Yield:
+                self.last_exception = None
+                w_result = self.popvalue()
+                jit.hint(self, force_virtualizable=True)
+                return w_result
+            except ExitFrame:
+                self.last_exception = None
+                return self.popvalue()
+            finally:
+                rstm.pop_marker()
 
     def jump_absolute(self, jumpto, ec):
         if we_are_jitted():
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to