本文整理汇总了Python中pypy.rlib.rgc.can_move函数的典型用法代码示例。如果您正苦于以下问题:Python can_move函数的具体用法?Python can_move怎么用?Python can_move使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了can_move函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: func
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
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:7,代码来源:test_gc.py
示例2: func
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
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:test_transformed_gc.py
示例3: func
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
开发者ID:enyst,项目名称:plexnet,代码行数:11,代码来源:test_boehm.py
示例4: rewrite_assembler
def rewrite_assembler(self, cpu, operations):
# Perform two kinds of rewrites in parallel:
#
# - Add COND_CALLs to the write barrier before SETFIELD_GC and
# SETARRAYITEM_GC operations.
#
# - Remove all uses of ConstPtrs away from the assembler.
# Idea: when running on a moving GC, we can't (easily) encode
# the ConstPtrs in the assembler, because they can move at any
# point in time. Instead, we store them in 'gcrefs.list', a GC
# but nonmovable list; and here, we modify 'operations' to
# replace direct usage of ConstPtr with a BoxPtr loaded by a
# GETFIELD_RAW from the array 'gcrefs.list'.
#
newops = []
for op in operations:
if op.opnum == rop.DEBUG_MERGE_POINT:
continue
# ---------- replace ConstPtrs with GETFIELD_RAW ----------
# xxx some performance issue here
for i in range(len(op.args)):
v = op.args[i]
if isinstance(v, ConstPtr) and bool(v.value):
addr = self.gcrefs.get_address_of_gcref(v.value)
# ^^^even for non-movable objects, to record their presence
if rgc.can_move(v.value):
box = BoxPtr(v.value)
addr = cpu.cast_adr_to_int(addr)
newops.append(ResOperation(rop.GETFIELD_RAW,
[ConstInt(addr)], box,
self.single_gcref_descr))
op.args[i] = box
# ---------- write barrier for SETFIELD_GC ----------
if op.opnum == rop.SETFIELD_GC:
v = op.args[1]
if isinstance(v, BoxPtr) or (isinstance(v, ConstPtr) and
bool(v.value)): # store a non-NULL
self._gen_write_barrier(newops, op.args[0], v)
op = ResOperation(rop.SETFIELD_RAW, op.args, None,
descr=op.descr)
# ---------- write barrier for SETARRAYITEM_GC ----------
if op.opnum == rop.SETARRAYITEM_GC:
v = op.args[2]
if isinstance(v, BoxPtr) or (isinstance(v, ConstPtr) and
bool(v.value)): # store a non-NULL
self._gen_write_barrier(newops, op.args[0], v)
op = ResOperation(rop.SETARRAYITEM_RAW, op.args, None,
descr=op.descr)
# ----------
newops.append(op)
del operations[:]
operations.extend(newops)
开发者ID:alkorzt,项目名称:pypy,代码行数:52,代码来源:gc.py
示例5: convert_to_imm
def convert_to_imm(self, c):
if isinstance(c, ConstInt):
return imm(c.value)
elif isinstance(c, ConstPtr):
if we_are_translated() and c.value and rgc.can_move(c.value):
print "convert_to_imm: ConstPtr needs special care"
raise AssertionError
return imm(rffi.cast(lltype.Signed, c.value))
elif isinstance(c, ConstAddr):
return imm(ll2ctypes.cast_adr_to_int(c.value))
else:
print "convert_to_imm: got a %s" % c
raise AssertionError
开发者ID:enyst,项目名称:plexnet,代码行数:13,代码来源:regalloc.py
示例6: get_nonmovingbuffer
def get_nonmovingbuffer(data):
"""
Either returns a non-moving copy or performs neccessary pointer
arithmetic to return a pointer to the characters of a string if the
string is already nonmovable. Must be followed by a
free_nonmovingbuffer call.
"""
if rgc.can_move(data):
count = len(data)
buf = lltype.malloc(TYPEP.TO, count, flavor="raw")
for i in range(count):
buf[i] = data[i]
return buf
else:
data_start = cast_ptr_to_adr(llstrtype(data)) + offsetof(STRTYPE, "chars") + itemoffsetof(STRTYPE.chars, 0)
return cast(TYPEP, data_start)
开发者ID:are-prabhu,项目名称:pypy,代码行数:16,代码来源:rffi.py
示例7: f
def f(i):
if i:
return rgc.can_move(lltype.malloc(T0))
else:
return rgc.can_move(lltype.malloc(T1, 1))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:5,代码来源:test_rgc.py
示例8: fn
def fn():
return rgc.can_move(A())
开发者ID:pombredanne,项目名称:pypy,代码行数:2,代码来源:test_newgc.py
示例9: func
def func():
a = rgc.malloc_nonmovable(TP, 3)
if a:
assert not rgc.can_move(a)
return 0
return 1
开发者ID:enyst,项目名称:plexnet,代码行数:6,代码来源:test_gc.py
注:本文中的pypy.rlib.rgc.can_move函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论