def f(n): res1 = -42 while n > 0: myjitdriver.jit_merge_point(n=n, res1=res1) x = X() res1 = residual(non_virtual_ref(x)) n -= 1 return res1
def leave_virtual_frame(self, vref, ref): self.set_state(InactiveContext) if vref is not jit.vref_None: jit.virtual_ref_finish(vref, ref) if vref is self._s_sender: # If this frame was not manipulated, _s_sender is still our # initial vref. If the frame was manipulated (or has no sender) # _s_sender is already a non_virtual_ref. self._s_sender = jit.non_virtual_ref(ref)
def descr__setstate__(self, space, w_args): from pypy.module._pickle_support import maker # helper fns from pypy.interpreter.pycode import PyCode from pypy.interpreter.module import Module args_w = space.unpackiterable(w_args, 18) w_f_back, w_builtin, w_pycode, w_valuestack, w_blockstack, w_exc_value, w_tb,\ w_globals, w_last_instr, w_finished, w_f_lineno, w_fastlocals, w_f_locals, \ w_f_trace, w_instr_lb, w_instr_ub, w_instr_prev_plus_one, w_cells = args_w new_frame = self pycode = space.interp_w(PyCode, w_pycode) if space.is_w(w_cells, space.w_None): closure = None cellvars = [] else: from pypy.interpreter.nestedscope import Cell cells_w = space.unpackiterable(w_cells) cells = [space.interp_w(Cell, w_cell) for w_cell in cells_w] ncellvars = len(pycode.co_cellvars) cellvars = cells[:ncellvars] closure = cells[ncellvars:] # do not use the instance's __init__ but the base's, because we set # everything like cells from here # XXX hack from pypy.interpreter.function import Function outer_func = Function(space, None, closure=closure, forcename="fake") PyFrame.__init__(self, space, pycode, w_globals, outer_func) f_back = space.interp_w(PyFrame, w_f_back, can_be_None=True) new_frame.f_backref = jit.non_virtual_ref(f_back) new_frame.builtin = space.interp_w(Module, w_builtin) new_frame.set_blocklist([unpickle_block(space, w_blk) for w_blk in space.unpackiterable(w_blockstack)]) values_w = maker.slp_from_tuple_with_nulls(space, w_valuestack) for w_value in values_w: new_frame.pushvalue(w_value) if space.is_w(w_exc_value, space.w_None): new_frame.last_exception = None else: from pypy.interpreter.pytraceback import PyTraceback tb = space.interp_w(PyTraceback, w_tb) new_frame.last_exception = OperationError(space.type(w_exc_value), w_exc_value, tb ) new_frame.last_instr = space.int_w(w_last_instr) new_frame.frame_finished_execution = space.is_true(w_finished) new_frame.f_lineno = space.int_w(w_f_lineno) fastlocals_w = maker.slp_from_tuple_with_nulls(space, w_fastlocals) new_frame.locals_stack_w[:len(fastlocals_w)] = fastlocals_w if space.is_w(w_f_trace, space.w_None): new_frame.w_f_trace = None else: new_frame.w_f_trace = w_f_trace new_frame.instr_lb = space.int_w(w_instr_lb) #the three for tracing new_frame.instr_ub = space.int_w(w_instr_ub) new_frame.instr_prev_plus_one = space.int_w(w_instr_prev_plus_one) self._setcellvars(cellvars)
def restore_top_frame(space, w_frame, w_saved): while w_frame.f_backref(): w_frame = w_frame.f_backref() w_frame.f_backref = non_virtual_ref(w_saved)
def descr__setstate__(self, space, w_args): from pypy.module._pickle_support import maker # helper fns from pypy.interpreter.pycode import PyCode from pypy.interpreter.module import Module args_w = space.unpackiterable(w_args, 17) w_f_back, w_builtin, w_pycode, w_locals_cells_stack, w_blockstack, w_exc_value, w_tb,\ w_globals, w_last_instr, w_finished, w_f_lineno, w_f_locals, \ w_f_trace, w_instr_lb, w_instr_ub, w_instr_prev_plus_one, w_stackdepth = args_w new_frame = self pycode = space.interp_w(PyCode, w_pycode) values_w = maker.slp_from_tuple_with_nulls(space, w_locals_cells_stack) nfreevars = len(pycode.co_freevars) closure = None if nfreevars: base = pycode.co_nlocals + len(pycode.co_cellvars) closure = values_w[base:base + nfreevars] # do not use the instance's __init__ but the base's, because we set # everything like cells from here # XXX hack from pypy.interpreter.function import Function outer_func = Function(space, None, closure=closure, forcename="fake") PyFrame.__init__(self, space, pycode, w_globals, outer_func) f_back = space.interp_w(PyFrame, w_f_back, can_be_None=True) new_frame.f_backref = jit.non_virtual_ref(f_back) if space.config.objspace.honor__builtins__: new_frame.builtin = space.interp_w(Module, w_builtin) else: assert space.interp_w(Module, w_builtin) is space.builtin new_frame.set_blocklist([ unpickle_block(space, w_blk) for w_blk in space.unpackiterable(w_blockstack) ]) self.locals_cells_stack_w = values_w[:] valuestackdepth = space.int_w(w_stackdepth) if not self._check_stack_index(valuestackdepth): raise oefmt(space.w_ValueError, "invalid stackdepth") assert valuestackdepth >= 0 self.valuestackdepth = valuestackdepth if space.is_w(w_exc_value, space.w_None): new_frame.last_exception = None else: from pypy.interpreter.pytraceback import PyTraceback tb = space.interp_w(PyTraceback, w_tb) new_frame.last_exception = OperationError(space.type(w_exc_value), w_exc_value, tb) new_frame.last_instr = space.int_w(w_last_instr) new_frame.frame_finished_execution = space.is_true(w_finished) d = new_frame.getorcreatedebug() d.f_lineno = space.int_w(w_f_lineno) if space.is_w(w_f_trace, space.w_None): d.w_f_trace = None else: d.w_f_trace = w_f_trace d.instr_lb = space.int_w(w_instr_lb) #the three for tracing d.instr_ub = space.int_w(w_instr_ub) d.instr_prev_plus_one = space.int_w(w_instr_prev_plus_one)
def store_s_sender(self, s_sender): assert s_sender is not None, "trying to store None s_sender" self._s_sender = jit.non_virtual_ref(s_sender) if self.get_state() is ActiveContext: self.set_state(DirtyContext)
def f(n): if n > 0: return virtual_ref(Y()) else: return non_virtual_ref(Z())
def descr__setstate__(self, space, w_args): from pypy.module._pickle_support import maker # helper fns from pypy.interpreter.pycode import PyCode from pypy.interpreter.module import Module args_w = space.unpackiterable(w_args, 17) w_f_back, w_builtin, w_pycode, w_locals_cells_stack, w_blockstack, w_exc_value, w_tb,\ w_globals, w_last_instr, w_finished, w_f_lineno, w_f_locals, \ w_f_trace, w_instr_lb, w_instr_ub, w_instr_prev_plus_one, w_stackdepth = args_w new_frame = self pycode = space.interp_w(PyCode, w_pycode) values_w = maker.slp_from_tuple_with_nulls(space, w_locals_cells_stack) nfreevars = len(pycode.co_freevars) closure = None if nfreevars: base = pycode.co_nlocals + len(pycode.co_cellvars) closure = values_w[base: base + nfreevars] # do not use the instance's __init__ but the base's, because we set # everything like cells from here # XXX hack from pypy.interpreter.function import Function outer_func = Function(space, None, closure=closure, forcename="fake") PyFrame.__init__(self, space, pycode, w_globals, outer_func) f_back = space.interp_w(PyFrame, w_f_back, can_be_None=True) new_frame.f_backref = jit.non_virtual_ref(f_back) if space.config.objspace.honor__builtins__: new_frame.builtin = space.interp_w(Module, w_builtin) else: assert space.interp_w(Module, w_builtin) is space.builtin new_frame.set_blocklist([unpickle_block(space, w_blk) for w_blk in space.unpackiterable(w_blockstack)]) self.locals_cells_stack_w = values_w[:] valuestackdepth = space.int_w(w_stackdepth) if not self._check_stack_index(valuestackdepth): raise OperationError(space.w_ValueError, space.wrap("invalid stackdepth")) assert valuestackdepth >= 0 self.valuestackdepth = valuestackdepth if space.is_w(w_exc_value, space.w_None): new_frame.last_exception = None else: from pypy.interpreter.pytraceback import PyTraceback tb = space.interp_w(PyTraceback, w_tb) new_frame.last_exception = OperationError(space.type(w_exc_value), w_exc_value, tb ) new_frame.last_instr = space.int_w(w_last_instr) new_frame.frame_finished_execution = space.is_true(w_finished) d = new_frame.getorcreatedebug() d.f_lineno = space.int_w(w_f_lineno) if space.is_w(w_f_trace, space.w_None): d.w_f_trace = None else: d.w_f_trace = w_f_trace d.instr_lb = space.int_w(w_instr_lb) #the three for tracing d.instr_ub = space.int_w(w_instr_ub) d.instr_prev_plus_one = space.int_w(w_instr_prev_plus_one)
def descr__setstate__(self, space, w_args): from pypy.module._pickle_support import maker # helper fns from pypy.interpreter.pycode import PyCode from pypy.interpreter.module import Module args_w = space.unpackiterable(w_args, 17) w_f_back, w_builtin, w_pycode, w_valuestack, w_blockstack, w_exc_value, w_tb,\ w_globals, w_last_instr, w_f_lineno, w_fastlocals, w_f_locals, \ w_f_trace, w_instr_lb, w_instr_ub, w_instr_prev_plus_one, w_cells = args_w new_frame = self pycode = space.interp_w(PyCode, w_pycode) if space.is_w(w_cells, space.w_None): closure = None cellvars = [] else: from pypy.interpreter.nestedscope import Cell cells_w = space.unpackiterable(w_cells) cells = [space.interp_w(Cell, w_cell) for w_cell in cells_w] ncellvars = len(pycode.co_cellvars) cellvars = cells[:ncellvars] closure = cells[ncellvars:] # do not use the instance's __init__ but the base's, because we set # everything like cells from here # XXX hack from pypy.interpreter.function import Function outer_func = Function(space, None, closure=closure, forcename="fake") PyFrame.__init__(self, space, pycode, w_globals, outer_func) f_back = space.interp_w(PyFrame, w_f_back, can_be_None=True) new_frame.f_backref = jit.non_virtual_ref(f_back) if space.config.objspace.honor__builtins__: new_frame.builtin = space.interp_w(Module, w_builtin) else: assert space.interp_w(Module, w_builtin) is space.builtin new_frame.set_blocklist([ unpickle_block(space, w_blk) for w_blk in space.unpackiterable(w_blockstack) ]) values_w = maker.slp_from_tuple_with_nulls(space, w_valuestack) for w_value in values_w: new_frame.pushvalue(w_value) if space.is_w(w_exc_value, space.w_None): new_frame.last_exception = None else: from pypy.interpreter.pytraceback import PyTraceback tb = space.interp_w(PyTraceback, w_tb) new_frame.last_exception = OperationError(space.type(w_exc_value), w_exc_value, tb) new_frame.last_instr = space.int_w(w_last_instr) d = new_frame.getorcreatedebug() d.f_lineno = space.int_w(w_f_lineno) fastlocals_w = maker.slp_from_tuple_with_nulls(space, w_fastlocals) new_frame.locals_stack_w[:len(fastlocals_w)] = fastlocals_w if space.is_w(w_f_trace, space.w_None): d.w_f_trace = None else: d.w_f_trace = w_f_trace d.instr_lb = space.int_w(w_instr_lb) #the three for tracing d.instr_ub = space.int_w(w_instr_ub) d.instr_prev_plus_one = space.int_w(w_instr_prev_plus_one) self._setcellvars(cellvars)