[pypy-commit] pypy result-in-resops: Progress. happily surpassed 50% of this particular test file (runner_test) ported
fijal
noreply at buildbot.pypy.org
Tue Aug 28 16:19:30 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: result-in-resops
Changeset: r56907:34c36602fd8a
Date: 2012-08-28 16:19 +0200
http://bitbucket.org/pypy/pypy/changeset/34c36602fd8a/
Log: Progress. happily surpassed 50% of this particular test file
(runner_test) ported
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
@@ -953,7 +953,7 @@
def op_call_i(self, calldescr, func, *args):
return self._do_call(calldescr, func, args, call_with_llptr=False)
op_call_f = op_call_i
- op_call_N = op_call_i
+ op_call_n = op_call_i
op_call_p = op_call_i
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
@@ -18,6 +18,7 @@
from pypy.rlib import longlong2float
from pypy.rlib.rarithmetic import intmask, is_valid_int
from pypy.jit.backend.detect_cpu import autodetect_main_model_and_size
+from pypy.jit.tool.oparser import parse
def boxfloat(x):
@@ -106,7 +107,6 @@
avoid_instances = False
def parse(self, s, namespace):
- from pypy.jit.tool.oparser import parse
if namespace is None:
namespace = {}
else:
@@ -1520,11 +1520,9 @@
def wait_a_bit():
pass
if longlong.is_64_bit:
- got1 = self.execute_operation(rop.READ_TIMESTAMP, [], 'int')
+ res1 = self.execute_operation(rop.READ_TIMESTAMP, [], 'int')
wait_a_bit()
- got2 = self.execute_operation(rop.READ_TIMESTAMP, [], 'int')
- res1 = got1.getint()
- res2 = got2.getint()
+ res2 = self.execute_operation(rop.READ_TIMESTAMP, [], 'int')
else:
got1 = self.execute_operation(rop.READ_TIMESTAMP, [], 'float')
wait_a_bit()
@@ -1614,33 +1612,33 @@
def test_cast_int_to_ptr(self):
res = self.execute_operation(rop.CAST_INT_TO_PTR,
- [BoxInt(-17)], 'ref').value
+ [BoxInt(-17)], 'ref')
assert lltype.cast_ptr_to_int(res) == -17
def test_cast_ptr_to_int(self):
x = lltype.cast_int_to_ptr(llmemory.GCREF, -19)
res = self.execute_operation(rop.CAST_PTR_TO_INT,
- [BoxPtr(x)], 'int').value
+ [BoxPtr(x)], 'int')
assert res == -19
def test_convert_float_bytes(self):
+ box = boxfloat(2.5)
t = 'int' if longlong.is_64_bit else 'float'
res = self.execute_operation(rop.CONVERT_FLOAT_BYTES_TO_LONGLONG,
- [boxfloat(2.5)], t).value
+ [box], t)
assert res == longlong2float.float2longlong(2.5)
- bytes = longlong2float.float2longlong(2.5)
res = self.execute_operation(rop.CONVERT_LONGLONG_BYTES_TO_FLOAT,
- [boxlonglong(res)], 'float').value
+ [boxlonglong(res)], 'float')
assert longlong.getrealfloat(res) == 2.5
def test_ooops_non_gc(self):
x = lltype.malloc(lltype.Struct('x'), flavor='raw')
v = heaptracker.adr2int(llmemory.cast_ptr_to_adr(x))
r = self.execute_operation(rop.PTR_EQ, [BoxInt(v), BoxInt(v)], 'int')
- assert r.value == 1
+ assert r == 1
r = self.execute_operation(rop.PTR_NE, [BoxInt(v), BoxInt(v)], 'int')
- assert r.value == 0
+ assert r == 0
lltype.free(x, flavor='raw')
def test_new_plain_struct(self):
@@ -1649,14 +1647,14 @@
sizedescr = cpu.sizeof(S)
r1 = self.execute_operation(rop.NEW, [], 'ref', descr=sizedescr)
r2 = self.execute_operation(rop.NEW, [], 'ref', descr=sizedescr)
- assert r1.value != r2.value
+ assert r1 != r2
xdescr = cpu.fielddescrof(S, 'x')
ydescr = cpu.fielddescrof(S, 'y')
- self.execute_operation(rop.SETFIELD_GC, [r1, BoxInt(150)],
+ self.execute_operation(rop.SETFIELD_GC, [BoxPtr(r1), BoxInt(150)],
'void', descr=ydescr)
- self.execute_operation(rop.SETFIELD_GC, [r1, BoxInt(190)],
+ self.execute_operation(rop.SETFIELD_GC, [BoxPtr(r1), BoxInt(190)],
'void', descr=xdescr)
- s = lltype.cast_opaque_ptr(lltype.Ptr(S), r1.value)
+ s = lltype.cast_opaque_ptr(lltype.Ptr(S), r1)
assert s.x == chr(190)
assert s.y == chr(150)
@@ -1668,27 +1666,27 @@
heaptracker.register_known_gctype(cpu, vtable, self.T)
r1 = self.execute_operation(rop.NEW_WITH_VTABLE, [T_box], 'ref')
r2 = self.execute_operation(rop.NEW_WITH_VTABLE, [T_box], 'ref')
- assert r1.value != r2.value
+ assert r1 != r2
descr1 = cpu.fielddescrof(self.S, 'chr1')
descr2 = cpu.fielddescrof(self.S, 'chr2')
descrshort = cpu.fielddescrof(self.S, 'short')
- self.execute_operation(rop.SETFIELD_GC, [r1, BoxInt(150)],
+ self.execute_operation(rop.SETFIELD_GC, [BoxPtr(r1), BoxInt(150)],
'void', descr=descr2)
- self.execute_operation(rop.SETFIELD_GC, [r1, BoxInt(190)],
+ self.execute_operation(rop.SETFIELD_GC, [BoxPtr(r1), BoxInt(190)],
'void', descr=descr1)
- self.execute_operation(rop.SETFIELD_GC, [r1, BoxInt(1313)],
+ self.execute_operation(rop.SETFIELD_GC, [BoxPtr(r1), BoxInt(1313)],
'void', descr=descrshort)
- s = lltype.cast_opaque_ptr(lltype.Ptr(self.T), r1.value)
+ s = lltype.cast_opaque_ptr(lltype.Ptr(self.T), r1)
assert s.parent.chr1 == chr(190)
assert s.parent.chr2 == chr(150)
- r = self.cpu.bh_getfield_gc_i(r1.value, descrshort)
+ r = self.cpu.bh_getfield_gc_i(r1, descrshort)
assert r == 1313
- self.cpu.bh_setfield_gc_i(r1.value, descrshort, 1333)
- r = self.cpu.bh_getfield_gc_i(r1.value, descrshort)
+ self.cpu.bh_setfield_gc_i(r1, descrshort, 1333)
+ r = self.cpu.bh_getfield_gc_i(r1, descrshort)
assert r == 1333
- r = self.execute_operation(rop.GETFIELD_GC, [r1], 'int',
+ r = self.execute_operation(rop.GETFIELD_GC_i, [BoxPtr(r1)], 'int',
descr=descrshort)
- assert r.value == 1333
+ assert r == 1333
t = lltype.cast_opaque_ptr(lltype.Ptr(self.T), t_box.value)
assert s.parent.parent.typeptr == t.parent.parent.typeptr
@@ -1699,23 +1697,23 @@
'ref', descr=arraydescr)
r2 = self.execute_operation(rop.NEW_ARRAY, [BoxInt(342)],
'ref', descr=arraydescr)
- assert r1.value != r2.value
- a = lltype.cast_opaque_ptr(lltype.Ptr(A), r1.value)
+ assert r1 != r2
+ a = lltype.cast_opaque_ptr(lltype.Ptr(A), r1)
assert a[0] == 0
assert len(a) == 342
def test_new_string(self):
r1 = self.execute_operation(rop.NEWSTR, [BoxInt(342)], 'ref')
r2 = self.execute_operation(rop.NEWSTR, [BoxInt(342)], 'ref')
- assert r1.value != r2.value
- a = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), r1.value)
+ assert r1 != r2
+ a = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), r1)
assert len(a.chars) == 342
def test_new_unicode(self):
r1 = self.execute_operation(rop.NEWUNICODE, [BoxInt(342)], 'ref')
r2 = self.execute_operation(rop.NEWUNICODE, [BoxInt(342)], 'ref')
- assert r1.value != r2.value
- a = lltype.cast_opaque_ptr(lltype.Ptr(rstr.UNICODE), r1.value)
+ assert r1 != r2
+ a = lltype.cast_opaque_ptr(lltype.Ptr(rstr.UNICODE), r1)
assert len(a.chars) == 342
def test_exceptions(self):
@@ -1727,8 +1725,8 @@
ops = '''
[i0]
- i1 = same_as(1)
- call(ConstClass(fptr), i0, descr=calldescr)
+ i1 = same_as_i(1)
+ call_n(ConstClass(fptr), i0, descr=calldescr)
p0 = guard_exception(ConstClass(xtp)) [i1]
finish(0, p0)
'''
diff --git a/pypy/jit/metainterp/executor.py b/pypy/jit/metainterp/executor.py
--- a/pypy/jit/metainterp/executor.py
+++ b/pypy/jit/metainterp/executor.py
@@ -7,7 +7,7 @@
from pypy.rlib.unroll import unrolling_iterable
from pypy.jit.metainterp.history import check_descr, AbstractDescr
from pypy.jit.metainterp.resoperation import INT, REF, FLOAT, rop,\
- create_resop, create_resop_1, create_resop_2
+ create_resop, create_resop_1, create_resop_2, create_resop_0
from pypy.jit.metainterp import resoperation
from pypy.jit.metainterp.blackhole import BlackholeInterpreter, NULL
from pypy.jit.codewriter import longlong
@@ -157,15 +157,22 @@
else:
cpu.bh_raw_store_i(addr, offset, arraydescr, valuebox.getint())
-def do_raw_load(cpu, _, addrbox, offsetbox, arraydescr):
+def do_raw_load_p(cpu, _, addrbox, offsetbox, arraydescr):
+ raise AssertionError("cannot store GC pointers in raw store")
+
+def do_raw_load_i(cpu, _, addrbox, offsetbox, arraydescr):
addr = addrbox.getint()
offset = offsetbox.getint()
- if arraydescr.is_array_of_pointers():
- raise AssertionError("cannot store GC pointers in raw store")
- elif arraydescr.is_array_of_floats():
- return BoxFloat(cpu.bh_raw_load_f(addr, offset, arraydescr))
- else:
- return BoxInt(cpu.bh_raw_load_i(addr, offset, arraydescr))
+ res = cpu.bh_raw_load_i(addr, offset, arraydescr)
+ return create_resop_2(rop.RAW_LOAD_i, res, addrbox, offsetbox,
+ descr=arraydescr)
+
+def do_raw_load_f(cpu, _, addrbox, offsetbox, arraydescr):
+ addr = addrbox.getint()
+ offset = offsetbox.getint()
+ res = cpu.bh_raw_load_f(addr, offset, arraydescr)
+ return create_resop_2(rop.RAW_LOAD_f, res, addrbox, offsetbox,
+ descr=arraydescr)
def exec_new_with_vtable(cpu, clsbox):
from pypy.jit.codewriter import heaptracker
@@ -234,14 +241,12 @@
rstr.copy_unicode_contents(src, dst, srcstart, dststart, length)
def do_read_timestamp(cpu, _):
- XXX # how do we deal with that?
x = read_timestamp()
if longlong.is_64_bit:
assert is_valid_int(x) # 64-bit
- return BoxInt(x)
else:
assert isinstance(x, r_longlong) # 32-bit
- return BoxFloat(x)
+ return create_resop_0(rop.READ_TIMESTAMP, x)
def do_keepalive(cpu, _, x):
pass
diff --git a/pypy/jit/metainterp/heapcache.py b/pypy/jit/metainterp/heapcache.py
--- a/pypy/jit/metainterp/heapcache.py
+++ b/pypy/jit/metainterp/heapcache.py
@@ -1,5 +1,4 @@
-from pypy.jit.metainterp.history import ConstInt
-from pypy.jit.metainterp.resoperation import rop
+from pypy.jit.metainterp.resoperation import rop, ConstInt
class HeapCache(object):
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
@@ -1071,7 +1071,7 @@
'CAST_INT_TO_FLOAT/1/f', # need some messy code in the backend
'CAST_FLOAT_TO_SINGLEFLOAT/1/i',
'CAST_SINGLEFLOAT_TO_FLOAT/1/f',
- 'CONVERT_FLOAT_BYTES_TO_LONGLONG/1/f',
+ 'CONVERT_FLOAT_BYTES_TO_LONGLONG/1/L', # float on 32bit, int on 64bit
'CONVERT_LONGLONG_BYTES_TO_FLOAT/1/f',
#
'INT_LT/2b/i',
@@ -1138,7 +1138,7 @@
'_MALLOC_LAST',
'FORCE_TOKEN/0/i',
'VIRTUAL_REF/2/i', # removed before it's passed to the backend
- 'READ_TIMESTAMP/0/f',
+ 'READ_TIMESTAMP/0/L', # float on 32bit, int on 64bit
'MARK_OPAQUE_PTR/1b/N',
'_NOSIDEEFFECT_LAST', # ----- end of no_side_effect operations -----
@@ -1295,6 +1295,11 @@
opnum += 1
return res
else:
+ if tp == 'L':
+ if longlong.is_64_bit:
+ tp = 'i'
+ else:
+ tp = 'f'
cls_name = '%s_OP' % name
bases = (get_base_class(mixin, tpmixin[tp], baseclass),)
dic = {'opnum': opnum}
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
@@ -285,7 +285,7 @@
opres = self.create_op(opnum, self._example_for(opnum), args, descr)
self.vars[res] = opres
if fail_args is not None:
- res.set_extra("failargs", fail_args)
+ opres.set_extra("failargs", fail_args)
return opres
def parse_op_no_result(self, line):
More information about the pypy-commit
mailing list