Skip to content

Commit 0a0ec31

Browse files
committed
static compiling prototype
Based on: Squash reloadso changes for cleaner history Sanitize macro names in llvm to avoid implied symbol Re-add jl_dump_bitcode and clean up debugging code generate llvm global variables for most literal_pointer_val switch to llvm-managed global variables, load and save them get much further in the static compile boot process (barely) working static-compiled repl static compiling
1 parent b406675 commit 0a0ec31

18 files changed

+648
-291
lines changed

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys0.ji:
6969
@$(QUIET_JULIA) cd base && \
7070
$(call spawn,$(JULIA_EXECUTABLE)) -bf sysimg.jl
7171
mv $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.ji $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys0.ji
72+
$(call spawn,$(BUILD)/bin/llc) -filetype=obj -relocation-model=pic -o sysimg0.o $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.bc
73+
$(CXX) -shared -fPIC -L$(BUILD)/lib -o $(BUILD)/lib/sysimg0.$(SHLIB_EXT) sysimg0.o -Wl,-undefined,dynamic_lookup -lgrisu -lrandom -lgmp -lpcre
7274

7375
$(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.ji: VERSION base/*.jl base/pkg/*.jl base/linalg/*.jl base/sparse/*.jl $(BUILD)/share/julia/helpdb.jl $(BUILD)/share/man/man1/julia.1 $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys0.ji
7476
@$(QUIET_JULIA) cd base && \
@@ -240,7 +242,7 @@ clean: | $(CLEAN_TARGETS)
240242
@$(MAKE) -C base clean
241243
@$(MAKE) -C src clean
242244
@$(MAKE) -C ui clean
243-
for repltype in "basic" "readline"; do \
245+
for repltype in "basic" "readline"; do \
244246
rm -f usr/bin/julia-debug-$${repltype}; \
245247
rm -f usr/bin/julia-$${repltype}; \
246248
done

base/precompile.jl

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
include = include_from_node1
2+
3+
# prime method cache with some things we know we'll need right after startup
4+
precompile(pwd, ())
5+
precompile(fdio, (Int32,))
6+
precompile(ProcessGroup, (Int, Array{Any,1}, Array{Any,1}))
7+
precompile(next, (Dict{Any,Any}, Int))
8+
precompile(start, (Dict{Any,Any},))
9+
precompile(perform_work, ())
10+
precompile(isempty, (Array{Any,1},))
11+
precompile(getindex, (Dict{Any,Any}, Int32))
12+
precompile(event_loop, (Bool,))
13+
precompile(_start, ())
14+
precompile(process_options, (Array{Any,1},))
15+
precompile(run_repl, ())
16+
precompile(any, (Function, Array{Any,1}))
17+
precompile(Dict{Any,Any}, (Int,))
18+
precompile(Set, ())
19+
precompile(setindex!, (Dict{Any,Any}, Bool, Cmd))
20+
precompile(rehash, (Dict{Any,Any}, Int))
21+
precompile(wait, (Int32,))
22+
precompile(systemerror, (Symbol, Bool))
23+
precompile(SystemError, (ASCIIString,))
24+
precompile(has, (EnvHash, ASCIIString))
25+
precompile(parse_input_line, (ASCIIString,))
26+
precompile(cmp, (Int32, Int32))
27+
precompile(min, (Int32, Int32))
28+
precompile(==, (ASCIIString, ASCIIString))
29+
precompile(arg_gen, (ASCIIString,))
30+
precompile(Random.librandom_init, ())
31+
precompile(Random.srand, (ASCIIString, Int))
32+
precompile(Random.srand, (Uint64,))
33+
precompile(open, (ASCIIString, Bool, Bool, Bool, Bool))
34+
precompile(done, (IntSet, Int64))
35+
precompile(next, (IntSet, Int64))
36+
precompile(ht_keyindex, (Dict{Any,Any}, Int32))
37+
precompile(perform_work, (Task,))
38+
precompile(notify_full, (RemoteValue,))
39+
precompile(notify_empty, (RemoteValue,))
40+
precompile(work_result, (RemoteValue,))
41+
precompile(take, (RemoteValue,))
42+
precompile(wait_full, (RemoteValue,))
43+
precompile(enq_work, (Task,))
44+
precompile(string, (Int,))
45+
precompile(parseint, (Type{Int}, ASCIIString, Int))
46+
precompile(repeat, (ASCIIString, Int))
47+
precompile(KeyError, (Int,))
48+
precompile(show, (Float64,))
49+
precompile(match, (Regex, ASCIIString))
50+
precompile(length, (ASCIIString,))
51+
precompile(alignment, (Float64,))
52+
precompile(repl_callback, (Expr, Int))
53+
precompile(istaskdone, (Task,))
54+
precompile(int, (Uint64,))
55+
precompile(copy, (Bool,))
56+
precompile(bool, (Bool,))
57+
precompile(bool, (RemoteRef,))
58+
precompile(wait, (RemoteRef,))
59+
precompile(hash, (RemoteRef,))
60+
precompile(take, (RemoteRef,))
61+
precompile(bitmix, (Int, Int))
62+
precompile(bitmix, (Uint, Int))
63+
precompile(bitmix, (Uint64, Int64))
64+
precompile(hash, (Int,))
65+
precompile(isequal, (Symbol, Symbol))
66+
precompile(isequal, (Bool, Bool))
67+
precompile(get, (EnvHash, ASCIIString, ASCIIString))
68+
precompile(rr2id, (RemoteRef,))
69+
precompile(isequal, (RemoteRef, WeakRef))
70+
precompile(isequal, (RemoteRef, RemoteRef))
71+
precompile(_ieval, (Symbol,))
72+
precompile(static_convert, (Nothing, Nothing))
73+
precompile(setindex!, (Array{Any,1}, WeakRef, Int))
74+
precompile(isequal, ((Int,Int),(Int,Int)))
75+
precompile(isequal, (Int,Int))
76+
precompile(RemoteRef, (Int, Int, Int))
77+
precompile(eval_user_input, (Expr, Bool))
78+
precompile(print, (Float64,))
79+
precompile(a2t, (Array{Any,1},))
80+
precompile(flush, (IOStream,))
81+
precompile(getindex, (Type{ByteString}, ASCIIString, ASCIIString))
82+
precompile(bytestring, (ASCIIString,))
83+
precompile(int, (Int,))
84+
precompile(uint, (Uint,))
85+
precompile(_atexit, ())
86+
precompile(read, (IOStream, Array{Uint32,1}))
87+
precompile(hex, (Char, Int))
88+
precompile(abs, (Char,))
89+
precompile(abstract_eval, (LambdaStaticData, ObjectIdDict, StaticVarInfo))
90+
precompile(length, (Range1{Int},))
91+
precompile(start, (Range1{Int},))
92+
precompile(done, (Range1{Int},Int))
93+
precompile(next, (Range1{Int},Int))
94+
precompile(IOStream, (ASCIIString, Array{Uint8,1}))
95+
precompile(mk_tupleref, (SymbolNode, Int))
96+
precompile(abstract_interpret, (Bool, ObjectIdDict, StaticVarInfo))
97+
precompile(eval_annotate, (LambdaStaticData, ObjectIdDict, StaticVarInfo, ObjectIdDict, Array{Any,1}))
98+
precompile(occurs_more, (Bool, Function, Int))
99+
precompile(isconstantfunc, (SymbolNode, StaticVarInfo))
100+
precompile(CallStack, (Expr, Module, (Nothing,), EmptyCallStack))
101+
precompile(convert, (Type{Module}, Module))
102+
precompile(effect_free, (Expr,))
103+
precompile(effect_free, (TopNode,))
104+
precompile(abspath, (ASCIIString,))
105+
precompile(isabspath, (ASCIIString,))
106+
precompile(split, (ASCIIString,))
107+
precompile(split, (ASCIIString, ASCIIString, Int, Bool))
108+
precompile(split, (ASCIIString, Regex, Int, Bool))
109+
precompile(print_joined, (IOBuffer, Array{String,1}, ASCIIString))
110+
precompile(beginswith, (ASCIIString, ASCIIString))
111+
precompile(resolve_globals, (Symbol, Module, Module, Vector{Any}, Vector{Any}))
112+
precompile(resolve_globals, (SymbolNode, Module, Module, Vector{Any}, Vector{Any}))
113+
precompile(BitArray, (Int,))
114+
precompile(getindex, (BitArray{1}, Int,))
115+
precompile(setindex!, (BitArray{1}, Bool, Int,))
116+
precompile(fill!, (BitArray{1}, Bool))
117+
precompile(pop!, (Array{Any,1},))
118+
precompile(unshift!, (Array{Any,1}, Task))
119+
precompile(nnz, (BitArray{1},))
120+
precompile(get_chunks_id, (Int,))
121+
precompile(occurs_more, (Uint8, Function, Int))
122+
precompile(abstract_eval_arg, (Uint8, ObjectIdDict, StaticVarInfo))
123+
precompile(occurs_outside_tupleref, (Function, Symbol, StaticVarInfo, Int))
124+
precompile(search, (ASCIIString, Regex, Int))
125+
precompile(setindex!, (Vector{Any}, Uint8, Int))
126+
precompile(setindex!, (Vector{Any}, Vector{Any}, Int))
127+
precompile(first, (Range1{Int},))
128+
precompile(last, (Range1{Int},))
129+
precompile(isempty, (ASCIIString,))
130+
precompile(normpath, (ASCIIString,))
131+
precompile(print, (ASCIIString,))
132+
precompile(println, (TTY,))
133+
precompile(print, (TTY,Char))
134+
precompile(==, (Bool,Bool))
135+
precompile(try_include, (ASCIIString,))
136+
precompile(isfile, (ASCIIString,))
137+
precompile(include_from_node1, (ASCIIString,))
138+
precompile(source_path, (Nothing,))
139+
precompile(task_local_storage, ())
140+
precompile(atexit, (Function,))
141+
precompile(print, (TTY, ASCIIString))
142+
precompile(close, (TTY,))
143+
precompile(read_buffer, (TTY,Int))
144+
precompile(put, (RemoteRef, Any))
145+
precompile(getpid, ())
146+
precompile(print, (IOStream, Int32))
147+
precompile(show, (IOStream, Int32))
148+
precompile(open, (ASCIIString, ASCIIString))
149+
precompile(readline, (ASCIIString,))
150+
precompile(endof, (Array{Any,1},))
151+
precompile(sym_replace, (Uint8, Array{Any,1}, Array{Any,1}, Array{Any,1}, Array{Any,1}))
152+
precompile(isslotempty, (Dict{Any,Any}, Int))
153+
precompile(setindex!, (Array{Uint8,1}, Uint8, Int))
154+
precompile(get, (Dict{Any,Any}, Symbol, ASCIIString))
155+
precompile(*, (ASCIIString, ASCIIString, ASCIIString))
156+
precompile(chop, (ASCIIString,))
157+
precompile(ismatch, (Regex, ASCIIString))
158+
precompile(!=, (Bool, Bool))
159+
precompile(nextind, (ASCIIString, Int))
160+
precompile(delete_var!, (Expr, Symbol))
161+
precompile(close, (IOStream,))
162+
precompile(haskey, (ObjectIdDict, Symbol))

base/sysimg.jl

+2-162
Original file line numberDiff line numberDiff line change
@@ -217,168 +217,7 @@ include("graphics.jl")
217217
include("profile.jl")
218218
importall .Profile
219219

220-
include = include_from_node1
221-
222-
# prime method cache with some things we know we'll need right after startup
223-
precompile(pwd, ())
224-
precompile(fdio, (Int32,))
225-
precompile(ProcessGroup, (Int, Array{Any,1}, Array{Any,1}))
226-
precompile(next, (Dict{Any,Any}, Int))
227-
precompile(start, (Dict{Any,Any},))
228-
precompile(perform_work, ())
229-
precompile(isempty, (Array{Any,1},))
230-
precompile(getindex, (Dict{Any,Any}, Int32))
231-
precompile(event_loop, (Bool,))
232-
precompile(_start, ())
233-
precompile(process_options, (Array{Any,1},))
234-
precompile(run_repl, ())
235-
precompile(any, (Function, Array{Any,1}))
236-
precompile(Dict{Any,Any}, (Int,))
237-
precompile(Set, ())
238-
precompile(setindex!, (Dict{Any,Any}, Bool, Cmd))
239-
precompile(rehash, (Dict{Any,Any}, Int))
240-
precompile(wait, (Int32,))
241-
precompile(systemerror, (Symbol, Bool))
242-
precompile(SystemError, (ASCIIString,))
243-
precompile(has, (EnvHash, ASCIIString))
244-
precompile(parse_input_line, (ASCIIString,))
245-
precompile(cmp, (Int32, Int32))
246-
precompile(min, (Int32, Int32))
247-
precompile(==, (ASCIIString, ASCIIString))
248-
precompile(arg_gen, (ASCIIString,))
249-
precompile(Random.librandom_init, ())
250-
precompile(Random.srand, (ASCIIString, Int))
251-
precompile(Random.srand, (Uint64,))
252-
precompile(open, (ASCIIString, Bool, Bool, Bool, Bool))
253-
precompile(done, (IntSet, Int64))
254-
precompile(next, (IntSet, Int64))
255-
precompile(ht_keyindex, (Dict{Any,Any}, Int32))
256-
precompile(perform_work, (Task,))
257-
precompile(notify_full, (RemoteValue,))
258-
precompile(notify_empty, (RemoteValue,))
259-
precompile(work_result, (RemoteValue,))
260-
precompile(take, (RemoteValue,))
261-
precompile(wait_full, (RemoteValue,))
262-
precompile(enq_work, (Task,))
263-
precompile(string, (Int,))
264-
precompile(parseint, (Type{Int}, ASCIIString, Int))
265-
precompile(repeat, (ASCIIString, Int))
266-
precompile(KeyError, (Int,))
267-
precompile(show, (Float64,))
268-
precompile(match, (Regex, ASCIIString))
269-
precompile(length, (ASCIIString,))
270-
precompile(alignment, (Float64,))
271-
precompile(repl_callback, (Expr, Int))
272-
precompile(istaskdone, (Task,))
273-
precompile(int, (Uint64,))
274-
precompile(copy, (Bool,))
275-
precompile(bool, (Bool,))
276-
precompile(bool, (RemoteRef,))
277-
precompile(wait, (RemoteRef,))
278-
precompile(hash, (RemoteRef,))
279-
precompile(take, (RemoteRef,))
280-
precompile(bitmix, (Int, Int))
281-
precompile(bitmix, (Uint, Int))
282-
precompile(bitmix, (Uint64, Int64))
283-
precompile(hash, (Int,))
284-
precompile(isequal, (Symbol, Symbol))
285-
precompile(isequal, (Bool, Bool))
286-
precompile(get, (EnvHash, ASCIIString, ASCIIString))
287-
precompile(rr2id, (RemoteRef,))
288-
precompile(isequal, (RemoteRef, WeakRef))
289-
precompile(isequal, (RemoteRef, RemoteRef))
290-
precompile(_ieval, (Symbol,))
291-
precompile(static_convert, (Nothing, Nothing))
292-
precompile(setindex!, (Array{Any,1}, WeakRef, Int))
293-
precompile(isequal, ((Int,Int),(Int,Int)))
294-
precompile(isequal, (Int,Int))
295-
precompile(RemoteRef, (Int, Int, Int))
296-
precompile(eval_user_input, (Expr, Bool))
297-
precompile(print, (Float64,))
298-
precompile(a2t, (Array{Any,1},))
299-
precompile(flush, (IOStream,))
300-
precompile(getindex, (Type{ByteString}, ASCIIString, ASCIIString))
301-
precompile(bytestring, (ASCIIString,))
302-
precompile(int, (Int,))
303-
precompile(uint, (Uint,))
304-
precompile(_atexit, ())
305-
precompile(read, (IOStream, Array{Uint32,1}))
306-
precompile(hex, (Char, Int))
307-
precompile(abs, (Char,))
308-
precompile(abstract_eval, (LambdaStaticData, ObjectIdDict, StaticVarInfo))
309-
precompile(length, (Range1{Int},))
310-
precompile(start, (Range1{Int},))
311-
precompile(done, (Range1{Int},Int))
312-
precompile(next, (Range1{Int},Int))
313-
precompile(IOStream, (ASCIIString, Array{Uint8,1}))
314-
precompile(mk_tupleref, (SymbolNode, Int))
315-
precompile(abstract_interpret, (Bool, ObjectIdDict, StaticVarInfo))
316-
precompile(eval_annotate, (LambdaStaticData, ObjectIdDict, StaticVarInfo, ObjectIdDict, Array{Any,1}))
317-
precompile(occurs_more, (Bool, Function, Int))
318-
precompile(isconstantfunc, (SymbolNode, StaticVarInfo))
319-
precompile(CallStack, (Expr, Module, (Nothing,), EmptyCallStack))
320-
precompile(convert, (Type{Module}, Module))
321-
precompile(effect_free, (Expr,))
322-
precompile(effect_free, (TopNode,))
323-
precompile(abspath, (ASCIIString,))
324-
precompile(isabspath, (ASCIIString,))
325-
precompile(split, (ASCIIString,))
326-
precompile(split, (ASCIIString, ASCIIString, Int, Bool))
327-
precompile(split, (ASCIIString, Regex, Int, Bool))
328-
precompile(print_joined, (IOBuffer, Array{String,1}, ASCIIString))
329-
precompile(beginswith, (ASCIIString, ASCIIString))
330-
precompile(resolve_globals, (Symbol, Module, Module, Vector{Any}, Vector{Any}))
331-
precompile(resolve_globals, (SymbolNode, Module, Module, Vector{Any}, Vector{Any}))
332-
precompile(BitArray, (Int,))
333-
precompile(getindex, (BitArray{1}, Int,))
334-
precompile(setindex!, (BitArray{1}, Bool, Int,))
335-
precompile(fill!, (BitArray{1}, Bool))
336-
precompile(pop!, (Array{Any,1},))
337-
precompile(unshift!, (Array{Any,1}, Task))
338-
precompile(nnz, (BitArray{1},))
339-
precompile(get_chunks_id, (Int,))
340-
precompile(occurs_more, (Uint8, Function, Int))
341-
precompile(abstract_eval_arg, (Uint8, ObjectIdDict, StaticVarInfo))
342-
precompile(occurs_outside_tupleref, (Function, Symbol, StaticVarInfo, Int))
343-
precompile(search, (ASCIIString, Regex, Int))
344-
precompile(setindex!, (Vector{Any}, Uint8, Int))
345-
precompile(setindex!, (Vector{Any}, Vector{Any}, Int))
346-
precompile(first, (Range1{Int},))
347-
precompile(last, (Range1{Int},))
348-
precompile(isempty, (ASCIIString,))
349-
precompile(normpath, (ASCIIString,))
350-
precompile(print, (ASCIIString,))
351-
precompile(println, (TTY,))
352-
precompile(print, (TTY,Char))
353-
precompile(==, (Bool,Bool))
354-
precompile(try_include, (ASCIIString,))
355-
precompile(isfile, (ASCIIString,))
356-
precompile(include_from_node1, (ASCIIString,))
357-
precompile(source_path, (Nothing,))
358-
precompile(task_local_storage, ())
359-
precompile(atexit, (Function,))
360-
precompile(print, (TTY, ASCIIString))
361-
precompile(close, (TTY,))
362-
precompile(read_buffer, (TTY,Int))
363-
precompile(put, (RemoteRef, Any))
364-
precompile(getpid, ())
365-
precompile(print, (IOStream, Int32))
366-
precompile(show, (IOStream, Int32))
367-
precompile(open, (ASCIIString, ASCIIString))
368-
precompile(readline, (ASCIIString,))
369-
precompile(endof, (Array{Any,1},))
370-
precompile(sym_replace, (Uint8, Array{Any,1}, Array{Any,1}, Array{Any,1}, Array{Any,1}))
371-
precompile(isslotempty, (Dict{Any,Any}, Int))
372-
precompile(setindex!, (Array{Uint8,1}, Uint8, Int))
373-
precompile(get, (Dict{Any,Any}, Symbol, ASCIIString))
374-
precompile(*, (ASCIIString, ASCIIString, ASCIIString))
375-
precompile(chop, (ASCIIString,))
376-
precompile(ismatch, (Regex, ASCIIString))
377-
precompile(!=, (Bool, Bool))
378-
precompile(nextind, (ASCIIString, Int))
379-
precompile(delete_var!, (Expr, Symbol))
380-
precompile(close, (IOStream,))
381-
precompile(haskey, (ObjectIdDict, Symbol))
220+
include("precompile.jl")
382221

383222
# invoke type inference, running the existing inference code on the new
384223
# inference code to cache an optimized version of it.
@@ -396,4 +235,5 @@ let JL_PRIVATE_LIBDIR = get(ENV, "JL_PRIVATE_LIBDIR", "lib/julia")
396235
# create system image file
397236
ccall(:jl_save_system_image, Void, (Ptr{Uint8},),
398237
"$JULIA_HOME/../$JL_PRIVATE_LIBDIR/sys.ji")
238+
ccall(:jl_dump_bitcode, Void, (Ptr{Uint8},), "$JULIA_HOME/../$JL_PRIVATE_LIBDIR/sys.bc")
399239
end

src/alloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ DLLEXPORT jl_value_t *jl_new_struct_uninit(jl_datatype_t *type)
219219
return jv;
220220
}
221221

222-
jl_tuple_t *jl_tuple(size_t n, ...)
222+
DLLEXPORT jl_tuple_t *jl_tuple(size_t n, ...)
223223
{
224224
va_list args;
225225
if (n == 0) return jl_null;

src/builtins.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
// exceptions -----------------------------------------------------------------
3131

32-
void jl_error(const char *str)
32+
DLLEXPORT void jl_error(const char *str)
3333
{
3434
if (jl_errorexception_type == NULL) {
3535
JL_PRINTF(JL_STDERR, "%s", str);

0 commit comments

Comments
 (0)