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


Python llmemory.cast_adr_to_int函数代码示例

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


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

示例1: test_force_to_int

 def test_force_to_int(self):
     S = lltype.Struct('S')
     p = lltype.malloc(S, flavor='raw')
     a = llmemory.cast_ptr_to_adr(p)
     i = llmemory.cast_adr_to_int(a, "forced")
     assert type(i) is int
     assert i == llmemory.cast_adr_to_int(a, "forced")
     lltype.free(p, flavor='raw')
开发者ID:ieure,项目名称:pypy,代码行数:8,代码来源:test_ll2ctypes.py

示例2: fn

 def fn(n):
     a = llmemory.cast_ptr_to_adr(p)
     if n == 2:
         return llmemory.cast_adr_to_int(a, "emulated")
     elif n == 4:
         return llmemory.cast_adr_to_int(a, "symbolic")
     else:
         return llmemory.cast_adr_to_int(a, "forced")
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:test_rptr.py

示例3: get_identityhash_from_addr

 def get_identityhash_from_addr(self, obj):
     if translated_to_c():
         return llmemory.cast_adr_to_int(obj)  # direct case
     else:
         try:
             adr = llarena.getfakearenaaddress(obj)  # -> arena address
         except RuntimeError:
             return llmemory.cast_adr_to_int(obj)  # not in an arena...
         return adr - self.space
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:9,代码来源:markcompact.py

示例4: test_address_eq_as_int

def test_address_eq_as_int():
    a = arena_malloc(50, False)
    arena_reserve(a, precomputed_size)
    p = llmemory.cast_adr_to_ptr(a, SPTR)
    a1 = llmemory.cast_ptr_to_adr(p)
    assert a == a1
    assert not (a != a1)
    assert (a+1) != a1
    assert not ((a+1) == a1)
    py.test.skip("cast_adr_to_int() is hard to get consistent")
    assert llmemory.cast_adr_to_int(a) == llmemory.cast_adr_to_int(a1)
    assert llmemory.cast_adr_to_int(a+1) == llmemory.cast_adr_to_int(a1) + 1
开发者ID:antoine1fr,项目名称:pygirl,代码行数:12,代码来源:test_llarena.py

示例5: id

    def id(self, ptr):
        # Default implementation for id(), assuming that "external" objects
        # never move.  Overriden in the HybridGC.
        obj = llmemory.cast_ptr_to_adr(ptr)

        # is it a tagged pointer? or an external object?
        if not self.is_valid_gc_object(obj) or self._is_external(obj):
            return llmemory.cast_adr_to_int(obj)

        # tagged pointers have ids of the form 2n + 1
        # external objects have ids of the form 4n (due to word alignment)
        # self._compute_id returns addresses of the form 2n + 1
        # if we multiply by 2, we get ids of the form 4n + 2, thus we get no
        # clashes
        return llmemory.cast_adr_to_int(self._compute_id(obj)) * 2
开发者ID:enyst,项目名称:plexnet,代码行数:15,代码来源:base.py

示例6: get_address_of_gcref

 def get_address_of_gcref(self, gcref):
     assert lltype.typeOf(gcref) == llmemory.GCREF
     # first look in the hashtable, using an inexact hash (fails after
     # the object moves)
     addr = llmemory.cast_ptr_to_adr(gcref)
     hash = llmemory.cast_adr_to_int(addr)
     hash -= hash >> self.HASHTABLE_BITS
     hash &= self.HASHTABLE_SIZE - 1
     addr_ref = self.hashtable[hash]
     # the following test is safe anyway, because the addresses found
     # in the hashtable are always the addresses of nonmovable stuff
     # ('addr_ref' is an address inside self.list, not directly the
     # address of a real moving GC object -- that's 'addr_ref.address[0]'.)
     if addr_ref.address[0] == addr:
         return addr_ref
     # if it fails, add an entry to the list
     if self.nextindex == len(self.list):
         # reallocate first, increasing a bit the size every time
         self.oldlists.append(self.list)
         self.list = self.alloc_gcref_list(len(self.list) // 4 * 5)
         self.nextindex = 0
     # add it
     index = self.nextindex
     self.list[index] = gcref
     addr_ref = lltype.direct_ptradd(lltype.direct_arrayitems(self.list),
                                     index)
     addr_ref = llmemory.cast_ptr_to_adr(addr_ref)
     self.nextindex = index + 1
     # record it in the hashtable
     self.hashtable[hash] = addr_ref
     return addr_ref
开发者ID:enyst,项目名称:plexnet,代码行数:31,代码来源:gc.py

示例7: start_of_page

def start_of_page(addr, page_size):
    """Return the address of the start of the page that contains 'addr'."""
    if we_are_translated():
        offset = llmemory.cast_adr_to_int(addr) % page_size
        return addr - offset
    else:
        return _start_of_page_untranslated(addr, page_size)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:minimarkpage.py

示例8: cast_whatever_to_int

def cast_whatever_to_int(T, value):
    if isinstance(T, lltype.Ptr):
        return lltype.cast_ptr_to_int(value)
    elif T is llmemory.Address:
        return llmemory.cast_adr_to_int(value)
    else:
        return lltype.cast_primitive(lltype.Signed, value)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:7,代码来源:rgenop.py

示例9: identityhash

 def identityhash(self, gcobj):
     # The following code should run at most twice.
     while 1:
         obj = llmemory.cast_ptr_to_adr(gcobj)
         hdr = self.header(obj)
         #
         if hdr.tid & GCFLAG_HASHFIELD:  # the hash is in a field at the end
             obj += self.get_size(obj)
             return obj.signed[0]
         #
         if not (hdr.tid & GCFLAG_HASHTAKEN):
             # It's the first time we ask for a hash, and it's not an
             # external object.  Shrink the top of space by the extra
             # hash word that will be needed after a collect.
             shrunk_top = self.top_of_space - llmemory.sizeof(lltype.Signed)
             if shrunk_top < self.free:
                 # Cannot shrink!  Do a collection, asking for at least
                 # one word of free space, and try again.  May raise
                 # MemoryError.  Obscure: not called directly, but
                 # across an llop, to make sure that there is the
                 # correct push_roots/pop_roots around the call...
                 llop.gc_obtain_free_space(llmemory.Address,
                                           llmemory.sizeof(lltype.Signed))
                 continue
             # Now we can have side-effects: set GCFLAG_HASHTAKEN
             # and lower the top of space.
             self.top_of_space = shrunk_top
             hdr.tid |= GCFLAG_HASHTAKEN
         #
         return llmemory.cast_adr_to_int(obj)  # direct case
开发者ID:enyst,项目名称:plexnet,代码行数:30,代码来源:semispace.py

示例10: writeobj

 def writeobj(self, obj):
     gc = self.gc
     typeid = gc.get_type_id(obj)
     self.write(llmemory.cast_adr_to_int(obj))
     self.write(gc.get_member_index(typeid))
     self.write(gc.get_size_incl_hash(obj))
     gc.trace(obj, self._writeref, None)
     self.write(-1)
开发者ID:ieure,项目名称:pypy,代码行数:8,代码来源:inspector.py

示例11: identityhash

 def identityhash(self, obj):
     obj = llmemory.cast_ptr_to_adr(obj)
     hdr = self.header(obj)
     if ord(hdr.flags) & FL_WITHHASH:
         obj += self.get_size(obj)
         return obj.signed[0]
     else:
         return llmemory.cast_adr_to_int(obj)
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:marksweep.py

示例12: id

 def id(self, ptr):
     # Default implementation for id(), assuming that "external" objects
     # never move.  Overriden in the HybridGC.
     obj = llmemory.cast_ptr_to_adr(ptr)
     if self._is_external(obj):
         result = obj
     else:
         result = self._compute_id(obj)
     return llmemory.cast_adr_to_int(result)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:9,代码来源:base.py

示例13: cast_adr_to_whatever

def cast_adr_to_whatever(T, addr):
    if T is llmemory.Address:
        return addr
    elif isinstance(T, lltype.Ptr):
        return llmemory.cast_adr_to_ptr(addr, T)
    elif T is lltype.Signed:
        return llmemory.cast_adr_to_int(addr)
    else:
        assert 0, "XXX not implemented"
开发者ID:antoine1fr,项目名称:pygirl,代码行数:9,代码来源:rgenop.py

示例14: load_now

 def load_now(self, asm, loc):
     value = llmemory.cast_adr_to_int(self.addr)
     if loc.is_register:
         assert isinstance(loc, insn.GPR)
         asm.load_word(loc.number, value)
     else:
         #print 'load_now to', loc.offset
         asm.load_word(rSCRATCH, value)
         asm.stw(rSCRATCH, rFP, loc.offset)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:9,代码来源:rgenop.py

示例15: revealconst

 def revealconst(self, T):
     if T is llmemory.Address:
         return self.addr
     elif isinstance(T, lltype.Ptr):
         return llmemory.cast_adr_to_ptr(self.addr, T)
     elif T is lltype.Signed:
         return llmemory.cast_adr_to_int(self.addr)
     else:
         assert 0, "XXX not implemented"
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:9,代码来源:rgenop.py


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