예제 #1
0
    def __init__(self,
                 space,
                 code,
                 globals,
                 constargs={},
                 outer_func=None,
                 name=None,
                 is_generator=False):
        ExecutionContext.__init__(self, space)
        self.code = code

        self.w_globals = w_globals = space.wrap(globals)

        self.crnt_offset = -1
        self.crnt_frame = None
        if outer_func and outer_func.closure:
            self.closure = [
                nestedscope.Cell(Constant(value))
                for value in outer_func.closure
            ]
        else:
            self.closure = None
        frame = self.create_frame()
        formalargcount = code.getformalargcount()
        arg_list = [Variable() for i in range(formalargcount)]
        for position, value in constargs.items():
            arg_list[position] = Constant(value)
        frame.setfastscope(arg_list)
        self.joinpoints = {}
        initialblock = SpamBlock(FrameState(frame).copy())
        self.pendingblocks = collections.deque([initialblock])
        self.graph = FunctionGraph(name or code.co_name, initialblock)
        self.is_generator = is_generator
예제 #2
0
    def __init__(self, space, code, globals, constargs={}, outer_func=None,
                 name=None, is_generator=False):
        ExecutionContext.__init__(self, space)
        self.code = code

        self.w_globals = w_globals = space.wrap(globals)

        self.crnt_offset = -1
        self.crnt_frame = None
        if outer_func and outer_func.closure:
            self.closure = [nestedscope.Cell(Constant(value))
                            for value in outer_func.closure]
        else:
            self.closure = None
        frame = self.create_frame()
        formalargcount = code.getformalargcount()
        arg_list = [Variable() for i in range(formalargcount)]
        for position, value in constargs.items():
            arg_list[position] = Constant(value)
        frame.setfastscope(arg_list)
        self.joinpoints = {}
        initialblock = SpamBlock(FrameState(frame).copy())
        self.pendingblocks = collections.deque([initialblock])
        self.graph = FunctionGraph(name or code.co_name, initialblock)
        self.is_generator = is_generator
예제 #3
0
    def test_check_escaping_jitted_with_two_differen_virtualizables(self):
        ec, frame, frame2 = self.enter_two_jitted_levels()

        frame3 = self.Frame(ec, frame)
        ec._chain(frame3)
        # frame3 is not inlined, but contains a loop itself, for which code has
        # been generated
        ExecutionContext._jit_rechain_frame(ec, frame3)
        ec.virtualizable = frame3

        frame3.look_at()
        assert not frame2.escaped
        assert frame3.escaped

        frame4 = self.Frame(ec, frame3)
        ec._chain(frame4)
        assert ec.framestackdepth == 4
        assert not frame4.escaped

        ec._unchain(frame4)
        assert frame3.escaped
        assert not frame2.escaped

        ec.virtualizable = frame

        ec._unchain(frame3)
        assert not frame2.escaped
예제 #4
0
    def test_check_escaping_multi_non_jitted_levels(self):
        ec, frame, frame2 = self.enter_two_jitted_levels()

        # recursive enter/leave seen by the jit
        frame3 = self.Frame(ec, frame)
        ec._chain(frame3)
        ExecutionContext._jit_rechain_frame(ec, frame3)
        ec.jitted = False

        assert frame3.escaped
        assert not frame2.escaped
        assert frame3.escaped

        frame4 = self.Frame(ec)
        ec._chain(frame4)
        assert ec.framestackdepth == 4

        ec._unchain(frame4)
        assert frame3.escaped
        assert not frame2.escaped

        ec.jitted = True
        assert frame3.f_back() is frame2
        ec._unchain(frame3)
        assert not frame2.escaped

        self.leave_two_jitted_levels(ec, frame, frame2)
예제 #5
0
    def test_check_escaping_multi_non_jitted_levels(self):
        ec, frame, frame2 = self.enter_two_jitted_levels()

        # recursive enter/leave seen by the jit
        frame3 = self.Frame(ec, frame)
        ec._chain(frame3)
        ExecutionContext._jit_rechain_frame(ec, frame3)
        ec.jitted = False

        assert frame3.escaped
        assert not frame2.escaped
        assert frame3.escaped

        frame4 = self.Frame(ec)
        ec._chain(frame4)
        assert ec.framestackdepth == 4

        ec._unchain(frame4)
        assert frame3.escaped
        assert not frame2.escaped

        ec.jitted = True
        assert frame3.f_back() is frame2
        ec._unchain(frame3)
        assert not frame2.escaped
      
        self.leave_two_jitted_levels(ec, frame, frame2)
예제 #6
0
    def test_check_escaping_jitted_with_two_differen_virtualizables(self):
        ec, frame, frame2 = self.enter_two_jitted_levels()

        frame3 = self.Frame(ec, frame)
        ec._chain(frame3)
        # frame3 is not inlined, but contains a loop itself, for which code has
        # been generated
        ExecutionContext._jit_rechain_frame(ec, frame3)
        ec.virtualizable = frame3

        frame3.look_at()
        assert not frame2.escaped
        assert frame3.escaped

        frame4 = self.Frame(ec, frame3)
        ec._chain(frame4)
        assert ec.framestackdepth == 4
        assert not frame4.escaped

        ec._unchain(frame4)
        assert frame3.escaped
        assert not frame2.escaped

        ec.virtualizable = frame

        ec._unchain(frame3)
        assert not frame2.escaped
예제 #7
0
 def __init__(self, space, code, globals, constargs={}, closure=None,
              name=None):
     ExecutionContext.__init__(self, space)
     self.code = code
     
     self.w_globals = w_globals = space.wrap(globals)
     
     self.crnt_offset = -1
     self.crnt_frame = None
     if closure is None:
         self.closure = None
     else:
         from pypy.interpreter.nestedscope import Cell
         self.closure = [Cell(Constant(value)) for value in closure]
     frame = self.create_frame()
     formalargcount = code.getformalargcount()
     arg_list = [Variable() for i in range(formalargcount)]
     for position, value in constargs.items():
         arg_list[position] = Constant(value)
     frame.setfastscope(arg_list)
     self.joinpoints = {}
     #for joinpoint in code.getjoinpoints():
     #    self.joinpoints[joinpoint] = []  # list of blocks
     initialblock = SpamBlock(FrameState(frame).copy())
     self.pendingblocks = collections.deque([initialblock])
     self.graph = FunctionGraph(name or code.co_name, initialblock)
예제 #8
0
 def __init__(self, space, code, globals, constargs={}, closure=None,
              name=None):
     ExecutionContext.__init__(self, space)
     self.code = code
     
     self.w_globals = w_globals = space.wrap(globals)
     
     self.crnt_offset = -1
     self.crnt_frame = None
     if closure is None:
         self.closure = None
     else:
         from pypy.interpreter.nestedscope import Cell
         self.closure = [Cell(Constant(value)) for value in closure]
     frame = self.create_frame()
     formalargcount = code.getformalargcount()
     arg_list = [Variable() for i in range(formalargcount)]
     for position, value in constargs.items():
         arg_list[position] = Constant(value)
     frame.setfastscope(arg_list)
     self.joinpoints = {}
     #for joinpoint in code.getjoinpoints():
     #    self.joinpoints[joinpoint] = []  # list of blocks
     initialblock = SpamBlock(FrameState(frame).copy())
     self.pendingblocks = [initialblock]
     self.graph = FunctionGraph(name or code.co_name, initialblock)
예제 #9
0
파일: flowcontext.py 프로젝트: alkorzt/pypy
 def sys_exc_info(self):
     operr = ExecutionContext.sys_exc_info(self)
     if isinstance(operr, ImplicitOperationError):
         # re-raising an implicit operation makes it an explicit one
         w_value = operr.get_w_value(self.space)
         operr = OperationError(operr.w_type, w_value)
     return operr
예제 #10
0
 def sys_exc_info(self):
     operr = ExecutionContext.sys_exc_info(self)
     if isinstance(operr, ImplicitOperationError):
         # re-raising an implicit operation makes it an explicit one
         w_value = operr.get_w_value(self.space)
         operr = OperationError(operr.w_type, w_value)
     return operr
예제 #11
0
    def test_check_escaping_not_all_inlined_enter_leave_seen(self):
        ec, frame, frame2 = self.enter_two_jitted_levels()

        # recursive enter/leave seen by the jit
        frame3 = self.Frame(ec, frame)
        ec._chain(frame3)
        ExecutionContext._jit_rechain_frame(ec, frame3)
        ec.jitted = False
        frame3.look_at()
        assert not frame2.escaped
        assert frame3.escaped

        ec.jitted = True
        assert frame3.f_back() is frame2
        ec._unchain(frame3)
        assert not frame2.escaped
      
        self.leave_two_jitted_levels(ec, frame, frame2)
예제 #12
0
파일: pyframe.py 프로젝트: enyst/plexnet
 def __init__(self, space, code, w_globals, closure):
     self = hint(self, access_directly=True, fresh_virtualizable=True)
     assert isinstance(code, pycode.PyCode)
     self.pycode = code
     eval.Frame.__init__(self, space, w_globals, code.co_nlocals)
     self.valuestack_w = [None] * code.co_stacksize
     self.valuestackdepth = 0
     self.lastblock = None
     self.blockcount = 0
     if space.config.objspace.honor__builtins__:
         self.builtin = space.builtin.pick_builtin(w_globals)
     # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
     # class bodies only have CO_NEWLOCALS.
     self.initialize_frame_scopes(closure, code)
     self.fastlocals_w = [None]*self.numlocals
     make_sure_not_resized(self.fastlocals_w)
     self.f_lineno = code.co_firstlineno
     ExecutionContext._init_chaining_attributes(self)
예제 #13
0
    def test_check_escaping_not_all_inlined_enter_leave_seen(self):
        ec, frame, frame2 = self.enter_two_jitted_levels()

        # recursive enter/leave seen by the jit
        frame3 = self.Frame(ec, frame)
        ec._chain(frame3)
        ExecutionContext._jit_rechain_frame(ec, frame3)
        ec.jitted = False
        frame3.look_at()
        assert not frame2.escaped
        assert frame3.escaped

        ec.jitted = True
        assert frame3.f_back() is frame2
        ec._unchain(frame3)
        assert not frame2.escaped

        self.leave_two_jitted_levels(ec, frame, frame2)
예제 #14
0
 def createexecutioncontext(self):
     "Factory function for execution contexts."
     return ExecutionContext(self)
예제 #15
0
파일: pyframe.py 프로젝트: enyst/plexnet
 def force_f_back(self):
     return ExecutionContext._force_back_of_frame(self)
예제 #16
0
파일: pyframe.py 프로젝트: enyst/plexnet
 def f_back(self):
     return ExecutionContext._extract_back_from_frame(self)
예제 #17
0
파일: pyframe.py 프로젝트: kipras/pypy
 def fget_f_back(self, space):
     f_back = ExecutionContext.getnextframe_nohidden(self)
     return self.space.wrap(f_back)
예제 #18
0
 def get_f_back(self):
     return ExecutionContext.getnextframe_nohidden(self)
예제 #19
0
파일: pyframe.py 프로젝트: purepython/pypy
 def fget_f_back(self, space):
     f_back = ExecutionContext.getnextframe_nohidden(self)
     return self.space.wrap(f_back)
예제 #20
0
 def __init__(self, ec, virtual_with_base_frame=None):
     self.ec = ec
     self.virtual_with_base_frame = virtual_with_base_frame
     self.escaped = not virtual_with_base_frame
     ExecutionContext._init_chaining_attributes(self)
예제 #21
0
파일: interp_jit.py 프로젝트: enyst/plexnet
def leave(next_instr, pycode, frame, ec):
    from pypy.interpreter.executioncontext import ExecutionContext
    # can't use a method here, since this function is seen later than the main
    # annotation       XXX no longer true, could be fixed
    ExecutionContext._jit_rechain_frame(ec, frame)
예제 #22
0
 def force_f_back(self):
     return ExecutionContext._force_back_of_frame(self)
예제 #23
0
 def f_back(self):
     return ExecutionContext._extract_back_from_frame(self)
예제 #24
0
 def __init__(self, ec, virtual_with_base_frame=None):
     self.ec = ec
     self.virtual_with_base_frame = virtual_with_base_frame
     self.escaped = not virtual_with_base_frame
     ExecutionContext._init_chaining_attributes(self)
예제 #25
0
def leave(next_instr, pycode, frame, ec):
    from pypy.interpreter.executioncontext import ExecutionContext
    # can't use a method here, since this function is seen later than the main
    # annotation       XXX no longer true, could be fixed
    ExecutionContext._jit_rechain_frame(ec, frame)