Commits

Armin Rigo committed 3d62f6e

In-progress, adding support for stm_read_int{8f,4f}: tests

Comments (0)

Files changed (5)

pypy/rpython/memory/gc/stmgc.py

 PRIMITIVE_SIZES   = {1: lltype.Char,
                      2: rffi.SHORT,
                      4: rffi.INT,
-                     8: lltype.SignedLongLong}
+                     8: lltype.SignedLongLong,
+                     '8f': rffi.DOUBLE,
+                     '4f': rffi.FLOAT}
 
 CALLBACK = lltype.Ptr(lltype.FuncType([llmemory.Address] * 3, lltype.Void))
 GETSIZE  = lltype.Ptr(lltype.FuncType([llmemory.Address], lltype.Signed))

pypy/rpython/memory/gc/test/test_stmgc.py

             callback(tls, key, value)
 
     def _get_stm_reader(size, TYPE):
-        assert rffi.sizeof(TYPE) == size
+        realsize = rffi.sizeof(TYPE)
+        assert size in (realsize, '%df' % realsize)
         PTYPE = rffi.CArrayPtr(TYPE)
         def stm_reader(self, obj, offset):
             hdr = self._gc.header(obj)
                     assert self._gc.header(localobj).tid & GCFLAG_GLOBAL == 0
                     adr = rffi.cast(PTYPE, localobj + offset)
                     return adr[0]
-            return 'stm_ll_read_int%d(%r, %r)' % (size, obj, offset)
+            return 'stm_ll_read_int%s(%r, %r)' % (size, obj, offset)
         return stm_reader
 
     for _size, _TYPE in PRIMITIVE_SIZES.items():
         _func = _get_stm_reader(_size, _TYPE)
-        locals()['stm_read_int%d' % _size] = _func
+        locals()['stm_read_int%s' % _size] = _func
 
     def stm_copy_transactional_to_raw(self, srcobj, dstobj, size):
         llmemory.raw_memcopy(srcobj, dstobj, size)

pypy/translator/stm/src_stm/et.c

   assert(thread_descriptor != NULL);
   if (activate)
     {
-      assert(active_thread_descriptor == NULL);
       active_thread_descriptor = thread_descriptor;
     }
   else
     {
-      assert(active_thread_descriptor != NULL);
       active_thread_descriptor = NULL;
     }
 }

pypy/translator/stm/stmgcintf.py

     tldict_enum = smexternal('stm_tldict_enum', [CALLBACK], lltype.Void)
 
     for _size, _TYPE in PRIMITIVE_SIZES.items():
-        _name = 'stm_read_int%d' % _size
+        _name = 'stm_read_int%s' % _size
         locals()[_name] = smexternal(_name, [llmemory.Address, lltype.Signed],
                                      _TYPE)
 

pypy/translator/stm/test/test_stmgcintf.py

         assert res == 84084
     test_stm_read_word_transactional_thread.in_transaction = True
 
-    def test_stm_read_int1(self):
+    def stm_read_intX(self, TYPE, sizesuffix):
+        print TYPE, sizesuffix
         S2 = lltype.Struct('S2', ('hdr', stmgc.StmGC.HDR),
-                                 ('c1', lltype.Char),
-                                 ('c2', lltype.Char),
-                                 ('c3', lltype.Char))
+                                 ('c1', TYPE),
+                                 ('c2', TYPE),
+                                 ('c3', TYPE))
         s2 = lltype.malloc(S2, flavor='raw')
         s2.hdr.tid = stmgc.GCFLAG_GLOBAL | stmgc.GCFLAG_WAS_COPIED
         s2.hdr.version = llmemory.NULL
-        s2.c1 = 'A'
-        s2.c2 = 'B'
-        s2.c3 = 'C'
-        reader = stm_operations.stm_read_int1
-        r1 = reader(llmemory.cast_ptr_to_adr(s2), SIZEOFHDR + 0)  # c1
-        r2 = reader(llmemory.cast_ptr_to_adr(s2), SIZEOFHDR + 1)  # c2
-        r3 = reader(llmemory.cast_ptr_to_adr(s2), SIZEOFHDR + 2)  # c3
+        s2.c1 = A = rffi.cast(TYPE, 65)
+        s2.c2 = B = rffi.cast(TYPE, 66)
+        s2.c3 = C = rffi.cast(TYPE, 67)
+        size = rffi.sizeof(TYPE)
+        assert sizesuffix in (size, '%df' % size)
+        reader = getattr(stm_operations, 'stm_read_int%s' % sizesuffix)
+        r1 = reader(llmemory.cast_ptr_to_adr(s2), SIZEOFHDR + 0 * size)  # c1
+        r2 = reader(llmemory.cast_ptr_to_adr(s2), SIZEOFHDR + 1 * size)  # c2
+        r3 = reader(llmemory.cast_ptr_to_adr(s2), SIZEOFHDR + 2 * size)  # c3
         lltype.free(s2, flavor='raw')
-        assert r1 == 'A' and r2 == 'B' and r3 == 'C'
+        assert r1 == A and r2 == B and r3 == C
+
+    def test_stm_read_int(self):
+        for size, TYPE in stmgc.PRIMITIVE_SIZES.items():
+            yield self.stm_read_intX, TYPE, size
 
     def test_stm_size_getter(self):
         def getsize(addr):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.