• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python objectmodel.we_are_translated函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.rlib.objectmodel.we_are_translated函数的典型用法代码示例。如果您正苦于以下问题:Python we_are_translated函数的具体用法?Python we_are_translated怎么用?Python we_are_translated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了we_are_translated函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: send_loop_to_backend

def send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd, loop, type):
    jitdriver_sd.on_compile(metainterp_sd.logger_ops, loop.token, loop.operations, type, greenkey)
    loopname = jitdriver_sd.warmstate.get_location_str(greenkey)
    globaldata = metainterp_sd.globaldata
    loop_token = loop.token
    loop_token.number = n = globaldata.loopnumbering
    globaldata.loopnumbering += 1

    if not we_are_translated():
        show_loop(metainterp_sd, loop)
        loop.check_consistency()

    operations = get_deep_immutable_oplist(loop.operations)
    metainterp_sd.profiler.start_backend()
    debug_start("jit-backend")
    try:
        ops_offset = metainterp_sd.cpu.compile_loop(loop.inputargs, operations, loop.token, name=loopname)
    finally:
        debug_stop("jit-backend")
    metainterp_sd.profiler.end_backend()
    metainterp_sd.stats.add_new_loop(loop)
    if not we_are_translated():
        if type != "entry bridge":
            metainterp_sd.stats.compiled()
        else:
            loop._ignore_during_counting = True
    metainterp_sd.log("compiled new " + type)
    #
    metainterp_sd.logger_ops.log_loop(loop.inputargs, loop.operations, n, type, ops_offset)
    short = loop.token.short_preamble
    if short:
        metainterp_sd.logger_ops.log_short_preamble(short[-1].inputargs, short[-1].operations)
    #
    if metainterp_sd.warmrunnerdesc is not None:  # for tests
        metainterp_sd.warmrunnerdesc.memory_manager.keep_loop_alive(loop.token)
开发者ID:pombredanne,项目名称:pypy,代码行数:35,代码来源:compile.py


示例2: send_bridge_to_backend

def send_bridge_to_backend(jitdriver_sd, metainterp_sd, faildescr, inputargs, operations, original_loop_token):
    n = metainterp_sd.cpu.get_fail_descr_number(faildescr)
    if not we_are_translated():
        show_procedures(metainterp_sd)
        seen = dict.fromkeys(inputargs)
        TreeLoop.check_consistency_of_branch(operations, seen)
    if metainterp_sd.warmrunnerdesc is not None:
        hooks = metainterp_sd.warmrunnerdesc.hooks
        debug_info = JitDebugInfo(
            jitdriver_sd, metainterp_sd.logger_ops, original_loop_token, operations, "bridge", fail_descr_no=n
        )
        hooks.before_compile_bridge(debug_info)
    else:
        hooks = None
        debug_info = None
    operations = get_deep_immutable_oplist(operations)
    metainterp_sd.profiler.start_backend()
    debug_start("jit-backend")
    try:
        asminfo = do_compile_bridge(metainterp_sd, faildescr, inputargs, operations, original_loop_token)
    finally:
        debug_stop("jit-backend")
    metainterp_sd.profiler.end_backend()
    if hooks is not None:
        debug_info.asminfo = asminfo
        hooks.after_compile_bridge(debug_info)
    if not we_are_translated():
        metainterp_sd.stats.compiled()
    metainterp_sd.log("compiled new bridge")
    #
    if asminfo is not None:
        ops_offset = asminfo.ops_offset
    else:
        ops_offset = None
    metainterp_sd.logger_ops.log_bridge(inputargs, operations, n, ops_offset)
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:35,代码来源:compile.py


示例3: generate_operations

    def generate_operations(self, mc):
        if not we_are_translated():
            print

        # reserve locations for the inputvars
        for i in range(len(self.inputvars_gv)):
            v = self.inputvars_gv[i]
            if v in self.lifetime:   # else: input argument is not used
                loc = self.inputlocations[i]
                if v in self.var2loc:   # duplicate inputvars_gv, which is ok
                    assert self.var2loc[v] == loc
                else:
                    self.var2loc[v] = loc
                    self.vars_in_use[v] = self.lifetime[v]
                    self.force_loc_used(v, loc)
                if not we_are_translated():
                    print 'in %20s:  %s' % (loc, short(v))

        self._check()
        self.mc = mc
        # Generate all operations.
        # Actual registers or stack locations are allocated as we go.
        for i in range(len(self.operations)):
            self.registers_pinned = 0        # bitmask
            op = self.operations[i]
            if op.clobbers_cc:
                self.clobber_cc()
                self._check()
            op.generate(self)
            if not we_are_translated():
                self._showprogress()
            self.operationindex = i + 1
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:32,代码来源:regalloc.py


示例4: f

        def f():
            state.gil = allocate_ll_lock()
            acquire_NOAUTO(state.gil, True)
            state.bootstrapping = allocate_lock()
            state.answers = []
            state.finished = 0
            # the next line installs before_extcall() and after_extcall()
            # to be called automatically around external function calls.
            # When not translated it does not work around time.sleep(),
            # so we have to call them manually for this test.
            invoke_around_extcall(before_extcall, after_extcall)

            g(10, 1)
            done = False
            willing_to_wait_more = 2000
            while not done:
                if not willing_to_wait_more:
                    break
                willing_to_wait_more -= 1
                done = len(state.answers) == expected

                if not we_are_translated(): before_extcall()
                time.sleep(0.01)
                if not we_are_translated(): after_extcall()

            if not we_are_translated(): before_extcall()
            time.sleep(0.1)
            if not we_are_translated(): after_extcall()

            return len(state.answers)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:30,代码来源:test_ll_thread.py


示例5: _really_force

    def _really_force(self):
        op = self.source_op
        assert op is not None
        # ^^^ This case should not occur any more (see test_bug_3).
        #
        if not we_are_translated():
            op.name = 'FORCE ' + self.source_op.name

        if self._is_immutable_and_filled_with_constants():
            box = self.optimizer.constant_fold(op)
            self.make_constant(box)
            for ofs, value in self._fields.iteritems():
                subbox = value.force_box()
                assert isinstance(subbox, Const)
                execute(self.optimizer.cpu, None, rop.SETFIELD_GC,
                        ofs, box, subbox)
            # keep self._fields, because it's all immutable anyway
        else:
            newoperations = self.optimizer.newoperations
            newoperations.append(op)
            self.box = box = op.result
            #
            iteritems = self._fields.iteritems()
            if not we_are_translated(): #random order is fine, except for tests
                iteritems = list(iteritems)
                iteritems.sort(key = lambda (x,y): x.sort_key())
            for ofs, value in iteritems:
                if value.is_null():
                    continue
                subbox = value.force_box()
                op = ResOperation(rop.SETFIELD_GC, [box, subbox], None,
                                  descr=ofs)
                newoperations.append(op)
            self._fields = None
开发者ID:ieure,项目名称:pypy,代码行数:34,代码来源:virtualize.py


示例6: send_loop_to_backend

def send_loop_to_backend(metainterp_sd, loop, type):
    globaldata = metainterp_sd.globaldata
    loop_token = loop.token
    loop_token.number = n = globaldata.loopnumbering
    globaldata.loopnumbering += 1

    metainterp_sd.logger_ops.log_loop(loop.inputargs, loop.operations, n, type)
    if not we_are_translated():
        show_loop(metainterp_sd, loop)
        loop.check_consistency()
    metainterp_sd.profiler.start_backend()
    debug_start("jit-backend")
    try:
        metainterp_sd.cpu.compile_loop(loop.inputargs, loop.operations,
                                       loop.token)
    finally:
        debug_stop("jit-backend")
    metainterp_sd.profiler.end_backend()
    metainterp_sd.stats.add_new_loop(loop)
    if not we_are_translated():
        if type != "entry bridge":
            metainterp_sd.stats.compiled()
        else:
            loop._ignore_during_counting = True
    metainterp_sd.log("compiled new " + type)
开发者ID:alkorzt,项目名称:pypy,代码行数:25,代码来源:compile.py


示例7: f

 def f():
     state.data = []
     state.threadlocals = gil.GILThreadLocals()
     state.threadlocals.setup_threads(space)
     thread.gc_thread_prepare()
     subident = thread.start_new_thread(bootstrap, ())
     mainident = thread.get_ident()
     runme()
     still_waiting = 3000
     while len(state.data) < 2*N:
         if not still_waiting:
             raise ValueError("time out")
         still_waiting -= 1
         if not we_are_translated(): gil.before_external_call()
         time.sleep(0.01)
         if not we_are_translated(): gil.after_external_call()
     i1 = i2 = 0
     for tid, i in state.data:
         if tid == mainident:
             assert i == i1; i1 += 1
         elif tid == subident:
             assert i == i2; i2 += 1
         else:
             assert 0
     assert i1 == N
     assert i2 == N
     return len(state.data)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:27,代码来源:test_gil.py


示例8: send_bridge_to_backend

def send_bridge_to_backend(metainterp_sd, faildescr, inputargs, operations):
    n = faildescr.get_index()
    metainterp_sd.logger_ops.log_bridge(inputargs, operations, n)
    metainterp_sd.profiler.start_backend()
    if not we_are_translated():
        show_loop(metainterp_sd)
        TreeLoop.check_consistency_of(inputargs, operations)
        pass
    metainterp_sd.cpu.compile_bridge(faildescr, inputargs, operations)        
    metainterp_sd.profiler.end_backend()
    if not we_are_translated():
        metainterp_sd.stats.compiled()
    metainterp_sd.log("compiled new bridge")            
开发者ID:enyst,项目名称:plexnet,代码行数:13,代码来源:compile.py


示例9: returns_bool_result

 def returns_bool_result(self):
     opnum = self.getopnum()
     if we_are_translated():
         assert opnum >= 0
     elif opnum < 0:
         return False     # for tests
     return opboolresult[opnum]
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:resoperation.py


示例10: gc_thread_after_fork

def gc_thread_after_fork(result_of_fork, opaqueaddr):
    """To call just after fork().
    """
    if we_are_translated():
        llop.gc_thread_after_fork(lltype.Void, result_of_fork, opaqueaddr)
    else:
        assert opaqueaddr == llmemory.NULL
开发者ID:gorakhargosh,项目名称:pypy,代码行数:7,代码来源:ll_thread.py


示例11: gc_thread_die

def gc_thread_die():
    """To call just before the final GIL release done by a dying
    thread.  After a thread_die(), no more gc operation should
    occur in this thread.
    """
    if we_are_translated():
        llop.gc_thread_die(lltype.Void)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:7,代码来源:ll_thread.py


示例12: call

 def call(self):
     space = self.space
     coro = AppCoroutine.w_getcurrent(space)
     assert isinstance(coro, AppCoroutine)
     cspace = coro._cspace
     w("-- initial DISTRIBUTOR thunk CALL in", str(id(coro)))
     sched.uler.trace_vars(coro, logic_args(self.args.unpack()))
     try:
         try:
             try:
                 _AppThunk.call(self)
             finally:
                 coro = AppCoroutine.w_getcurrent(space)
                 assert isinstance(coro, AppCoroutine)
                 cspace = coro._cspace
         except FailedSpace, exc:
             w("-- EXIT of DISTRIBUTOR %s, space is FAILED with %s" % (id(coro),
                                                                       str(exc)))
             failed_value = W_FailedValue(exc)
             interp_bind(cspace._solution, failed_value)
         except Exception, exc:
             # maybe app_level let something buble up ...
             w("-- exceptional EXIT of DISTRIBUTOR %s with %s" % (id(coro),
                                                                  str(exc)))
             if not we_are_translated():
                 import traceback
                 traceback.print_exc()
             failed_value = W_FailedValue(exc)
             sched.uler.dirty_traced_vars(coro, failed_value)
             interp_bind(cspace._solution, failed_value)
             cspace.fail()
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:31,代码来源:thunk.py


示例13: __init__

 def __init__(self, value=0):
     if not we_are_translated():
         if isinstance(value, int):
             value = int(value)    # bool -> int
         else:
             assert isinstance(value, Symbolic)
     self.value = value
开发者ID:jerroldgao,项目名称:pypy,代码行数:7,代码来源:history.py


示例14: __init__

 def __init__(self, w_type, w_value, tb=None):
     if not we_are_translated() and w_type is None:
         from pypy.tool.error import FlowingError
         raise FlowingError(w_value)
     self.setup(w_type)
     self._w_value = w_value
     self._application_traceback = tb
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:error.py


示例15: ll_arraycopy

def ll_arraycopy(source, dest, source_start, dest_start, length):
    from pypy.rpython.lltypesystem.lloperation import llop
    from pypy.rlib.objectmodel import keepalive_until_here

    # supports non-overlapping copies only
    if not we_are_translated():
        if source == dest:
            assert (source_start + length <= dest_start or
                    dest_start + length <= source_start)

    TP = lltype.typeOf(source).TO
    assert TP == lltype.typeOf(dest).TO
    if isinstance(TP.OF, lltype.Ptr) and TP.OF.TO._gckind == 'gc':
        # perform a write barrier that copies necessary flags from
        # source to dest
        if not llop.gc_writebarrier_before_copy(lltype.Bool, source, dest):
            # if the write barrier is not supported, copy by hand
            for i in range(length):
                dest[i + dest_start] = source[i + source_start]
            return
    source_addr = llmemory.cast_ptr_to_adr(source)
    dest_addr   = llmemory.cast_ptr_to_adr(dest)
    cp_source_addr = (source_addr + llmemory.itemoffsetof(TP, 0) +
                      llmemory.sizeof(TP.OF) * source_start)
    cp_dest_addr = (dest_addr + llmemory.itemoffsetof(TP, 0) +
                    llmemory.sizeof(TP.OF) * dest_start)
    
    llmemory.raw_memcopy(cp_source_addr, cp_dest_addr,
                         llmemory.sizeof(TP.OF) * length)
    keepalive_until_here(source)
    keepalive_until_here(dest)
开发者ID:ieure,项目名称:pypy,代码行数:31,代码来源:rgc.py


示例16: _write

 def _write(self, storage, width, i, offset, value):
     #value = byteswap(value) XXX
     if we_are_translated():
         libffi.array_setitem(clibffi.cast_type_to_ffitype(self.T),
                              width, storage, i, offset, value)
     else:
         libffi.array_setitem_T(self.T, width, storage, i, offset, value)
开发者ID:ParitoshThapliyal59,项目名称:pypy,代码行数:7,代码来源:types.py


示例17: _read

 def _read(self, storage, width, i, offset):
     if we_are_translated():
         res = libffi.array_getitem(clibffi.cast_type_to_ffitype(self.T),
                                     width, storage, i, offset)
     else:
         res = libffi.array_getitem_T(self.T, width, storage, i, offset)
     return byteswap(res)
开发者ID:ParitoshThapliyal59,项目名称:pypy,代码行数:7,代码来源:types.py


示例18: reraise

def reraise(lle):
    if we_are_translated():
        e = cast_base_ptr_to_instance(Exception, lle)
        raise e
    else:
        etype = rclass.ll_type(lle)
        raise LLException(etype, lle)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:jitexc.py


示例19: step

 def step(self):
     next = self.w_active_context.getNextBytecode()
     # we_are_translated returns false on top of CPython and true when
     # translating the interpreter
     if not objectmodel.we_are_translated():
         bytecodeimpl = BYTECODE_TABLE[next]
         if self._w_last_active_context != self.w_active_context:
             cnt = 0
             p = self.w_active_context
             # AK make method
             while p is not None:
                 cnt += 1
                 p = p.w_sender
             self._last_indent = "  " * cnt
             self._w_last_active_context = self.w_active_context
         if self.should_trace():
             
             print "%sStack=%s" % (
                 self._last_indent,
                 repr(self.w_active_context.stack),)
             print "%sBytecode at %d (%d:%s):" % (
                 self._last_indent,
                 self.w_active_context.pc,
                 next, bytecodeimpl.__name__,)
         bytecodeimpl(self.w_active_context, self)
     else:
         # this is a performance optimization: when translating the
         # interpreter, the bytecode dispatching is not implemented as a
         # list lookup and an indirect call but as a switch. The for loop
         # below produces the switch (by being unrolled).
         for code, bytecodeimpl in unrolling_bytecode_table:
             if code == next:
                 bytecodeimpl(self.w_active_context, self)
                 break
开发者ID:antoine1fr,项目名称:pygirl,代码行数:34,代码来源:interpreter.py


示例20: _dispatch_loop

 def _dispatch_loop(self):
     code = self.code.co_code
     instr_index = 0
     while True:
         jitdriver.jit_merge_point(code=code, instr_index=instr_index,
                                   frame=self)
         self.stack_depth = hint(self.stack_depth, promote=True)
         op = ord(code[instr_index])
         instr_index += 1
         if op >= opcode.HAVE_ARGUMENT:
             low = ord(code[instr_index])
             hi = ord(code[instr_index + 1])
             oparg = (hi << 8) | low
             instr_index += 2
         else:
             oparg = 0
         if we_are_translated():
             for opdesc in unrolling_opcode_descs:
                 if op == opdesc.index:
                     meth = getattr(self, opdesc.methodname)
                     instr_index = meth(oparg, instr_index, code)
                     break
             else:
                 raise MissingOpcode(op)
         else:
             meth = getattr(self, opcode_method_names[op])
             instr_index = meth(oparg, instr_index, code)
开发者ID:alkorzt,项目名称:pypy,代码行数:27,代码来源:interpreter.py



注:本文中的pypy.rlib.objectmodel.we_are_translated函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ebnfparse.make_parse_function函数代码示例发布时间:2022-05-27
下一篇:
Python objectmodel.r_dict函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap