Commits

Carl Friedrich Bolz committed 0c9d8be Merge

merge default

  • Participants
  • Parent commits 69a33b0, c7a48d3
  • Branches small-unroll-improvements

Comments (0)

Files changed (7)

File rpython/config/test/test_translationoption.py

 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') 

File rpython/config/translationoption.py

 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.
 
 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
 
                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={

File rpython/jit/backend/x86/test/test_zrpy_gcasmgcc.py

+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"

File rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py

         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)))

File rpython/jit/metainterp/optimizeopt/unroll.py

             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
             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()

File rpython/jit/metainterp/optimizeopt/virtualstate.py

     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, {}):
     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
         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)
         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)
         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
 
         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
         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
 

File rpython/jit/metainterp/test/test_loop.py

         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"