コード例 #1
0
ファイル: test_asmmemmgr.py プロジェクト: Darriall/pypy
 def test_insert_gcroot_marker(self):
     puts = []
     class FakeGcRootMap:
         def register_asm_addr(self, retaddr, mark):
             puts.append((retaddr, mark))
     #
     mc = BlockBuilderMixin()
     mc.writechar('X')
     mc.writechar('x')
     mc.insert_gcroot_marker(['a', 'b', 'c', 'd'])
     mc.writechar('Y')
     mc.writechar('y')
     mc.insert_gcroot_marker(['e', 'f', 'g'])
     mc.writechar('Z')
     mc.writechar('z')
     #
     gcrootmap = FakeGcRootMap()
     allblocks = []
     rawstart = mc.materialize(self.memmgr, allblocks, gcrootmap)
     p = rffi.cast(rffi.CArrayPtr(lltype.Char), rawstart)
     assert p[0] == 'X'
     assert p[1] == 'x'
     assert p[2] == 'Y'
     assert p[3] == 'y'
     assert p[4] == 'Z'
     assert p[5] == 'z'
     # 'allblocks' should be one block of length 6 + 15
     # (15 = alignment - 1) containing the range(rawstart, rawstart + 6)
     [(blockstart, blockend)] = allblocks
     assert blockend == blockstart + 6 + (mc.ALIGN_MATERIALIZE - 1)
     assert blockstart <= rawstart < rawstart + 6 <= blockend
     assert puts == [(rawstart + 2, ['a', 'b', 'c', 'd']),
                     (rawstart + 4, ['e', 'f', 'g'])]
コード例 #2
0
    def test_insert_gcroot_marker(self):
        puts = []

        class FakeGcRootMap:
            def register_asm_addr(self, retaddr, mark):
                puts.append((retaddr, mark))

        #
        mc = BlockBuilderMixin()
        mc.writechar('X')
        mc.writechar('x')
        mc.insert_gcroot_marker(['a', 'b', 'c', 'd'])
        mc.writechar('Y')
        mc.writechar('y')
        mc.insert_gcroot_marker(['e', 'f', 'g'])
        mc.writechar('Z')
        mc.writechar('z')
        #
        gcrootmap = FakeGcRootMap()
        allblocks = []
        rawstart = mc.materialize(self.memmgr, allblocks, gcrootmap)
        p = rffi.cast(rffi.CArrayPtr(lltype.Char), rawstart)
        assert p[0] == 'X'
        assert p[1] == 'x'
        assert p[2] == 'Y'
        assert p[3] == 'y'
        assert p[4] == 'Z'
        assert p[5] == 'z'
        assert allblocks == [(rawstart, rawstart + 6)]
        assert puts == [(rawstart + 2, ['a', 'b', 'c', 'd']),
                        (rawstart + 4, ['e', 'f', 'g'])]
コード例 #3
0
ファイル: test_asmmemmgr.py プロジェクト: bukzor/pypy
 def test_insert_gcroot_marker(self):
     puts = []
     class FakeGcRootMap:
         def register_asm_addr(self, retaddr, mark):
             puts.append((retaddr, mark))
     #
     mc = BlockBuilderMixin()
     mc.writechar('X')
     mc.writechar('x')
     mc.insert_gcroot_marker(['a', 'b', 'c', 'd'])
     mc.writechar('Y')
     mc.writechar('y')
     mc.insert_gcroot_marker(['e', 'f', 'g'])
     mc.writechar('Z')
     mc.writechar('z')
     #
     gcrootmap = FakeGcRootMap()
     allblocks = []
     rawstart = mc.materialize(self.memmgr, allblocks, gcrootmap)
     p = rffi.cast(rffi.CArrayPtr(lltype.Char), rawstart)
     assert p[0] == 'X'
     assert p[1] == 'x'
     assert p[2] == 'Y'
     assert p[3] == 'y'
     assert p[4] == 'Z'
     assert p[5] == 'z'
     assert allblocks == [(rawstart, rawstart + 6)]
     assert puts == [(rawstart + 2, ['a', 'b', 'c', 'd']),
                     (rawstart + 4, ['e', 'f', 'g'])]
コード例 #4
0
ファイル: test_asmmemmgr.py プロジェクト: weijiwei/pypy
    def test_insert_gcroot_marker(self):
        puts = []

        class FakeGcRootMap:
            def register_asm_addr(self, retaddr, mark):
                puts.append((retaddr, mark))

        #
        mc = BlockBuilderMixin()
        mc.writechar('X')
        mc.writechar('x')
        mc.insert_gcroot_marker(['a', 'b', 'c', 'd'])
        mc.writechar('Y')
        mc.writechar('y')
        mc.insert_gcroot_marker(['e', 'f', 'g'])
        mc.writechar('Z')
        mc.writechar('z')
        #
        gcrootmap = FakeGcRootMap()
        allblocks = []
        rawstart = mc.materialize(self.memmgr, allblocks, gcrootmap)
        p = rffi.cast(rffi.CArrayPtr(lltype.Char), rawstart)
        assert p[0] == 'X'
        assert p[1] == 'x'
        assert p[2] == 'Y'
        assert p[3] == 'y'
        assert p[4] == 'Z'
        assert p[5] == 'z'
        # 'allblocks' should be one block of length 6 + 15
        # (15 = alignment - 1) containing the range(rawstart, rawstart + 6)
        [(blockstart, blockend)] = allblocks
        assert blockend == blockstart + 6 + (mc.ALIGN_MATERIALIZE - 1)
        assert blockstart <= rawstart < rawstart + 6 <= blockend
        assert puts == [(rawstart + 2, ['a', 'b', 'c', 'd']),
                        (rawstart + 4, ['e', 'f', 'g'])]