File: jittest.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 (54 lines) | stat: -rw-r--r-- 1,839 bytes parent folder | download | duplicates (5)
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
51
52
53
54
"""
This file is imported by rpython.translator.driver when running the
target --pyjittest.  Feel free to hack it as needed; it is imported
only after the '---> Checkpoint' fork.
"""

import os
from rpython import conftest
from rpython.rtyper.llinterp import LLInterpreter
from rpython.rtyper.annlowlevel import llstr
from rpython.jit.metainterp import warmspot
from rpython.tool import runsubprocess

os.environ['PYPY_DONT_RUN_SUBPROCESS'] = '1'
reload(runsubprocess)


#ARGS = ["--jit", "threshold=100000,trace_eagerness=100000",
#        "-S", "/home/arigo/pypysrc/32compiled/z.py"]
ARGS = ["targettest_executable_name",
        "-r", "13", "/home/arigo/git/pyrlang/test_beam/fact.beam",
        "fact", "20000"]


def jittest(driver):
    graph = driver.translator._graphof(driver.entry_point)
    interp = LLInterpreter(driver.translator.rtyper)

    get_policy = driver.extra.get('jitpolicy', None)
    if get_policy is None:
        from rpython.jit.codewriter.policy import JitPolicy
        jitpolicy = JitPolicy()
    else:
        jitpolicy = get_policy(driver)

    from rpython.jit.backend.llgraph.runner import LLGraphCPU
    apply_jit(jitpolicy, interp, graph, LLGraphCPU)


def apply_jit(policy, interp, graph, CPUClass):
    print 'warmspot.jittify_and_run() started...'
    if conftest.option is None:
        class MyOpt:
            pass
        conftest.option = MyOpt()
    conftest.option.view = False
    conftest.option.viewloops = True   # XXX doesn't seem to work
    LIST = graph.getargs()[0].concretetype
    lst = LIST.TO.ll_newlist(len(ARGS))
    for i, arg in enumerate(ARGS):
        lst.ll_setitem_fast(i, llstr(arg))
    warmspot.jittify_and_run(interp, graph, [lst], policy=policy,
                             listops=True, CPUClass=CPUClass,
                             backendopt=True, inline=True)