Skip to content

Commit 1b844be

Browse files
authored
move builtin generation logic to precompilation time (#139)
* move builtin generation logic to precompilation time * updates * always run * Update src/JuliaInterpreter.jl Co-Authored-By: KristofferC <[email protected]>
1 parent 1a1f50d commit 1b844be

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

deps/build.jl

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/JuliaInterpreter.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,20 @@ module CompiledCalls
2020
# This module is for handling intrinsics that must be compiled (llvmcall)
2121
end
2222

23+
const BUILTIN_FILE = joinpath(@__DIR__, "builtins-julia$(Int(VERSION.major)).$(Int(VERSION.minor)).jl")
24+
25+
@info "Generating builtins for this julia version..."
26+
gen_builtins_file = joinpath(@__DIR__, "generate_builtins.jl")
27+
# Run as separate command to prevent including the generate_builtins into the precompile cache
28+
run(`$(Base.julia_cmd()) --startup-file=no $gen_builtins_file`)
29+
include_dependency(gen_builtins_file)
30+
2331
include("types.jl")
2432
include("utils.jl")
2533
include("construct.jl")
2634
include("localmethtable.jl")
2735
include("interpret.jl")
28-
include("builtins-julia$(Int(VERSION.major)).$(Int(VERSION.minor)).jl")
36+
include(BUILTIN_FILE)
2937
include("optimize.jl")
3038
include("commands.jl")
3139
include("breakpoints.jl")

src/generate_builtins.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# This file generates builtins.jl.
2+
using InteractiveUtils
23

34
function scopedname(f)
45
io = IOBuffer()
@@ -66,6 +67,11 @@ end
6667

6768
# `io` is for the generated source file
6869
# `intrinsicsfile` is the path to Julia's `src/intrinsics.h` file
70+
function generate_builtins(file::String)
71+
open(file, "w") do io
72+
generate_builtins(io::IO)
73+
end
74+
end
6975
function generate_builtins(io::IO)
7076
pat = r"(ADD_I|ALIAS)\((\w*),"
7177
print(io,
@@ -209,3 +215,5 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
209215
end
210216
""")
211217
end
218+
219+
generate_builtins(joinpath(@__DIR__, "builtins-julia$(Int(VERSION.major)).$(Int(VERSION.minor)).jl"))

0 commit comments

Comments
 (0)