Beispiel #1
0
 def _more(self):
     chunk = rffi.cast(CLOSURES, alloc(CHUNK))
     count = CHUNK//rffi.sizeof(FFI_CLOSUREP.TO)
     for i in range(count):
         rffi.cast(rffi.VOIDPP, chunk)[0] = self.free_list
         self.free_list = rffi.cast(rffi.VOIDP, chunk)
         chunk = rffi.ptradd(chunk, 1)
Beispiel #2
0
 def _more(self):
     chunk = rffi.cast(CLOSURES, alloc(CHUNK))
     count = CHUNK//rffi.sizeof(FFI_CLOSUREP.TO)
     for i in range(count):
         rffi.cast(rffi.VOIDPP, chunk)[0] = self.free_list
         self.free_list = rffi.cast(rffi.VOIDP, chunk)
         chunk = rffi.ptradd(chunk, 1)
Beispiel #3
0
def test_alloc_free():
    map_size = 65536
    data = alloc(map_size)
    for i in range(0, map_size, 171):
        data[i] = chr(i & 0xff)
    for i in range(0, map_size, 171):
        assert data[i] == chr(i & 0xff)
    free(data, map_size)
Beispiel #4
0
def test_alloc_free():
    map_size = 65536
    data = alloc(map_size)
    for i in range(0, map_size, 171):
        data[i] = chr(i & 0xff)
    for i in range(0, map_size, 171):
        assert data[i] == chr(i & 0xff)
    free(data, map_size)
Beispiel #5
0
def detect_sse2():
    data = alloc(4096)
    pos = 0
    for c in ("\xB8\x01\x00\x00\x00"     # MOV EAX, 1
              "\x53"                     # PUSH EBX
              "\x0F\xA2"                 # CPUID
              "\x5B"                     # POP EBX
              "\x92"                     # XCHG EAX, EDX
              "\xC3"):                   # RET
        data[pos] = c
        pos += 1
    fnptr = rffi.cast(lltype.Ptr(lltype.FuncType([], lltype.Signed)), data)
    code = fnptr()
    free(data, 4096)
    return bool(code & (1<<25)) and bool(code & (1<<26))
Beispiel #6
0
def detect_sse2():
    data = alloc(4096)
    pos = 0
    for c in ("\xB8\x01\x00\x00\x00"  # MOV EAX, 1
              "\x53"  # PUSH EBX
              "\x0F\xA2"  # CPUID
              "\x5B"  # POP EBX
              "\x92"  # XCHG EAX, EDX
              "\xC3"):  # RET
        data[pos] = c
        pos += 1
    fnptr = rffi.cast(lltype.Ptr(lltype.FuncType([], lltype.Signed)), data)
    code = fnptr()
    free(data, 4096)
    return bool(code & (1 << 25)) and bool(code & (1 << 26))
Beispiel #7
0
 def _allocate_large_block(self, minsize):
     # Compute 'size' from 'minsize': it must be rounded up to
     # 'large_alloc_size'.  Additionally, we use the following line
     # to limit how many mmap() requests the OS will see in total:
     minsize = max(minsize, intmask(self.total_memory_allocated >> 4))
     size = minsize + self.large_alloc_size - 1
     size = (size // self.large_alloc_size) * self.large_alloc_size
     data = rmmap.alloc(size)
     if not we_are_translated():
         if self._allocated is None:
             self._allocated = []
         self._allocated.append((data, size))
         if sys.maxint > 2147483647:
             # Hack to make sure that mcs are not within 32-bits of one
             # another for testing purposes
             rmmap.hint.pos += 0x80000000 - size
     self.total_memory_allocated += r_uint(size)
     data = rffi.cast(lltype.Signed, data)
     return self._add_free_block(data, data + size)
Beispiel #8
0
 def _allocate_large_block(self, minsize):
     # Compute 'size' from 'minsize': it must be rounded up to
     # 'large_alloc_size'.  Additionally, we use the following line
     # to limit how many mmap() requests the OS will see in total:
     minsize = max(minsize, intmask(self.total_memory_allocated >> 4))
     size = minsize + self.large_alloc_size - 1
     size = (size // self.large_alloc_size) * self.large_alloc_size
     data = rmmap.alloc(size)
     if not we_are_translated():
         if self._allocated is None:
             self._allocated = []
         self._allocated.append((data, size))
         if sys.maxint > 2147483647:
             # Hack to make sure that mcs are not within 32-bits of one
             # another for testing purposes
             rmmap.hint.pos += 0x80000000 - size
     self.total_memory_allocated += r_uint(size)
     data = rffi.cast(lltype.Signed, data)
     return self._add_free_block(data, data + size)
Beispiel #9
0
 def __init__(self, map_size):
     data = alloc(map_size)
     self._init(data, map_size)
Beispiel #10
0
 def entry_point(argv):
     one = alloc(1024)
     free(one, 1024)
     return 0
Beispiel #11
0
 def entry_point(argv):
     one = alloc(1024)
     free(one, 1024)
     return 0
Beispiel #12
0
 def __init__(self, map_size):
     data = alloc(map_size)
     self._init(data, map_size)