Commits

Armin Rigo  committed 83ec8d8

fix

  • Participants
  • Parent commits 7b32ea5
  • Branches op_malloc_gc

Comments (0)

Files changed (2)

File pypy/jit/backend/llsupport/rewrite.py

+import sys
 from pypy.rlib.rarithmetic import ovfcheck
 from pypy.jit.metainterp.history import ConstInt, BoxPtr, ConstPtr
 from pypy.jit.metainterp.resoperation import ResOperation, rop
         """Try to generate or update a CALL_MALLOC_NURSERY.
         If that fails, generate a plain CALL_MALLOC_GC instead.
         """
+        if size <= (sys.maxint & ~(WORD-1)):
+            size = self.round_up_for_allocation(size)
+        else:
+            size = sys.maxint  #corner case: generate a malloc that always fail
+        #
         if not self.gc_ll_descr.can_use_nursery_malloc(size):
             self.gen_malloc_fixedsize(size, v_result)
             return
         #
-        size = self.round_up_for_allocation(size)
         op = None
-        #
         if self._op_malloc_nursery is not None:
             # already a MALLOC_NURSERY: increment its total size
             total_size = self._op_malloc_nursery.getarg(0).getint()

File pypy/jit/backend/llsupport/test/test_rewrite.py

             jump()
         """, """
             [p1]
-            p0 = call_malloc_gc(ConstClass(malloc_fixedsize), 102, \
+            p0 = call_malloc_gc(ConstClass(malloc_fixedsize), 104, \
                                 descr=malloc_fixedsize_descr)
             setfield_gc(p0, ConstClass(o_vtable), descr=vtable_descr)
             jump()
         self.gc_ll_descr.max_size_of_young_obj = 100
         self.check_rewrite("""
             []
-            p0 = new_array(100, descr=bdescr)
+            p0 = new_array(103, descr=bdescr)
             jump()
         """, """
             []
             p0 = call_malloc_gc(ConstClass(malloc_fixedsize), \
-                                %(bdescr.basesize + 100)d,    \
+                                %(bdescr.basesize + 104)d,    \
                                 descr=malloc_fixedsize_descr)
             setfield_gc(p0, 8765, descr=tiddescr)
-            setfield_gc(p0, 100, descr=blendescr)
+            setfield_gc(p0, 103, descr=blendescr)
             jump()
         """)
 
             jump()
         """, """
             [p1]
-            p0 = call_malloc_gc(ConstClass(malloc_fixedsize), 102, \
+            p0 = call_malloc_gc(ConstClass(malloc_fixedsize), 104, \
                                 descr=malloc_fixedsize_descr)
             setfield_gc(p0, 9315, descr=tiddescr)
             setfield_gc(p0, ConstClass(o_vtable), descr=vtable_descr)