[pypy-svn] r68627 - pypy/trunk/pypy/jit/backend/x86

fijal at codespeak.net fijal at codespeak.net
Mon Oct 19 14:53:14 CEST 2009


Author: fijal
Date: Mon Oct 19 14:53:14 2009
New Revision: 68627

Modified:
   pypy/trunk/pypy/jit/backend/x86/assembler.py
   pypy/trunk/pypy/jit/backend/x86/support.py
Log:
Correct fix. This is a bit hairy, leave at least a comment. I suppose
one more test would not hurt a lot


Modified: pypy/trunk/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/assembler.py	Mon Oct 19 14:53:14 2009
@@ -81,10 +81,15 @@
         self.fail_boxes_float = NonmovableGrowableArrayFloat()
 
     def leave_jitted_hook(self):
-        fail_boxes_ptr = self.fail_boxes_ptr
-        for chunk in fail_boxes_ptr.chunks:
+        # XXX BIG FAT WARNING XXX
+        # At this point, we should not call anyone here, because
+        # RPython-level exception might be set. Here be dragons
+        i = 0
+        while i < self.fail_boxes_ptr.lgt:
+            chunk = self.fail_boxes_ptr.chunks[i]
             llop.gc_assume_young_pointers(lltype.Void,
                                       llmemory.cast_ptr_to_adr(chunk))
+            i += 1
 
     def make_sure_mc_exists(self):
         if self.mc is None:

Modified: pypy/trunk/pypy/jit/backend/x86/support.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/support.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/support.py	Mon Oct 19 14:53:14 2009
@@ -1,5 +1,7 @@
 
 from pypy.rpython.lltypesystem import lltype, rffi, llmemory
+from pypy.rlib import rgc
+from pypy.rlib.objectmodel import we_are_translated
 
 CHUNK_SIZE = 1000
 
@@ -9,11 +11,17 @@
     class NonmovableGrowableArray(object):
         def __init__(self):
             self.chunks = []
-            self._grow()
+            self.lgt = 0
 
         def _grow(self):
-            self.chunks.append(lltype.malloc(ATP, CHUNK_SIZE,
-                                             zero=True))
+            # XXX workaround for a fact that rgc.malloc_nonmovable always
+            #     returns nullptr when run on top of python
+            if we_are_translated():
+                new_item = rgc.malloc_nonmovable(ATP, CHUNK_SIZE, zero=True)
+            else:
+                new_item = lltype.malloc(ATP, CHUNK_SIZE, zero=True)
+            self.chunks.append(new_item)
+            self.lgt += 1
 
         def get_addr_for_num(self, i):
             chunk_no, ofs = self._no_of(i)



More information about the Pypy-commit mailing list