예제 #1
0
 def setup_once_vector(self):
     if IS_BIG_ENDIAN:
         # 2x 64 bit signed integer(1) BE
         data = (b'\x00' * 7 + b'\x01') * 2
     else:
         # 2x 64 bit signed integer(1) LE
         data = (b'\x01' + b'\x00' * 7) * 2
     datablockwrapper = MachineDataBlockWrapper(self.cpu.asmmemmgr, [])
     mem = datablockwrapper.malloc_aligned(len(data), alignment=16)
     datablockwrapper.done()
     addr = rffi.cast(rffi.CArrayPtr(lltype.Char), mem)
     for i in range(len(data)):
         addr[i] = data[i]
     self.VEC_DOUBLE_WORD_ONES = mem
예제 #2
0
 def setup_once_vector(self):
     if IS_BIG_ENDIAN:
         # 2x 64 bit signed integer(1) BE
         data = (b'\x00' * 7 + b'\x01') * 2
     else:
         # 2x 64 bit signed integer(1) LE
         data = (b'\x01' + b'\x00' * 7) * 2
     datablockwrapper = MachineDataBlockWrapper(self.cpu.asmmemmgr, [])
     mem = datablockwrapper.malloc_aligned(len(data), alignment=16)
     datablockwrapper.done()
     addr = rffi.cast(rffi.CArrayPtr(lltype.Char), mem)
     for i in range(len(data)):
         addr[i] = data[i]
     self.VEC_DOUBLE_WORD_ONES = mem
예제 #3
0
def test_machinedatablock():
    ops = []

    class FakeMemMgr:
        _addr = 1597

        def open_malloc(self, minsize):
            result = (self._addr, self._addr + 100)
            ops.append(('malloc', minsize) + result)
            self._addr += 200
            return result

        def open_free(self, frm, to):
            ops.append(('free', frm, to))
            return to - frm >= 8

    #
    allblocks = []
    md = MachineDataBlockWrapper(FakeMemMgr(), allblocks)
    p = md.malloc_aligned(26, 16)
    assert p == 1600
    assert ops == [('malloc', 26 + 15, 1597, 1697)]
    del ops[:]
    #
    p = md.malloc_aligned(26, 16)
    assert p == 1632
    p = md.malloc_aligned(26, 16)
    assert p == 1664
    assert allblocks == []
    assert ops == []
    #
    p = md.malloc_aligned(27, 16)
    assert p == 1808
    assert allblocks == [(1597, 1697)]
    assert ops == [('free', 1690, 1697), ('malloc', 27 + 15, 1797, 1897)]
    del ops[:]
    #
    md.done()
    assert allblocks == [(1597, 1697), (1797, 1835)]
    assert ops == [('free', 1835, 1897)]
예제 #4
0
def test_machinedatablock():
    ops = []
    class FakeMemMgr:
        _addr = 1597
        def open_malloc(self, minsize):
            result = (self._addr, self._addr + 100)
            ops.append(('malloc', minsize) + result)
            self._addr += 200
            return result
        def open_free(self, frm, to):
            ops.append(('free', frm, to))
            return to - frm >= 8
    #
    allblocks = []
    md = MachineDataBlockWrapper(FakeMemMgr(), allblocks)
    p = md.malloc_aligned(26, 16)
    assert p == 1600
    assert ops == [('malloc', 26 + 15, 1597, 1697)]
    del ops[:]
    #
    p = md.malloc_aligned(26, 16)
    assert p == 1632
    p = md.malloc_aligned(26, 16)
    assert p == 1664
    assert allblocks == []
    assert ops == []
    #
    p = md.malloc_aligned(27, 16)
    assert p == 1808
    assert allblocks == [(1597, 1697)]
    assert ops == [('free', 1690, 1697),
                   ('malloc', 27 + 15, 1797, 1897)]
    del ops[:]
    #
    md.done()
    assert allblocks == [(1597, 1697), (1797, 1835)]
    assert ops == [('free', 1835, 1897)]