Author: Armin Rigo <[email protected]>
Branch: raw-memory-pressure-nursery
Changeset: r52470:e4a336273b9f
Date: 2012-02-14 19:50 +0100
http://bitbucket.org/pypy/pypy/changeset/e4a336273b9f/

Log:    The proper voodoo dance to have it work untranslated. The test still
        fails but for a good reason now.

diff --git a/pypy/rpython/memory/gc/minimark.py 
b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -740,11 +740,16 @@
 
     def raw_malloc_memory_pressure(self, obj, sizehint):
         size = self.get_size(obj)
+        obj = llarena.getfakearenaaddress(obj)
         if obj + size == self.nursery_free:
-            sizehint = llarena.round_up_for_allocation(sizehint, WORD)
+            sizehint = llarena.round_up_for_allocation(
+                sizehint, llmemory.sizeof(lltype.Signed))
+            sizehint = llmemory.raw_malloc_usage(sizehint)
             if (self.nursery_top - self.nursery_free) < sizehint:
                 self.nursery_free = self.nursery_top
             else:
+                llarena.arena_reserve(self.nursery_free,
+                                      llmemory.sizeof(lltype.Signed))
                 self.nursery_free.signed[0] = sizehint
                 self.header(obj).tid |= GCFLAG_OWNS_RAW_MEMORY
                 self.nursery_free += sizehint
diff --git a/pypy/rpython/memory/gc/test/test_direct.py 
b/pypy/rpython/memory/gc/test/test_direct.py
--- a/pypy/rpython/memory/gc/test/test_direct.py
+++ b/pypy/rpython/memory/gc/test/test_direct.py
@@ -596,11 +596,12 @@
     def test_memory_pressure(self):
         obj = self.malloc(S)
         nursery_size = self.gc.nursery_size
+        BYTE = llmemory.sizeof(lltype.Char)
         self.gc.raw_malloc_memory_pressure(llmemory.cast_ptr_to_adr(obj),
-                                           nursery_size / 2)
+                                           BYTE * (nursery_size / 2))
         obj2 = self.malloc(S)
         self.gc.raw_malloc_memory_pressure(llmemory.cast_ptr_to_adr(obj2),
-                                           nursery_size / 2)
+                                           BYTE * (nursery_size / 2))
         # obj should be dead by now
         assert self.gc.nursery_free == self.gc.nursery        
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to