1. agentultra
  2. pypy

Commits

Hakan Ardo  committed 2e08608

dont call get_cloned() on values not surviving

  • Participants
  • Parent commits f93eceb
  • Branches jit-short_from_state

Comments (0)

Files changed (2)

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

View file
  • Ignore whitespace
         new.producer = self.producer
         assert self.posponedop is None
 
-        for box, value in self.values.items():
+        for box in short_boxes.keys() + surviving_boxes:
             box = new.getinterned(box)
+            value = self.getvalue(box)
             force = box in surviving_boxes
             value = value.get_cloned(new, valuemap,
                                      force_if_needed=force)

File pypy/jit/metainterp/test/test_string.py

View file
  • Ignore whitespace
             return sa
         assert self.meta_interp(f, [16, 'a']) == f(16, 'a')
 
+    def test_boxed_virtual_string_not_surviving(self):
+        class StrBox(object):
+            def __init__(self, val):
+                self.val = val
+        class IntBox(object):
+            def __init__(self, val):
+                self.val = val
+        _str = self._str
+        mydriver = JitDriver(reds = ['i', 'nt', 'sa'], greens = [])
+        def f(c):
+            nt = StrBox(_str(c*16))
+            sa = StrBox(_str(''))
+            i = IntBox(0)
+            while i.val < len(nt.val):
+                mydriver.jit_merge_point(i=i, nt=nt, sa=sa)
+                sa = StrBox(sa.val + StrBox(nt.val[i.val]).val)
+                i = IntBox(i.val + 1)
+            return len(sa.val)
+        assert self.meta_interp(f, ['a']) == f('a')
+
 #class TestOOtype(StringTests, OOJitMixin):
 #    CALL = "oosend"
 #    CALL_PURE = "oosend_pure"