1. Pypy
  2. Untitled project
  3. pypy

Commits

Armin Rigo  committed 51157f5

(fijal, arigo)

Finish the test. Argh, painful :-(

  • Participants
  • Parent commits 20b7b00
  • Branches stackroot-speedup

Comments (0)

Files changed (1)

File pypy/rpython/memory/gctransform/test/test_framework.py

View file
 from pypy.rpython.memory.gctransform.transform import GcHighLevelOp
 from pypy.rpython.memory.gctransform.framework import FrameworkGCTransformer, \
     CollectAnalyzer, find_initializing_stores, find_clean_setarrayitems
-from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rpython.lltypesystem import lltype, llmemory, rffi
 from pypy.rpython.rtyper import LowLevelOpList
 from pypy.translator.c.gc import FrameworkGcPolicy
 from pypy.translator.translator import TranslationContext, graphof
 def test_contains_stack_check():
     from pypy.translator.transform import insert_ll_stackcheck
     from pypy.translator.c.genc import CStandaloneBuilder
+    from pypy.rpython.memory.gctransform.shadowstack import sizeofaddr
     #
     class A:
         pass
         A()
     def f_recursive(n):
         A()
-        if n > 5:
+        if n > 2:
             f_recursive(n-1)
-    def f(n):
-        a = A()
-        f_non_recursive(n)
-        f_recursive(n)
-        return a
+    for f1 in [f_non_recursive, f_recursive]:
 
-    t = rtype(f, [int])
-    insert_ll_stackcheck(t)
-    g_non_recursive = t._graphof(f_non_recursive)
-    assert not hasattr(g_non_recursive, 'contains_stack_check')
-    g_recursive = t._graphof(f_recursive)
-    assert g_recursive.contains_stack_check is True
-    #
-    cbuild = CStandaloneBuilder(t, f, t.config,
-                                gcpolicy=FrameworkGcPolicy2)
-    db = cbuild.generate_graphs_for_llinterp()
-    import pdb; pdb.set_trace()
+        def f(n):
+            a = A()
+            f1(n)
+            return a
+
+        t = rtype(f, [int])
+        insert_ll_stackcheck(t)
+        g1 = t._graphof(f1)
+        if f1 is f_non_recursive:
+            assert not hasattr(g1, 'contains_stack_check')
+        else:
+            assert g1.contains_stack_check is True
+        #
+        cbuild = CStandaloneBuilder(t, f, t.config,
+                                    gcpolicy=FrameworkGcPolicy2)
+        db = cbuild.generate_graphs_for_llinterp()
+        #
+        # check that in the non-recursive case, around the call
+        # to f1 we save one gcptr 'a'; and in the recursive case,
+        # we save two, because there are 'a' and a marker for
+        # shadowstack.
+        if f1 is f_non_recursive:
+            expected = 1
+        else:
+            expected = 2
+        adr_adds = []
+        for block in t._graphof(f).iterblocks():
+            for op in block.operations:
+                if op.opname == 'adr_add':
+                    adr_adds.append(op)
+        assert len(adr_adds) == 1
+        got = adr_adds[0].args[1].value
+        assert got.repeat == expected