예제 #1
0
 def func():
     from pypy.rlib import rgc
     a = rgc.malloc_nonmovable(TP, 3)
     if a:
         assert not rgc.can_move(a)
         return 0
     return 1
예제 #2
0
파일: test_gc.py 프로젝트: griels/pypy-sc
 def func():
     from pypy.rlib import rgc
     a = rgc.malloc_nonmovable(TP, 3)
     if a:
         assert not rgc.can_move(a)
         return 0
     return 1
예제 #3
0
 def func():
     #try:
     a = rgc.malloc_nonmovable(TP, 3, zero=True)
     rgc.collect()
     if a:
         assert not rgc.can_move(a)
         return 0
     return 1
예제 #4
0
파일: gc.py 프로젝트: xx312022850/pypy
 def alloc_gcref_list(self, n):
     # Important: the GRREF_LISTs allocated are *non-movable*.  This
     # requires support in the gc (only the hybrid GC supports it so far).
     if we_are_translated():
         list = rgc.malloc_nonmovable(self.GCREF_LIST, n)
         assert list, "malloc_nonmovable failed!"
     else:
         list = lltype.malloc(self.GCREF_LIST, n)  # for tests only
     return list
예제 #5
0
파일: gc.py 프로젝트: enyst/plexnet
 def alloc_gcref_list(self, n):
     # Important: the GRREF_LISTs allocated are *non-movable*.  This
     # requires support in the gc (only the hybrid GC supports it so far).
     if we_are_translated():
         list = rgc.malloc_nonmovable(self.GCREF_LIST, n)
         assert list, "malloc_nonmovable failed!"
     else:
         list = lltype.malloc(self.GCREF_LIST, n)     # for tests only
     return list
예제 #6
0
 def _grow(self):
     # XXX workaround for a fact that rgc.malloc_nonmovable always
     #     returns nullptr when run on top of python
     if we_are_translated():
         new_item = rgc.malloc_nonmovable(ATP, CHUNK_SIZE, zero=True)
     else:
         new_item = lltype.malloc(ATP, CHUNK_SIZE, zero=True)
     self.chunks.append(new_item)
     self.lgt += 1
예제 #7
0
 def _grow(self):
     # XXX workaround for a fact that rgc.malloc_nonmovable always
     #     returns nullptr when run on top of python
     if we_are_translated():
         new_item = rgc.malloc_nonmovable(ATP, CHUNK_SIZE, zero=True)
     else:
         new_item = lltype.malloc(ATP, CHUNK_SIZE, zero=True)
     self.chunks.append(new_item)
     self.lgt += 1
예제 #8
0
 def func():
     try:
         a = rgc.malloc_nonmovable(TP)
         rgc.collect()
         if a:
             assert not rgc.can_move(a)
             return 0
         return 1
     except Exception, e:
         return 2
예제 #9
0
파일: test_boehm.py 프로젝트: enyst/plexnet
 def func():
     try:
         from pypy.rlib import rgc
         a = rgc.malloc_nonmovable(TP, 3)
         rgc.collect()
         if a:
             assert not rgc.can_move(a)
             return 0
         return 1
     except Exception, e:
         return 2
예제 #10
0
파일: test_boehm.py 프로젝트: njues/Sypy
 def func():
     try:
         from pypy.rlib import rgc
         a = rgc.malloc_nonmovable(TP, 3)
         rgc.collect()
         if a:
             assert not rgc.can_move(a)
             return 0
         return 1
     except Exception, e:
         return 2
예제 #11
0
파일: rffi.py 프로젝트: alkorzt/pypy
 def alloc_buffer(count):
     """
     Returns a (raw_buffer, gc_buffer) pair, allocated with count bytes.
     The raw_buffer can be safely passed to a native function which expects
     it to not move. Call str_from_buffer with the returned values to get a
     safe high-level string. When the garbage collector cooperates, this
     allows for the process to be performed without an extra copy.
     Make sure to call keep_buffer_alive_until_here on the returned values.
     """
     str_chars_offset = offsetof(STRTYPE, "chars") + itemoffsetof(STRTYPE.chars, 0)
     gc_buf = rgc.malloc_nonmovable(STRTYPE, count)
     if gc_buf:
         realbuf = cast_ptr_to_adr(gc_buf) + str_chars_offset
         raw_buf = cast(TYPEP, realbuf)
         return raw_buf, gc_buf
     else:
         raw_buf = lltype.malloc(TYPEP.TO, count, flavor="raw")
         return raw_buf, lltype.nullptr(STRTYPE)
예제 #12
0
 def alloc_buffer(count):
     """
     Returns a (raw_buffer, gc_buffer) pair, allocated with count bytes.
     The raw_buffer can be safely passed to a native function which expects
     it to not move. Call str_from_buffer with the returned values to get a
     safe high-level string. When the garbage collector cooperates, this
     allows for the process to be performed without an extra copy.
     Make sure to call keep_buffer_alive_until_here on the returned values.
     """
     str_chars_offset = (offsetof(STRTYPE, 'chars') + \
                         itemoffsetof(STRTYPE.chars, 0))
     gc_buf = rgc.malloc_nonmovable(STRTYPE, count)
     if gc_buf:
         realbuf = cast_ptr_to_adr(gc_buf) + str_chars_offset
         raw_buf = cast(TYPEP, realbuf)
         return raw_buf, gc_buf
     else:
         raw_buf = lltype.malloc(TYPEP.TO, count, flavor='raw')
         return raw_buf, lltype.nullptr(STRTYPE)
예제 #13
0
 def func():
     a = rgc.malloc_nonmovable(TP, 3)
     if a:
         assert not rgc.can_move(a)
         return 0
     return 1
예제 #14
0
파일: test_gc.py 프로젝트: enyst/plexnet
 def func():
     a = rgc.malloc_nonmovable(TP, 3)
     if a:
         assert not rgc.can_move(a)
         return 0
     return 1