[pypy-svn] r77400 - in pypy/branch/smaller-writebarrier/pypy: rpython/lltypesystem translator/c/test

arigo at codespeak.net arigo at codespeak.net
Mon Sep 27 11:46:07 CEST 2010


Author: arigo
Date: Mon Sep 27 11:46:06 2010
New Revision: 77400

Modified:
   pypy/branch/smaller-writebarrier/pypy/rpython/lltypesystem/llarena.py
   pypy/branch/smaller-writebarrier/pypy/translator/c/test/test_lltyped.py
Log:
Have the arena malloc and free functions map directly to malloc() and free()
in C; and a minimal test.


Modified: pypy/branch/smaller-writebarrier/pypy/rpython/lltypesystem/llarena.py
==============================================================================
--- pypy/branch/smaller-writebarrier/pypy/rpython/lltypesystem/llarena.py	(original)
+++ pypy/branch/smaller-writebarrier/pypy/rpython/lltypesystem/llarena.py	Mon Sep 27 11:46:06 2010
@@ -472,8 +472,13 @@
     clear_large_memory_chunk = llmemory.raw_memclear
 
 
+llimpl_malloc = rffi.llexternal('malloc', [lltype.Signed], llmemory.Address,
+                                sandboxsafe=True, _nowrapper=True)
+llimpl_free = rffi.llexternal('free', [llmemory.Address], lltype.Void,
+                              sandboxsafe=True, _nowrapper=True)
+
 def llimpl_arena_malloc(nbytes, zero):
-    addr = llmemory.raw_malloc(nbytes)
+    addr = llimpl_malloc(nbytes)
     if zero and bool(addr):
         clear_large_memory_chunk(addr, nbytes)
     return addr
@@ -483,11 +488,8 @@
                   llfakeimpl=arena_malloc,
                   sandboxsafe=True)
 
-def llimpl_arena_free(arena_addr):
-    # NB. minimark.py assumes that arena_free() is actually just a raw_free().
-    llmemory.raw_free(arena_addr)
 register_external(arena_free, [llmemory.Address], None, 'll_arena.arena_free',
-                  llimpl=llimpl_arena_free,
+                  llimpl=llimpl_free,
                   llfakeimpl=arena_free,
                   sandboxsafe=True)
 

Modified: pypy/branch/smaller-writebarrier/pypy/translator/c/test/test_lltyped.py
==============================================================================
--- pypy/branch/smaller-writebarrier/pypy/translator/c/test/test_lltyped.py	(original)
+++ pypy/branch/smaller-writebarrier/pypy/translator/c/test/test_lltyped.py	Mon Sep 27 11:46:06 2010
@@ -783,6 +783,17 @@
         res = fn()
         assert res == 42
 
+    def test_llarena(self):
+        from pypy.rpython.lltypesystem import llmemory, llarena
+        #
+        def f():
+            a = llarena.arena_malloc(800, False)
+            llarena.arena_reset(a, 800, 2)
+            llarena.arena_free(a)
+        #
+        fn = self.getcompiled(f, [])
+        fn()
+
     def test_padding_in_prebuilt_struct(self):
         from pypy.rpython.lltypesystem import rffi
         from pypy.rpython.tool import rffi_platform



More information about the Pypy-commit mailing list