[pypy-commit] pypy dynamic-specialized-tuple: cast_ptr_to_adr and getinteriorfield of struct
alex_gaynor
noreply at buildbot.pypy.org
Wed Mar 14 07:44:21 CET 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: dynamic-specialized-tuple
Changeset: r53534:63de687563ae
Date: 2012-03-13 23:44 -0700
http://bitbucket.org/pypy/pypy/changeset/63de687563ae/
Log: cast_ptr_to_adr and getinteriorfield of struct
diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -234,6 +234,7 @@
def rewrite_op_cast_int_to_unichar(self, op): pass
def rewrite_op_cast_int_to_uint(self, op): pass
def rewrite_op_cast_uint_to_int(self, op): pass
+ def rewrite_op_cast_ptr_to_adr(self, op): pass
def _rewrite_symmetric(self, op):
"""Rewrite 'c1+v2' into 'v2+c1' in an attempt to avoid generating
@@ -795,13 +796,15 @@
opname = "unicodegetitem"
return SpaceOperation(opname, [op.args[0], op.args[2]], op.result)
else:
- v_inst, v_index, c_field = op.args
if op.result.concretetype is lltype.Void:
return
- # only GcArray of Struct supported
- assert isinstance(v_inst.concretetype.TO, lltype.GcArray)
- STRUCT = v_inst.concretetype.TO.OF
- assert isinstance(STRUCT, lltype.Struct)
+ v_inst = op.args[0]
+
+ if isinstance(v_inst.concretetype.TO, lltype.GcArray):
+ v_inst, v_index, c_field = op.args
+ else:
+ v_inst, c_field, v_index = op.args
+
descr = self.cpu.interiorfielddescrof(v_inst.concretetype.TO,
c_field.value)
args = [v_inst, v_index, descr]
diff --git a/pypy/jit/codewriter/test/test_jtransform.py b/pypy/jit/codewriter/test/test_jtransform.py
--- a/pypy/jit/codewriter/test/test_jtransform.py
+++ b/pypy/jit/codewriter/test/test_jtransform.py
@@ -1232,3 +1232,11 @@
op1 = Transformer(FakeCPU()).rewrite_operation(op)
assert op1.opname == "setinteriorfield_gc_i"
assert op1.args == [v, const(0), const(1), ('interiorfielddescr', S, "data")]
+
+
+ op = SpaceOperation("getinteriorfield",
+ [v, c_data, const(0)], varoftype(lltype.Signed)
+ )
+ op1 = Transformer(FakeCPU()).rewrite_operation(op)
+ assert op1.opname == "getinteriorfield_gc_i"
+ assert op1.args == [v, const(0), ('interiorfielddescr', S, "data")]
\ No newline at end of file
More information about the pypy-commit
mailing list