[pypy-commit] pypy optresult: hack on a const a bit
fijal
noreply at buildbot.pypy.org
Tue May 26 19:54:18 CEST 2015
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: optresult
Changeset: r77592:32e203611ca3
Date: 2015-05-26 19:51 +0200
http://bitbucket.org/pypy/pypy/changeset/32e203611ca3/
Log: hack on a const a bit
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
@@ -3,6 +3,7 @@
from rpython.jit.metainterp.resoperation import AbstractValue, ResOperation,\
rop
from rpython.jit.metainterp.history import ConstInt
+from rpython.rtyper.lltypesystem import rstr, lltype
""" The tag field on PtrOptInfo has a following meaning:
@@ -325,6 +326,24 @@
def get_last_guard(self, optimizer):
return None
+
+ def _unpack_str(self, mode):
+ return mode.hlstr(lltype.cast_opaque_ptr(
+ lltype.Ptr(mode.LLTYPE), self._const.getref_base()))
+
+ def getstrlen(self, op, string_optimizer, mode, ignored):
+ return ConstInt(len(self._unpack_str(mode)))
+
+ def string_copy_parts(self, op, string_optimizer, targetbox, offsetbox,
+ mode):
+ from rpython.jit.metainterp.optimizeopt import vstring
+ from rpython.jit.metainterp.optimizeopt.optimizer import CONST_0
+
+ lgt = self.getstrlen(op, string_optimizer, mode, None)
+ return vstring.copy_str_content(string_optimizer, self._const,
+ targetbox, CONST_0, offsetbox,
+ lgt, mode)
+
class XPtrOptInfo(AbstractInfo):
_attrs_ = ('_tag', 'known_class', 'last_guard_pos', 'lenbound')
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
@@ -68,27 +68,10 @@
self.lenbound = intutils.ConstIntBound(self.length)
return self.lenbound
- def get_constant_string_spec(self, mode):
- if self.is_constant():
- xxx
- return None
-
def force_box(self, op, optforce):
if not self.is_virtual():
return op
self._is_virtual = False
- if self.mode is mode_string:
- s = self.get_constant_string_spec(mode_string)
- if s is not None:
- c_s = get_const_ptr_for_string(s)
- self.make_constant(c_s)
- return
- else:
- s = self.get_constant_string_spec(mode_unicode)
- if s is not None:
- c_s = get_const_ptr_for_unicode(s)
- self.make_constant(c_s)
- return
lengthbox = self.getstrlen(op, optforce, self.mode, None)
newop = ResOperation(self.mode.NEWSTR, [lengthbox])
if not we_are_translated():
@@ -109,14 +92,6 @@
def getstrlen(self, op, string_optimizer, mode, lengthop):
if self.lgtop is not None:
return self.lgtop
- if mode is mode_string:
- s = self.get_constant_string_spec(mode_string)
- if s is not None:
- return ConstInt(len(s))
- else:
- s = self.get_constant_string_spec(mode_unicode)
- if s is not None:
- return ConstInt(len(s))
if string_optimizer is None:
return None
assert not self.is_virtual()
More information about the pypy-commit
mailing list