[pypy-svn] r77382 - in pypy/branch/jit-str/pypy/jit: codewriter metainterp/optimizeopt metainterp/test
arigo at codespeak.net
arigo at codespeak.net
Sun Sep 26 17:15:08 CEST 2010
Author: arigo
Date: Sun Sep 26 17:15:06 2010
New Revision: 77382
Modified:
pypy/branch/jit-str/pypy/jit/codewriter/effectinfo.py
pypy/branch/jit-str/pypy/jit/codewriter/jtransform.py
pypy/branch/jit-str/pypy/jit/metainterp/optimizeopt/string.py
pypy/branch/jit-str/pypy/jit/metainterp/test/test_optimizeopt.py
pypy/branch/jit-str/pypy/jit/metainterp/test/test_ztranslation.py
Log:
Mostly translation fixes. Also undo a reordering in string.py which was buggy
(and shown by test_optimizeopt).
Modified: pypy/branch/jit-str/pypy/jit/codewriter/effectinfo.py
==============================================================================
--- pypy/branch/jit-str/pypy/jit/codewriter/effectinfo.py (original)
+++ pypy/branch/jit-str/pypy/jit/codewriter/effectinfo.py Sun Sep 26 17:15:06 2010
@@ -129,20 +129,14 @@
# ____________________________________________________________
-_callinfo_for_oopspec = {}
-
-def _callinfo_for_oopspec_memo(oopspecindex):
- return _callinfo_for_oopspec.get(oopspecindex, (None, 0))
-_callinfo_for_oopspec_memo._annspecialcase_ = 'specialize:memo'
+_callinfo_for_oopspec = {} # {oopspecindex: (calldescr, func_as_int)}
def callinfo_for_oopspec(oopspecindex):
- """A memo function that returns the calldescr and the function
+ """A function that returns the calldescr and the function
address (as an int) of one of the OS_XYZ functions defined above.
Don't use this if there might be several implementations of the same
OS_XYZ specialized by type, e.g. OS_ARRAYCOPY."""
- calldescr, func = _callinfo_for_oopspec_memo(oopspecindex)
- assert calldescr is not None
- return calldescr, func
+ return _callinfo_for_oopspec[oopspecindex]
def _funcptr_for_oopspec_memo(oopspecindex):
Modified: pypy/branch/jit-str/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/branch/jit-str/pypy/jit/codewriter/jtransform.py (original)
+++ pypy/branch/jit-str/pypy/jit/codewriter/jtransform.py Sun Sep 26 17:15:06 2010
@@ -1055,7 +1055,9 @@
[c_func] + [varoftype(T) for T in argtypes],
varoftype(resulttype))
calldescr = self.callcontrol.getcalldescr(op, oopspecindex)
- _callinfo_for_oopspec[oopspecindex] = calldescr, c_func.value
+ func = heaptracker.adr2int(
+ llmemory.cast_ptr_to_adr(c_func.value))
+ _callinfo_for_oopspec[oopspecindex] = calldescr, func
def _handle_stroruni_call(self, op, oopspec_name, args):
if args[0].concretetype.TO == rstr.STR:
Modified: pypy/branch/jit-str/pypy/jit/metainterp/optimizeopt/string.py
==============================================================================
--- pypy/branch/jit-str/pypy/jit/metainterp/optimizeopt/string.py (original)
+++ pypy/branch/jit-str/pypy/jit/metainterp/optimizeopt/string.py Sun Sep 26 17:15:06 2010
@@ -172,6 +172,8 @@
return None
start = self.vstart.box.getint()
length = self.vlength.box.getint()
+ assert start >= 0
+ assert length >= 0
return s1[start : start + length]
return None
@@ -384,6 +386,9 @@
return True
#
vstr.ensure_nonnull()
+ lengthbox = _int_sub(newoperations, vstop.force_box(),
+ vstart.force_box())
+ #
if isinstance(vstr, VStringSliceValue):
# double slicing s[i:j][k:l]
vintermediate = vstr
@@ -393,8 +398,6 @@
vstart.force_box())
vstart = self.getvalue(startbox)
#
- lengthbox = _int_sub(newoperations, vstop.force_box(),
- vstart.force_box())
value = self.make_vstring_slice(op.result, op)
value.setup(vstr, vstart, self.getvalue(lengthbox))
return True
@@ -506,12 +509,9 @@
def generate_modified_call(self, oopspecindex, args, result):
calldescr, func = callinfo_for_oopspec(oopspecindex)
- func = llmemory.cast_ptr_to_adr(func)
- func = heaptracker.adr2int(func)
op = ResOperation(rop.CALL, [ConstInt(func)] + args, result,
descr=calldescr)
self.optimizer.newoperations.append(op)
- generate_modified_call._annspecialcase_ = 'specialize:arg(1)'
def propagate_forward(self, op):
opnum = op.opnum
Modified: pypy/branch/jit-str/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/jit-str/pypy/jit/metainterp/test/test_optimizeopt.py (original)
+++ pypy/branch/jit-str/pypy/jit/metainterp/test/test_optimizeopt.py Sun Sep 26 17:15:06 2010
@@ -4164,10 +4164,8 @@
if isinstance(value, calldescrtype):
if (value.get_extra_info() and
value.get_extra_info().oopspecindex == oopspecindex):
- from pypy.rpython.lltypesystem import lltype
- func = lltype.nullptr(lltype.FuncType([], lltype.Void))
# returns 0 for 'func' in this test
- return value, func
+ return value, 0
raise AssertionError("not found: oopspecindex=%d" % oopspecindex)
#
saved = string.callinfo_for_oopspec
Modified: pypy/branch/jit-str/pypy/jit/metainterp/test/test_ztranslation.py
==============================================================================
--- pypy/branch/jit-str/pypy/jit/metainterp/test/test_ztranslation.py (original)
+++ pypy/branch/jit-str/pypy/jit/metainterp/test/test_ztranslation.py Sun Sep 26 17:15:06 2010
@@ -21,6 +21,7 @@
# - full optimizer
# - jitdriver hooks
# - two JITs
+ # - string concatenation, slicing and comparison
class Frame(object):
_virtualizable2_ = ['i']
@@ -60,11 +61,15 @@
frame.i -= 1
return total * 10
#
- myjitdriver2 = JitDriver(greens = ['g'], reds = ['m', 'x'])
+ myjitdriver2 = JitDriver(greens = ['g'], reds = ['m', 'x', 's'])
def f2(g, m, x):
+ s = ""
while m > 0:
- myjitdriver2.can_enter_jit(g=g, m=m, x=x)
- myjitdriver2.jit_merge_point(g=g, m=m, x=x)
+ myjitdriver2.can_enter_jit(g=g, m=m, x=x, s=s)
+ myjitdriver2.jit_merge_point(g=g, m=m, x=x, s=s)
+ s += 'xy'
+ if s[:2] == 'yz':
+ return -666
m -= 1
x += 3
return x
More information about the Pypy-commit
mailing list