def store_final_boxes_in_guard(self, op, pendingfields): assert pendingfields is not None if op.getdescr() is not None: descr = op.getdescr() assert isinstance(descr, compile.ResumeGuardDescr) else: descr = compile.invent_fail_descr_for_op(op.getopnum(), self) op.setdescr(descr) assert isinstance(descr, compile.ResumeGuardDescr) assert isinstance(op, GuardResOp) modifier = resume.ResumeDataVirtualAdder(self, descr, op, self.trace, self.resumedata_memo) try: newboxes = modifier.finish(pendingfields) if (newboxes is not None and len(newboxes) > self.metainterp_sd.options.failargs_limit): raise resume.TagOverflow except resume.TagOverflow: raise compile.giveup() # check no duplicates #if not we_are_translated(): seen = {} for box in newboxes: if box is not None: assert box not in seen seen[box] = None descr.store_final_boxes(op, newboxes, self.metainterp_sd) # if op.getopnum() == rop.GUARD_VALUE: op = self._maybe_replace_guard_value(op, descr) return op
def store_final_boxes_in_guard(self, op, pendingfields): assert pendingfields is not None if op.getdescr() is not None: descr = op.getdescr() assert isinstance(descr, compile.ResumeAtPositionDescr) else: descr = compile.invent_fail_descr_for_op(op.getopnum(), self) op.setdescr(descr) assert isinstance(descr, compile.ResumeGuardDescr) assert isinstance(op, GuardResOp) modifier = resume.ResumeDataVirtualAdder(descr, op, self.resumedata_memo) try: newboxes = modifier.finish(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, self.metainterp_sd) # 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