[pypy-commit] pypy faster-rstruct-2: fix writeanalyze.py to take into account llop.gc_store_indexed
antocuni
pypy.commits at gmail.com
Sat May 20 05:55:23 EDT 2017
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: faster-rstruct-2
Changeset: r91346:85d3ab6fe80b
Date: 2017-05-20 11:54 +0200
http://bitbucket.org/pypy/pypy/changeset/85d3ab6fe80b/
Log: fix writeanalyze.py to take into account llop.gc_store_indexed
diff --git a/rpython/translator/backendopt/test/test_writeanalyze.py b/rpython/translator/backendopt/test/test_writeanalyze.py
--- a/rpython/translator/backendopt/test/test_writeanalyze.py
+++ b/rpython/translator/backendopt/test/test_writeanalyze.py
@@ -269,6 +269,34 @@
assert struct == "struct"
assert name.endswith("foobar")
+ def test_gc_store_indexed(self):
+ from rpython.rtyper.lltypesystem import lltype, llmemory
+ from rpython.rtyper.lltypesystem.lloperation import llop
+ from rpython.rlib.rgc import (resizable_list_supporting_raw_ptr,
+ ll_for_resizable_list)
+
+ def write_item(lst, byte_offset, value):
+ ll_data = ll_for_resizable_list(lst)
+ ll_items = ll_data.items
+ LIST = lltype.typeOf(ll_data).TO # rlist.LIST_OF(lltype.Char)
+ base_ofs = llmemory.itemoffsetof(LIST.items.TO, 0)
+ scale_factor = llmemory.sizeof(lltype.Char)
+ llop.gc_store_indexed(lltype.Void, ll_items, byte_offset, value,
+ scale_factor, base_ofs)
+
+ def f(x):
+ lst = resizable_list_supporting_raw_ptr(['A', 'B', 'C', 'D'])
+ write_item(lst, 0, 'E')
+ t, wa = self.translate(f, [int])
+ fgraph = graphof(t, f)
+ result = wa.analyze(fgraph.startblock.operations[-1])
+ #
+ assert len(result) == 1
+ array, A = list(result)[0]
+ assert array == "array"
+ assert A.TO.OF == lltype.Char
+
+
class TestLLtypeReadWriteAnalyze(BaseTest):
Analyzer = ReadWriteAnalyzer
diff --git a/rpython/translator/backendopt/writeanalyze.py b/rpython/translator/backendopt/writeanalyze.py
--- a/rpython/translator/backendopt/writeanalyze.py
+++ b/rpython/translator/backendopt/writeanalyze.py
@@ -61,6 +61,9 @@
if graphinfo is None or not graphinfo.is_fresh_malloc(op.args[0]):
name = self._getinteriorname(op)
return self._interiorfield_result(op.args[0].concretetype, name)
+ elif op.opname == "gc_store_indexed":
+ if graphinfo is None or not graphinfo.is_fresh_malloc(op.args[0]):
+ return self._array_result(op.args[0].concretetype)
return empty_set
def _array_result(self, TYPE):
More information about the pypy-commit
mailing list