Author: Maciej Fijalkowski <[email protected]>
Branch: remove-frame-force
Changeset: r62008:1531cf4492f0
Date: 2013-03-04 16:17 +0200
http://bitbucket.org/pypy/pypy/changeset/1531cf4492f0/
Log: I think this is enough to make frame forcing non-existant.
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -268,27 +268,9 @@
raise NotImplementedError
def get_traceback(self):
- """Calling this marks the PyTraceback as escaped, i.e. it becomes
- accessible and inspectable by app-level Python code. For the JIT.
- Note that this has no effect if there are already several traceback
- frames recorded, because in this case they are already marked as
- escaping by executioncontext.leave() being called with
- got_exception=True.
- """
- from pypy.interpreter.pytraceback import PyTraceback
- tb = self._application_traceback
- if tb is not None and isinstance(tb, PyTraceback):
- tb.frame.mark_as_escaped()
- return tb
+ return self._application_traceback
def set_traceback(self, traceback):
- """Set the current traceback. It should either be a traceback
- pointing to some already-escaped frame, or a traceback for the
- current frame. To support the latter case we do not mark the
- frame as escaped. The idea is that it will be marked as escaping
- only if the exception really propagates out of this frame, by
- executioncontext.leave() being called with got_exception=True.
- """
self._application_traceback = traceback
# ____________________________________________________________
diff --git a/pypy/interpreter/executioncontext.py
b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -59,22 +59,13 @@
frame.f_backref = self.topframeref
self.topframeref = jit.virtual_ref(frame)
- def leave(self, frame, w_exitvalue, got_exception):
+ def leave(self, frame, w_exitvalue):
try:
if self.profilefunc:
self._trace(frame, 'leaveframe', w_exitvalue)
finally:
frame_vref = self.topframeref
self.topframeref = frame.f_backref
- if frame.escaped or got_exception:
- # if this frame escaped to applevel, we must ensure that also
- # f_back does
- f_back = frame.f_backref()
- if f_back:
- f_back.mark_as_escaped()
- # force the frame (from the JIT point of view), so that it can
- # be accessed also later
- frame_vref()
jit.virtual_ref_finish(frame_vref, frame)
if self.w_tracefunc is not None and not frame.hide():
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -49,7 +49,6 @@
instr_ub = 0
instr_prev_plus_one = 0
is_being_profiled = False
- escaped = False # see mark_as_escaped()
def __init__(self, space, code, w_globals, outer_func):
if not we_are_translated():
@@ -72,15 +71,6 @@
self.initialize_frame_scopes(outer_func, code)
self.f_lineno = code.co_firstlineno
- def mark_as_escaped(self):
- """
- Must be called on frames that are exposed to applevel, e.g. by
- sys._getframe(). This ensures that the virtualref holding the frame
- is properly forced by ec.leave(), and thus the frame will be still
- accessible even after the corresponding C stack died.
- """
- self.escaped = True
-
def append_block(self, block):
assert block.previous is self.lastblock
self.lastblock = block
@@ -153,7 +143,6 @@
not self.space.config.translating)
executioncontext = self.space.getexecutioncontext()
executioncontext.enter(self)
- got_exception = True
w_exitvalue = self.space.w_None
try:
executioncontext.call_trace(self)
@@ -180,9 +169,8 @@
# clean up the exception, might be useful for not
# allocating exception objects in some cases
self.last_exception = None
- got_exception = False
finally:
- executioncontext.leave(self, w_exitvalue, got_exception)
+ executioncontext.leave(self, w_exitvalue)
return w_exitvalue
execute_frame.insert_stack_check_here = True
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -43,7 +43,6 @@
break
depth -= 1
f = ec.getnextframe_nohidden(f)
- f.mark_as_escaped()
return space.wrap(f)
@unwrap_spec(new_limit="c_int")
diff --git a/rpython/jit/metainterp/pyjitpl.py
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -1170,16 +1170,10 @@
# virtual_ref_finish() assumes that we have a stack-like, last-in
# first-out order.
metainterp = self.metainterp
- vrefbox = metainterp.virtualref_boxes.pop()
+ metainterp.virtualref_boxes.pop()
lastbox = metainterp.virtualref_boxes.pop()
assert box.getref_base() == lastbox.getref_base()
- vrefinfo = metainterp.staticdata.virtualref_info
- vref = vrefbox.getref_base()
- if vrefinfo.is_virtual_ref(vref):
- # XXX write a comment about nullbox
- nullbox = self.metainterp.cpu.ts.CONST_NULL
- metainterp.history.record(rop.VIRTUAL_REF_FINISH,
- [vrefbox, nullbox], None)
+ # we just pop it
@arguments()
def opimpl_ll_read_timestamp(self):
diff --git a/rpython/jit/metainterp/test/test_virtualref.py
b/rpython/jit/metainterp/test/test_virtualref.py
--- a/rpython/jit/metainterp/test/test_virtualref.py
+++ b/rpython/jit/metainterp/test/test_virtualref.py
@@ -59,7 +59,7 @@
self.interp_operations(f, [])
self.check_operations_history(new_with_vtable=1, # X()
virtual_ref=1,
- virtual_ref_finish=1)
+ virtual_ref_finish=0)
def test_make_vref_guard(self):
if not isinstance(self, TestLLtype):
@@ -551,7 +551,7 @@
assert res == 1
self.check_resops(new_with_vtable=4) # vref, xy
- def test_cannot_use_invalid_virtualref(self):
+ def test_force_after_finish(self):
myjitdriver = JitDriver(greens = [], reds = ['n'])
#
class XY:
diff --git a/rpython/jit/metainterp/virtualref.py
b/rpython/jit/metainterp/virtualref.py
--- a/rpython/jit/metainterp/virtualref.py
+++ b/rpython/jit/metainterp/virtualref.py
@@ -163,8 +163,8 @@
assert not vref.forced
from rpython.jit.metainterp.compile import
ResumeGuardForcedDescr
ResumeGuardForcedDescr.force_now(self.cpu, token)
- assert vref.virtual_token == TOKEN_NONE
- assert vref.forced
+ if vref.virtual_token != TOKEN_NONE or not vref.forced:
+ raise InvalidVirtualRef
elif not vref.forced:
# token == TOKEN_NONE and the vref was not forced: it's invalid
raise InvalidVirtualRef
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit