本文整理汇总了Python中pypy.rpython.memory.gc.semispace.SemiSpaceGC.malloc_fixedsize_clear方法的典型用法代码示例。如果您正苦于以下问题:Python SemiSpaceGC.malloc_fixedsize_clear方法的具体用法?Python SemiSpaceGC.malloc_fixedsize_clear怎么用?Python SemiSpaceGC.malloc_fixedsize_clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.rpython.memory.gc.semispace.SemiSpaceGC
的用法示例。
在下文中一共展示了SemiSpaceGC.malloc_fixedsize_clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: malloc_fixedsize_clear
# 需要导入模块: from pypy.rpython.memory.gc.semispace import SemiSpaceGC [as 别名]
# 或者: from pypy.rpython.memory.gc.semispace.SemiSpaceGC import malloc_fixedsize_clear [as 别名]
def malloc_fixedsize_clear(self, typeid, size, can_collect,
has_finalizer=False, contains_weakptr=False):
if (has_finalizer or not can_collect or
(raw_malloc_usage(size) > self.lb_young_var_basesize and
raw_malloc_usage(size) > self.largest_young_fixedsize)):
# ^^^ we do two size comparisons; the first one appears redundant,
# but it can be constant-folded if 'size' is a constant; then
# it almost always folds down to False, which kills the
# second comparison as well.
ll_assert(not contains_weakptr, "wrong case for mallocing weakref")
# "non-simple" case or object too big: don't use the nursery
return SemiSpaceGC.malloc_fixedsize_clear(self, typeid, size,
can_collect,
has_finalizer,
contains_weakptr)
size_gc_header = self.gcheaderbuilder.size_gc_header
totalsize = size_gc_header + size
result = self.nursery_free
if raw_malloc_usage(totalsize) > self.nursery_top - result:
result = self.collect_nursery()
llarena.arena_reserve(result, totalsize)
# GCFLAG_NO_YOUNG_PTRS is never set on young objs
self.init_gc_object(result, typeid, flags=0)
self.nursery_free = result + totalsize
if contains_weakptr:
self.young_objects_with_weakrefs.append(result + size_gc_header)
return llmemory.cast_adr_to_ptr(result+size_gc_header, llmemory.GCREF)
示例2: coalloc_fixedsize_clear
# 需要导入模块: from pypy.rpython.memory.gc.semispace import SemiSpaceGC [as 别名]
# 或者: from pypy.rpython.memory.gc.semispace.SemiSpaceGC import malloc_fixedsize_clear [as 别名]
def coalloc_fixedsize_clear(self, coallocator, typeid, size):
# note: a coallocated object can never return a weakref, since the
# coallocation analysis is done at a time where weakrefs are
# represented as opaque objects which aren't allocated using malloc but
# with weakref_create
if self.is_in_nursery(coallocator):
return self.malloc_fixedsize_clear(typeid, size,
True, False, False)
else:
return SemiSpaceGC.malloc_fixedsize_clear(self, typeid, size,
True, False, False)