forked from rubinius/rubinius
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjit.rake
91 lines (78 loc) · 2.71 KB
/
jit.rake
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
namespace :jit do
task :generate_header do
puts "GEN vm/llvm/types.cpp.gen"
classes = %w!
rubinius::ObjectFlags
rubinius::HeaderWord
rubinius::ObjectHeader
rubinius::Object
rubinius::StackVariables
rubinius::CallFrame
rubinius::UnwindInfo
rubinius::VariableScope
rubinius::CompiledMethod
rubinius::Executable
rubinius::Dispatch
rubinius::Arguments
rubinius::Tuple
rubinius::Array
rubinius::Class
rubinius::Module
rubinius::StaticScope
rubinius::InstructionSequence
rubinius::InlineCache
rubinius::InlineCacheHit
rubinius::BlockEnvironment
rubinius::BlockInvocation
rubinius::Numeric
rubinius::Float
rubinius::jit::RuntimeData
rubinius::CallUnit
jit_state!
require 'tempfile'
files = %w!vm/call_frame.hpp
vm/arguments.hpp
vm/dispatch.hpp
vm/inline_cache.hpp
vm/builtin/block_environment.hpp
vm/builtin/integer.hpp
vm/builtin/float.hpp
vm/llvm/jit_runtime.hpp!
path = "llvm-type-temp.cpp"
File.open(path, "w+") do |f|
files.each do |file|
f.puts "#include \"#{file}\""
end
i = 0
classes.each do |klass|
f.puts "void useme#{i}(#{klass}* thing);"
f.puts "void blah#{i}(#{klass}* thing) { useme#{i}(thing); }"
i += 1
end
end
str = `llvm-g++ -I. -Ivm -Ivm/external_libs/libtommath -emit-llvm -S -o - "#{path}"`
return unless $?.exitstatus == 0
File.unlink path
types = []
str.split("\n").each do |line|
line.gsub!(
'%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Alloc_hider"',
'%"struct.rubinius::HeaderWord"')
classes.each do |klass|
if /%"?struct.#{klass}(::\$[^\s]+)?"? = type/.match(line)
types << line
end
end
end
opaque = %w!VM TypeInfo VMMethod Fixnum Symbol Selector LookupTable MethodTable
jit::RuntimeDataHolder Inliners!
File.open("vm/gen/types.ll","w+") do |f|
opaque.each do |o|
f.puts "%\"struct.rubinius::#{o}\" = type opaque"
end
f.puts(*types)
end
`llvm-as < vm/gen/types.ll > vm/gen/types.bc`
`vm/external_libs/llvm/Release/bin/llc -march=cpp -cppgen=contents -o vm/llvm/types.cpp.gen vm/gen/types.bc`
end
end