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
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
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
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)
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)
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)
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
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)
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)
def createexecutioncontext(self): "Factory function for execution contexts." return ExecutionContext(self)
def force_f_back(self): return ExecutionContext._force_back_of_frame(self)
def f_back(self): return ExecutionContext._extract_back_from_frame(self)
def fget_f_back(self, space): f_back = ExecutionContext.getnextframe_nohidden(self) return self.space.wrap(f_back)
def get_f_back(self): return ExecutionContext.getnextframe_nohidden(self)
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)
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)