Author: Maciej Fijalkowski <[email protected]>
Branch: result-in-resops
Changeset: r56887:758e5ef63116
Date: 2012-08-27 18:53 +0200
http://bitbucket.org/pypy/pypy/changeset/758e5ef63116/
Log: port the backend test until we run into issues
diff --git a/pypy/jit/backend/llgraph/llimpl.py
b/pypy/jit/backend/llgraph/llimpl.py
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -932,7 +932,7 @@
else:
raise NotImplementedError
- def op_call(self, calldescr, func, *args):
+ def op_call_i(self, calldescr, func, *args):
return self._do_call(calldescr, func, args, call_with_llptr=False)
def op_call_release_gil(self, calldescr, func, *args):
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
@@ -6,7 +6,7 @@
JitCellToken, TargetToken,
BoxObj, BoxFloat)
from pypy.jit.metainterp.resoperation import rop, create_resop_dispatch,\
- create_resop, ConstInt, ConstPtr, ConstFloat, ConstObj
+ create_resop, ConstInt, ConstPtr, ConstFloat, ConstObj, create_resop_2
from pypy.jit.metainterp.typesystem import deref
from pypy.jit.codewriter.effectinfo import EffectInfo
from pypy.rpython.lltypesystem import lltype, llmemory, rstr, rffi, rclass
@@ -87,7 +87,7 @@
results = []
else:
results = [op0]
- op1 = create_resop(rop.FINISH, results, None, descr=BasicFailDescr(0))
+ op1 = create_resop(rop.FINISH, None, results, descr=BasicFailDescr(0))
if op0.is_guard():
op0.setfailargs([])
if not descr:
@@ -361,13 +361,13 @@
def test_execute_operations_in_env(self):
cpu = self.cpu
inputargs, operations, looptoken = self.parse("""
- [x, y]
- label(y, x, descr=targettoken)
- z = int_add(x, y)
- t = int_sub(y, 1)
- u = int_eq(t, 0)
- guard_false(u, descr=faildescr) [t, z]
- jump(t, z, descr=targettoken)
+ [ix, iy]
+ label(iy, ix, descr=targettoken)
+ iz = int_add(ix, iy)
+ it = int_sub(iy, 1)
+ iu = int_eq(it, 0)
+ guard_false(iu, descr=faildescr) [it, iz]
+ jump(it, iz, descr=targettoken)
""", None)
cpu.compile_loop(inputargs, operations, looptoken)
self.cpu.execute_token(looptoken, 0, 10)
@@ -392,42 +392,35 @@
def test_ovf_operations(self, reversed=False):
minint = -sys.maxint-1
boom = 'boom'
- for opnum, testcases in [
- (rop.INT_ADD_OVF, [(10, -2, 8),
+ for op, testcases in [
+ ('int_add_ovf', [(10, -2, 8),
(-1, minint, boom),
(sys.maxint//2, sys.maxint//2+2, boom)]),
- (rop.INT_SUB_OVF, [(-20, -23, 3),
+ ('int_sub_ovf', [(-20, -23, 3),
(-2, sys.maxint, boom),
(sys.maxint//2, -(sys.maxint//2+2), boom)]),
- (rop.INT_MUL_OVF, [(minint/2, 2, minint),
+ ('int_mul_ovf', [(minint/2, 2, minint),
(-2, -(minint/2), minint),
(minint/2, -2, boom)]),
]:
- v1 = BoxInt(testcases[0][0])
- v2 = BoxInt(testcases[0][1])
- v_res = BoxInt()
+ if not reversed:
+ inputargs, operations, looptoken = self.parse("""
+ [i1, i2]
+ ires = %s(i1, i2)
+ guard_no_overflow(descr=faildescr1) []
+ finish(ires, descr=faildescr2)
+ """ % op, namespace={'faildescr1': BasicFailDescr(1),
+ 'faildescr2': BasicFailDescr(2)})
+ else:
+ inputargs, operations, looptoken = self.parse("""
+ [i1, i2]
+ ires = %s(i1, i2)
+ guard_overflow(descr=faildescr1) [ires]
+ finish(descr=faildescr2)
+ """ % op, namespace={'faildescr1': BasicFailDescr(1),
+ 'faildescr2': BasicFailDescr(2)})
#
- if not reversed:
- ops = [
- ResOperation(opnum, [v1, v2], v_res),
- ResOperation(rop.GUARD_NO_OVERFLOW, [], None,
- descr=BasicFailDescr(1)),
- ResOperation(rop.FINISH, [v_res], None,
- descr=BasicFailDescr(2)),
- ]
- ops[1].setfailargs([])
- else:
- v_exc = self.cpu.ts.BoxRef()
- ops = [
- ResOperation(opnum, [v1, v2], v_res),
- ResOperation(rop.GUARD_OVERFLOW, [], None,
- descr=BasicFailDescr(1)),
- ResOperation(rop.FINISH, [], None,
descr=BasicFailDescr(2)),
- ]
- ops[1].setfailargs([v_res])
- #
- looptoken = JitCellToken()
- self.cpu.compile_loop([v1, v2], ops, looptoken)
+ self.cpu.compile_loop(inputargs, operations, looptoken)
for x, y, z in testcases:
excvalue = self.cpu.grab_exc_value()
assert not excvalue
@@ -496,7 +489,7 @@
# first, try it with the "normal" calldescr
calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
EffectInfo.MOST_GENERAL)
- res = self.execute_operation(rop.CALL,
+ res = self.execute_operation(rop.CALL_i,
[funcbox, BoxInt(num), BoxInt(num)],
'int', descr=calldescr)
assert res.value == 2 * num
diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -9,7 +9,7 @@
from pypy.conftest import option
from pypy.jit.metainterp.resoperation import rop, AbstractValue, INT, REF,\
- FLOAT, repr_pointer, repr_object, ConstPtr
+ FLOAT, repr_pointer, repr_object, ConstPtr, ConstFloat
from pypy.jit.codewriter import heaptracker, longlong
import weakref
diff --git a/pypy/jit/metainterp/resoperation.py
b/pypy/jit/metainterp/resoperation.py
--- a/pypy/jit/metainterp/resoperation.py
+++ b/pypy/jit/metainterp/resoperation.py
@@ -15,6 +15,8 @@
HOLE = '_'
def create_resop_dispatch(opnum, result, args, descr=None):
+ """ NOT_RPYTHON this is for tests only!
+ """
cls = opclasses[opnum]
if cls.NUMARGS == 0:
return create_resop_0(opnum, result, descr)
diff --git a/pypy/jit/metainterp/test/test_executor.py
b/pypy/jit/metainterp/test/test_executor.py
--- a/pypy/jit/metainterp/test/test_executor.py
+++ b/pypy/jit/metainterp/test/test_executor.py
@@ -1,18 +1,15 @@
import py
import sys, random
from pypy.rlib.rarithmetic import r_uint, intmask
-from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.rpython.lltypesystem import llmemory, rffi
from pypy.jit.metainterp.executor import execute
from pypy.jit.metainterp.executor import execute_varargs, execute_nonspec
from pypy.jit.metainterp.resoperation import rop, opboolinvers, opboolreflex,
opname
-from pypy.jit.metainterp.history import BoxInt, ConstInt
-from pypy.jit.metainterp.history import BoxPtr, ConstPtr
-from pypy.jit.metainterp.history import BoxFloat, ConstFloat
-from pypy.jit.metainterp.history import AbstractDescr, Box
+from pypy.jit.metainterp.history import BoxInt, BoxPtr, BoxFloat, AbstractDescr
+from pypy.jit.metainterp.resoperation import ConstInt, ConstPtr, ConstFloat
from pypy.jit.metainterp import history
from pypy.jit.codewriter import longlong
from pypy.jit.backend.model import AbstractCPU
-from pypy.rpython.lltypesystem import llmemory, rffi
class FakeDescr(AbstractDescr):
pass
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit