当前位置: 首页>>代码示例>>Python>>正文


Python llmemory.cast_adr_to_ptr函数代码示例

本文整理汇总了Python中pypy.rpython.lltypesystem.llmemory.cast_adr_to_ptr函数的典型用法代码示例。如果您正苦于以下问题:Python cast_adr_to_ptr函数的具体用法?Python cast_adr_to_ptr怎么用?Python cast_adr_to_ptr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cast_adr_to_ptr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: malloc_fixedsize

 def malloc_fixedsize(self, typeid16, size, can_collect,
                      has_finalizer=False, contains_weakptr=False):
     if can_collect:
         self.maybe_collect()
     size_gc_header = self.gcheaderbuilder.size_gc_header
     try:
         tot_size = size_gc_header + size
         usage = raw_malloc_usage(tot_size)
         bytes_malloced = ovfcheck(self.bytes_malloced+usage)
         ovfcheck(self.heap_usage + bytes_malloced)
     except OverflowError:
         raise memoryError
     result = raw_malloc(tot_size)
     if not result:
         raise memoryError
     hdr = llmemory.cast_adr_to_ptr(result, self.HDRPTR)
     hdr.typeid16 = typeid16
     hdr.mark = False
     hdr.flags = '\x00'
     if has_finalizer:
         hdr.next = self.malloced_objects_with_finalizer
         self.malloced_objects_with_finalizer = hdr
     elif contains_weakptr:
         hdr.next = self.objects_with_weak_pointers
         self.objects_with_weak_pointers = hdr
     else:
         hdr.next = self.malloced_objects
         self.malloced_objects = hdr
     self.bytes_malloced = bytes_malloced
     result += size_gc_header
     #llop.debug_print(lltype.Void, 'malloc typeid', typeid16,
     #                 '->', llmemory.cast_adr_to_int(result))
     self.write_malloc_statistics(typeid16, tot_size, result, False)
     return llmemory.cast_adr_to_ptr(result, llmemory.GCREF)
开发者ID:alkorzt,项目名称:pypy,代码行数:34,代码来源:marksweep.py

示例2: ll_memcpy

def ll_memcpy(dst, src, length):
    C_ARRAY = lltype.Ptr(lltype.FixedSizeArray(lltype.Char, 1))
    c_src = llmemory.cast_adr_to_ptr(src, C_ARRAY)
    c_dst = llmemory.cast_adr_to_ptr(dst, C_ARRAY)
    for i in range(length):
        c_dst[i] = c_src[i]
    return dst
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:test_rfunc.py

示例3: malloc_varsize_clear

 def malloc_varsize_clear(self, typeid16, length, size, itemsize,
                          offset_to_length, can_collect):
     if can_collect:
         self.maybe_collect()
     size_gc_header = self.gcheaderbuilder.size_gc_header
     try:
         fixsize = size_gc_header + size
         varsize = ovfcheck(itemsize * length)
         tot_size = ovfcheck(fixsize + varsize)
         usage = raw_malloc_usage(tot_size)
         bytes_malloced = ovfcheck(self.bytes_malloced+usage)
         ovfcheck(self.heap_usage + bytes_malloced)
     except OverflowError:
         raise memoryError
     result = raw_malloc(tot_size)
     if not result:
         raise memoryError
     raw_memclear(result, tot_size)        
     (result + size_gc_header + offset_to_length).signed[0] = length
     hdr = llmemory.cast_adr_to_ptr(result, self.HDRPTR)
     hdr.typeid16 = typeid16
     hdr.mark = False
     hdr.flags = '\x00'
     hdr.next = self.malloced_objects
     self.malloced_objects = hdr
     self.bytes_malloced = bytes_malloced
         
     result += size_gc_header
     #llop.debug_print(lltype.Void, 'malloc_varsize length', length,
     #                 'typeid', typeid16,
     #                 '->', llmemory.cast_adr_to_int(result))
     self.write_malloc_statistics(typeid16, tot_size, result, True)
     return llmemory.cast_adr_to_ptr(result, llmemory.GCREF)
开发者ID:alkorzt,项目名称:pypy,代码行数:33,代码来源:marksweep.py

示例4: markcompactcollect

 def markcompactcollect(self, needed=0):
     start_time = self.debug_collect_start()
     self.debug_check_consistency()
     self.to_see = self.AddressStack()
     self.mark_roots_recursively()
     if (self.objects_with_finalizers.non_empty() or
         self.run_finalizers.non_empty()):
         self.mark_objects_with_finalizers()
         self._trace_and_mark()
     self.to_see.delete()
     num_of_alive_objs = self.compute_alive_objects()
     size_of_alive_objs = self.totalsize_of_objs
     totalsize = self.new_space_size(size_of_alive_objs, needed +
                                     num_of_alive_objs * BYTES_PER_TID)
     tid_backup_size = (llmemory.sizeof(self.TID_BACKUP, 0) +
                        llmemory.sizeof(TID_TYPE) * num_of_alive_objs)
     used_space_now = self.next_collect_after + raw_malloc_usage(tid_backup_size)
     if totalsize >= self.space_size or used_space_now >= self.space_size:
         toaddr = self.double_space_size(totalsize)
         llarena.arena_reserve(toaddr + size_of_alive_objs, tid_backup_size)
         self.tid_backup = llmemory.cast_adr_to_ptr(
             toaddr + size_of_alive_objs,
             lltype.Ptr(self.TID_BACKUP))
         resizing = True
     else:
         toaddr = llarena.arena_new_view(self.space)
         llarena.arena_reserve(self.top_of_space, tid_backup_size)
         self.tid_backup = llmemory.cast_adr_to_ptr(
             self.top_of_space,
             lltype.Ptr(self.TID_BACKUP))
         resizing = False
     self.next_collect_after = totalsize
     weakref_offsets = self.collect_weakref_offsets()
     finaladdr = self.update_forward_pointers(toaddr, num_of_alive_objs)
     if (self.run_finalizers.non_empty() or
         self.objects_with_finalizers.non_empty()):
         self.update_run_finalizers()
     if self.objects_with_weakrefs.non_empty():
         self.invalidate_weakrefs(weakref_offsets)
     self.update_objects_with_id()
     self.compact(resizing)
     if not resizing:
         size = toaddr + self.space_size - finaladdr
         llarena.arena_reset(finaladdr, size, True)
     else:
         if we_are_translated():
             # because we free stuff already in raw_memmove, we
             # would get double free here. Let's free it anyway
             llarena.arena_free(self.space)
         llarena.arena_reset(toaddr + size_of_alive_objs, tid_backup_size,
                             True)
     self.space        = toaddr
     self.free         = finaladdr
     self.top_of_space = toaddr + self.next_collect_after
     self.debug_check_consistency()
     self.tid_backup = lltype.nullptr(self.TID_BACKUP)
     if self.run_finalizers.non_empty():
         self.execute_finalizers()
     self.debug_collect_finish(start_time)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:59,代码来源:markcompact.py

示例5: ll_dealloc

 def ll_dealloc(addr):
     # bump refcount to 1
     gcheader = llmemory.cast_adr_to_ptr(addr - gc_header_offset, HDRPTR)
     gcheader.refcount = 1
     v = llmemory.cast_adr_to_ptr(addr, QUERY_ARG_TYPE)
     rtti = queryptr(v)
     gcheader.refcount = 0
     llop.gc_call_rtti_destructor(lltype.Void, rtti, addr)
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:refcounting.py

示例6: cast_adr_to_int

 def cast_adr_to_int(self, adr):
     if not adr:
         return 0
     try:
         ptr = llmemory.cast_adr_to_ptr(adr, gc_ll_descr.WB_FUNCPTR)
         assert ptr._obj._callable == \
                llop1._write_barrier_failing_case
         return 42
     except lltype.InvalidCast:
         ptr = llmemory.cast_adr_to_ptr(
             adr, gc_ll_descr.WB_ARRAY_FUNCPTR)
         assert ptr._obj._callable == \
                llop1._write_barrier_from_array_failing_case
         return 43
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:14,代码来源:test_gc.py

示例7: test_look_inside_object

def test_look_inside_object():
    # this code is also used in translation tests below
    myarenasize = 50
    a = arena_malloc(myarenasize, False)
    b = a + round_up_for_allocation(llmemory.sizeof(lltype.Char))
    arena_reserve(b, precomputed_size)
    (b + llmemory.offsetof(SX, 'x')).signed[0] = 123
    assert llmemory.cast_adr_to_ptr(b, SPTR).x == 123
    llmemory.cast_adr_to_ptr(b, SPTR).x += 1
    assert (b + llmemory.offsetof(SX, 'x')).signed[0] == 124
    arena_reset(a, myarenasize, True)
    arena_reserve(b, round_up_for_allocation(llmemory.sizeof(SX)))
    assert llmemory.cast_adr_to_ptr(b, SPTR).x == 0
    arena_free(a)
    return 42
开发者ID:antoine1fr,项目名称:pygirl,代码行数:15,代码来源:test_llarena.py

示例8: _mark_root_and_clear_bit

 def _mark_root_and_clear_bit(self, root):
     gcobjectaddr = root.address[0]
     self._mark_stack.append(gcobjectaddr)
     size_gc_header = self.gcheaderbuilder.size_gc_header
     gc_info = gcobjectaddr - size_gc_header
     hdr = llmemory.cast_adr_to_ptr(gc_info, self.HDRPTR)
     hdr.mark = False
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:marksweep.py

示例9: get_forwarding_address

 def get_forwarding_address(self, obj):
     tid = self.header(obj).tid
     if tid & GCFLAG_IMMORTAL:
         return obj      # prebuilt objects are "forwarded" to themselves
     else:
         stub = llmemory.cast_adr_to_ptr(obj, self.FORWARDSTUBPTR)
         return stub.forw
开发者ID:antoine1fr,项目名称:pygirl,代码行数:7,代码来源:semispace.py

示例10: init_gc_object_immortal

 def init_gc_object_immortal(self, addr, typeid16, flags=0):
     hdr = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(self.HDR))
     flags |= GCFLAG_HASHTAKEN | GCFLAG_MARKBIT
     # All prebuilt GC objects have the GCFLAG_MARKBIT always set.
     # That's convenient to make the GC always think that they
     # survive the current collection.
     hdr.tid = self.combine(typeid16, flags)
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:7,代码来源:markcompact.py

示例11: llf

 def llf(n):
     a = malloc(A, 5)
     a[3].x = 42
     adr_s = llmemory.cast_ptr_to_adr(a[0])
     adr_s += size * n
     s = llmemory.cast_adr_to_ptr(adr_s, PS)
     return s.x
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:test_lltyped.py

示例12: malloc_resizable_buffer

 def malloc_resizable_buffer(self, TYPE, n):
     typeid = self.get_type_id(TYPE)
     addr = self.gc.malloc(typeid, n)
     result = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(TYPE))
     if not self.gc.malloc_zero_filled:
         gctypelayout.zero_gc_pointers(result)
     return result
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:7,代码来源:gcwrapper.py

示例13: f

 def f():
     adr = lladdress.raw_malloc(sizeofs)
     s = llmemory.cast_adr_to_ptr(adr, STRUCTPTR)
     s.y = 5 # does not crash
     result = (adr + offsety).signed[0] * 10 + int(offsety < sizeofs)
     lladdress.raw_free(adr)
     return result
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:test_symbolic.py

示例14: init_gc_object_immortal

 def init_gc_object_immortal(self, addr, typeid, flags=0):
     # prebuilt gc structures always have the mark bit set
     # ignore flags
     hdr = llmemory.cast_adr_to_ptr(addr, self.HDRPTR)
     hdr.typeid16 = typeid
     hdr.mark = True
     hdr.flags = '\x00'
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:marksweep.py

示例15: op_gc_reload_possibly_moved

 def op_gc_reload_possibly_moved(self, v_newaddr, v_ptr):
     assert v_newaddr.concretetype is llmemory.Address
     assert isinstance(v_ptr.concretetype, lltype.Ptr)
     assert v_ptr.concretetype.TO._gckind == 'gc'
     newaddr = self.getval(v_newaddr)
     p = llmemory.cast_adr_to_ptr(newaddr, v_ptr.concretetype)
     self.setvar(v_ptr, p)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:7,代码来源:llinterp.py


注:本文中的pypy.rpython.lltypesystem.llmemory.cast_adr_to_ptr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。