[pypy-commit] pypy optresult: handle null in a few more places

fijal noreply at buildbot.pypy.org
Wed May 27 09:22:40 CEST 2015


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: optresult
Changeset: r77607:4e460872afa9
Date: 2015-05-27 09:22 +0200
http://bitbucket.org/pypy/pypy/changeset/4e460872afa9/

Log:	handle null in a few more places

diff --git a/rpython/jit/metainterp/optimizeopt/info.py b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -50,6 +50,9 @@
     def same_info(self, other):
         return self is other
 
+    def getstrlen(self, arg, opt, mode, create_ops=True):
+        return None
+
     
 class NonNullPtrInfo(PtrInfo):
     _attrs_ = ('last_guard_pos',)
@@ -340,7 +343,10 @@
         return self._unpack_str(mode)
     
     def getstrlen(self, op, string_optimizer, mode, create_ops=True):
-        return ConstInt(len(self._unpack_str(mode)))
+        s = self._unpack_str(mode)
+        if not s:
+            return None
+        return ConstInt(len(s))
 
     def string_copy_parts(self, op, string_optimizer, targetbox, offsetbox,
                           mode):
diff --git a/rpython/jit/metainterp/optimizeopt/vstring.py b/rpython/jit/metainterp/optimizeopt/vstring.py
--- a/rpython/jit/metainterp/optimizeopt/vstring.py
+++ b/rpython/jit/metainterp/optimizeopt/vstring.py
@@ -895,7 +895,7 @@
         if self.handle_str_equal_level2(arg2, arg1, op, mode):
             return True
         #
-        if i1.is_nonnull() and i2.is_nonnull():
+        if i1 and i1.is_nonnull() and i2 and i2.is_nonnull():
             if l1box is not None and l2box is not None and l1box.same_box(l2box):
                 do = EffectInfo.OS_STREQ_LENGTHOK
             else:
@@ -925,28 +925,29 @@
                     l1box = i1.getstrlen(arg1, self, mode, False)
                 if isinstance(l1box, ConstInt) and l1box.value == 1:
                     # comparing two single chars
-                    vchar1 = self.strgetitem(resultop, arg1, optimizer.CONST_0, mode)
-                    vchar2 = self.strgetitem(resultop, arg2, optimizer.CONST_0, mode)
+                    vchar1 = self.strgetitem(None, arg1, optimizer.CONST_0,
+                                             mode)
+                    vchar2 = self.strgetitem(None, arg2, optimizer.CONST_0,
+                                             mode)
                     seo = self.optimizer.send_extra_operation
                     op = self.optimizer.replace_op_with(resultop, rop.INT_EQ,
                                 [vchar1, vchar2], descr=DONT_CHANGE)
                     seo(op)
                     return True
                 if isinstance(i1, VStringSliceInfo):
-                    vchar = self.strgetitem(v2, optimizer.CVAL_ZERO, mode)
+                    vchar = self.strgetitem(None, arg2, optimizer.CONST_0,
+                                            mode)
                     do = EffectInfo.OS_STREQ_SLICE_CHAR
-                    self.generate_modified_call(do, [v1.vstr.force_box(self),
-                                                     v1.vstart.force_box(self),
-                                                     v1.vlength.force_box(self),
-                                                     vchar.force_box(self)],
+                    self.generate_modified_call(do, [i1.s, i1.start,
+                                                     i1.lgtop, vchar],
                                                      resultop, mode)
                     return True
         #
         if i2 and i2.is_null():
-            if i1.is_nonnull():
+            if i1 and i1.is_nonnull():
                 self.make_constant(resultop, CONST_0)
                 return True
-            if i1.is_null():
+            if i1 and i1.is_null():
                 self.make_constant(resultop, CONST_1)
                 return True
             op = self.optimizer.replace_op_with(resultop, rop.PTR_EQ,
@@ -976,15 +977,13 @@
                                                 resultbox, mode)
                     return True
             #
-        if i1.is_virtual() and isinstance(i1, VStringSliceInfo):
-            if v2.is_nonnull():
+        if isinstance(i1, VStringSliceInfo) and i1.is_virtual():
+            if i2 and i2.is_nonnull():
                 do = EffectInfo.OS_STREQ_SLICE_NONNULL
             else:
                 do = EffectInfo.OS_STREQ_SLICE_CHECKNULL
-            self.generate_modified_call(do, [v1.vstr.force_box(self),
-                                             v1.vstart.force_box(self),
-                                             v1.vlength.force_box(self),
-                                             v2.force_box(self)], resultbox, mode)
+            self.generate_modified_call(do, [i1.s, i1.start, i1.lgtop,
+                                             arg2], resultbox, mode)
             return True
         return False
 


More information about the pypy-commit mailing list