Author: Armin Rigo <[email protected]>
Branch: fast-gil
Changeset: r72195:499ad6f94da1
Date: 2014-06-24 16:18 +0200
http://bitbucket.org/pypy/pypy/changeset/499ad6f94da1/

Log:    Fixes: must look in rpy_fastgil for the extra missing stack too

diff --git a/rpython/memory/gctransform/asmgcroot.py 
b/rpython/memory/gctransform/asmgcroot.py
--- a/rpython/memory/gctransform/asmgcroot.py
+++ b/rpython/memory/gctransform/asmgcroot.py
@@ -2,6 +2,7 @@
      copygraph, SpaceOperation, checkgraph)
 from rpython.rlib.debug import ll_assert
 from rpython.rlib.nonconst import NonConstant
+from rpython.rlib import rgil
 from rpython.rtyper.annlowlevel import llhelper
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rtyper.lltypesystem.lloperation import llop
@@ -356,16 +357,19 @@
         initialframedata = anchor.address[1]
         stackscount = 0
         while initialframedata != anchor:     # while we have not looped back
-            self.fill_initial_frame(curframe, initialframedata)
-            # Loop over all the frames in the stack
-            while self.walk_to_parent_frame(curframe, otherframe):
-                swap = curframe
-                curframe = otherframe    # caller becomes callee
-                otherframe = swap
+            self.walk_frames(curframe, otherframe, initialframedata)
             # Then proceed to the next piece of stack
             initialframedata = initialframedata.address[1]
             stackscount += 1
         #
+        # for the JIT: rpy_fastgil may contain an extra framedata
+        rpy_fastgil = rgil.gil_fetch_fastgil().signed[0]
+        if rpy_fastgil != 1:
+            ll_assert(rpy_fastgil != 0, "walk_stack_from doesn't have the GIL")
+            initialframedata = rffi.cast(llmemory.Address, rpy_fastgil)
+            self.walk_frames(curframe, otherframe, initialframedata)
+            stackscount += 1
+        #
         expected = rffi.stackcounter.stacks_counter
         if NonConstant(0):
             rffi.stackcounter.stacks_counter += 42    # hack to force it
@@ -374,6 +378,14 @@
         lltype.free(otherframe, flavor='raw')
         lltype.free(curframe, flavor='raw')
 
+    def walk_frames(self, curframe, otherframe, initialframedata):
+        self.fill_initial_frame(curframe, initialframedata)
+        # Loop over all the frames in the stack
+        while self.walk_to_parent_frame(curframe, otherframe):
+            swap = curframe
+            curframe = otherframe    # caller becomes callee
+            otherframe = swap
+
     def fill_initial_frame(self, curframe, initialframedata):
         # Read the information provided by initialframedata
         initialframedata += 2*sizeofaddr #skip the prev/next words at the start
diff --git a/rpython/translator/c/src/mem.c b/rpython/translator/c/src/mem.c
--- a/rpython/translator/c/src/mem.c
+++ b/rpython/translator/c/src/mem.c
@@ -115,6 +115,11 @@
         got += 1;
         fd = ((void* *) (((char *)fd) + sizeof(void*)))[0];
     }
+    if (rpy_fastgil != 1) {
+        RPyAssert(rpy_fastgil != 0,
+                          "pypy_check_stack_count doesn't have the GIL");
+        got++;  /* <= the extra one currently stored in rpy_fastgil */
+    }
     RPyAssert(got == stacks_counter - 1,
               "bad stacks_counter or non-closed stacks around");
 # endif
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to