Exemplo n.º 1
0
 def exc_handling(guard_op):
     # operations need to start with correct GUARD_EXCEPTION
     if guard_op._exc_box is None:
         op = ResOperation(rop.GUARD_NO_EXCEPTION, [], None)
     else:
         op = ResOperation(rop.GUARD_EXCEPTION, [guard_op._exc_box],
                           BoxPtr())
     op.descr = BasicFailDescr()
     op.fail_args = []
     return op
Exemplo n.º 2
0
 def exc_handling(guard_op):
     # operations need to start with correct GUARD_EXCEPTION
     if guard_op._exc_box is None:
         op = ResOperation(rop.GUARD_NO_EXCEPTION, [], None)
     else:
         op = ResOperation(rop.GUARD_EXCEPTION, [guard_op._exc_box],
                           BoxPtr())
     op.descr = BasicFailDescr()
     op.fail_args = []
     return op
Exemplo n.º 3
0
 def parse_result_op(self, line):
     res, op = line.split("=", 1)
     res = res.strip()
     op = op.strip()
     opnum, args, descr, fail_args = self.parse_op(op)
     if res in self.vars:
         raise ParseError("Double assign to var %s in line: %s" % (res, line))
     rvar = self.box_for_var(res)
     self.vars[res] = rvar
     res = ResOperation(opnum, args, rvar, descr)
     res.fail_args = fail_args
     return res
Exemplo n.º 4
0
 def parse_result_op(self, line):
     res, op = line.split("=", 1)
     res = res.strip()
     op = op.strip()
     opnum, args, descr, fail_args = self.parse_op(op)
     if res in self.vars:
         raise ParseError("Double assign to var %s in line: %s" %
                          (res, line))
     rvar = self.box_for_var(res)
     self.vars[res] = rvar
     res = ResOperation(opnum, args, rvar, descr)
     res.fail_args = fail_args
     return res
Exemplo n.º 5
0
 def produce_into(self, builder, r):
     fail_subset = builder.subset_of_intvars(r)
     subset, f, exc = self.raising_func_code(builder, r)
     TP = lltype.FuncType([lltype.Signed] * len(subset), lltype.Void)
     ptr = llhelper(lltype.Ptr(TP), f)
     c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
     args = [c_addr] + subset
     descr = builder.cpu.calldescrof(TP, TP.ARGS, TP.RESULT)
     self.put(builder, args, descr)
     exc_box = ConstAddr(llmemory.cast_ptr_to_adr(exc), builder.cpu)
     assert builder.cpu.get_exception()
     builder.cpu.clear_exception()
     op = ResOperation(rop.GUARD_EXCEPTION, [exc_box], BoxPtr(),
                       descr=BasicFailDescr())
     op.fail_args = fail_subset
     builder.loop.operations.append(op)
Exemplo n.º 6
0
 def produce_into(self, builder, r):
     fail_subset = builder.subset_of_intvars(r)
     original_intvars = builder.intvars[:]
     super(AbstractOvfOperation, self).produce_into(builder, r)
     if builder.cpu._overflow_flag:   # overflow detected
         del builder.cpu._overflow_flag
         op = ResOperation(rop.GUARD_OVERFLOW, [], None)
         # the overflowed result should not be used any more, but can
         # be used on the failure path: recompute fail_subset including
         # the result, and then remove it from builder.intvars.
         fail_subset = builder.subset_of_intvars(r)
         builder.intvars[:] = original_intvars
     else:
         op = ResOperation(rop.GUARD_NO_OVERFLOW, [], None)
     op.descr = BasicFailDescr()
     op.fail_args = fail_subset
     builder.loop.operations.append(op)
Exemplo n.º 7
0
 def produce_into(self, builder, r):
     fail_subset = builder.subset_of_intvars(r)
     original_intvars = builder.intvars[:]
     super(AbstractOvfOperation, self).produce_into(builder, r)
     if builder.cpu._overflow_flag:  # overflow detected
         del builder.cpu._overflow_flag
         op = ResOperation(rop.GUARD_OVERFLOW, [], None)
         # the overflowed result should not be used any more, but can
         # be used on the failure path: recompute fail_subset including
         # the result, and then remove it from builder.intvars.
         fail_subset = builder.subset_of_intvars(r)
         builder.intvars[:] = original_intvars
     else:
         op = ResOperation(rop.GUARD_NO_OVERFLOW, [], None)
     op.descr = BasicFailDescr()
     op.fail_args = fail_subset
     builder.loop.operations.append(op)
Exemplo n.º 8
0
 def produce_into(self, builder, r):
     fail_subset = builder.subset_of_intvars(r)
     subset, f = self.non_raising_func_code(builder, r)
     if len(subset) == 0:
         RES = lltype.Void
     else:
         RES = lltype.Signed
     TP = lltype.FuncType([lltype.Signed] * len(subset), RES)
     ptr = llhelper(lltype.Ptr(TP), f)
     c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
     args = [c_addr] + subset
     descr = builder.cpu.calldescrof(TP, TP.ARGS, TP.RESULT)
     self.put(builder, args, descr)
     op = ResOperation(rop.GUARD_NO_EXCEPTION, [], None,
                       descr=BasicFailDescr())
     op.fail_args = fail_subset
     builder.loop.operations.append(op)
Exemplo n.º 9
0
 def produce_into(self, builder, r):
     subset, f = self.non_raising_func_code(builder, r)
     if len(subset) == 0:
         RES = lltype.Void
     else:
         RES = lltype.Signed
     TP = lltype.FuncType([lltype.Signed] * len(subset), RES)
     ptr = llhelper(lltype.Ptr(TP), f)
     c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
     args = [c_addr] + subset
     descr = builder.cpu.calldescrof(TP, TP.ARGS, TP.RESULT)
     self.put(builder, args, descr)
     _, vtableptr = builder.get_random_structure_type_and_vtable(r)
     exc_box = ConstAddr(llmemory.cast_ptr_to_adr(vtableptr), builder.cpu)
     op = ResOperation(rop.GUARD_EXCEPTION, [exc_box], BoxPtr(),
                       descr=BasicFailDescr())
     op.fail_args = builder.subset_of_intvars(r)
     op._exc_box = None
     builder.should_fail_by = op
     builder.guard_op = op
     builder.loop.operations.append(op)
Exemplo n.º 10
0
 def produce_into(self, builder, r):
     subset, f, exc = self.raising_func_code(builder, r)
     TP = lltype.FuncType([lltype.Signed] * len(subset), lltype.Void)
     ptr = llhelper(lltype.Ptr(TP), f)
     c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
     args = [c_addr] + subset
     descr = builder.cpu.calldescrof(TP, TP.ARGS, TP.RESULT)
     self.put(builder, args, descr)
     assert builder.cpu.get_exception()
     builder.cpu.clear_exception()
     while True:
         _, vtableptr = builder.get_random_structure_type_and_vtable(r)
         if vtableptr != exc:
             break
     other_box = ConstAddr(llmemory.cast_ptr_to_adr(vtableptr), builder.cpu)
     op = ResOperation(rop.GUARD_EXCEPTION, [other_box], BoxPtr(),
                       descr=BasicFailDescr())
     op._exc_box = ConstAddr(llmemory.cast_ptr_to_adr(exc), builder.cpu)
     op.fail_args = builder.subset_of_intvars(r)
     builder.should_fail_by = op
     builder.guard_op = op
     builder.loop.operations.append(op)
Exemplo n.º 11
0
 def parse_op_no_result(self, line):
     opnum, args, descr, fail_args = self.parse_op(line)
     res = ResOperation(opnum, args, None, descr)
     res.fail_args = fail_args
     return res
Exemplo n.º 12
0
 def parse_op_no_result(self, line):
     opnum, args, descr, fail_args = self.parse_op(line)
     res = ResOperation(opnum, args, None, descr)
     res.fail_args = fail_args
     return res