[pypy-svn] r16127 - in pypy/dist/pypy/translator/llvm2: . module

ericvrp at codespeak.net ericvrp at codespeak.net
Thu Aug 18 10:52:54 CEST 2005


Author: ericvrp
Date: Thu Aug 18 10:52:53 2005
New Revision: 16127

Modified:
   pypy/dist/pypy/translator/llvm2/module/extfunction.py
   pypy/dist/pypy/translator/llvm2/varsize.py
Log:
Fixed: string null terminator was written one byte to far.
Modified: no longer clear all malloced data, let's see if that works.



Modified: pypy/dist/pypy/translator/llvm2/module/extfunction.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/extfunction.py	(original)
+++ pypy/dist/pypy/translator/llvm2/module/extfunction.py	Thu Aug 18 10:52:53 2005
@@ -11,17 +11,20 @@
 
 gc_boehm = """declare ccc sbyte* %GC_malloc(uint)
 declare ccc sbyte* %GC_malloc_atomic(uint)
-declare ccc sbyte* %memset(sbyte*, int, uint)
+
+;XXX now trying to set only null terminator of varsize array for chars!
+;    might need to clear the hash value of rpystrings too.
+;declare ccc sbyte* %memset(sbyte*, int, uint)
 
 internal fastcc sbyte* %gc_malloc(uint %n) {
     %ptr = call ccc sbyte* %GC_malloc(uint %n)
-    call ccc sbyte* %memset(sbyte* %ptr, int 0, uint %n)
+    ;call ccc sbyte* %memset(sbyte* %ptr, int 0, uint %n)
     ret sbyte* %ptr
 }
 
 internal fastcc sbyte* %gc_malloc_atomic(uint %n) {
     %ptr = call ccc sbyte* %GC_malloc_atomic(uint %n)
-    call ccc sbyte* %memset(sbyte* %ptr, int 0, uint %n)
+    ;call ccc sbyte* %memset(sbyte* %ptr, int 0, uint %n)
     ret sbyte* %ptr
 }
 """

Modified: pypy/dist/pypy/translator/llvm2/varsize.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/varsize.py	(original)
+++ pypy/dist/pypy/translator/llvm2/varsize.py	Thu Aug 18 10:52:53 2005
@@ -41,19 +41,20 @@
     codewriter.malloc("%ptr", "sbyte", "%usize", atomic=atomicmalloc)
     codewriter.cast("%result", "sbyte*", "%ptr", ref + "*")
  
-    indices_to_array = tuple(indices_to_array) + (("uint", 0),)
+    indices_to_arraylength = tuple(indices_to_array) + (("uint", 0),)
     # the following accesses the length field of the array 
     codewriter.getelementptr("%arraylength", ref + "*", 
                              "%result", 
-                             *indices_to_array)
+                             *indices_to_arraylength)
     codewriter.store(lentype, "%len", "%arraylength")
 
     if ARRAY is STR.chars:
         # NUL the last element
+        lastelemindices = list(indices_to_array) + [("uint", 1), (lentype, "%len")]
         codewriter.getelementptr("%terminator",
                                  ref + "*",
                                  "%result", 
-                                 *elemindices)
+                                 *lastelemindices)
         codewriter.store(elemtype, 0, "%terminator")
     
     codewriter.ret(ref + "*", "%result")



More information about the Pypy-commit mailing list