forked from hpi-swa/RSqueak
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtargettinybenchsmalltalk.py
More file actions
executable file
·51 lines (40 loc) · 1.49 KB
/
targettinybenchsmalltalk.py
File metadata and controls
executable file
·51 lines (40 loc) · 1.49 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
#! /usr/bin/env python
import sys
from rpython.jit.codewriter.policy import JitPolicy
from spyvm import model, objspace, interpreter, squeakimage
# This loads the whole mini.image in advance. At run-time,
# it executes the tinyBenchmark. In this way we get an RPython
# "image" frozen into the executable, mmap'ed by the OS from
# there and loaded lazily when needed :-)
# XXX this only compiles if sys.recursionlimit is high enough!
# On non-Linux platforms I don't know if there is enough stack to
# compile...
#sys.setrecursionlimit(100000)
imagefile = ""
def setup():
space = objspace.ObjSpace()
stream = squeakimage.Stream(filename=imagefile)
image = squeakimage.ImageReader(space, stream).create_image()
interp = interpreter.Interpreter(space, image)
w_selector = interp.perform(space.wrap_string("loopTest"), "asSymbol")
w_object = model.W_SmallInteger(0)
s_class = w_object.class_shadow(space)
w_method = s_class.lookup(w_selector)
s_frame = w_method.create_frame(space, w_object)
return interp, s_frame
interp, s_frame = setup()
def entry_point(argv):
try:
interp.loop(s_frame.w_self())
except interpreter.ReturnFromTopLevel, e:
w_result = e.object
assert isinstance(w_result, model.W_BytesObject)
print w_result.as_string()
return 0
# _____ Define and setup target ___
def target(*args):
return entry_point, None
def jitpolicy(driver):
return JitPolicy()
if __name__ == "__main__":
entry_point(sys.argv)