-
Notifications
You must be signed in to change notification settings - Fork 15
/
targetrsqueak.py
executable file
·95 lines (79 loc) · 3 KB
/
targetrsqueak.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#! /usr/bin/env python
import sys
import os
from rsqueakvm.util import system
from rpython.config.config import to_optparse
from rpython.config.translationoption import get_combined_translation_config
from rpython.jit.codewriter.policy import JitPolicy
from rpython.rlib import objectmodel
sys.setrecursionlimit(15000)
def target(driver, args):
driver.exe_name = "rsqueak"
config = driver.config
parser(config).parse_args(args)
driver.config.translation.suggest(**{
"jit": True,
"jit_opencoder_model": "big",
})
driver.config.translation.set(gcrootfinder="shadowstack")
if system.IS_WINDOWS:
driver.config.translation.suggest(**{
"icon": os.path.join(os.path.dirname(__file__), "rsqueak.ico")
})
config.translating = True
system.expose_options(driver.config)
if 'PythonPlugin' in system.optional_plugins:
# Disable vmprof, because it causes compiling errors
system.disabled_plugins += ',ProfilerPlugin'
# We must not import this before the config was exposed
from rsqueakvm.main import safe_entry_point
if 'PythonPlugin' in system.optional_plugins:
from rsqueakvm.plugins.python.utils import entry_point
from pypy.tool.ann_override import PyPyAnnotatorPolicy
ann_policy = PyPyAnnotatorPolicy()
return entry_point, None, ann_policy
return safe_entry_point, None, None
def jitpolicy(self):
if "PythonPlugin" in system.optional_plugins:
from pypy.module.pypyjit.policy import PyPyJitPolicy
from pypy.module.pypyjit.hooks import pypy_hooks
return PyPyJitPolicy(pypy_hooks)
elif "JitHooks" in system.optional_plugins:
from rsqueakvm.plugins.vmdebugging.hooks import jitiface
return JitPolicy(jitiface)
else:
return JitPolicy()
def parser(config):
return to_optparse(config, useoptions=["rsqueak.*"])
def print_help(config):
to_optparse(config).print_help()
take_options = True
def get_additional_config_options():
return system.translation_options()
if __name__ == '__main__':
assert not objectmodel.we_are_translated()
from rpython.translator.driver import TranslationDriver
driver = TranslationDriver()
driver.config = get_combined_translation_config(
system.translation_options(),
translating=False)
if "--" in sys.argv:
idx = sys.argv.index("--")
configargs, args = sys.argv[0:idx], sys.argv[idx:]
else:
configargs, args = [], sys.argv
f, _, _ = target(driver, configargs)
try:
sys.exit(f(args))
except SystemExit:
pass
except:
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like
# device, so we call the default hook
sys.__excepthook__(type, value, tb)
else:
import pdb, traceback
_type, value, tb = sys.exc_info()
traceback.print_exception(_type, value, tb)
pdb.post_mortem(tb)