Beispiel #1
0
 def store_final_boxes_in_guard(self, op):
     descr = op.getdescr()
     assert isinstance(descr, compile.ResumeGuardDescr)
     modifier = resume.ResumeDataVirtualAdder(descr, self.resumedata_memo)
     newboxes = modifier.finish(self.values, self.pendingfields)
     if len(newboxes) > self.metainterp_sd.options.failargs_limit: # XXX be careful here
         compile.giveup()
     descr.store_final_boxes(op, newboxes)
     #
     if op.getopnum() == rop.GUARD_VALUE:
         if self.getvalue(op.getarg(0)) in self.bool_boxes:
             # Hack: turn guard_value(bool) into guard_true/guard_false.
             # This is done after the operation is emitted to let
             # store_final_boxes_in_guard set the guard_opnum field of the
             # descr to the original rop.GUARD_VALUE.
             constvalue = op.getarg(1).getint()
             if constvalue == 0:
                 opnum = rop.GUARD_FALSE
             elif constvalue == 1:
                 opnum = rop.GUARD_TRUE
             else:
                 raise AssertionError("uh?")
             newop = ResOperation(opnum, [op.getarg(0)], op.result, descr)
             newop.setfailargs(op.getfailargs())
             return newop
         else:
             # a real GUARD_VALUE.  Make it use one counter per value.
             descr.make_a_counter_per_value(op)
     return op
Beispiel #2
0
 def store_final_boxes_in_guard(self, op):
     descr = op.getdescr()
     assert isinstance(descr, compile.ResumeGuardDescr)
     modifier = resume.ResumeDataVirtualAdder(descr, self.resumedata_memo)
     try:
         newboxes = modifier.finish(self, self.pendingfields)
         if len(newboxes) > self.metainterp_sd.options.failargs_limit:
             raise resume.TagOverflow
     except resume.TagOverflow:
         raise compile.giveup()
     descr.store_final_boxes(op, newboxes)
     #
     if op.getopnum() == rop.GUARD_VALUE:
         if self.getvalue(op.getarg(0)) in self.bool_boxes:
             # Hack: turn guard_value(bool) into guard_true/guard_false.
             # This is done after the operation is emitted to let
             # store_final_boxes_in_guard set the guard_opnum field of the
             # descr to the original rop.GUARD_VALUE.
             constvalue = op.getarg(1).getint()
             if constvalue == 0:
                 opnum = rop.GUARD_FALSE
             elif constvalue == 1:
                 opnum = rop.GUARD_TRUE
             else:
                 raise AssertionError("uh?")
             newop = ResOperation(opnum, [op.getarg(0)], op.result, descr)
             newop.setfailargs(op.getfailargs())
             return newop
         else:
             # a real GUARD_VALUE.  Make it use one counter per value.
             descr.make_a_counter_per_value(op)
     return op
Beispiel #3
0
 def _add_pending_fields(self, pending_setfields):
     rd_pendingfields = lltype.nullptr(PENDINGFIELDSP.TO)
     if pending_setfields:
         n = len(pending_setfields)
         rd_pendingfields = lltype.malloc(PENDINGFIELDSP.TO, n)
         for i in range(n):
             descr, box, fieldbox, itemindex = pending_setfields[i]
             lldescr = annlowlevel.cast_instance_to_base_ptr(descr)
             num = self._gettagged(box)
             fieldnum = self._gettagged(fieldbox)
             # the index is limited to 2147483647 (64-bit machines only)
             if itemindex > 2147483647:
                 from pypy.jit.metainterp import compile
                 compile.giveup()
             itemindex = rffi.cast(rffi.INT, itemindex)
             #
             rd_pendingfields[i].lldescr  = lldescr
             rd_pendingfields[i].num      = num
             rd_pendingfields[i].fieldnum = fieldnum
             rd_pendingfields[i].itemindex= itemindex
     self.storage.rd_pendingfields = rd_pendingfields