Author: Armin Rigo <[email protected]>
Branch: bitstring
Changeset: r83909:8d1271f7508d
Date: 2016-04-26 15:51 +0200
http://bitbucket.org/pypy/pypy/changeset/8d1271f7508d/

Log:    More fixes. Remove the CUTOFF in backendopt/writeanalyze.

diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -479,6 +479,9 @@
             all_descrs.append(v)
         return all_descrs
 
+    def fetch_all_descrs(self):
+        return self.descrs.values()
+
     def calldescrof(self, FUNC, ARGS, RESULT, effect_info):
         key = ('call', getkind(RESULT),
                tuple([getkind(A) for A in ARGS]),
diff --git a/rpython/jit/codewriter/effectinfo.py 
b/rpython/jit/codewriter/effectinfo.py
--- a/rpython/jit/codewriter/effectinfo.py
+++ b/rpython/jit/codewriter/effectinfo.py
@@ -174,6 +174,14 @@
         result.call_release_gil_target = call_release_gil_target
         if result.check_can_raise(ignore_memoryerror=True):
             assert oopspecindex in cls._OS_CANRAISE
+
+        if (result._write_descrs_arrays is not None and
+            len(result._write_descrs_arrays) == 1):
+            # this is used only for ARRAYCOPY operations
+            [result.single_write_descr_array] = result._write_descrs_arrays
+        else:
+            result.single_write_descr_array = None
+
         cls._cache[key] = result
         return result
 
@@ -190,9 +198,11 @@
         return bitstring.bitcheck(self.bitstring_write_descrs_arrays,
                                   arraydescr.ei_index)
     def check_readonly_descr_interiorfield(self, interiorfielddescr):
+        # NOTE: this is not used so far
         return 
bitstring.bitcheck(self.bitstring_readonly_descrs_interiorfields,
                                   interiorfielddescr.ei_index)
     def check_write_descr_interiorfield(self, interiorfielddescr):
+        # NOTE: this is not used so far
         return bitstring.bitcheck(self.bitstring_write_descrs_interiorfields,
                                   interiorfielddescr.ei_index)
 
diff --git a/rpython/jit/codewriter/test/test_effectinfo.py 
b/rpython/jit/codewriter/test/test_effectinfo.py
--- a/rpython/jit/codewriter/test/test_effectinfo.py
+++ b/rpython/jit/codewriter/test/test_effectinfo.py
@@ -33,6 +33,7 @@
     assert list(effectinfo._readonly_descrs_fields) == [('fielddescr', S, "a")]
     assert not effectinfo._write_descrs_fields
     assert not effectinfo._write_descrs_arrays
+    assert effectinfo.single_write_descr_array is None
 
 
 def test_include_write_field():
@@ -61,6 +62,7 @@
     assert not effectinfo._readonly_descrs_fields
     assert not effectinfo._write_descrs_fields
     assert list(effectinfo._write_descrs_arrays) == [('arraydescr', A)]
+    assert effectinfo.single_write_descr_array == ('arraydescr', A)
 
 
 def test_dont_include_read_and_write_field():
diff --git a/rpython/jit/metainterp/heapcache.py 
b/rpython/jit/metainterp/heapcache.py
--- a/rpython/jit/metainterp/heapcache.py
+++ b/rpython/jit/metainterp/heapcache.py
@@ -209,7 +209,7 @@
               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 @@
             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 @@
                         
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/optimizeopt/heap.py 
b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -432,10 +432,14 @@
     optimize_GUARD_EXCEPTION = optimize_GUARD_NO_EXCEPTION
 
     def force_from_effectinfo(self, effectinfo):
+        # 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)
-            elif effectinfo.check_write_descr_field(fielddescr):
+            if effectinfo.check_write_descr_field(fielddescr):
                 if fielddescr.is_always_pure():
                     continue
                 try:
@@ -447,7 +451,7 @@
         for arraydescr, submap in self.cached_arrayitems.items():
             if effectinfo.check_readonly_descr_array(arraydescr):
                 self.force_lazy_setarrayitem_submap(submap)
-            elif effectinfo.check_write_descr_array(arraydescr):
+            if effectinfo.check_write_descr_array(arraydescr):
                 self.force_lazy_setarrayitem_submap(submap, can_cache=False)
                 if arraydescr in self.corresponding_array_descrs:
                     dictdescr = self.corresponding_array_descrs.pop(arraydescr)
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py 
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -620,10 +620,10 @@
             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_util.py 
b/rpython/jit/metainterp/optimizeopt/test/test_util.py
--- 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.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 @@
             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/test/test_heapcache.py 
b/rpython/jit/metainterp/test/test_heapcache.py
--- a/rpython/jit/metainterp/test/test_heapcache.py
+++ b/rpython/jit/metainterp/test/test_heapcache.py
@@ -27,8 +27,12 @@
     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 @@
     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/translator/backendopt/writeanalyze.py 
b/rpython/translator/backendopt/writeanalyze.py
--- a/rpython/translator/backendopt/writeanalyze.py
+++ b/rpython/translator/backendopt/writeanalyze.py
@@ -4,7 +4,11 @@
 top_set = object()
 empty_set = frozenset()
 
-CUTOFF = 1000
+# CUTOFF is disabled, as it gave a strangely not-working-any-more effect
+# if the size of the result grows past that bound.  The main user was
+# optimizeopt/heap.py (force_from_effectinfo), which has been rewritten
+# to be happy with any size now.
+#CUTOFF = 1000
 
 class WriteAnalyzer(graphanalyze.GraphAnalyzer):
     def bottom_result(self):
@@ -22,8 +26,8 @@
     def add_to_result(self, result, other):
         if other is top_set:
             return top_set
-        if len(other) + len(result) > CUTOFF:
-            return top_set
+        #if len(other) + len(result) > CUTOFF:
+        #    return top_set
         result.update(other)
         return result
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to