Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 9
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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 12
0
 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)
Exemplo n.º 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)
Exemplo n.º 14
0
 def createexecutioncontext(self):
     "Factory function for execution contexts."
     return ExecutionContext(self)
Exemplo n.º 15
0
 def force_f_back(self):
     return ExecutionContext._force_back_of_frame(self)
Exemplo n.º 16
0
 def f_back(self):
     return ExecutionContext._extract_back_from_frame(self)
Exemplo n.º 17
0
 def fget_f_back(self, space):
     f_back = ExecutionContext.getnextframe_nohidden(self)
     return self.space.wrap(f_back)
Exemplo n.º 18
0
 def get_f_back(self):
     return ExecutionContext.getnextframe_nohidden(self)
Exemplo n.º 19
0
 def fget_f_back(self, space):
     f_back = ExecutionContext.getnextframe_nohidden(self)
     return self.space.wrap(f_back)
Exemplo n.º 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)
Exemplo n.º 21
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)
Exemplo n.º 22
0
 def force_f_back(self):
     return ExecutionContext._force_back_of_frame(self)
Exemplo n.º 23
0
 def f_back(self):
     return ExecutionContext._extract_back_from_frame(self)
Exemplo n.º 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)
Exemplo n.º 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)