當前位置: 首頁>>代碼示例>>Python>>正文


Python resoperation.ResOperation類代碼示例

本文整理匯總了Python中pypy.jit.metainterp.resoperation.ResOperation的典型用法代碼示例。如果您正苦於以下問題:Python ResOperation類的具體用法?Python ResOperation怎麽用?Python ResOperation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ResOperation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: has_pure_result

 def has_pure_result(self, opnum, args, descr):
     op = ResOperation(opnum, args, None, descr)
     key = self.optimizer.make_args_key(op)
     op = self.optimizer.pure_operations.get(key, None)
     if op is None:
         return False
     return op.getdescr() is descr
開發者ID:ieure,項目名稱:pypy,代碼行數:7,代碼來源:optimizer.py

示例2: store_final_boxes_in_guard

 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
開發者ID:,項目名稱:,代碼行數:29,代碼來源:

示例3: exc_handling

 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
開發者ID:alkorzt,項目名稱:pypy,代碼行數:10,代碼來源:test_random.py

示例4: optimize_NEW_ARRAY

 def optimize_NEW_ARRAY(self, op):
     sizebox = self.get_constant_box(op.getarg(0))
     if sizebox is not None:
         # if the original 'op' did not have a ConstInt as argument,
         # build a new one with the ConstInt argument
         if not isinstance(op.getarg(0), ConstInt):
             op = ResOperation(rop.NEW_ARRAY, [sizebox], op.result, descr=op.getdescr())
         self.make_varray(op.getdescr(), sizebox.getint(), op.result, op)
     else:
         self.getvalue(op.result).ensure_nonnull()
         self.emit_operation(op)
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例5: parse_result_op

 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
開發者ID:enyst,項目名稱:plexnet,代碼行數:12,代碼來源:oparser.py

示例6: _optimize_NEWSTR

 def _optimize_NEWSTR(self, op, mode):
     length_box = self.get_constant_box(op.getarg(0))
     if length_box:
         # if the original 'op' did not have a ConstInt as argument,
         # build a new one with the ConstInt argument
         if not isinstance(op.getarg(0), ConstInt):
             op = ResOperation(mode.NEWSTR, [length_box], op.result)
         vvalue = self.make_vstring_plain(op.result, op, mode)
         vvalue.setup(length_box.getint())
     else:
         self.getvalue(op.result).ensure_nonnull()
         self.emit_operation(op)
         self.pure(mode.STRLEN, [op.result], op.getarg(0))
開發者ID:,項目名稱:,代碼行數:13,代碼來源:

示例7: produce_into

 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)
     op = ResOperation(rop.GUARD_EXCEPTION, [exc_box], BoxPtr(),
                       descr=BasicFailDescr())
     op.setfailargs(fail_subset)
     builder.loop.operations.append(op)
開發者ID:gorakhargosh,項目名稱:pypy,代碼行數:14,代碼來源:test_ll_random.py

示例8: produce_into

 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 = self.getcalldescr(builder, TP)
     self.put(builder, args, descr)
     op = ResOperation(rop.GUARD_NO_EXCEPTION, [], BoxPtr(),
                       descr=BasicFailDescr())
     op._exc_box = ConstAddr(llmemory.cast_ptr_to_adr(exc), builder.cpu)
     op.setfailargs(builder.subset_of_intvars(r))
     builder.should_fail_by = op
     builder.guard_op = op
     builder.loop.operations.append(op)
開發者ID:Debug-Orz,項目名稱:Sypy,代碼行數:15,代碼來源:test_ll_random.py

示例9: produce_into

 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)
開發者ID:alkorzt,項目名稱:pypy,代碼行數:17,代碼來源:test_random.py

示例10: produce_into

 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)
開發者ID:alkorzt,項目名稱:pypy,代碼行數:17,代碼來源:test_ll_random.py

示例11: produce_into

 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()
     op = ResOperation(rop.GUARD_NO_EXCEPTION, [], BoxPtr(),
                       descr=builder.make_fail_descr())
     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)
開發者ID:enyst,項目名稱:plexnet,代碼行數:17,代碼來源:test_ll_random.py

示例12: _really_force

 def _really_force(self, optforce):
     if self.mode is mode_string:
         s = self.get_constant_string_spec(mode_string)
         if s is not None:
             c_s = get_const_ptr_for_string(s)
             self.make_constant(c_s)
             return
     else:
         s = self.get_constant_string_spec(mode_unicode)
         if s is not None:
             c_s = get_const_ptr_for_unicode(s)
             self.make_constant(c_s)
             return
     assert self.source_op is not None
     self.box = box = self.source_op.result
     lengthbox = self.getstrlen(optforce, self.mode)
     op = ResOperation(self.mode.NEWSTR, [lengthbox], box)
     if not we_are_translated():
         op.name = 'FORCE'
     optforce.emit_operation(op)
     self.string_copy_parts(optforce, box, CONST_0, self.mode)
開發者ID:,項目名稱:,代碼行數:21,代碼來源:

示例13: handle_malloc_operation

 def handle_malloc_operation(self, op):
     opnum = op.getopnum()
     if opnum == rop.NEW:
         self.handle_new_fixedsize(op.getdescr(), op)
     elif opnum == rop.NEW_WITH_VTABLE:
         classint = op.getarg(0).getint()
         descr = heaptracker.vtable2descr(self.cpu, classint)
         self.handle_new_fixedsize(descr, op)
         if self.gc_ll_descr.fielddescr_vtable is not None:
             op = ResOperation(rop.SETFIELD_GC,
                               [op.result, ConstInt(classint)], None,
                               descr=self.gc_ll_descr.fielddescr_vtable)
             self.newops.append(op)
     elif opnum == rop.NEW_ARRAY:
         descr = op.getdescr()
         assert isinstance(descr, ArrayDescr)
         self.handle_new_array(descr, op)
     elif opnum == rop.NEWSTR:
         self.handle_new_array(self.gc_ll_descr.str_descr, op)
     elif opnum == rop.NEWUNICODE:
         self.handle_new_array(self.gc_ll_descr.unicode_descr, op)
     else:
         raise NotImplementedError(op.getopname())
開發者ID:Debug-Orz,項目名稱:Sypy,代碼行數:23,代碼來源:rewrite.py

示例14: produce_into

 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.fakemetainterp._got_exc:  # overflow detected
         assert isinstance(builder.fakemetainterp._got_exc, OverflowError)
         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.setdescr(BasicFailDescr())
     op.setfailargs(fail_subset)
     builder.loop.operations.append(op)
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例15: optimize_VIRTUAL_REF

 def optimize_VIRTUAL_REF(self, op):
     op = ResOperation(rop.SAME_AS, [op.getarg(0)], op.result)
     self.emit_operation(op)
開發者ID:junion,項目名稱:butlerbot-unstable,代碼行數:3,代碼來源:simplify.py


注:本文中的pypy.jit.metainterp.resoperation.ResOperation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。