def ll_prepare_free_slot(_unused): """Free up a slot in the array of MAX entries, ready for storing a new shadowstackref. Return the memory of the now-unused full shadowstack. """ index = fullstack_cache[0] if index > 0: return llmemory.NULL # there is already at least one free slot # # make a compact copy in one old entry and return the # original full-sized memory index = -index ll_assert(index > 0, "prepare_free_slot: cache[0] == 0") compacting = lltype.cast_int_to_ptr(SHADOWSTACKREFPTR, fullstack_cache[index]) index += 1 if index >= ShadowStackPool.MAX: index = 1 fullstack_cache[0] = -index # update to the next value in order # compacting.detach() original = compacting.base size = compacting.top - original new = llmemory.raw_malloc(size) if new == llmemory.NULL: return llmemory.NULL llmemory.raw_memcopy(original, new, size) compacting.base = new compacting.top = new + size return original
def fn(n): s = lltype.cast_int_to_ptr(PS, n) assert lltype.typeOf(s) == PS assert lltype.cast_ptr_to_int(s) == n t = lltype.cast_pointer(PT, s) assert lltype.typeOf(t) == PT assert lltype.cast_ptr_to_int(t) == n assert s == lltype.cast_pointer(PS, t)
def test_name_gcref(): from rpython.rtyper.lltypesystem import lltype, llmemory, rclass from rpython.translator.c import primitive from rpython.translator.c.database import LowLevelDatabase x = lltype.cast_int_to_ptr(rclass.OBJECTPTR, 19) y = lltype.cast_opaque_ptr(llmemory.GCREF, x) db = LowLevelDatabase() assert primitive.name_gcref(y, db) == "((void*) 19)"
def cast_int_to_adr(int): if isinstance(int, AddressAsInt): return int.adr try: ptr = lltype.cast_int_to_ptr(_NONGCREF, int) except ValueError: from rpython.rtyper.lltypesystem import ll2ctypes ptr = ll2ctypes._int2obj[int]._as_ptr() return cast_ptr_to_adr(ptr)
def test_name_gcref(): from rpython.rtyper.lltypesystem import lltype, llmemory from rpython.rtyper import rclass from rpython.translator.c import primitive from rpython.translator.c.database import LowLevelDatabase x = lltype.cast_int_to_ptr(rclass.OBJECTPTR, 19) y = lltype.cast_opaque_ptr(llmemory.GCREF, x) db = LowLevelDatabase() assert primitive.name_gcref(y, db) == "((void*) 19)"
def convert_const(self, value): if value._identity is _identity_for_ints: config = self.rtyper.annotator.translator.config assert config.translation.taggedpointers, "need to enable tagged pointers to use erase_int" return lltype.cast_int_to_ptr(self.lowleveltype, value._x * 2 + 1) bk = self.rtyper.annotator.bookkeeper s_obj = value._identity.get_input_annotation(bk) r_obj = self.rtyper.getrepr(s_obj) if r_obj.lowleveltype is lltype.Void: return lltype.nullptr(self.lowleveltype.TO) v = r_obj.convert_const(value._x) return lltype.cast_opaque_ptr(self.lowleveltype, v)
def ll_int_to_unboxed(PTRTYPE, value): return lltype.cast_int_to_ptr(PTRTYPE, value * 2 + 1)
def op_cast_int_to_ptr(self, RESTYPE, int1): return lltype.cast_int_to_ptr(RESTYPE, int1)
def fn(n): t = lltype.cast_int_to_ptr(PT, n) assert lltype.typeOf(t) == PT assert lltype.cast_ptr_to_int(t) == n o = lltype.cast_opaque_ptr(PQ, t) assert lltype.cast_ptr_to_int(o) == n
def ll_int_to_unboxed(PTRTYPE, value): return lltype.cast_int_to_ptr(PTRTYPE, value*2+1)