forked from pixie-lang/pixie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtarget2.py
More file actions
151 lines (115 loc) · 4.2 KB
/
target2.py
File metadata and controls
151 lines (115 loc) · 4.2 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import pixie.vm2.interpreter as i
from pixie.vm2.interpreter import run_stack
from pixie.vm2.object import StackCell
import pixie.vm2.rt as rt
from pixie.vm2.primitives import nil, true, false
import pixie.vm2.code as code
from pixie.vm2.keyword import keyword as kw
from pixie.vm2.symbol import symbol as sym
from pixie.vm2.numbers import parse_number
from pixie.vm2.pxic_reader import read_file, read_object, Reader
from rpython.rlib.objectmodel import we_are_translated
rt.init()
import sys
def testit(max):
rdr = Reader("./bootstrap.pxic")
while True:
try:
obj = read_object(rdr)
except EOFError:
break
if not we_are_translated():
print ".",
sys.stdout.flush()
run_stack(None, i.InterpretK(obj, None))
return None
#pixie_code = read_file("/tmp/bootstrap.pxic")
#return run_stack(None, i.InterpretK(pixie_code, None))
#val = testit()
#print val.int_val(), val
def entry_point(args):
#s = rt.wrap(u"Foo")
from pixie.vm2.string import String
v = parse_number(u"1")
s = String(u"Foo")
max = 10000 #int(args[1])
val = testit(max)
return 43
def entry_point0():
#s = rt.wrap(u"Foo")
from pixie.vm2.string import String
v = parse_number(u"1")
s = String(u"Foo")
max = 10000 #int(args[1])
val = testit(max)
return 43
## JIT STUFF
from rpython.jit.codewriter.policy import JitPolicy
from rpython.rlib.jit import JitHookInterface, Counters
from rpython.rlib.rfile import create_stdio
from rpython.annotator.policy import AnnotatorPolicy
from rpython.rtyper.lltypesystem import lltype
from rpython.jit.metainterp import warmspot
def run_child(glob, loc):
interp = loc['interp']
graph = loc['graph']
interp.malloc_check = False
def returns_null(T, *args, **kwds):
return lltype.nullptr(T)
interp.heap.malloc_nonmovable = returns_null # XXX
from rpython.jit.backend.llgraph.runner import LLGraphCPU
#LLtypeCPU.supports_floats = False # for now
apply_jit(interp, graph, LLGraphCPU)
def apply_jit(interp, graph, CPUClass):
print 'warmspot.jittify_and_run() started...'
policy = Policy()
warmspot.jittify_and_run(interp, graph, [], policy=policy,
listops=True, CPUClass=CPUClass,
backendopt=True, inline=True)
def run_debug(argv):
from rpython.rtyper.test.test_llinterp import get_interpreter
# first annotate and rtype
try:
interp, graph = get_interpreter(entry_point0, [], backendopt=False,
#config=config,
#type_system=config.translation.type_system,
policy=Policy())
except Exception, e:
print '%s: %s' % (e.__class__, e)
pdb.post_mortem(sys.exc_info()[2])
raise
# parent process loop: spawn a child, wait for the child to finish,
# print a message, and restart
#unixcheckpoint.restartable_point(auto='run')
from rpython.jit.codewriter.codewriter import CodeWriter
CodeWriter.debug = True
run_child(globals(), locals())
#stacklet.global_state = stacklet.GlobalState()
class DebugIFace(JitHookInterface):
def on_abort(self, reason, jitdriver, greenkey, greenkey_repr, logops, operations):
print "Aborted Trace, reason: ", Counters.counter_names[reason], logops, greenkey_repr
#from rpython.rlib.objectmodel import we_are_translated
#import pdb; pdb.set_trace()
#exit(0)
pass
def before_compile_bridge(self, debug_info):
print "Compiling Bridge", debug_info
pass
import sys, pdb
class Policy(JitPolicy, AnnotatorPolicy):
def __init__(self):
JitPolicy.__init__(self, DebugIFace())
def jitpolicy(driver):
return JitPolicy(jithookiface=DebugIFace())
def target(*args):
import pixie.vm.rt as rt
driver = args[0]
driver.exe_name = "pixie-vm2"
rt.__config__ = args[0].config
print "ARG INFO: ", args
return entry_point, None
import rpython.config.translationoption
print rpython.config.translationoption.get_combined_translation_config()
if __name__ == "__main__":
#run_debug(sys.argv)
entry_point([])