Author: Maciej Fijalkowski <[email protected]>
Branch: continulet-jit-3
Changeset: r58233:370f2d98b923
Date: 2012-10-18 21:58 +0200
http://bitbucket.org/pypy/pypy/changeset/370f2d98b923/
Log: more tests
diff --git a/pypy/jit/backend/llgraph/runner.py
b/pypy/jit/backend/llgraph/runner.py
--- a/pypy/jit/backend/llgraph/runner.py
+++ b/pypy/jit/backend/llgraph/runner.py
@@ -243,13 +243,19 @@
def force(self, frame):
assert not frame._forced
frame._forced = True
- guard_op = frame.lltrace.operations[frame.current_index + 1]
call_op = frame.current_op
+ if call_op.getopnum() == rop.FINISH:
+ guard_op = call_op
+ else:
+ guard_op = frame.lltrace.operations[frame.current_index + 1]
frame.latest_values = frame._getfailargs(guard_op, call_op.result)
descr = guard_op.getdescr()
frame.latest_descr = descr
return descr
+ def set_savedata_ref(self, frame, data):
+ frame.saved_data = data
+
def calldescrof(self, FUNC, ARGS, RESULT, effect_info):
key = ('call', getkind(RESULT),
tuple([getkind(A) for A in ARGS]),
@@ -529,6 +535,13 @@
class LLFrame(object):
_TYPE = llmemory.GCREF
+
+ # some obscure hacks to support comparison with llmemory.GCREF
+ def __ne__(self, other):
+ return not self == other
+ def __eq__(self, other):
+ return isinstance(other, LLFrame) and self is other
+
_forced = False
_execution_finished = False
diff --git a/pypy/jit/backend/test/runner_test.py
b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -2328,6 +2328,20 @@
assert self.cpu.get_latest_value_int(frame, 2) == 10
assert values == [1, 10, frame]
+ def test_force_from_finish(self):
+ loop = parse('''
+ [i1, i2]
+ p0 = jit_frame()
+ finish(p0, descr=faildescr1) [i1, i2]
+ ''', namespace={'faildescr1': BasicFailDescr(1)})
+ looptoken = JitCellToken()
+ self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
+ frame = self.cpu.execute_token(looptoken, 20, 0)
+ descr = self.cpu.force(frame)
+ assert self.cpu.get_latest_descr(frame) is descr
+ assert self.cpu.get_latest_value_int(frame, 0) == 20
+ assert self.cpu.get_latest_value_int(frame, 1) == 0
+
def test_call_to_c_function(self):
from pypy.rlib.libffi import CDLL, types, ArgChain, FUNCFLAG_CDECL
from pypy.rpython.lltypesystem.ll2ctypes import libc_name
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -2988,7 +2988,7 @@
"""
expected = """
[p1]
- i0 = force_token()
+ p0 = jit_frame()
jump(p1)
"""
self.optimize_loop(ops, expected)
diff --git a/pypy/jit/metainterp/test/test_virtualizable.py
b/pypy/jit/metainterp/test/test_virtualizable.py
--- a/pypy/jit/metainterp/test/test_virtualizable.py
+++ b/pypy/jit/metainterp/test/test_virtualizable.py
@@ -229,7 +229,7 @@
res = self.meta_interp(f, [20])
assert res == 134
self.check_simple_loop(setfield_gc=1, getfield_gc=0)
- self.check_resops(setfield_gc=2, getfield_gc=3)
+ self.check_resops(setfield_gc=2, getfield_gc=4)
# ------------------------------
diff --git a/pypy/jit/tool/oparser.py b/pypy/jit/tool/oparser.py
--- a/pypy/jit/tool/oparser.py
+++ b/pypy/jit/tool/oparser.py
@@ -225,7 +225,8 @@
if endnum == -1:
raise ParseError("invalid line: %s" % line)
args, descr = self.parse_args(opname, line[num + 1:endnum])
- if rop._GUARD_FIRST <= opnum <= rop._GUARD_LAST:
+ fail_args = None
+ if rop._GUARD_FIRST <= opnum <= rop._GUARD_LAST or opnum == rop.FINISH:
i = line.find('[', endnum) + 1
j = line.find(']', i)
if (i <= 0 or j <= 0) and not self.nonstrict:
@@ -248,7 +249,6 @@
if hasattr(descr, '_oparser_uses_descr_of_guard'):
descr._oparser_uses_descr_of_guard(self, fail_args)
else:
- fail_args = None
if opnum == rop.FINISH:
if descr is None and self.invent_fail_descr:
descr = self.invent_fail_descr(self.model, fail_args)
diff --git a/pypy/jit/tool/test/test_oparser.py
b/pypy/jit/tool/test/test_oparser.py
--- a/pypy/jit/tool/test/test_oparser.py
+++ b/pypy/jit/tool/test/test_oparser.py
@@ -7,6 +7,9 @@
from pypy.jit.metainterp.history import AbstractDescr, BoxInt, JitCellToken,\
TargetToken
+class FakeDescr(AbstractDescr):
+ pass
+
class BaseTestOparser(object):
OpParser = None
@@ -21,7 +24,7 @@
# a comment
i2 = int_add(i0, i1)
i3 = int_sub(i2, 3) # another comment
- finish() # (tricky)
+ finish() [] # (tricky)
"""
loop = self.parse(x)
assert len(loop.operations) == 3
@@ -42,6 +45,16 @@
assert loop.operations[0].getdescr()
assert loop.operations[0].getfailargs() == []
+ def test_failargs_finish(self):
+ d = FakeDescr()
+ x = """
+ [p0]
+ finish(descr=f) [p0]
+ """
+ loop = self.parse(x, None, {'f': d})
+ assert loop.operations[0].getdescr() is d
+ assert loop.operations[0].getfailargs() == loop.inputargs
+
def test_descr(self):
class Xyz(AbstractDescr):
I_am_a_descr = True # for the mock case
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit