[pypy-svn] r62598 - in pypy/branch/pyjitpl5/pypy/jit/backend/llgraph: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 5 17:38:37 CET 2009
Author: arigo
Date: Thu Mar 5 17:38:36 2009
New Revision: 62598
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
Log:
setfield_gc
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py Thu Mar 5 17:38:36 2009
@@ -973,6 +973,13 @@
newvalue = cast_from_int(FIELDTYPE, newvalue, memocast)
setattr(ptr, fieldname, newvalue)
+def do_setfield_gc_ptr(struct, fielddesc, newvalue):
+ STRUCT, fieldname = symbolic.TokenToField[fielddesc/2]
+ ptr = lltype.cast_opaque_ptr(lltype.Ptr(STRUCT), struct)
+ FIELDTYPE = getattr(STRUCT, fieldname)
+ newvalue = cast_from_ptr(FIELDTYPE, newvalue)
+ setattr(ptr, fieldname, newvalue)
+
# ____________________________________________________________
@@ -1068,3 +1075,4 @@
setannotation(do_setarrayitem_gc_int, annmodel.s_None)
setannotation(do_setarrayitem_gc_ptr, annmodel.s_None)
setannotation(do_setfield_gc_int, annmodel.s_None)
+setannotation(do_setfield_gc_ptr, annmodel.s_None)
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py Thu Mar 5 17:38:36 2009
@@ -384,6 +384,17 @@
llimpl.do_setarrayitem_gc_int(array, index, newvalue,
self.memo_cast)
+ def do_setfield_gc(self, args):
+ struct = args[0].getptr_base()
+ fielddescr = args[1].getint()
+ if self.typefor(fielddescr) == 'ptr':
+ newvalue = args[2].getptr_base()
+ llimpl.do_setfield_gc_ptr(struct, fielddescr, newvalue)
+ else:
+ newvalue = args[2].getint()
+ llimpl.do_setfield_gc_int(struct, fielddescr, newvalue,
+ self.memo_cast)
+
class GuardFailed(object):
returns = False
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py Thu Mar 5 17:38:36 2009
@@ -199,6 +199,12 @@
BoxInt(descrfld_x)])
assert x.value == ord('Z')
#
+ cpu.do_setfield_gc(
+ [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)),
+ BoxInt(descrfld_x),
+ BoxInt(ord('4'))])
+ assert s.x == '4'
+ #
descrfld_y = cpu.fielddescrof(S, 'y')
s.y = a
x = cpu.do_getfield_gc(
@@ -207,6 +213,13 @@
assert isinstance(x, BoxPtr)
assert x.getptr(lltype.Ptr(A)) == a
#
+ s.y = lltype.nullptr(A)
+ cpu.do_setfield_gc(
+ [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)),
+ BoxInt(descrfld_y),
+ x])
+ assert s.y == a
+ #
RS = lltype.Struct('S', ('x', lltype.Char), ('y', lltype.Ptr(A)))
descrfld_rx = cpu.fielddescrof(RS, 'x')
rs = lltype.malloc(RS, immortal=True)
More information about the Pypy-commit
mailing list