[pypy-commit] pypy dynamic-specialized-tuple: (agaynor, fijal) more jtransform support
fijal
noreply at buildbot.pypy.org
Wed Mar 14 10:03:22 CET 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: dynamic-specialized-tuple
Changeset: r53544:e32c245cdc74
Date: 2012-03-14 02:03 -0700
http://bitbucket.org/pypy/pypy/changeset/e32c245cdc74/
Log: (agaynor, fijal) more jtransform support
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
@@ -392,15 +392,18 @@
return llimpl.grab_exc_value()
def arraydescrof(self, A):
- assert A.OF != lltype.Void
- assert isinstance(A, lltype.GcArray) or A._hints.get('nolength', False)
size = symbolic.get_size(A)
- if isinstance(A.OF, lltype.Ptr) or isinstance(A.OF, lltype.Primitive):
- token = history.getkind(A.OF)[0]
- elif isinstance(A.OF, lltype.Struct):
- token = 's'
+ if isinstance(A, lltype.GcStruct):
+ token = 'S'
else:
- token = '?'
+ assert A.OF != lltype.Void
+ assert isinstance(A, lltype.GcArray) or A._hints.get('nolength', False)
+ if isinstance(A.OF, lltype.Ptr) or isinstance(A.OF, lltype.Primitive):
+ token = history.getkind(A.OF)[0]
+ elif isinstance(A.OF, lltype.Struct):
+ token = 's'
+ else:
+ token = '?'
return self.getdescr(size, token)
# ---------- the backend-dependent operations ----------
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
@@ -52,7 +52,7 @@
self.vable_flags = {}
renamings = {}
renamings_constants = {} # subset of 'renamings', {Var:Const} only
- newoperations = []
+ self._newoperations = newoperations = []
#
def do_rename(var, var_or_const):
if var.concretetype is lltype.Void:
@@ -226,6 +226,15 @@
def rewrite_op_jit_record_known_class(self, op):
return SpaceOperation("record_known_class", [op.args[0], op.args[1]], None)
+ def rewrite_op_cast_adr_to_ptr(self, op):
+ # HACK
+ prev_op = self._newoperations.pop()
+ if prev_op.opname != 'getinteriorfield_gc_i':
+ raise Exception("Must cast_adr_to_ptr of directly read adr")
+ prev_op.opname = 'getinteriorfield_gc_r'
+ prev_op.result = op.result
+ return prev_op
+
def rewrite_op_cast_bool_to_int(self, op): pass
def rewrite_op_cast_bool_to_uint(self, op): pass
def rewrite_op_cast_char_to_int(self, op): pass
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
@@ -961,6 +961,19 @@
assert op1.args == [v1]
assert op1.result == v2
+def test_malloc_varsize_struct():
+ S = lltype.GcStruct('x', ('a', lltype.Signed),
+ ('b', lltype.Array(lltype.Signed)))
+ v0 = varoftype(lltype.Signed)
+ v1 = varoftype(lltype.Ptr(S))
+ c_S = Constant(S, lltype.Void)
+ c_flavor = Constant({'flavor': 'gc'}, lltype.Void)
+ op = SpaceOperation('malloc_varsize', [c_S, c_flavor, v0], v1)
+ op1 = Transformer(FakeCPU()).rewrite_operation(op)
+ assert op1.opname == 'new_array'
+ assert op1.args == [('arraydescr', S), v0]
+ assert op1.result == v1
+
def test_str_concat():
# test that the oopspec is present and correctly transformed
PSTR = lltype.Ptr(rstr.STR)
@@ -1257,7 +1270,8 @@
SpaceOperation("cast_adr_to_ptr", [v1], v2)
]
- op1 = Transformer(FakeCPU()).optimize_block(block)
+ Transformer(FakeCPU()).optimize_block(block)
+ [op1] = block.operations
assert op1.opname == "getinteriorfield_gc_r"
- assert op1.args == [v, const(0), ('interiorfielddescr', S, 'data')]
+ assert op1.args == [v0, const(0), ('interiorfielddescr', S, 'data')]
assert op1.result == v2
More information about the pypy-commit
mailing list