def fn(n): s = str(n) if not rgc.can_move(s): return 13 res = int(rgc.pin(s)) if res: rgc.unpin(s) return res
def fn(n): from rpython.rlib.debug import debug_print s = str(n) if not rgc.can_move(s): return 13 res = int(rgc.pin(s)) if res: res += int(rgc._is_pinned(s)) rgc.unpin(s) return res
def keep_buffer_alive_until_here(raw_buf, gc_buf, case_num): """ Keeps buffers alive or frees temporary buffers created by alloc_buffer. This must be called after a call to alloc_buffer, usually in a try/finally block. """ keepalive_until_here(gc_buf) if case_num == 1: rgc.unpin(gc_buf) if case_num == 2: lltype.free(raw_buf, flavor='raw')
def free_nonmovingbuffer(data, buf, is_pinned, is_raw): """ Keep 'data' alive and unpin it if it was pinned ('is_pinned' is true). Otherwise free the non-moving copy ('is_raw' is true). """ if is_pinned: rgc.unpin(data) if is_raw: lltype.free(buf, flavor='raw') # if is_pinned and is_raw are false: data was already nonmovable, # we have nothing to clean up keepalive_until_here(data)
def free_nonmovingbuffer(data, buf, flag): """ Keep 'data' alive and unpin it if it was pinned (flag==\5). Otherwise free the non-moving copy (flag==\6). """ if flag == '\x05': rgc.unpin(data) if flag == '\x06': lltype.free(buf, flavor='raw') # if flag == '\x04': data was already nonmovable, # we have nothing to clean up keepalive_until_here(data)
def get_y(n): if not helper.inst: helper.inst = Y() helper.inst.x = 101 helper.pinned = True check(rgc.pin(helper.inst)) elif n < 100 and helper.pinned: rgc.unpin(helper.inst) helper.pinned = False # if helper.pinned: check(rgc._is_pinned(helper.inst)) helper.count_pinned += 1 else: check(not rgc._is_pinned(helper.inst)) helper.count_unpinned += 1 return helper.inst