Commits

Armin Rigo committed 9770716

Double this test, once with asmgcc and once with shadowstack.

  • Participants
  • Parent commits 7bab349
  • Branches jitypes2

Comments (0)

Files changed (1)

File pypy/jit/backend/x86/test/test_zrpy_gc.py

         self.run('compile_framework_minimal_size_in_nursery')
 
 
-def test_close_stack():
-    from pypy.rlib.libffi import CDLL, types, ArgChain, clibffi
-    from pypy.rpython.lltypesystem.ll2ctypes import libc_name
-    from pypy.rpython.annlowlevel import llhelper
-    from pypy.jit.metainterp.optimizeopt import ALL_OPTS_NAMES
-    #
-    class Glob(object):
-        pass
-    glob = Glob()
-    class X(object):
-        pass
-    #
-    def callback(p1, p2):
-        for i in range(100):
-            glob.lst.append(X())
-        return rffi.cast(rffi.INT, 1)
-    CALLBACK = lltype.Ptr(lltype.FuncType([lltype.Signed,
-                                           lltype.Signed], rffi.INT))
-    #
-    @dont_look_inside
-    def alloc1():
-        return llmemory.raw_malloc(16)
-    @dont_look_inside
-    def free1(p):
-        llmemory.raw_free(p)
-    #
-    def f42():
-        length = len(glob.lst)
-        c_qsort = glob.c_qsort
-        raw = alloc1()
-        fn = llhelper(CALLBACK, rffi._make_wrapper_for(CALLBACK, callback))
-        argchain = ArgChain()
-        argchain = argchain.arg(rffi.cast(lltype.Signed, raw))
-        argchain = argchain.arg(rffi.cast(rffi.SIZE_T, 2))
-        argchain = argchain.arg(rffi.cast(rffi.SIZE_T, 8))
-        argchain = argchain.arg(rffi.cast(lltype.Signed, fn))
-        c_qsort.call(argchain, lltype.Void)
-        free1(raw)
-        check(len(glob.lst) > length)
-        del glob.lst[:]
-    #
-    def before():
-        libc = CDLL(libc_name)
-        types_size_t = clibffi.cast_type_to_ffitype(rffi.SIZE_T)
-        c_qsort = libc.getpointer('qsort', [types.pointer, types_size_t,
-                                            types_size_t, types.pointer],
-                                  types.void)
-        glob.c_qsort = c_qsort
-        glob.lst = []
-    #
-    myjitdriver = JitDriver(greens=[], reds=['n'])
-    def main(n, x):
-        before()
-        while n > 0:
-            myjitdriver.jit_merge_point(n=n)
-            f42()
-            n -= 1
-    #
-    res = compile_and_run(get_entry(get_g(main)), DEFL_GC,
-                          gcrootfinder="asmgcc", jit=True,
-                          enable_opts=ALL_OPTS_NAMES)
-    assert int(res) == 20
-
-
 class TestShadowStack(CompileFrameworkTests):
     gcrootfinder = "shadowstack"
 
 class TestAsmGcc(CompileFrameworkTests):
     gcrootfinder = "asmgcc"
+
+
+class OtherFrameworkGCTests(object):
+    def test_close_stack(self):
+        from pypy.rlib.libffi import CDLL, types, ArgChain, clibffi
+        from pypy.rpython.lltypesystem.ll2ctypes import libc_name
+        from pypy.rpython.annlowlevel import llhelper
+        from pypy.jit.metainterp.optimizeopt import ALL_OPTS_NAMES
+        #
+        class Glob(object):
+            pass
+        glob = Glob()
+        class X(object):
+            pass
+        #
+        def callback(p1, p2):
+            for i in range(100):
+                glob.lst.append(X())
+            return rffi.cast(rffi.INT, 1)
+        CALLBACK = lltype.Ptr(lltype.FuncType([lltype.Signed,
+                                               lltype.Signed], rffi.INT))
+        #
+        @dont_look_inside
+        def alloc1():
+            return llmemory.raw_malloc(16)
+        @dont_look_inside
+        def free1(p):
+            llmemory.raw_free(p)
+        #
+        def f42():
+            length = len(glob.lst)
+            c_qsort = glob.c_qsort
+            raw = alloc1()
+            fn = llhelper(CALLBACK, rffi._make_wrapper_for(CALLBACK, callback))
+            argchain = ArgChain()
+            argchain = argchain.arg(rffi.cast(lltype.Signed, raw))
+            argchain = argchain.arg(rffi.cast(rffi.SIZE_T, 2))
+            argchain = argchain.arg(rffi.cast(rffi.SIZE_T, 8))
+            argchain = argchain.arg(rffi.cast(lltype.Signed, fn))
+            c_qsort.call(argchain, lltype.Void)
+            free1(raw)
+            check(len(glob.lst) > length)
+            del glob.lst[:]
+        #
+        def before():
+            libc = CDLL(libc_name)
+            types_size_t = clibffi.cast_type_to_ffitype(rffi.SIZE_T)
+            c_qsort = libc.getpointer('qsort', [types.pointer, types_size_t,
+                                                types_size_t, types.pointer],
+                                      types.void)
+            glob.c_qsort = c_qsort
+            glob.lst = []
+        #
+        myjitdriver = JitDriver(greens=[], reds=['n'])
+        def main(n, x):
+            before()
+            while n > 0:
+                myjitdriver.jit_merge_point(n=n)
+                f42()
+                n -= 1
+        #
+        res = compile_and_run(get_entry(get_g(main)), DEFL_GC,
+                              gcrootfinder=self.gcrootfinder, jit=True,
+                              enable_opts=ALL_OPTS_NAMES)
+        assert int(res) == 20
+
+class TestOtherShadowStack(OtherFrameworkGCTests):
+    gcrootfinder = "shadowstack"
+
+class TestOtherAsmGcc(OtherFrameworkGCTests):
+    gcrootfinder = "asmgcc"