def crash_in_jit(e): if not we_are_translated(): print "~~~ Crash in JIT!" print '~~~ %s: %s' % (e.__class__, e) if sys.stdout == sys.__stdout__: import pdb; pdb.post_mortem(sys.exc_info()[2]) raise fatalerror('~~~ Crash in JIT! %s' % (e,), traceback=True)
def malloc_unicode(length): try: return llop1.do_malloc_varsize_clear( llmemory.GCREF, unicode_type_id, length, unicode_basesize,unicode_itemsize, unicode_ofs_length, True) except MemoryError: fatalerror("out of memory (from JITted code)") return lltype.nullptr(llmemory.GCREF.TO)
def malloc_unicode(length): try: return llop1.do_malloc_varsize_clear(llmemory.GCREF, unicode_type_id, length, unicode_basesize, unicode_itemsize, unicode_ofs_length, True) except MemoryError: fatalerror("out of memory (from JITted code)") return lltype.nullptr(llmemory.GCREF.TO)
def malloc_array(itemsize, tid, num_elem): type_id = llop.extract_ushort(rffi.USHORT, tid) _check_typeid(type_id) try: return llop1.do_malloc_varsize_clear( llmemory.GCREF, type_id, num_elem, self.array_basesize, itemsize, self.array_length_ofs, True) except MemoryError: fatalerror("out of memory (from JITted code)") return lltype.nullptr(llmemory.GCREF.TO)
def malloc_fixedsize_slowpath(size): try: gcref = llop1.do_malloc_fixedsize_clear(llmemory.GCREF, 0, size, True, False, False) except MemoryError: fatalerror("out of memory (from JITted code)") return r_ulonglong(0) res = rffi.cast(lltype.Signed, gcref) nurs_free = llop1.gc_adr_of_nursery_free(llmemory.Address).signed[0] return r_ulonglong(nurs_free) << 32 | r_ulonglong(r_uint(res))
def malloc_fixedsize_slowpath(size): try: gcref = llop1.do_malloc_fixedsize_clear( llmemory.GCREF, 0, size, True, False, False) except MemoryError: fatalerror("out of memory (from JITted code)") return r_ulonglong(0) res = rffi.cast(lltype.Signed, gcref) nurs_free = llop1.gc_adr_of_nursery_free( llmemory.Address).signed[0] return r_ulonglong(nurs_free) << 32 | r_ulonglong(r_uint(res))
def malloc_array(itemsize, tid, num_elem): type_id = llop.extract_ushort(llgroup.HALFWORD, tid) check_typeid(type_id) try: return llop1.do_malloc_varsize_clear( llmemory.GCREF, type_id, num_elem, self.array_basesize, itemsize, self.array_length_ofs, True) except MemoryError: fatalerror("out of memory (from JITted code)") return lltype.nullptr(llmemory.GCREF.TO)
def malloc_basic(size, tid): type_id = llop.extract_ushort(rffi.USHORT, tid) has_finalizer = bool(tid & (1 << 16)) _check_typeid(type_id) try: res = llop1.do_malloc_fixedsize_clear(llmemory.GCREF, type_id, size, True, has_finalizer, False) except MemoryError: fatalerror("out of memory (from JITted code)") res = lltype.nullptr(llmemory.GCREF.TO) #llop.debug_print(lltype.Void, "\tmalloc_basic", size, type_id, # "-->", res) return res
def malloc_basic(size, tid): type_id = llop.extract_ushort(llgroup.HALFWORD, tid) has_finalizer = bool(tid & (1<<llgroup.HALFSHIFT)) check_typeid(type_id) try: res = llop1.do_malloc_fixedsize_clear(llmemory.GCREF, type_id, size, True, has_finalizer, False) except MemoryError: fatalerror("out of memory (from JITted code)") res = lltype.nullptr(llmemory.GCREF.TO) #llop.debug_print(lltype.Void, "\tmalloc_basic", size, type_id, # "-->", res) return res
def malloc_slowpath(size): if self.DEBUG: random_usage_of_xmm_registers() assert size >= self.minimal_size_in_nursery try: # NB. although we call do_malloc_fixedsize_clear() here, # it's a bit of a hack because we set tid to 0 and may # also use it to allocate varsized objects. The tid # and possibly the length are both set afterward. gcref = llop1.do_malloc_fixedsize_clear(llmemory.GCREF, 0, size, True, False, False) except MemoryError: fatalerror("out of memory (from JITted code)") return 0 return rffi.cast(lltype.Signed, gcref)
def crash_in_jit(e): tb = not we_are_translated() and sys.exc_info()[2] try: raise e except JitException: raise # go through except MemoryError: raise # go through except StackOverflow: raise # go through except Exception, e: if not we_are_translated(): print "~~~ Crash in JIT!" print '~~~ %s: %s' % (e.__class__, e) if sys.stdout == sys.__stdout__: import pdb; pdb.post_mortem(tb) raise e.__class__, e, tb fatalerror('~~~ Crash in JIT! %s' % (e,), traceback=True)
def portal(codeno, frame): print 'ENTER:', codeno, frame.thing.val i = 0 while i < 10: driver.can_enter_jit(frame=frame, codeno=codeno, i=i) driver.jit_merge_point(frame=frame, codeno=codeno, i=i) nextval = frame.thing.val if codeno == 0: subframe = Frame() subframe.thing = Thing(nextval) nextval = portal(1, subframe) elif codeno == 1: if frame.thing.val > 40: change(Thing(13)) nextval = 13 else: fatalerror("bad codeno = " + str(codeno)) frame.thing = Thing(nextval + 1) i += 1 print 'LEAVE:', codeno, frame.thing.val return frame.thing.val