diff options
author | Armin Rigo <arigo@tunes.org> | 2016-05-11 08:24:40 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2016-05-11 08:24:40 +0200 |
commit | 49dd28056415ee01ed66ec75db3a234da2ad287a (patch) | |
tree | 50c2c512bb193d9612a60ae218655ba864d50176 /rpython/jit/metainterp | |
parent | Backend (diff) | |
parent | Add comment (diff) | |
download | pypy-49dd28056415ee01ed66ec75db3a234da2ad287a.tar.gz pypy-49dd28056415ee01ed66ec75db3a234da2ad287a.tar.bz2 pypy-49dd28056415ee01ed66ec75db3a234da2ad287a.zip |
hg merge default
Diffstat (limited to 'rpython/jit/metainterp')
22 files changed, 135 insertions, 84 deletions
diff --git a/rpython/jit/metainterp/blackhole.py b/rpython/jit/metainterp/blackhole.py index e2f187a884..fcf0c20e9c 100644 --- a/rpython/jit/metainterp/blackhole.py +++ b/rpython/jit/metainterp/blackhole.py @@ -172,7 +172,7 @@ class BlackholeInterpBuilder(object): # call the method bhimpl_xxx() try: result = unboundmethod(*args) - except Exception, e: + except Exception as e: if verbose and not we_are_translated(): print '-> %s!' % (e.__class__.__name__,) if resulttype == 'i' or resulttype == 'r' or resulttype == 'f': @@ -323,7 +323,7 @@ class BlackholeInterpreter(object): break except jitexc.JitException: raise # go through - except Exception, e: + except Exception as e: lle = get_llexception(self.cpu, e) self.handle_exception_in_frame(lle) @@ -1527,9 +1527,9 @@ class BlackholeInterpreter(object): # we now proceed to interpret the bytecode in this frame self.run() # - except jitexc.JitException, e: + except jitexc.JitException as e: raise # go through - except Exception, e: + except Exception as e: # if we get an exception, return it to the caller frame current_exc = get_llexception(self.cpu, e) if not self.nextblackholeinterp: @@ -1660,7 +1660,7 @@ def _handle_jitexception(blackholeinterp, exc): # We have reached a recursive portal level. try: blackholeinterp._handle_jitexception_in_portal(exc) - except Exception, e: + except Exception as e: # It raised a general exception (it should not be a JitException here). lle = get_llexception(blackholeinterp.cpu, e) else: diff --git a/rpython/jit/metainterp/executor.py b/rpython/jit/metainterp/executor.py index dd0c7616ac..80a3d60740 100644 --- a/rpython/jit/metainterp/executor.py +++ b/rpython/jit/metainterp/executor.py @@ -51,28 +51,28 @@ def _do_call(cpu, metainterp, argboxes, descr, rettype): if rettype == INT: try: result = cpu.bh_call_i(func, args_i, args_r, args_f, descr) - except Exception, e: + except Exception as e: metainterp.execute_raised(e) result = 0 return result if rettype == REF: try: result = cpu.bh_call_r(func, args_i, args_r, args_f, descr) - except Exception, e: + except Exception as e: metainterp.execute_raised(e) result = NULL return result if rettype == FLOAT: try: result = cpu.bh_call_f(func, args_i, args_r, args_f, descr) - except Exception, e: + except Exception as e: metainterp.execute_raised(e) result = longlong.ZEROF return result if rettype == VOID: try: cpu.bh_call_v(func, args_i, args_r, args_f, descr) - except Exception, e: + except Exception as e: metainterp.execute_raised(e) return None raise AssertionError("bad rettype") diff --git a/rpython/jit/metainterp/heapcache.py b/rpython/jit/metainterp/heapcache.py index 4c8dd21481..ad4b89070c 100644 --- a/rpython/jit/metainterp/heapcache.py +++ b/rpython/jit/metainterp/heapcache.py @@ -209,7 +209,7 @@ class HeapCache(object): isinstance(argboxes[3], ConstInt) and isinstance(argboxes[4], ConstInt) and isinstance(argboxes[5], ConstInt) and - len(descr.get_extra_info().write_descrs_arrays) == 1): + descr.get_extra_info().single_write_descr_array is not None): # ARRAYCOPY with constant starts and constant length doesn't escape # its argument # XXX really? @@ -299,9 +299,9 @@ class HeapCache(object): isinstance(argboxes[3], ConstInt) and isinstance(argboxes[4], ConstInt) and isinstance(argboxes[5], ConstInt) and - len(effectinfo.write_descrs_arrays) == 1 + effectinfo.single_write_descr_array is not None ): - descr = effectinfo.write_descrs_arrays[0] + descr = effectinfo.single_write_descr_array cache = self.heap_array_cache.get(descr, None) srcstart = argboxes[3].getint() dststart = argboxes[4].getint() @@ -328,10 +328,10 @@ class HeapCache(object): idx_cache._clear_cache_on_write(seen_allocation_of_target) return elif ( - len(effectinfo.write_descrs_arrays) == 1 + effectinfo.single_write_descr_array is not None ): # Fish the descr out of the effectinfo - cache = self.heap_array_cache.get(effectinfo.write_descrs_arrays[0], None) + cache = self.heap_array_cache.get(effectinfo.single_write_descr_array, None) if cache is not None: for idx, cache in cache.iteritems(): cache._clear_cache_on_write(seen_allocation_of_target) diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py index c0bfb45a35..042f50553f 100644 --- a/rpython/jit/metainterp/history.py +++ b/rpython/jit/metainterp/history.py @@ -1,3 +1,4 @@ +import sys from rpython.rtyper.extregistry import ExtRegistryEntry from rpython.rtyper.lltypesystem import lltype, llmemory, rffi from rpython.rlib.objectmodel import we_are_translated, Symbolic @@ -87,9 +88,10 @@ def repr_rpython(box, typechars): class AbstractDescr(AbstractValue): - __slots__ = ('descr_index',) + __slots__ = ('descr_index', 'ei_index') llopaque = True descr_index = -1 + ei_index = sys.maxint def repr_of_descr(self): return '%r' % (self,) diff --git a/rpython/jit/metainterp/optimizeopt/heap.py b/rpython/jit/metainterp/optimizeopt/heap.py index 57c42829cf..201e6ded0a 100644 --- a/rpython/jit/metainterp/optimizeopt/heap.py +++ b/rpython/jit/metainterp/optimizeopt/heap.py @@ -432,28 +432,35 @@ class OptHeap(Optimization): optimize_GUARD_EXCEPTION = optimize_GUARD_NO_EXCEPTION def force_from_effectinfo(self, effectinfo): - # XXX we can get the wrong complexity here, if the lists - # XXX stored on effectinfo are large - for fielddescr in effectinfo.readonly_descrs_fields: - self.force_lazy_set(fielddescr) - for arraydescr in effectinfo.readonly_descrs_arrays: - self.force_lazy_setarrayitem(arraydescr) - for fielddescr in effectinfo.write_descrs_fields: - if fielddescr.is_always_pure(): - continue - try: - del self.cached_dict_reads[fielddescr] - except KeyError: - pass - self.force_lazy_set(fielddescr, can_cache=False) - for arraydescr in effectinfo.write_descrs_arrays: - self.force_lazy_setarrayitem(arraydescr, can_cache=False) - if arraydescr in self.corresponding_array_descrs: - dictdescr = self.corresponding_array_descrs.pop(arraydescr) + # Note: this version of the code handles effectively + # effectinfos that store arbitrarily many descrs, by looping + # on self.cached_{fields, arrayitems} and looking them up in + # the bitstrings stored in the effectinfo. + for fielddescr, cf in self.cached_fields.items(): + if effectinfo.check_readonly_descr_field(fielddescr): + cf.force_lazy_set(self, fielddescr) + if effectinfo.check_write_descr_field(fielddescr): + if fielddescr.is_always_pure(): + continue + try: + del self.cached_dict_reads[fielddescr] + except KeyError: + pass + cf.force_lazy_set(self, fielddescr, can_cache=False) + # + for arraydescr, submap in self.cached_arrayitems.items(): + if effectinfo.check_readonly_descr_array(arraydescr): + self.force_lazy_setarrayitem_submap(submap) + if effectinfo.check_write_descr_array(arraydescr): + self.force_lazy_setarrayitem_submap(submap, can_cache=False) + # + for arraydescr, dictdescr in self.corresponding_array_descrs.items(): + if effectinfo.check_write_descr_array(arraydescr): try: del self.cached_dict_reads[dictdescr] except KeyError: pass # someone did it already + # if effectinfo.check_forces_virtual_or_virtualizable(): vrefinfo = self.optimizer.metainterp_sd.virtualref_info self.force_lazy_set(vrefinfo.descr_forced) @@ -476,6 +483,10 @@ class OptHeap(Optimization): if indexb is None or indexb.contains(idx): cf.force_lazy_set(self, None, can_cache) + def force_lazy_setarrayitem_submap(self, submap, can_cache=True): + for cf in submap.itervalues(): + cf.force_lazy_set(self, None, can_cache) + def force_all_lazy_sets(self): items = self.cached_fields.items() if not we_are_translated(): diff --git a/rpython/jit/metainterp/optimizeopt/intutils.py b/rpython/jit/metainterp/optimizeopt/intutils.py index 688627f52f..0fae33379a 100644 --- a/rpython/jit/metainterp/optimizeopt/intutils.py +++ b/rpython/jit/metainterp/optimizeopt/intutils.py @@ -1,5 +1,8 @@ +import sys from rpython.rlib.rarithmetic import ovfcheck, LONG_BIT, maxint, is_valid_int from rpython.rlib.objectmodel import we_are_translated +from rpython.rtyper.lltypesystem import lltype +from rpython.rtyper.lltypesystem.lloperation import llop from rpython.jit.metainterp.resoperation import rop, ResOperation from rpython.jit.metainterp.optimizeopt.info import AbstractInfo, INFO_NONNULL,\ INFO_UNKNOWN, INFO_NULL diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py index b26d8ffe48..5b210ce0c7 100644 --- a/rpython/jit/metainterp/optimizeopt/rewrite.py +++ b/rpython/jit/metainterp/optimizeopt/rewrite.py @@ -620,10 +620,10 @@ class OptRewrite(Optimization): and length and ((dest_info and dest_info.is_virtual()) or length.getint() <= 8) and ((source_info and source_info.is_virtual()) or length.getint() <= 8) - and len(extrainfo.write_descrs_arrays) == 1): # <-sanity check + and extrainfo.single_write_descr_array is not None): #<-sanity check source_start = source_start_box.getint() dest_start = dest_start_box.getint() - arraydescr = extrainfo.write_descrs_arrays[0] + arraydescr = extrainfo.single_write_descr_array if arraydescr.is_array_of_structs(): return False # not supported right now diff --git a/rpython/jit/metainterp/optimizeopt/test/test_intbound.py b/rpython/jit/metainterp/optimizeopt/test/test_intbound.py index f974d67264..0dedd21c7a 100644 --- a/rpython/jit/metainterp/optimizeopt/test/test_intbound.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_intbound.py @@ -240,6 +240,8 @@ def test_shift_overflow(): def test_div_bound(): + from rpython.rtyper.lltypesystem import lltype + from rpython.rtyper.lltypesystem.lloperation import llop for _, _, b1 in some_bounds(): for _, _, b2 in some_bounds(): b3 = b1.py_div_bound(b2) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py index b05c86ea15..36c2b5bbbd 100644 --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py @@ -5536,6 +5536,28 @@ class OptimizeOptTest(BaseTestWithUnroll): """ self.optimize_loop(ops, expected) + def test_division_bound_bug(self): + py.test.skip("XXX re-enable") + ops = """ + [i4] + i1 = int_ge(i4, -50) + guard_true(i1) [] + i2 = int_le(i4, -40) + guard_true(i2) [] + # here, -50 <= i4 <= -40 + + i5 = int_floordiv(i4, 30) + # here, we know that that i5 == -1 (C-style handling of negatives!) + escape_n(i5) + jump(i4) + """ + expected = """ + [i4, i5] + escape_n(-1) + jump(i4, -1) + """ + self.optimize_loop(ops, expected) + def test_subsub_ovf(self): ops = """ [i0] diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py b/rpython/jit/metainterp/optimizeopt/test/test_util.py index 9bfa2e420b..e5e8aec487 100644 --- a/rpython/jit/metainterp/optimizeopt/test/test_util.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py @@ -10,7 +10,7 @@ from rpython.jit.backend.llgraph import runner from rpython.jit.metainterp.history import (TreeLoop, AbstractDescr, JitCellToken, TargetToken) from rpython.jit.metainterp.optimizeopt.util import sort_descrs, equaloplists -from rpython.jit.codewriter.effectinfo import EffectInfo +from rpython.jit.codewriter.effectinfo import EffectInfo, compute_bitstrings from rpython.jit.metainterp.logger import LogOperations from rpython.jit.tool.oparser import OpParser, pure_parse, convert_loop_to_trace from rpython.jit.metainterp.quasiimmut import QuasiImmutDescr @@ -530,6 +530,7 @@ class BaseTest(object): metainterp_sd.virtualref_info = self.vrefinfo if hasattr(self, 'callinfocollection'): metainterp_sd.callinfocollection = self.callinfocollection + compute_bitstrings(self.cpu.fetch_all_descrs()) # compile_data.enable_opts = self.enable_opts state = optimize_trace(metainterp_sd, None, compile_data) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_zdisable_opts.py b/rpython/jit/metainterp/optimizeopt/test/test_zdisable_opts.py index 890cafd75d..43f372af3e 100644 --- a/rpython/jit/metainterp/optimizeopt/test/test_zdisable_opts.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_zdisable_opts.py @@ -39,7 +39,7 @@ for optnum in range(len(allopts)): def raises(self, e, fn, *args): try: fn(*args) - except Exception, e: + except Exception as e: return e opt = allopts[optnum] diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py index 4088916ad1..55ae54dcae 100644 --- a/rpython/jit/metainterp/optimizeopt/virtualstate.py +++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py @@ -91,7 +91,7 @@ class AbstractVirtualStateInfo(object): state.renum[self.position] = other.position try: self._generate_guards(other, op, runtime_op, state) - except VirtualStatesCantMatch, e: + except VirtualStatesCantMatch as e: state.bad[self] = state.bad[other] = None if e.state is None: e.state = state diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py index bc5f04999a..68489c72d5 100644 --- a/rpython/jit/metainterp/pyjitpl.py +++ b/rpython/jit/metainterp/pyjitpl.py @@ -1837,7 +1837,11 @@ class MetaInterpStaticData(object): self.cpu.propagate_exception_descr = exc_descr # self.globaldata = MetaInterpGlobalData(self) + + def finish_setup_descrs(self): + from rpython.jit.codewriter import effectinfo self.all_descrs = self.cpu.setup_descrs() + effectinfo.compute_bitstrings(self.all_descrs) def _setup_once(self): """Runtime setup needed by the various components of the JIT.""" @@ -2029,7 +2033,7 @@ class MetaInterp(object): else: try: self.compile_done_with_this_frame(resultbox) - except SwitchToBlackhole, stb: + except SwitchToBlackhole as stb: self.aborted_tracing(stb.reason) sd = self.staticdata result_type = self.jitdriver_sd.result_type @@ -2062,7 +2066,7 @@ class MetaInterp(object): self.popframe() try: self.compile_exit_frame_with_exception(self.last_exc_box) - except SwitchToBlackhole, stb: + except SwitchToBlackhole as stb: self.aborted_tracing(stb.reason) raise jitexc.ExitFrameWithExceptionRef(self.cpu, lltype.cast_opaque_ptr(llmemory.GCREF, excvalue)) @@ -2095,7 +2099,7 @@ class MetaInterp(object): guard_op = self.history.record(opnum, moreargs, lltype.nullptr(llmemory.GCREF.TO)) else: - guard_op = self.history.record(opnum, moreargs, None) + guard_op = self.history.record(opnum, moreargs, None) self.capture_resumedata(resumepc) # ^^^ records extra to history self.staticdata.profiler.count_ops(opnum, Counters.GUARDS) @@ -2249,7 +2253,7 @@ class MetaInterp(object): def execute_raised(self, exception, constant=False): if isinstance(exception, jitexc.JitException): - raise jitexc.JitException, exception # go through + raise exception # go through llexception = jitexc.get_llexception(self.cpu, exception) self.execute_ll_raised(llexception, constant) @@ -2362,7 +2366,7 @@ class MetaInterp(object): self.seen_loop_header_for_jdindex = -1 try: self.interpret() - except SwitchToBlackhole, stb: + except SwitchToBlackhole as stb: self.run_blackhole_interp_to_cancel_tracing(stb) assert False, "should always raise" @@ -2399,7 +2403,7 @@ class MetaInterp(object): if self.resumekey_original_loop_token is None: # very rare case raise SwitchToBlackhole(Counters.ABORT_BRIDGE) self.interpret() - except SwitchToBlackhole, stb: + except SwitchToBlackhole as stb: self.run_blackhole_interp_to_cancel_tracing(stb) assert False, "should always raise" @@ -3271,7 +3275,7 @@ def _get_opimpl_method(name, argcodes): print '\tpyjitpl: %s(%s)' % (name, ', '.join(map(repr, args))), try: resultbox = unboundmethod(self, *args) - except Exception, e: + except Exception as e: if self.debug: print '-> %s!' % e.__class__.__name__ raise diff --git a/rpython/jit/metainterp/test/support.py b/rpython/jit/metainterp/test/support.py index 5b140eac23..cf2c7b924c 100644 --- a/rpython/jit/metainterp/test/support.py +++ b/rpython/jit/metainterp/test/support.py @@ -132,6 +132,7 @@ def _run_with_pyjitpl(testself, args, stats): metainterp_sd = pyjitpl.MetaInterpStaticData(cw.cpu, opt) stats.metainterp_sd = metainterp_sd metainterp_sd.finish_setup(cw) + metainterp_sd.finish_setup_descrs() [jitdriver_sd] = metainterp_sd.jitdrivers_sd metainterp = pyjitpl.MetaInterp(metainterp_sd, jitdriver_sd) diff --git a/rpython/jit/metainterp/test/test_blackhole.py b/rpython/jit/metainterp/test/test_blackhole.py index c0b23fead7..5b2e0cd7e9 100644 --- a/rpython/jit/metainterp/test/test_blackhole.py +++ b/rpython/jit/metainterp/test/test_blackhole.py @@ -205,7 +205,7 @@ class TestBlackhole(LLJitMixin): myjitdriver.jit_merge_point(x=x, y=y) try: choices(x) - except FooError, e: + except FooError as e: if e.num == 0: break y += e.num diff --git a/rpython/jit/metainterp/test/test_compile.py b/rpython/jit/metainterp/test/test_compile.py index 9afc16408d..3d2e85b969 100644 --- a/rpython/jit/metainterp/test/test_compile.py +++ b/rpython/jit/metainterp/test/test_compile.py @@ -164,7 +164,7 @@ def test_compile_tmp_callback(): fail_descr = cpu.get_latest_descr(deadframe) try: fail_descr.handle_fail(deadframe, FakeMetaInterpSD(), None) - except jitexc.ExitFrameWithExceptionRef, e: + except jitexc.ExitFrameWithExceptionRef as e: assert lltype.cast_opaque_ptr(lltype.Ptr(EXC), e.value) == llexc else: assert 0, "should have raised" diff --git a/rpython/jit/metainterp/test/test_exception.py b/rpython/jit/metainterp/test/test_exception.py index c711e9bfc7..30ad14d3fd 100644 --- a/rpython/jit/metainterp/test/test_exception.py +++ b/rpython/jit/metainterp/test/test_exception.py @@ -17,7 +17,7 @@ class ExceptionTests: def f(n): try: return g(n) - except MyError, e: + except MyError as e: return e.n + 10 res = self.interp_operations(f, [9]) assert res == 8 @@ -141,7 +141,7 @@ class ExceptionTests: try: b(n) return 0 - except MyError, e: + except MyError as e: return e.n def f(n): return a(n) @@ -161,7 +161,7 @@ class ExceptionTests: myjitdriver.jit_merge_point(n=n) try: check(n, 0) - except MyError, e: + except MyError as e: n = check(e.n, 1) return n assert f(53) == -2 @@ -290,7 +290,7 @@ class ExceptionTests: myjitdriver.can_enter_jit(n=n) myjitdriver.jit_merge_point(n=n) n = n - check(n) - except MyError, e: + except MyError as e: return e.n assert f(53) == -2 res = self.meta_interp(f, [53], policy=StopAtXPolicy(check)) @@ -517,7 +517,7 @@ class ExceptionTests: def f(n): try: portal(n) - except SomeException, e: + except SomeException as e: return 3 return 2 @@ -536,7 +536,7 @@ class ExceptionTests: def main(n): try: f(n) - except MyError, e: + except MyError as e: return e.n res = self.meta_interp(main, [41], repeat=7) @@ -572,7 +572,7 @@ class ExceptionTests: try: f(n) return 3 - except MyError, e: + except MyError as e: return e.n except ValueError: return 8 @@ -590,7 +590,7 @@ class ExceptionTests: def f(x): try: return g(x) - except Exception, e: + except Exception as e: if isinstance(e, OverflowError): return -42 raise diff --git a/rpython/jit/metainterp/test/test_heapcache.py b/rpython/jit/metainterp/test/test_heapcache.py index 619504ff37..b8593723af 100644 --- a/rpython/jit/metainterp/test/test_heapcache.py +++ b/rpython/jit/metainterp/test/test_heapcache.py @@ -27,8 +27,12 @@ class FakeEffectinfo(object): def __init__(self, extraeffect, oopspecindex, write_descrs_fields, write_descrs_arrays): self.extraeffect = extraeffect self.oopspecindex = oopspecindex - self.write_descrs_fields = write_descrs_fields - self.write_descrs_arrays = write_descrs_arrays + self._write_descrs_fields = write_descrs_fields + self._write_descrs_arrays = write_descrs_arrays + if len(write_descrs_arrays) == 1: + [self.single_write_descr_array] = write_descrs_arrays + else: + self.single_write_descr_array = None def has_random_effects(self): return self.extraeffect == self.EF_RANDOM_EFFECTS @@ -37,14 +41,14 @@ class FakeCallDescr(object): def __init__(self, extraeffect, oopspecindex=None, write_descrs_fields=[], write_descrs_arrays=[]): self.extraeffect = extraeffect self.oopspecindex = oopspecindex - self.write_descrs_fields = write_descrs_fields - self.write_descrs_arrays = write_descrs_arrays + self.__write_descrs_fields = write_descrs_fields + self.__write_descrs_arrays = write_descrs_arrays def get_extra_info(self): return FakeEffectinfo( self.extraeffect, self.oopspecindex, - write_descrs_fields=self.write_descrs_fields, - write_descrs_arrays=self.write_descrs_arrays, + write_descrs_fields=self.__write_descrs_fields, + write_descrs_arrays=self.__write_descrs_arrays, ) arraycopydescr1 = FakeCallDescr(FakeEffectinfo.EF_CANNOT_RAISE, FakeEffectinfo.OS_ARRAYCOPY, write_descrs_arrays=[descr1]) diff --git a/rpython/jit/metainterp/test/test_recursive.py b/rpython/jit/metainterp/test/test_recursive.py index 39f1a2b643..42cc1afa22 100644 --- a/rpython/jit/metainterp/test/test_recursive.py +++ b/rpython/jit/metainterp/test/test_recursive.py @@ -729,7 +729,7 @@ class RecursiveTests: if codeno == 2: try: portal(1) - except MyException, me: + except MyException as me: i += me.x i += 1 if codeno == 1: @@ -1092,7 +1092,7 @@ class RecursiveTests: if codeno < 10: try: portal(codeno + 5, k+1) - except GotValue, e: + except GotValue as e: i += e.result codeno += 1 elif codeno == 10: @@ -1106,7 +1106,7 @@ class RecursiveTests: def main(codeno, k): try: portal(codeno, k) - except GotValue, e: + except GotValue as e: return e.result assert main(0, 1) == 2095 diff --git a/rpython/jit/metainterp/test/test_virtualizable.py b/rpython/jit/metainterp/test/test_virtualizable.py index 5b9d0d6254..10ec8395b8 100644 --- a/rpython/jit/metainterp/test/test_virtualizable.py +++ b/rpython/jit/metainterp/test/test_virtualizable.py @@ -665,7 +665,7 @@ class ImplicitVirtualizableTests(object): jitdriver.jit_merge_point(frame=frame) try: g() - except FooError, e: + except FooError as e: frame.x -= e.value frame.y += 1 return frame.x diff --git a/rpython/jit/metainterp/test/test_warmspot.py b/rpython/jit/metainterp/test/test_warmspot.py index dfcc99f609..9f4311b474 100644 --- a/rpython/jit/metainterp/test/test_warmspot.py +++ b/rpython/jit/metainterp/test/test_warmspot.py @@ -45,7 +45,7 @@ class TestLLWarmspot(LLJitMixin): def main(a): try: interpreter_loop(a) - except Exit, e: + except Exit as e: return e.result res = self.meta_interp(main, [1]) @@ -624,7 +624,7 @@ class TestWarmspotDirect(object): pass def setup_descrs(self): - pass + return [] def get_latest_descr(self, deadframe): assert isinstance(deadframe, FakeDeadFrame) @@ -674,7 +674,7 @@ class TestWarmspotDirect(object): assert jd._assembler_call_helper(FakeDeadFrame(1), 0) == 10 try: jd._assembler_call_helper(FakeDeadFrame(3), 0) - except LLException, lle: + except LLException as lle: assert lle[0] == self.exc_vtable else: py.test.fail("DID NOT RAISE") diff --git a/rpython/jit/metainterp/warmspot.py b/rpython/jit/metainterp/warmspot.py index c1255b751d..6d65333621 100644 --- a/rpython/jit/metainterp/warmspot.py +++ b/rpython/jit/metainterp/warmspot.py @@ -82,7 +82,7 @@ def jittify_and_run(interp, graph, args, repeat=1, graph_and_interp_only=False, backendopt=False, trace_limit=sys.maxint, inline=False, loop_longevity=0, retrace_limit=5, function_threshold=4, disable_unrolling=sys.maxint, - enable_opts=ALL_OPTS_NAMES, max_retrace_guards=15, + enable_opts=ALL_OPTS_NAMES, max_retrace_guards=15, max_unroll_recursion=7, vec=1, vec_all=0, vec_cost=0, vec_length=60, vec_ratio=2, vec_guard_ratio=3, **kwds): from rpython.config.config import ConfigError @@ -277,6 +277,7 @@ class WarmRunnerDesc(object): for vinfo in vinfos: if vinfo is not None: vinfo.finish() + self.metainterp_sd.finish_setup_descrs() if self.cpu.translate_support_code: self.annhelper.finish() @@ -487,7 +488,7 @@ class WarmRunnerDesc(object): if opencoder_model == 'big': self.metainterp_sd.opencoder_model = BigModel else: - self.metainterp_sd.opencoder_model = Model + self.metainterp_sd.opencoder_model = Model self.stats.metainterp_sd = self.metainterp_sd def make_virtualizable_infos(self): @@ -541,7 +542,7 @@ class WarmRunnerDesc(object): raise # go through except StackOverflow: raise # go through - except Exception, e: + except Exception as e: if not we_are_translated(): print "~~~ Crash in JIT!" print '~~~ %s: %s' % (e.__class__, e) @@ -906,7 +907,7 @@ class WarmRunnerDesc(object): # want to interrupt the whole interpreter loop. return support.maybe_on_top_of_llinterp(rtyper, portal_ptr)(*args) - except jitexc.ContinueRunningNormally, e: + except jitexc.ContinueRunningNormally as e: args = () for ARGTYPE, attrname, count in portalfunc_ARGS: x = getattr(e, attrname)[count] @@ -917,28 +918,28 @@ class WarmRunnerDesc(object): except jitexc.DoneWithThisFrameVoid: assert result_kind == 'void' return - except jitexc.DoneWithThisFrameInt, e: + except jitexc.DoneWithThisFrameInt as e: assert result_kind == 'int' return specialize_value(RESULT, e.result) - except jitexc.DoneWithThisFrameRef, e: + except jitexc.DoneWithThisFrameRef as e: assert result_kind == 'ref' return specialize_value(RESULT, e.result) - except jitexc.DoneWithThisFrameFloat, e: + except jitexc.DoneWithThisFrameFloat as e: assert result_kind == 'float' return specialize_value(RESULT, e.result) - except jitexc.ExitFrameWithExceptionRef, e: + except jitexc.ExitFrameWithExceptionRef as e: value = ts.cast_to_baseclass(e.value) if not we_are_translated(): raise LLException(ts.get_typeptr(value), value) else: value = cast_base_ptr_to_instance(Exception, value) - raise Exception, value + raise value def handle_jitexception(e): # XXX the bulk of this function is mostly a copy-paste from above try: raise e - except jitexc.ContinueRunningNormally, e: + except jitexc.ContinueRunningNormally as e: args = () for ARGTYPE, attrname, count in portalfunc_ARGS: x = getattr(e, attrname)[count] @@ -951,22 +952,22 @@ class WarmRunnerDesc(object): except jitexc.DoneWithThisFrameVoid: assert result_kind == 'void' return - except jitexc.DoneWithThisFrameInt, e: + except jitexc.DoneWithThisFrameInt as e: assert result_kind == 'int' return e.result - except jitexc.DoneWithThisFrameRef, e: + except jitexc.DoneWithThisFrameRef as e: assert result_kind == 'ref' return e.result - except jitexc.DoneWithThisFrameFloat, e: + except jitexc.DoneWithThisFrameFloat as e: assert result_kind == 'float' return e.result - except jitexc.ExitFrameWithExceptionRef, e: + except jitexc.ExitFrameWithExceptionRef as e: value = ts.cast_to_baseclass(e.value) if not we_are_translated(): raise LLException(ts.get_typeptr(value), value) else: value = cast_base_ptr_to_instance(Exception, value) - raise Exception, value + raise value jd._ll_portal_runner = ll_portal_runner # for debugging jd.portal_runner_ptr = self.helper_func(jd._PTR_PORTAL_FUNCTYPE, @@ -984,7 +985,7 @@ class WarmRunnerDesc(object): fail_descr = self.cpu.get_latest_descr(deadframe) try: fail_descr.handle_fail(deadframe, self.metainterp_sd, jd) - except jitexc.JitException, e: + except jitexc.JitException as e: return handle_jitexception(e) else: assert 0, "should have raised" |