[pypy-svn] r74839 - in pypy/branch/blackhole-improvement/pypy/jit: codewriter metainterp metainterp/test
arigo at codespeak.net
arigo at codespeak.net
Fri May 28 12:13:33 CEST 2010
Author: arigo
Date: Fri May 28 12:13:31 2010
New Revision: 74839
Modified:
pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py
pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
pypy/branch/blackhole-improvement/pypy/jit/metainterp/compile.py
pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
pypy/branch/blackhole-improvement/pypy/jit/metainterp/resume.py
pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_virtualizable.py
pypy/branch/blackhole-improvement/pypy/jit/metainterp/virtualizable.py
Log:
test_virtualizable passes.
Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py Fri May 28 12:13:31 2010
@@ -873,9 +873,10 @@
if args[0] in self.vable_array_vars: # virtualizable array
vars = self.vable_array_vars[args[0]]
(v_base, arrayfielddescr, arraydescr) = vars
- return SpaceOperation('arraylen_vable',
- [v_base, arrayfielddescr, arraydescr],
- op.result)
+ return [SpaceOperation('-live-', [], None),
+ SpaceOperation('arraylen_vable',
+ [v_base, arrayfielddescr, arraydescr],
+ op.result)]
return SpaceOperation('arraylen_gc', [args[0], arraydescr], op.result)
do_fixed_list_len_foldable = do_fixed_list_len
@@ -885,9 +886,10 @@
vars = self.vable_array_vars[args[0]]
(v_base, arrayfielddescr, arraydescr) = vars
kind = getkind(op.result.concretetype)
- return SpaceOperation('getarrayitem_vable_%s' % kind[0],
- [v_base, arrayfielddescr, arraydescr,
- args[1]], op.result)
+ return [SpaceOperation('-live-', [], None),
+ SpaceOperation('getarrayitem_vable_%s' % kind[0],
+ [v_base, arrayfielddescr, arraydescr,
+ args[1]], op.result)]
v_index, extraop = self._prepare_list_getset(op, arraydescr, args,
'check_neg_index')
extra = getkind(op.result.concretetype)[0]
@@ -905,9 +907,10 @@
vars = self.vable_array_vars[args[0]]
(v_base, arrayfielddescr, arraydescr) = vars
kind = getkind(args[2].concretetype)
- return SpaceOperation('setarrayitem_vable_%s' % kind[0],
- [v_base, arrayfielddescr, arraydescr,
- args[1], args[2]], None)
+ return [SpaceOperation('-live-', [], None),
+ SpaceOperation('setarrayitem_vable_%s' % kind[0],
+ [v_base, arrayfielddescr, arraydescr,
+ args[1], args[2]], None)]
v_index, extraop = self._prepare_list_getset(op, arraydescr, args,
'check_neg_index')
kind = getkind(args[2].concretetype)[0]
Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py Fri May 28 12:13:31 2010
@@ -808,7 +808,8 @@
def get_portal_runner(self):
metainterp_sd = self.builder.metainterp_sd
- fnptr = llmemory.cast_ptr_to_adr(metainterp_sd.portal_runner_ptr)
+ fnptr = llmemory.cast_ptr_to_adr(metainterp_sd._portal_runner_ptr)
+ fnptr = llmemory.cast_adr_to_int(fnptr)
calldescr = metainterp_sd.portal_code.calldescr
return fnptr, calldescr
Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/compile.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/compile.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/compile.py Fri May 28 12:13:31 2010
@@ -349,11 +349,8 @@
def handle_async_forcing(self, force_token):
from pypy.jit.metainterp.resume import force_from_resumedata
metainterp_sd = self.metainterp_sd
- expect_virtualizable = metainterp_sd.virtualizable_info is not None
all_virtuals = force_from_resumedata(metainterp_sd, self)
- # Handle virtualizable_boxes: store them on the real virtualizable now
- if expect_virtualizable:
- metainterp_sd.virtualizable_info.forced_vable(virtualizable_boxes)
+ # The virtualizable data was stored on the real virtualizable above.
# Handle all_virtuals: keep them for later blackholing from the
# future failure of the GUARD_NOT_FORCED
self.save_data(force_token, all_virtuals)
Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py Fri May 28 12:13:31 2010
@@ -1019,9 +1019,9 @@
# xxx do something about code duplication
resbox = self.metainterp.execute_and_record_varargs(
rop.CALL_MAY_FORCE, allboxes, descr=descr)
- self.metainterp.vable_and_vrefs_after_residual_call()
if resbox is not None:
self.make_result_of_lastop(resbox)
+ self.metainterp.vable_and_vrefs_after_residual_call()
self.generate_guard(rop.GUARD_NOT_FORCED, None)
self.metainterp.handle_possible_exception()
return resbox
@@ -1553,7 +1553,10 @@
# run it.
from pypy.jit.metainterp.blackhole import convert_and_run_from_pyjitpl
self.aborted_tracing(stb.reason)
- convert_and_run_from_pyjitpl(self, stb.current_exc)
+ current_exc = lltype.nullptr(llmemory.GCREF.TO)
+ if self.last_exc_value_box is not None:
+ current_exc = self.last_exc_value_box.getref()
+ convert_and_run_from_pyjitpl(self, current_exc)
assert False # ^^^ must raise
def remove_consts_and_duplicates(self, boxes, endindex, duplicates):
@@ -1826,7 +1829,8 @@
virtualizable = vinfo.unwrap_virtualizable_box(virtualizable_box)
if vinfo.tracing_after_residual_call(virtualizable):
# the virtualizable escaped during CALL_MAY_FORCE.
- raise XXX-SwitchToBlackhole(ABORT_ESCAPE, yyy)
+ self.load_fields_from_virtualizable()
+ raise SwitchToBlackhole(ABORT_ESCAPE)
def stop_tracking_virtualref(self, i):
virtualbox = self.virtualref_boxes[i]
@@ -1916,8 +1920,8 @@
def load_fields_from_virtualizable(self):
# Force a reload of the virtualizable fields into the local
- # boxes (called only in escaping cases)
- assert self.is_blackholing()
+ # boxes (called only in escaping cases). Only call this function
+ # just before SwitchToBlackhole.
vinfo = self.staticdata.virtualizable_info
if vinfo is not None:
virtualizable_box = self.virtualizable_boxes[-1]
@@ -2031,9 +2035,8 @@
it to reload the current top-of-stack frame that gets interpreted."""
class SwitchToBlackhole(Exception):
- def __init__(self, reason, current_exc=lltype.nullptr(llmemory.GCREF.TO)):
+ def __init__(self, reason):
self.reason = reason
- self.current_exc = current_exc
# ____________________________________________________________
Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/resume.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/resume.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/resume.py Fri May 28 12:13:31 2010
@@ -744,13 +744,17 @@
def force_from_resumedata(metainterp_sd, storage):
resumereader = ResumeDataDirectReader(metainterp_sd.cpu, storage)
+ resumereader.handling_async_forcing()
vinfo = metainterp_sd.virtualizable_info
vrefinfo = metainterp_sd.virtualref_info
resumereader.consume_vref_and_vable(vrefinfo, vinfo)
return resumereader.virtuals
class ResumeDataDirectReader(AbstractResumeDataReader):
- resume_after_guard_not_forced = False
+ resume_after_guard_not_forced = 0
+ # 0: not a GUARD_NOT_FORCED
+ # 1: in handle_async_forcing
+ # 2: resuming from the GUARD_NOT_FORCED
def __init__(self, cpu, storage, all_virtuals=None):
self._init(cpu, storage)
@@ -759,9 +763,12 @@
else:
# special case for resuming after a GUARD_NOT_FORCED: we already
# have the virtuals
- self.resume_after_guard_not_forced = True
+ self.resume_after_guard_not_forced = 2
self.virtuals = all_virtuals
+ def handling_async_forcing(self):
+ self.resume_after_guard_not_forced = 1
+
def consume_one_section(self, blackholeinterp):
self.blackholeinterp = blackholeinterp
info = blackholeinterp.get_current_position_info()
@@ -785,11 +792,16 @@
return len(nums)
virtualizable = self.decode_ref(nums[-1])
virtualizable = vinfo.cast_gcref_to_vtype(virtualizable)
- # just jumped away from assembler (case 4 in the comment in
- # virtualizable.py) into tracing (case 2); check that vable_token
- # is and stays 0. Note the call to reset_vable_token() in
- # warmstate.py.
- assert not virtualizable.vable_token
+ if self.resume_after_guard_not_forced == 1:
+ # in the middle of handle_async_forcing()
+ assert virtualizable.vable_token
+ virtualizable.vable_token = vinfo.TOKEN_NONE
+ else:
+ # just jumped away from assembler (case 4 in the comment in
+ # virtualizable.py) into tracing (case 2); check that vable_token
+ # is and stays 0. Note the call to reset_vable_token() in
+ # warmstate.py.
+ assert not virtualizable.vable_token
return vinfo.write_from_resume_data_partial(virtualizable, self, nums)
def load_value_of_type(self, TYPE, tagged):
@@ -809,7 +821,7 @@
def consume_vref_and_vable(self, vrefinfo, vinfo):
nums = self.cur_numb.nums
self.cur_numb = self.cur_numb.prev
- if not self.resume_after_guard_not_forced:
+ if self.resume_after_guard_not_forced != 2:
end_vref = self.consume_vable_info(vinfo, nums)
self.consume_virtualref_info(vrefinfo, nums, end_vref)
Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_virtualizable.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_virtualizable.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_virtualizable.py Fri May 28 12:13:31 2010
@@ -522,7 +522,7 @@
def test_external_pass(self):
- jitdriver = JitDriver(greens = [], reds = ['frame', 'n', 'z'],
+ jitdriver = JitDriver(greens = [], reds = ['n', 'z', 'frame'],
virtualizables = ['frame'])
class BaseFrame(object):
@@ -822,7 +822,7 @@
assert res == f(123)
def test_external_read_sometimes_recursive(self):
- jitdriver = JitDriver(greens = [], reds = ['frame', 'rec'],
+ jitdriver = JitDriver(greens = [], reds = ['rec', 'frame'],
virtualizables = ['frame'])
class Frame(object):
@@ -942,7 +942,7 @@
assert res == f(123)
def test_promote_index_in_virtualizable_list(self):
- jitdriver = JitDriver(greens = [], reds = ['frame', 'n'],
+ jitdriver = JitDriver(greens = [], reds = ['n', 'frame'],
virtualizables = ['frame'])
class Frame(object):
_virtualizable2_ = ['stackpos', 'stack[*]']
@@ -1085,7 +1085,7 @@
res = self.meta_interp(f, [10])
assert res == 55
- self.check_loops(new_with_vtable=0, oois=1)
+ self.check_loops(new_with_vtable=0, ptr_eq=1)
def test_virtual_child_frame_with_arrays(self):
myjitdriver = JitDriver(greens = [], reds = ['frame'],
@@ -1197,7 +1197,7 @@
if not self.basic:
py.test.skip("purely frontend test")
- myjitdriver = JitDriver(greens = [], reds = ['frame', 'fail'],
+ myjitdriver = JitDriver(greens = [], reds = ['fail', 'frame'],
virtualizables = ['frame'])
class Frame(object):
@@ -1252,7 +1252,7 @@
self.x = x
self.next = None
- driver = JitDriver(greens=[], reds=['frame', 'result'],
+ driver = JitDriver(greens=[], reds=['result', 'frame'],
virtualizables=['frame'])
def interp(caller):
@@ -1285,15 +1285,15 @@
self.n = n
self.next = None
- driver = JitDriver(greens=[], reds=['frame', 'result'],
+ driver = JitDriver(greens=[], reds=['result', 'frame'],
virtualizables=['frame'])
- def p(code, pc):
+ def p(pc, code):
code = hlstr(code)
return "%s %d %s" % (code, pc, code[pc])
- def c(code, pc):
+ def c(pc, code):
return "l" not in hlstr(code)
- myjitdriver = JitDriver(greens=['code', 'pc'], reds=['frame'],
+ myjitdriver = JitDriver(greens=['pc', 'code'], reds=['frame'],
virtualizables=["frame"],
get_printable_location=p, can_inline=c)
def f(code, frame):
Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/virtualizable.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/virtualizable.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/virtualizable.py Fri May 28 12:13:31 2010
@@ -271,12 +271,6 @@
assert virtualizable.vable_token == self.TOKEN_NONE
force_now._dont_inline_ = True
- def forced_vable(self, virtualizable_boxes):
- virtualizable_box = virtualizable_boxes[-1]
- virtualizable = self.unwrap_virtualizable_box(virtualizable_box)
- self.write_boxes(virtualizable, virtualizable_boxes)
- virtualizable.vable_token = self.TOKEN_NONE
-
# ____________________________________________________________
#
# The 'vable_token' field of a virtualizable is either 0, -1, or points
More information about the Pypy-commit
mailing list