Author: Remi Meier <[email protected]>
Branch: stmgc-c8
Changeset: r82526:36a2560a3194
Date: 2016-02-26 12:08 +0100
http://bitbucket.org/pypy/pypy/changeset/36a2560a3194/
Log: fix llop.gc_load_indexed for STM
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -725,15 +725,19 @@
' (((%(char)s *)%(addr)s) + %(offset)s))[0];' % locals())
def OP_GC_LOAD_INDEXED(self, op):
+ tlprefix, char = '', 'char'
+ if (self._is_stm() and isinstance(op.args[0].concretetype, Ptr)
+ and op.args[0].concretetype.TO._gckind == 'gc'):
+ tlprefix, char = ' TLPREFIX ', 'rpygcchar_t'
addr = self.expr(op.args[0])
index = self.expr(op.args[1])
scale = self.expr(op.args[2])
base_ofs = self.expr(op.args[3])
result = self.expr(op.result)
TYPE = op.result.concretetype
- typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '')
+ typename = cdecl(self.db.gettype(TYPE).replace('@', tlprefix+'*@'), '')
return (
- "%(result)s = ((%(typename)s) (((char *)%(addr)s) + "
+ "%(result)s = ((%(typename)s) (((%(char)s *)%(addr)s) + "
"%(base_ofs)s + %(scale)s * %(index)s))[0];"
% locals())
diff --git a/rpython/translator/stm/test/test_ztranslated.py
b/rpython/translator/stm/test/test_ztranslated.py
--- a/rpython/translator/stm/test/test_ztranslated.py
+++ b/rpython/translator/stm/test/test_ztranslated.py
@@ -13,6 +13,20 @@
class TestSTMTranslated(CompiledSTMTests):
+ def test_math(self):
+ from rpython.rtyper.lltypesystem.module.ll_math import sqrt_nonneg
+ def entry_point(argv):
+ lst = []
+ for i in range(int(argv[1])):
+ lst.append(sqrt_nonneg(99))
+ print '<', len(lst), '>'
+ return 0
+ #
+ t, cbuilder = self.compile(entry_point, backendopt=True)
+ data = cbuilder.cmdexec('5')
+ assert '< 5 >' in data, "got: %r" % (data,)
+
+
def test_malloc(self):
class Foo:
pass
@@ -431,6 +445,25 @@
data = cbuilder.cmdexec('')
assert '< 42 >\n< 84 >\n' in data
+ def test_gc_load_indexed(self):
+ from rpython.rtyper.annlowlevel import llstr
+ from rpython.rtyper.lltypesystem.rstr import STR
+ from rpython.rtyper.lltypesystem import lltype, llmemory, rffi,
lloperation
+
+ s = "hillo world"
+ lls = llstr(s)
+ base_ofs = (llmemory.offsetof(STR, 'chars') +
+ llmemory.itemoffsetof(STR.chars, 0))
+ scale_factor = llmemory.sizeof(lltype.Char)
+
+ def main(argv):
+ print int(llop.gc_load_indexed(rffi.SHORT, lls, int(argv[1]),
+ scale_factor, base_ofs))
+ return 0
+ t, cbuilder = self.compile(main)
+ data = cbuilder.cmdexec('1')
+ assert '105\n'
+
def test_raw_load_store_on_gc(self):
X = lltype.GcStruct('X', ('foo', lltype.Signed))
prebuilt = lltype.malloc(X, immortal=True)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit