1. Van Lindberg
  2. pypy

Commits

Armin Rigo  committed 665b14e Merge

merge heads

  • Participants
  • Parent commits 5478d1f, 3150cc4
  • Branches default

Comments (0)

Files changed (3)

File pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py

View file
  • Ignore whitespace
         """
         self.optimize_strunicode_loop(ops, expected)
 
+    def test_str_slice_plain_virtual(self):
+        ops = """
+        []
+        p0 = newstr(11)
+        copystrcontent(s"hello world", p0, 0, 0, 11)
+        p1 = call(0, p0, 0, 5, descr=strslicedescr)
+        finish(p1)
+        """
+        expected = """
+        []
+        p0 = newstr(11)
+        copystrcontent(s"hello world", p0, 0, 0, 11)
+        # Eventually this should just return s"hello", but ATM this test is
+        # just verifying that it doesn't return "\0\0\0\0\0", so being
+        # slightly underoptimized is ok.
+        p1 = newstr(5)
+        copystrcontent(p0, p1, 0, 0, 5)
+        finish(p1)
+        """
+        self.optimize_strunicode_loop(ops, expected)
+
     # ----------
     def optimize_strunicode_loop_extradescrs(self, ops, optops):
         class FakeCallInfoCollection:

File pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py

View file
  • Ignore whitespace
         """
         self.optimize_loop(ops, expected)
 
+    def test_repeated_setfield_mixed_with_guard(self):
+        ops = """
+        [p22, p18]
+        setfield_gc(p22, 2, descr=valuedescr)
+        guard_nonnull_class(p18, ConstClass(node_vtable)) []
+        setfield_gc(p22, 2, descr=valuedescr)
+        jump(p22, p18)
+        """
+        preamble = """
+        [p22, p18]
+        setfield_gc(p22, 2, descr=valuedescr)
+        guard_nonnull_class(p18, ConstClass(node_vtable)) []
+        jump(p22, p18)
+        """
+        expected = """
+        [p22, p18]
+        jump(p22, p18)
+        """
+        self.optimize_loop(ops, expected, preamble)
+
 class TestLLtype(OptimizeOptTest, LLtypeMixin):
     pass
 

File pypy/jit/metainterp/optimizeopt/vstring.py

View file
  • Ignore whitespace
         #
         if (isinstance(vstr, VStringPlainValue) and vstart.is_constant()
             and vstop.is_constant()):
-            # slicing with constant bounds of a VStringPlainValue
-            value = self.make_vstring_plain(op.result, op, mode)
-            value.setup_slice(vstr._chars, vstart.box.getint(),
-                                           vstop.box.getint())
-            return True
+            # slicing with constant bounds of a VStringPlainValue, if any of
+            # the characters is unitialized we don't do this special slice, we
+            # do the regular copy contents.
+            for i in range(vstart.box.getint(), vstop.box.getint()):
+                if vstr.getitem(i) is optimizer.CVAL_UNINITIALIZED_ZERO:
+                    break
+            else:
+                value = self.make_vstring_plain(op.result, op, mode)
+                value.setup_slice(vstr._chars, vstart.box.getint(),
+                                               vstop.box.getint())
+                return True
         #
         vstr.ensure_nonnull()
         lengthbox = _int_sub(self, vstop.force_box(self),