File: test_zdisable_opts.py

package info (click to toggle)
pypy 7.0.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 107,216 kB
  • sloc: python: 1,201,787; ansic: 62,419; asm: 5,169; cpp: 3,017; sh: 2,534; makefile: 545; xml: 243; lisp: 45; awk: 4
file content (50 lines) | stat: -rw-r--r-- 1,962 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

import py
from rpython.jit.metainterp.optimizeopt.test.test_optimizeopt import OptimizeOptTest
from rpython.jit.metainterp.optimizeopt.test.test_util import LLtypeMixin
from rpython.jit.metainterp.resoperation import rop

def setup_module(mod):
    py.test.skip("purpose unclear")

allopts = OptimizeOptTest.enable_opts.split(':')
for optnum in range(len(allopts)):
    myopts = allopts[:]
    del myopts[optnum]

    class TestLLtype(OptimizeOptTest, LLtypeMixin):
        enable_opts = ':'.join(myopts)

        def optimize_loop(self, ops, expected, expected_preamble=None,
                          call_pure_results=None, expected_short=None):
            loop = self.parse(ops, postprocess=self.postprocess)
            if expected != "crash!":
                expected = self.parse(expected)
            if expected_preamble:
                expected_preamble = self.parse(expected_preamble)
            if expected_short:
                expected_short = self.parse(expected_short)

            preamble = self.unroll_and_optimize(loop, call_pure_results)

            for op in preamble.operations + loop.operations:
                assert op.getopnum() not in (rop.CALL_PURE,
                                             rop.CALL_LOOPINVARIANT,
                                             rop.VIRTUAL_REF_FINISH,
                                             rop.VIRTUAL_REF,
                                             rop.QUASIIMMUT_FIELD,
                                             rop.MARK_OPAQUE_PTR,
                                             rop.RECORD_EXACT_CLASS)

        def raises(self, e, fn, *args):
            try:
                fn(*args)
            except Exception as e:
                return e

    opt = allopts[optnum]
    exec "TestNo%sLLtype = TestLLtype" % (opt[0].upper() + opt[1:])

del TestLLtype # No need to run the last set twice
del TestNoUnrollLLtype # This case is take care of by test_optimizebasic