示例#1
0
 def handle_call_assembler(self, op):
     descrs = self.gc_ll_descr.getframedescrs(self.cpu)
     loop_token = op.getdescr()
     assert isinstance(loop_token, history.JitCellToken)
     jfi = loop_token.compiled_loop_token.frame_info
     llfi = heaptracker.adr2int(llmemory.cast_ptr_to_adr(jfi))
     size_box = history.BoxInt()
     frame = history.BoxPtr()
     self.gen_malloc_frame(llfi, frame, size_box)
     op2 = ResOperation(rop.SETFIELD_GC,
                        [frame, history.ConstInt(llfi)],
                        None,
                        descr=descrs.jf_frame_info)
     self.newops.append(op2)
     arglist = op.getarglist()
     index_list = loop_token.compiled_loop_token._ll_initial_locs
     for i, arg in enumerate(arglist):
         descr = self.cpu.getarraydescr_for_frame(arg.type)
         assert self.cpu.JITFRAME_FIXED_SIZE & 1 == 0
         _, itemsize, _ = self.cpu.unpack_arraydescr_size(descr)
         index = index_list[i] // itemsize  # index is in bytes
         self.newops.append(
             ResOperation(rop.SETARRAYITEM_GC,
                          [frame, ConstInt(index), arg], None, descr))
     descr = op.getdescr()
     assert isinstance(descr, JitCellToken)
     jd = descr.outermost_jitdriver_sd
     args = [frame]
     if jd and jd.index_of_virtualizable >= 0:
         args = [frame, arglist[jd.index_of_virtualizable]]
     else:
         args = [frame]
     self.newops.append(
         ResOperation(rop.CALL_ASSEMBLER, args, op.result, op.getdescr()))
示例#2
0
def wrap(cpu, value, in_const_box=False):
    if isinstance(lltype.typeOf(value), lltype.Ptr):
        if lltype.typeOf(value).TO._gckind == 'gc':
            value = lltype.cast_opaque_ptr(llmemory.GCREF, value)
            if in_const_box:
                return history.ConstPtr(value)
            else:
                return history.BoxPtr(value)
        else:
            adr = llmemory.cast_ptr_to_adr(value)
            value = heaptracker.adr2int(adr)
            # fall through to the end of the function
    elif (isinstance(value, float)
          or longlong.is_longlong(lltype.typeOf(value))):
        if isinstance(value, float):
            value = longlong.getfloatstorage(value)
        else:
            value = rffi.cast(lltype.SignedLongLong, value)
        if in_const_box:
            return history.ConstFloat(value)
        else:
            return history.BoxFloat(value)
    elif isinstance(value, str) or isinstance(value, unicode):
        assert len(value) == 1  # must be a character
        value = ord(value)
    elif lltype.typeOf(value) is lltype.SingleFloat:
        value = longlong.singlefloat2int(value)
    else:
        value = intmask(value)
    if in_const_box:
        return history.ConstInt(value)
    else:
        return history.BoxInt(value)
示例#3
0
 def get_exc_value_box(self, evalue):
     return history.BoxPtr(evalue)