[pypy-svn] r58503 - in pypy/branch/gc-experiments/pypy: rpython/lltypesystem translator/c/src translator/c/test

fijal at codespeak.net fijal at codespeak.net
Tue Sep 30 14:11:47 CEST 2008


Author: fijal
Date: Tue Sep 30 14:11:46 2008
New Revision: 58503

Modified:
   pypy/branch/gc-experiments/pypy/rpython/lltypesystem/llmemory.py
   pypy/branch/gc-experiments/pypy/rpython/lltypesystem/lloperation.py
   pypy/branch/gc-experiments/pypy/translator/c/src/mem.h
   pypy/branch/gc-experiments/pypy/translator/c/test/test_lladdresses.py
Log:
Support for raw_memmove


Modified: pypy/branch/gc-experiments/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/branch/gc-experiments/pypy/rpython/lltypesystem/llmemory.py	(original)
+++ pypy/branch/gc-experiments/pypy/rpython/lltypesystem/llmemory.py	Tue Sep 30 14:11:46 2008
@@ -790,3 +790,19 @@
                 setattr(dest._obj, name, llvalue)
     else:
         raise TypeError(T)
+
+from pypy.rpython.extregistry import ExtRegistryEntry
+
+class RawMemmoveEntry(ExtRegistryEntry):
+    _about_ = raw_memmove
+
+    def compute_result_annotation(self, s_from, s_to, s_size):
+        from pypy.annotation.model import SomeAddress, SomeInteger
+        assert isinstance(s_from, SomeAddress)
+        assert isinstance(s_to, SomeAddress)
+        assert isinstance(s_size, SomeInteger)
+    
+    def specialize_call(self, hop):
+        hop.exception_cannot_occur()
+        v_list = hop.inputargs(Address, Address, lltype.Signed)
+        return hop.genop('raw_memmove', v_list)

Modified: pypy/branch/gc-experiments/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/gc-experiments/pypy/rpython/lltypesystem/lloperation.py	(original)
+++ pypy/branch/gc-experiments/pypy/rpython/lltypesystem/lloperation.py	Tue Sep 30 14:11:46 2008
@@ -368,6 +368,7 @@
     'raw_free':             LLOp(),
     'raw_memclear':         LLOp(),
     'raw_memcopy':          LLOp(),
+    'raw_memmove':          LLOp(),
     'raw_load':             LLOp(sideeffects=False),
     'raw_store':            LLOp(),
     'stack_malloc':         LLOp(), # mmh

Modified: pypy/branch/gc-experiments/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/branch/gc-experiments/pypy/translator/c/src/mem.h	(original)
+++ pypy/branch/gc-experiments/pypy/translator/c/src/mem.h	Tue Sep 30 14:11:46 2008
@@ -90,6 +90,7 @@
     if (r != NULL) memset((void*) r, 0, size);
     
 #define OP_RAW_MEMCOPY(x,y,size,r) memcpy(y,x,size);
+#define OP_RAW_MEMMOVE(x,y,size,r) memmove(y,x,size);
 
 /************************************************************/
 

Modified: pypy/branch/gc-experiments/pypy/translator/c/test/test_lladdresses.py
==============================================================================
--- pypy/branch/gc-experiments/pypy/translator/c/test/test_lladdresses.py	(original)
+++ pypy/branch/gc-experiments/pypy/translator/c/test/test_lladdresses.py	Tue Sep 30 14:11:46 2008
@@ -96,6 +96,19 @@
     res = fc()
     assert res
 
+def test_raw_memmove():
+    def f():
+        addr = raw_malloc(100)
+        addr.signed[0] = 12
+        (addr + 10).signed[0] = 42
+        raw_memmove(addr, addr + 4, 96)
+        result = (addr + 4).signed[0] + (addr + 14).signed[0]
+        raw_free(addr)
+        return result
+    fc = compile(f, [])
+    res = fc()
+    assert res
+
 def test_pointer_comparison():
     def f():
         result = 0



More information about the Pypy-commit mailing list