[pypy-svn] pypy out-of-line-guards: Fix effectinfo and write a test

fijal commits-noreply at bitbucket.org
Mon Jan 10 14:10:15 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: out-of-line-guards
Changeset: r40548:85da27b8e18b
Date: 2011-01-02 21:33 +0200
http://bitbucket.org/pypy/pypy/changeset/85da27b8e18b/

Log:	Fix effectinfo and write a test

diff --git a/pypy/jit/codewriter/call.py b/pypy/jit/codewriter/call.py
--- a/pypy/jit/codewriter/call.py
+++ b/pypy/jit/codewriter/call.py
@@ -228,24 +228,16 @@
             extraeffect = EffectInfo.EF_CANNOT_RAISE
         #
         readwrite_res = self.readwrite_analyzer.analyze(op)
-        if readwrite_res is top_set:
-            extraeffect = EffectInfo.EF_FORCES_JIT_INVARIANT
-        else:
-            for effect, struct, name in readwrite_res:
-                if (effect == 'struct' and
-                    (name in struct.TO._hints.get('jit_invariant_fields', []))):
-                    extraeffect = EffectInfo.EF_FORCES_JIT_INVARIANT
-                    break
 
         effectinfo = effectinfo_from_writeanalyze(
             readwrite_res, self.cpu, extraeffect, oopspecindex)
         #
+        res = self.cpu.calldescrof(FUNC, tuple(NON_VOID_ARGS), RESULT,
+                                    effectinfo)
         if pure or loopinvariant:
-            assert effectinfo is not None
-            assert extraeffect < EffectInfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE
-        #
-        return self.cpu.calldescrof(FUNC, tuple(NON_VOID_ARGS), RESULT,
-                                    effectinfo)
+            assert res.effectinfo is not None
+            assert res.extraeffect < EffectInfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE
+        return res
 
     def _canraise(self, op):
         if op.opname == 'pseudo_call_cannot_raise':

diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -97,6 +97,11 @@
     for tup in effects:
         if tup[0] == "struct":
             add_struct(write_descrs_fields, tup)
+            if (isinstance(tup[1], lltype.Ptr) and
+                tup[1].TO._hints.get('jit_invariant_fields')):
+                fields = tup[1].TO._hints['jit_invariant_fields'].fields
+                if tup[2] in fields:
+                    extraeffect = EffectInfo.EF_FORCES_JIT_INVARIANT
         elif tup[0] == "readstruct":
             tupw = ("struct",) + tup[1:]
             if tupw not in effects:

diff --git a/pypy/jit/codewriter/test/test_effectinfo.py b/pypy/jit/codewriter/test/test_effectinfo.py
--- a/pypy/jit/codewriter/test/test_effectinfo.py
+++ b/pypy/jit/codewriter/test/test_effectinfo.py
@@ -86,3 +86,14 @@
     assert not effectinfo.readonly_descrs_fields
     assert not effectinfo.write_descrs_fields
     assert not effectinfo.write_descrs_arrays
+
+def test_jit_invariant_extraeffect():
+    from pypy.rpython.rclass import FieldListAccessor
+
+    fla = FieldListAccessor()
+    fla.initialize(None, {'inst_x':'asmcodes_x'})
+    S = lltype.GcStruct('S', ('inst_x', lltype.Signed),
+                        hints={'jit_invariant_fields':fla})
+    effects = frozenset([('struct', lltype.Ptr(S), 'inst_x')])
+    effectinfo = effectinfo_from_writeanalyze(effects, FakeCPU())
+    assert effectinfo.extraeffect == effectinfo.EF_FORCES_JIT_INVARIANT


More information about the Pypy-commit mailing list