コード例 #1
0
ファイル: test_logger.py プロジェクト: alkorzt/pypy
 def test_guard_descr(self):
     namespace = {'fdescr': BasicFailDescr()}
     inp = '''
     [i0]
     guard_true(i0, descr=fdescr) [i0]
     '''
     loop = pure_parse(inp, namespace=namespace)
     logger = Logger(self.make_metainterp_sd(), guard_number=True)
     output = logger.log_loop(loop)
     assert output.splitlines()[-1] == "guard_true(i0, descr=<Guard0>) [i0]"
     pure_parse(output)
     
     logger = Logger(self.make_metainterp_sd(), guard_number=False)
     output = logger.log_loop(loop)
     lastline = output.splitlines()[-1]
     assert lastline.startswith("guard_true(i0, descr=<")
     assert not lastline.startswith("guard_true(i0, descr=<Guard")
コード例 #2
0
    def test_guard_descr(self):
        namespace = {'fdescr': BasicFailDescr()}
        inp = '''
        [i0]
        guard_true(i0, descr=fdescr) [i0]
        '''
        loop = pure_parse(inp, namespace=namespace)
        logger = Logger(self.make_metainterp_sd(), guard_number=True)
        output = logger.log_loop(loop)
        assert output.splitlines()[-1] == "guard_true(i0, descr=<Guard0>) [i0]"
        pure_parse(output)

        logger = Logger(self.make_metainterp_sd(), guard_number=False)
        output = logger.log_loop(loop)
        lastline = output.splitlines()[-1]
        assert lastline.startswith("guard_true(i0, descr=<")
        assert not lastline.startswith("guard_true(i0, descr=<Guard")
コード例 #3
0
ファイル: test_logger.py プロジェクト: neurobcn/plexnet
 def test_guard(self):
     namespace = {'fdescr': BasicFailDescr(4)}
     inp = '''
     [i0]
     guard_true(i0, descr=fdescr) [i0]
     '''
     loop = pure_parse(inp, namespace=namespace)
     logger = Logger(self.ts, guard_number=True)
     output = logger.log_loop(loop)
     assert output.splitlines()[-1] == "guard_true(i0, descr=<Guard4>) [i0]"
     pure_parse(output)
     
     def boom():
         raise Exception
     namespace['fdescr'].get_index = boom
     logger = Logger(self.ts, guard_number=False)
     output = logger.log_loop(loop)
     assert output.splitlines()[-1].startswith("guard_true(i0, descr=<")
コード例 #4
0
ファイル: test_logger.py プロジェクト: alkorzt/pypy
 def test_jump(self):
     namespace = {'target': LoopToken(3)}
     inp = '''
     [i0]
     jump(i0, descr=target)
     '''
     loop = pure_parse(inp, namespace=namespace)
     logger = Logger(self.make_metainterp_sd())
     output = logger.log_loop(loop)
     assert output.splitlines()[-1] == "jump(i0, descr=<Loop3>)"
     pure_parse(output)
コード例 #5
0
ファイル: test_logger.py プロジェクト: neurobcn/plexnet
 def test_jump(self):
     namespace = {'target': LoopToken(3)}
     inp = '''
     [i0]
     jump(i0, descr=target)
     '''
     loop = pure_parse(inp, namespace=namespace)
     logger = Logger(self.ts)
     output = logger.log_loop(loop)
     assert output.splitlines()[-1] == "jump(i0, descr=<Loop3>)"
     pure_parse(output)
コード例 #6
0
 def test_jump(self):
     namespace = {'target': JitCellToken()}
     namespace['target'].number = 3
     inp = '''
     [i0]
     jump(i0, descr=target)
     '''
     loop = pure_parse(inp, namespace=namespace)
     logger = Logger(self.make_metainterp_sd())
     output = logger.log_loop(loop)
     assert output.splitlines()[-1] == "jump(i0, descr=<Loop3>)"
     pure_parse(output)
コード例 #7
0
 def reparse(self, inp, namespace=None, check_equal=True):
     """ parse loop once, then log it and parse again.
     Checks that we get the same thing.
     """
     if namespace is None:
         namespace = {}
     loop = pure_parse(inp, namespace=namespace)
     logger = Logger(self.make_metainterp_sd())
     output = logger.log_loop(loop, namespace)
     oloop = pure_parse(output, namespace=namespace)
     if check_equal:
         equaloplists(loop.operations, oloop.operations)
         assert oloop.inputargs == loop.inputargs
     return logger, loop, oloop
コード例 #8
0
ファイル: test_logger.py プロジェクト: alkorzt/pypy
 def reparse(self, inp, namespace=None, check_equal=True):
     """ parse loop once, then log it and parse again.
     Checks that we get the same thing.
     """
     if namespace is None:
         namespace = {}
     loop = pure_parse(inp, namespace=namespace)
     logger = Logger(self.make_metainterp_sd())
     output = logger.log_loop(loop, namespace)
     oloop = pure_parse(output, namespace=namespace)
     if check_equal:
         equaloplists(loop.operations, oloop.operations)
         assert oloop.inputargs == loop.inputargs
     return loop, oloop
コード例 #9
0
 def test_class_name(self):
     from pypy.rpython.lltypesystem import lltype
     AbcVTable = lltype.Struct('AbcVTable')
     abcvtable = lltype.malloc(AbcVTable, immortal=True)
     namespace = {'Name': abcvtable}
     inp = '''
     [i0]
     p = new_with_vtable(ConstClass(Name))
     '''
     loop = pure_parse(inp, namespace=namespace)
     logger = Logger(self.make_metainterp_sd())
     output = logger.log_loop(loop)
     assert output.splitlines()[-1].endswith(
         " = new_with_vtable(ConstClass(Name))")
     pure_parse(output, namespace=namespace)
コード例 #10
0
ファイル: test_logger.py プロジェクト: alkorzt/pypy
 def test_class_name(self):
     from pypy.rpython.lltypesystem import lltype
     AbcVTable = lltype.Struct('AbcVTable')
     abcvtable = lltype.malloc(AbcVTable, immortal=True)
     namespace = {'Name': abcvtable}
     inp = '''
     [i0]
     p = new_with_vtable(ConstClass(Name))
     '''
     loop = pure_parse(inp, namespace=namespace)
     logger = Logger(self.make_metainterp_sd())
     output = logger.log_loop(loop)
     assert output.splitlines()[-1].endswith(
         " = new_with_vtable(ConstClass(Name))")
     pure_parse(output, namespace=namespace)
コード例 #11
0
    def test_ops_offset(self):
        inp = '''
        [i0]
        i1 = int_add(i0, 1)
        i2 = int_mul(i1, 2)
        jump(i2)
        '''
        loop = pure_parse(inp)
        ops = loop.operations
        ops_offset = {ops[0]: 10, ops[2]: 30, None: 40}
        logger = Logger(self.make_metainterp_sd())
        output = logger.log_loop(loop, ops_offset=ops_offset)
        assert output.strip() == """
[i0]
+10: i2 = int_add(i0, 1)
i4 = int_mul(i2, 2)
+30: jump(i4)
+40: --end of the loop--
""".strip()
コード例 #12
0
    def test_ops_offset(self):
        inp = '''
        [i0]
        i1 = int_add(i0, 1)
        i2 = int_mul(i1, 2)
        jump(i2)
        '''
        loop = pure_parse(inp)
        ops = loop.operations
        ops_offset = {
            ops[0]: 10,
            ops[2]: 30,
            None: 40
            }
        logger = Logger(self.make_metainterp_sd())
        output = logger.log_loop(loop, ops_offset=ops_offset)
        assert output.strip() == """
[i0]
+10: i2 = int_add(i0, 1)
i4 = int_mul(i2, 2)
+30: jump(i4)
+40: --end of the loop--
""".strip()