本文整理汇总了Python中pypy.rpython.memory.gc.semispace.SemiSpaceGC.make_a_copy方法的典型用法代码示例。如果您正苦于以下问题:Python SemiSpaceGC.make_a_copy方法的具体用法?Python SemiSpaceGC.make_a_copy怎么用?Python SemiSpaceGC.make_a_copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.rpython.memory.gc.semispace.SemiSpaceGC
的用法示例。
在下文中一共展示了SemiSpaceGC.make_a_copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_a_copy
# 需要导入模块: from pypy.rpython.memory.gc.semispace import SemiSpaceGC [as 别名]
# 或者: from pypy.rpython.memory.gc.semispace.SemiSpaceGC import make_a_copy [as 别名]
def make_a_copy(self, obj, objsize):
# During a full collect, all copied objects might implicitly come
# from the nursery. If they do, we must add the GCFLAG_NO_YOUNG_PTRS.
# If they don't, we count how many times they are copied and when
# some threshold is reached we make the copy a non-movable "external"
# object. The threshold is MAX_SEMISPACE_AGE.
tid = self.header(obj).tid
# XXX the following logic is not doing exactly what is explained
# above: any object without GCFLAG_NO_YOUNG_PTRS has its age not
# incremented. This is accidental: it means that objects that
# are very often modified to point to young objects don't reach
# the 3rd generation. For now I'll leave it this way because
# I'm not sure that it's a bad thing.
if not (tid & GCFLAG_NO_YOUNG_PTRS):
tid |= GCFLAG_NO_YOUNG_PTRS # object comes from the nursery
elif (tid & GCFLAG_AGE_MASK) < GCFLAG_AGE_MAX:
tid += GCFLAG_AGE_ONE
else:
newobj = self.make_a_nonmoving_copy(obj, objsize)
if newobj:
return newobj
tid &= ~GCFLAG_AGE_MASK
# skip GenerationGC.make_a_copy() as we already did the right
# thing about GCFLAG_NO_YOUNG_PTRS
newobj = SemiSpaceGC.make_a_copy(self, obj, objsize)
self.header(newobj).tid = tid
return newobj
示例2: make_a_copy
# 需要导入模块: from pypy.rpython.memory.gc.semispace import SemiSpaceGC [as 别名]
# 或者: from pypy.rpython.memory.gc.semispace.SemiSpaceGC import make_a_copy [as 别名]
def make_a_copy(self, obj, objsize):
newobj = SemiSpaceGC.make_a_copy(self, obj, objsize)
# During a full collect, all copied objects might implicitly come
# from the nursery. In case they do, we must add this flag:
self.header(newobj).tid |= GCFLAG_NO_YOUNG_PTRS
return newobj