本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_repr_ll2ctypes
def test_repr_ll2ctypes():
ptr = lltype.malloc(rffi.VOIDPP.TO, 10, flavor='raw')
# force it to be a ll2ctypes object
ptr = rffi.cast(rffi.VOIDPP, rffi.cast(rffi.LONG, ptr))
adr = llmemory.cast_ptr_to_adr(ptr)
lltype.free(ptr, flavor='raw')
intval = llmemory.cast_adr_to_int(adr, 'symbolic')
box = BoxInt(intval)
s = box.repr_rpython()
assert s.startswith('12345/') # the arbitrary hash value used by
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:10,代码来源:test_history.py
示例17: _get_object_hash
def _get_object_hash(self, obj, objsize, tid):
# Returns the hash of the object, which must not be GC_HASH_NOTTAKEN.
gc_hash = tid & GCFLAG_HASHMASK
if gc_hash == GC_HASH_HASFIELD:
obj = llarena.getfakearenaaddress(obj)
return (obj + objsize).signed[0]
elif gc_hash == GC_HASH_TAKEN_ADDR:
return llmemory.cast_adr_to_int(obj)
elif gc_hash == GC_HASH_TAKEN_NURS:
return self._compute_current_nursery_hash(obj)
else:
assert 0, "gc_hash == GC_HASH_NOTTAKEN"
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:12,代码来源:semispace.py
示例18: id
def id(self, ptr):
obj = llmemory.cast_ptr_to_adr(ptr)
# is it a tagged pointer?
if not self.is_valid_gc_object(obj):
return llmemory.cast_adr_to_int(obj)
if self._is_external(obj):
# a prebuilt or rawmalloced object
if self.is_last_generation(obj):
# a generation 3 object may be one that used to live in
# the semispace. So we still need to check if the object had
# its id taken before. If not, we can use its address as its
# id as it is not going to move any more.
result = self.objects_with_id.get(obj, obj)
else:
# a generation 2 external object was never non-external in
# the past, so it cannot be listed in self.objects_with_id.
result = obj
else:
result = self._compute_id(obj) # common case
return llmemory.cast_adr_to_int(result) * 2 # see comment in base.py
开发者ID:ieure,项目名称:pypy,代码行数:22,代码来源:hybrid.py
示例19: _generalcast
def _generalcast(T, value):
if isinstance(T, lltype.Ptr):
return lltype.cast_pointer(T, value)
elif T == llmemory.Address:
return llmemory.cast_ptr_to_adr(value)
else:
T1 = lltype.typeOf(value)
if T1 is llmemory.Address:
value = llmemory.cast_adr_to_int(value)
elif isinstance(T1, lltype.Ptr):
value = lltype.cast_ptr_to_int(value)
else:
value = value
return lltype.cast_primitive(T, value)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:14,代码来源:llimpl.py
示例20: identityhash
def identityhash(self, gcobj):
# Unlike SemiSpaceGC.identityhash(), this function does not have
# to care about reducing top_of_space. The reason is as
# follows. When we collect, each object either moves to the
# left or stays where it is. If it moves to the left (and if it
# has GCFLAG_HASHTAKEN), we can give it a hash field, and the
# end of the new object cannot move to the right of the end of
# the old object. If it stays where it is, then we don't need
# to add the hash field. So collecting can never actually grow
# the consumed size.
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]
#
hdr.tid |= GCFLAG_HASHTAKEN
return llmemory.cast_adr_to_int(obj) # direct case
开发者ID:alkorzt,项目名称:pypy,代码行数:19,代码来源:markcompact.py
注:本文中的pypy.rpython.lltypesystem.llmemory.cast_adr_to_int函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论