Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: small-unroll-improvements Changeset: r70444:0c9d8beef0c6 Date: 2014-04-04 18:46 +0200 http://bitbucket.org/pypy/pypy/changeset/0c9d8beef0c6/
Log: merge default diff --git a/rpython/config/test/test_translationoption.py b/rpython/config/test/test_translationoption.py --- a/rpython/config/test/test_translationoption.py +++ b/rpython/config/test/test_translationoption.py @@ -1,10 +1,17 @@ import py from rpython.config.translationoption import get_combined_translation_config from rpython.config.translationoption import set_opt_level -from rpython.config.config import ConflictConfigError +from rpython.config.config import ConflictConfigError, ConfigError +from rpython.translator.platform import platform as compiler def test_no_gcrootfinder_with_boehm(): config = get_combined_translation_config() config.translation.gcrootfinder = "shadowstack" py.test.raises(ConflictConfigError, set_opt_level, config, '0') + +if compiler.name == 'msvc': + def test_no_asmgcrot_on_msvc(): + config = get_combined_translation_config() + py.test.raises(ConfigError, config.translation.setoption, + 'gcrootfinder', 'asmgcc', 'user') diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py --- a/rpython/config/translationoption.py +++ b/rpython/config/translationoption.py @@ -1,9 +1,10 @@ import sys import os from rpython.config.config import OptionDescription, BoolOption, IntOption, ArbitraryOption, FloatOption -from rpython.config.config import ChoiceOption, StrOption, Config +from rpython.config.config import ChoiceOption, StrOption, Config, ConflictConfigError from rpython.config.config import ConfigError from rpython.config.support import detect_number_of_processors +from rpython.translator.platform import platform as compiler DEFL_INLINE_THRESHOLD = 32.4 # just enough to inline add__Int_Int() # and just small enough to prevend inlining of some rlist functions. @@ -16,8 +17,13 @@ if sys.platform.startswith("linux"): DEFL_ROOTFINDER_WITHJIT = "asmgcc" + ROOTFINDERS = ["n/a", "shadowstack", "asmgcc"] +elif compiler.name == 'msvc': + DEFL_ROOTFINDER_WITHJIT = "shadowstack" + ROOTFINDERS = ["n/a", "shadowstack"] else: DEFL_ROOTFINDER_WITHJIT = "shadowstack" + ROOTFINDERS = ["n/a", "shadowstack", "asmgcc"] IS_64_BITS = sys.maxint > 2147483647 @@ -85,7 +91,7 @@ default=IS_64_BITS, cmdline="--gcremovetypeptr"), ChoiceOption("gcrootfinder", "Strategy for finding GC Roots (framework GCs only)", - ["n/a", "shadowstack", "asmgcc"], + ROOTFINDERS, "shadowstack", cmdline="--gcrootfinder", requires={ diff --git a/rpython/jit/backend/x86/test/test_zrpy_gcasmgcc.py b/rpython/jit/backend/x86/test/test_zrpy_gcasmgcc.py --- a/rpython/jit/backend/x86/test/test_zrpy_gcasmgcc.py +++ b/rpython/jit/backend/x86/test/test_zrpy_gcasmgcc.py @@ -1,4 +1,9 @@ +import py from rpython.jit.backend.llsupport.test.zrpy_gc_test import CompileFrameworkTests +from rpython.translator.platform import platform as compiler + +if compiler.name == 'msvc': + py.test.skip('asmgcc buggy on msvc') class TestAsmGcc(CompileFrameworkTests): gcrootfinder = "asmgcc" diff --git a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py --- a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py @@ -89,6 +89,11 @@ assert isgeneral(OptValue(ConstPtr(fooref)), OptValue(ConstPtr(fooref))) + value1 = OptValue(BoxPtr()) + value1.make_nonnull(None) + value2 = OptValue(ConstPtr(LLtypeMixin.nullptr)) + assert not isgeneral(value1, value2) + def test_field_matching_generalization(self): const1 = NotVirtualStateInfo(OptValue(ConstInt(1))) const2 = NotVirtualStateInfo(OptValue(ConstInt(2))) diff --git a/rpython/jit/metainterp/optimizeopt/unroll.py b/rpython/jit/metainterp/optimizeopt/unroll.py --- a/rpython/jit/metainterp/optimizeopt/unroll.py +++ b/rpython/jit/metainterp/optimizeopt/unroll.py @@ -296,7 +296,7 @@ i += 1 newoperations = self.optimizer.get_newoperations() self.short.append(ResOperation(rop.JUMP, short_jumpargs, None, descr=start_label.getdescr())) - self.finilize_short_preamble(start_label) + self.finalize_short_preamble(start_label) def close_loop(self, start_label, jumpop): virtual_state = self.initial_virtual_state @@ -403,9 +403,9 @@ assert isinstance(target_token, TargetToken) target_token.targeting_jitcell_token.retraced_count = sys.maxint - self.finilize_short_preamble(start_label) + self.finalize_short_preamble(start_label) - def finilize_short_preamble(self, start_label): + def finalize_short_preamble(self, start_label): short = self.short assert short[-1].getopnum() == rop.JUMP target_token = start_label.getdescr() diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py --- a/rpython/jit/metainterp/optimizeopt/virtualstate.py +++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py @@ -18,7 +18,15 @@ position = -1 def generalization_of(self, other, renum, bad): - raise NotImplementedError + assert self.position != -1 + if self.position in renum: + result = renum[self.position] == other.position + else: + renum[self.position] = other.position + result = self.generalization_of_renumbering_done(other, renum, bad) + if not result: + bad[self] = bad[other] = None + return result def generate_guards(self, other, box, cpu, extra_guards, renum): if self.generalization_of(other, renum, {}): @@ -67,37 +75,21 @@ def __init__(self, fielddescrs): self.fielddescrs = fielddescrs - def generalization_of(self, other, renum, bad): - assert self.position != -1 - if self.position in renum: - if renum[self.position] == other.position: - return True - bad[self] = None - bad[other] = None - return False - renum[self.position] = other.position + def generalization_of_renumbering_done(self, other, renum, bad): if not self._generalization_of(other): - bad[self] = None - bad[other] = None return False assert isinstance(other, AbstractVirtualStructStateInfo) assert len(self.fielddescrs) == len(self.fieldstate) assert len(other.fielddescrs) == len(other.fieldstate) if len(self.fielddescrs) != len(other.fielddescrs): - bad[self] = None - bad[other] = None return False for i in range(len(self.fielddescrs)): if other.fielddescrs[i] is not self.fielddescrs[i]: - bad[self] = None - bad[other] = None return False if not self.fieldstate[i].generalization_of(other.fieldstate[i], renum, bad): - bad[self] = None - bad[other] = None return False return True @@ -130,11 +122,8 @@ self.known_class = known_class def _generalization_of(self, other): - if not isinstance(other, VirtualStateInfo): - return False - if not self.known_class.same_constant(other.known_class): - return False - return True + return (isinstance(other, VirtualStateInfo) and + self.known_class.same_constant(other.known_class)) def debug_header(self, indent): debug_print(indent + 'VirtualStateInfo(%d):' % self.position) @@ -146,11 +135,8 @@ self.typedescr = typedescr def _generalization_of(self, other): - if not isinstance(other, VStructStateInfo): - return False - if self.typedescr is not other.typedescr: - return False - return True + return (isinstance(other, VStructStateInfo) and + self.typedescr is other.typedescr) def debug_header(self, indent): debug_print(indent + 'VStructStateInfo(%d):' % self.position) @@ -165,28 +151,14 @@ return (isinstance(other, VArrayStateInfo) and self.arraydescr is other.arraydescr) - def generalization_of(self, other, renum, bad): - assert self.position != -1 - if self.position in renum: - if renum[self.position] == other.position: - return True - bad[self] = None - bad[other] = None - return False - renum[self.position] = other.position + def generalization_of_renumbering_done(self, other, renum, bad): if not self._generalization_of(other): - bad[self] = None - bad[other] = None return False if len(self.fieldstate) != len(other.fieldstate): - bad[self] = None - bad[other] = None return False for i in range(len(self.fieldstate)): if not self.fieldstate[i].generalization_of(other.fieldstate[i], renum, bad): - bad[self] = None - bad[other] = None return False return True @@ -216,41 +188,23 @@ self.arraydescr = arraydescr self.fielddescrs = fielddescrs - def generalization_of(self, other, renum, bad): - assert self.position != -1 - if self.position in renum: - if renum[self.position] == other.position: - return True - bad[self] = None - bad[other] = None - return False - renum[self.position] = other.position + def generalization_of_renumbering_done(self, other, renum, bad): if not self._generalization_of(other): - bad[self] = None - bad[other] = None return False assert isinstance(other, VArrayStructStateInfo) if len(self.fielddescrs) != len(other.fielddescrs): - bad[self] = None - bad[other] = None return False p = 0 for i in range(len(self.fielddescrs)): if len(self.fielddescrs[i]) != len(other.fielddescrs[i]): - bad[self] = None - bad[other] = None return False for j in range(len(self.fielddescrs[i])): if self.fielddescrs[i][j] is not other.fielddescrs[i][j]: - bad[self] = None - bad[other] = None return False if not self.fieldstate[p].generalization_of(other.fieldstate[p], renum, bad): - bad[self] = None - bad[other] = None return False p += 1 return True @@ -302,49 +256,31 @@ self.position_in_notvirtuals = -1 self.lenbound = value.lenbound - def generalization_of(self, other, renum, bad): + def generalization_of_renumbering_done(self, other, renum, bad): # XXX This will always retrace instead of forcing anything which # might be what we want sometimes? - assert self.position != -1 - if self.position in renum: - if renum[self.position] == other.position: - return True - bad[self] = None - bad[other] = None - return False - renum[self.position] = other.position if not isinstance(other, NotVirtualStateInfo): - bad[self] = None - bad[other] = None return False if other.level < self.level: - bad[self] = None - bad[other] = None return False if self.level == LEVEL_CONSTANT: if not self.constbox.same_constant(other.constbox): - bad[self] = None - bad[other] = None return False elif self.level == LEVEL_KNOWNCLASS: if not self.known_class.same_constant(other.known_class): - bad[self] = None - bad[other] = None return False + elif self.level == LEVEL_NONNULL: + if other.constbox and not other.constbox.nonnull(): + return False + if not self.intbound.contains_bound(other.intbound): - bad[self] = None - bad[other] = None return False if self.lenbound and other.lenbound: if self.lenbound.mode != other.lenbound.mode or \ self.lenbound.descr != other.lenbound.descr or \ not self.lenbound.bound.contains_bound(other.lenbound.bound): - bad[self] = None - bad[other] = None return False elif self.lenbound: - bad[self] = None - bad[other] = None return False return True diff --git a/rpython/jit/metainterp/test/test_loop.py b/rpython/jit/metainterp/test/test_loop.py --- a/rpython/jit/metainterp/test/test_loop.py +++ b/rpython/jit/metainterp/test/test_loop.py @@ -502,6 +502,50 @@ assert self.meta_interp(h, [25]) == h(25) + def test_two_bridged_loops_classes(self): + myjitdriver = JitDriver(greens = ['pos'], reds = ['i', 'n', 'x', 's']) + class A(object): + pass + bytecode = "I7i" + def f(n, s): + i = x = 0 + pos = 0 + op = '-' + while pos < len(bytecode): + myjitdriver.jit_merge_point(pos=pos, i=i, n=n, s=s, x=x) + op = bytecode[pos] + if op == 'i': + i += 1 + pos -= 2 + myjitdriver.can_enter_jit(pos=pos, i=i, n=n, s=s, x=x) + continue + elif op == 'I': + if not (i < n): + pos += 2 + elif op == '7': + if s is not None: + x = x + 7 + else: + x = x + 2 + pos += 1 + return x + + def g(n, s): + if s == 2: + s = None + else: + s = A() + sa = 0 + for i in range(7): + sa += f(n, s) + return sa + #assert self.meta_interp(g, [25, 1]) == g(25, 1) + + def h(n): + return g(n, 1) + g(n, 2) + assert self.meta_interp(h, [25]) == h(25) + + def test_three_nested_loops(self): myjitdriver = JitDriver(greens = ['i'], reds = ['x']) bytecode = ".+357" _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit