[pypy-commit] pypy result-in-resops: make one test pass
fijal
noreply at buildbot.pypy.org
Tue Jul 24 16:59:49 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: result-in-resops
Changeset: r56427:ce72695c7c79
Date: 2012-07-24 16:59 +0200
http://bitbucket.org/pypy/pypy/changeset/ce72695c7c79/
Log: make one test pass
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
@@ -200,20 +200,21 @@
c._obj.externalobj.operations[-1].setdescr(descr)
for i in range(op.numargs()):
x = op.getarg(i)
- if isinstance(x, history.Box):
+ if not x.is_constant():
llimpl.compile_add_var(c, var2index[x])
- elif isinstance(x, history.ConstInt):
- llimpl.compile_add_int_const(c, x.value)
- elif isinstance(x, self.ts.ConstRef):
- llimpl.compile_add_ref_const(c, x.value, self.ts.BASETYPE)
- elif isinstance(x, history.ConstFloat):
- llimpl.compile_add_float_const(c, x.value)
- elif isinstance(x, Descr):
- llimpl.compile_add_descr_arg(c, x.ofs, x.typeinfo,
- x.arg_types)
else:
- raise Exception("'%s' args contain: %r" % (op.getopname(),
- x))
+ if isinstance(x, history.ConstInt):
+ llimpl.compile_add_int_const(c, x.value)
+ elif isinstance(x, self.ts.ConstRef):
+ llimpl.compile_add_ref_const(c, x.value, self.ts.BASETYPE)
+ elif isinstance(x, history.ConstFloat):
+ llimpl.compile_add_float_const(c, x.value)
+ elif isinstance(x, Descr):
+ llimpl.compile_add_descr_arg(c, x.ofs, x.typeinfo,
+ x.arg_types)
+ else:
+ raise Exception("'%s' args contain: %r" % (op.getopname(),
+ x))
if op.is_guard():
faildescr = op.getdescr()
assert isinstance(faildescr, history.AbstractFailDescr)
@@ -234,11 +235,11 @@
llimpl.compile_add_fail_arg(c, -1)
if op.type == INT:
- var2index[x] = llimpl.compile_add_int_result(c)
+ var2index[op] = llimpl.compile_add_int_result(c)
elif op.type == REF:
- var2index[x] = llimpl.compile_add_ref_result(c, self.ts.BASETYPE)
+ var2index[op] = llimpl.compile_add_ref_result(c, self.ts.BASETYPE)
elif op.type == FLOAT:
- var2index[x] = llimpl.compile_add_float_result(c)
+ var2index[op] = llimpl.compile_add_float_result(c)
op = operations[-1]
assert op.is_final()
if op.getopnum() == rop.JUMP:
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
@@ -7,7 +7,8 @@
ConstInt, ConstPtr,
BoxObj,
ConstObj, BoxFloat, ConstFloat)
-from pypy.jit.metainterp.resoperation import rop
+from pypy.jit.metainterp.resoperation import rop, create_resop_dispatch,\
+ create_resop
from pypy.jit.metainterp.typesystem import deref
from pypy.jit.codewriter.effectinfo import EffectInfo
from pypy.jit.tool.oparser import parse
@@ -77,46 +78,46 @@
if result_type == 'void':
result = None
elif result_type == 'int':
- result = BoxInt()
+ result = 0
elif result_type == 'ref':
- result = BoxPtr()
+ result = lltype.nullptr(llmemory.GCREF)
elif result_type == 'float':
- result = BoxFloat()
+ result = 0.0
else:
raise ValueError(result_type)
+ op0 = create_resop_dispatch(opnum, result, valueboxes)
if result is None:
results = []
else:
- results = [result]
- operations = [ResOperation(opnum, valueboxes, result),
- ResOperation(rop.FINISH, results, None,
- descr=BasicFailDescr(0))]
- if operations[0].is_guard():
- operations[0].setfailargs([])
+ results = [op0]
+ op1 = create_resop(rop.FINISH, results, None, descr=BasicFailDescr(0))
+ if op0.is_guard():
+ op0.setfailargs([])
if not descr:
descr = BasicFailDescr(1)
if descr is not None:
- operations[0].setdescr(descr)
+ op0.setdescr(descr)
inputargs = []
for box in valueboxes:
if isinstance(box, Box) and box not in inputargs:
inputargs.append(box)
- return inputargs, operations
+ return inputargs, [op0, op1]
class BaseBackendTest(Runner):
avoid_instances = False
+ class namespace:
+ faildescr = BasicFailDescr(1)
+
def test_compile_linear_loop(self):
- i0 = BoxInt()
- i1 = BoxInt()
- operations = [
- ResOperation(rop.INT_ADD, [i0, ConstInt(1)], i1),
- ResOperation(rop.FINISH, [i1], None, descr=BasicFailDescr(1))
- ]
- inputargs = [i0]
+ loop = parse("""
+ [i0]
+ i1 = int_add(i0, 1)
+ finish(i1, descr=faildescr)
+ """, namespace=self.namespace.__dict__)
looptoken = JitCellToken()
- self.cpu.compile_loop(inputargs, operations, looptoken)
+ self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
fail = self.cpu.execute_token(looptoken, 2)
res = self.cpu.get_latest_value_int(0)
assert res == 3
More information about the pypy-commit
mailing list