[pypy-svn] r70888 - in pypy/branch/stringbuilder2/pypy: rpython rpython/lltypesystem rpython/lltypesystem/test translator/c/src

arigo at codespeak.net arigo at codespeak.net
Tue Jan 26 15:56:38 CET 2010


Author: arigo
Date: Tue Jan 26 15:56:37 2010
New Revision: 70888

Modified:
   pypy/branch/stringbuilder2/pypy/rpython/llinterp.py
   pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/llmemory.py
   pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/lloperation.py
   pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/test/test_llmemory.py
   pypy/branch/stringbuilder2/pypy/translator/c/src/mem.h
Log:
Kill 'raw_realloc_{shrink,grow}', which are old
apparently-unused lloperations.


Modified: pypy/branch/stringbuilder2/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/stringbuilder2/pypy/rpython/llinterp.py	(original)
+++ pypy/branch/stringbuilder2/pypy/rpython/llinterp.py	Tue Jan 26 15:56:37 2010
@@ -964,14 +964,6 @@
         assert lltype.typeOf(size) == lltype.Signed
         return llmemory.raw_malloc(size)
 
-    def op_raw_realloc_grow(self, addr, old_size, size):
-        assert lltype.typeOf(size) == lltype.Signed
-        return llmemory.raw_realloc_grow(addr, old_size, size)
-
-    def op_raw_realloc_shrink(self, addr, old_size, size):
-        assert lltype.typeOf(size) == lltype.Signed
-        return llmemory.raw_realloc_shrink(addr, old_size, size)
-
     op_boehm_malloc = op_boehm_malloc_atomic = op_raw_malloc
 
     def op_boehm_register_finalizer(self, p, finalizer):

Modified: pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/llmemory.py	(original)
+++ pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/llmemory.py	Tue Jan 26 15:56:37 2010
@@ -716,18 +716,6 @@
         raise NotImplementedError(size)
     return size._raw_malloc([], zero=False)
 
-def raw_realloc_grow(addr, old_size, size):
-    new_area = size._raw_malloc([], zero=False)
-    raw_memcopy(addr, new_area, old_size)
-    raw_free(addr)
-    return new_area
-
-def raw_realloc_shrink(addr, old_size, size):
-    new_area = size._raw_malloc([], zero=False)
-    raw_memcopy(addr, new_area, size)
-    raw_free(addr)
-    return new_area
-
 def raw_free(adr):
     # try to free the whole object if 'adr' is the address of the header
     from pypy.rpython.memory.gcheader import GCHeaderBuilder

Modified: pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/lloperation.py	(original)
+++ pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/lloperation.py	Tue Jan 26 15:56:37 2010
@@ -389,8 +389,6 @@
     'boehm_register_finalizer': LLOp(),
     'boehm_disappearing_link': LLOp(),
     'raw_malloc':           LLOp(),
-    'raw_realloc_grow':     LLOp(),
-    'raw_realloc_shrink':   LLOp(),
     'raw_malloc_usage':     LLOp(sideeffects=False),
     'raw_free':             LLOp(),
     'raw_memclear':         LLOp(),

Modified: pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/test/test_llmemory.py
==============================================================================
--- pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/test/test_llmemory.py	(original)
+++ pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/test/test_llmemory.py	Tue Jan 26 15:56:37 2010
@@ -624,31 +624,3 @@
     # the following line crashes if the array is dead
     ptr1 = cast_adr_to_ptr(adr, lltype.Ptr(lltype.FixedSizeArray(Address, 1)))
     ptr1[0] = NULL
-
-def test_realloc():
-    A = lltype.Array(lltype.Float)
-    adr = raw_malloc(sizeof(A, 10))
-    ptr = cast_adr_to_ptr(adr, lltype.Ptr(A))
-    for i in range(10):
-        ptr[i] = float(i)
-    adr2 = raw_realloc_shrink(adr, sizeof(A, 10), sizeof(A, 5))
-    ptr2 = cast_adr_to_ptr(adr2, lltype.Ptr(A))
-    assert len(ptr2) == 5
-    assert ptr2[3] == 3.0
-    assert ptr2[1] == 1.0
-
-def test_realloc_struct():
-    S = lltype.Struct('x', ('one', lltype.Signed),
-                      ('a', lltype.Array(lltype.Float)))
-    adr = raw_malloc(sizeof(S, 5))
-    ptr = cast_adr_to_ptr(adr, lltype.Ptr(S))
-    for i in range(5):
-        ptr.a[i] = float(i)
-    ptr.one = 3
-    adr2 = raw_realloc_grow(adr, sizeof(S, 5), sizeof(S, 10))
-    ptr2 = cast_adr_to_ptr(adr2, lltype.Ptr(S))
-    assert len(ptr2.a) == 10
-    assert ptr2.a[3] == 3.0
-    assert ptr2.a[0] == 0.0
-    assert ptr2.one == 3
-    

Modified: pypy/branch/stringbuilder2/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/branch/stringbuilder2/pypy/translator/c/src/mem.h	(original)
+++ pypy/branch/stringbuilder2/pypy/translator/c/src/mem.h	Tue Jan 26 15:56:37 2010
@@ -101,10 +101,6 @@
 
 #define OP_RAW_MALLOC_USAGE(size, r) r = size
 
-#define OP_RAW_REALLOC_SHRINK(p, old_size, size, r) r = PyObject_Realloc((void*)p, size)
-
-#define OP_RAW_REALLOC_GROW(p, old_size, size, r) r = PyObject_Realloc((void*)p, size)
-
 #ifdef MS_WINDOWS
 #define alloca  _alloca
 #endif



More information about the Pypy-commit mailing list