[pypy-svn] r76430 - pypy/branch/x86-64-jit-backend/pypy/jit/backend/x86

jcreigh at codespeak.net jcreigh at codespeak.net
Mon Aug 2 15:59:34 CEST 2010


Author: jcreigh
Date: Mon Aug  2 15:59:32 2010
New Revision: 76430

Modified:
   pypy/branch/x86-64-jit-backend/pypy/jit/backend/x86/assembler.py
Log:
fix obscure GC issue related to pending_guard_tokens being a prebuilt GC object

Modified: pypy/branch/x86-64-jit-backend/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/x86-64-jit-backend/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/x86-64-jit-backend/pypy/jit/backend/x86/assembler.py	Mon Aug  2 15:59:32 2010
@@ -337,14 +337,22 @@
         self.write_pending_failure_recoveries()
 
     def write_pending_failure_recoveries(self):
-        for tok in self.pending_guard_tokens:
+        # NB: We must be careful to only modify pending_guard_tokens, not
+        # re-assign it to a different list. Since it is a prebuilt gc object,
+        # if we were to re-assign it, the original list would never be freed.
+        # This is particularly bad in the case where the failargs of a token
+        # contains a BoxPtr to an object, which would also never be freed.
+        #
+        # This is why we pop() off the end instead of iterating and then
+        # saying "self.pending_guard_tokens = []"
+        while len(self.pending_guard_tokens) > 0:
+            tok = self.pending_guard_tokens.pop()
             # Okay to write to _mc because we've already made sure that
             # there's enough space by "reserving" bytes.
             addr = self.generate_quick_failure(self.mc._mc, tok.faildescr, tok.failargs, tok.fail_locs, tok.exc, tok.desc_bytes)
             tok.faildescr._x86_adr_recovery_stub = addr
             self.patch_jump_for_descr(tok.faildescr, addr)
 
-        self.pending_guard_tokens = []
         self.mc.reset_reserved_bytes()
         self.mc.done()
 



More information about the Pypy-commit mailing list