Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bin/generate_builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const RECENTLY_ADDED = Core.Builtin[
Core.get_binding_type, Core.set_binding_type!,
Core.getglobal, Core.setglobal!,
Core.modifyfield!, Core.replacefield!, Core.swapfield!,
Core.finalizer
Core.finalizer, Core._compute_sparams, Core._svec_ref,
Core.compilerbarrier
]
const kwinvoke = Core.kwfunc(Core.invoke)

Expand Down Expand Up @@ -316,4 +317,5 @@ end
""")
end

generate_builtins(joinpath(@__DIR__, "..", "src", "builtins.jl"))
builtins_dir = get(ENV, "JULIAINTERPRETER_BUILTINS_DIR", joinpath(@__DIR__, "..", "src"))
generate_builtins(joinpath(builtins_dir, "builtins.jl"))
10 changes: 10 additions & 0 deletions src/builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return maybe_recurse_expanded_builtin(frame, new_expr)
elseif f === Core._call_latest
return Some{Any}(Core._call_latest(getargs(args, frame)...))
elseif @static isdefined(Core, :_compute_sparams) && f === Core._compute_sparams
return Some{Any}(Core._compute_sparams(getargs(args, frame)...))
elseif f === Core._equiv_typedef
return Some{Any}(Core._equiv_typedef(getargs(args, frame)...))
elseif f === Core._expr
Expand All @@ -106,6 +108,8 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return Some{Any}(Core._setsuper!(getargs(args, frame)...))
elseif f === Core._structtype
return Some{Any}(Core._structtype(getargs(args, frame)...))
elseif @static isdefined(Core, :_svec_ref) && f === Core._svec_ref
return Some{Any}(Core._svec_ref(getargs(args, frame)...))
elseif f === Core._typebody!
return Some{Any}(Core._typebody!(getargs(args, frame)...))
elseif f === Core._typevar
Expand Down Expand Up @@ -142,6 +146,12 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
else
return Some{Any}(Core.arraysize(getargs(args, frame)...))
end
elseif @static isdefined(Core, :compilerbarrier) && f === Core.compilerbarrier
if nargs == 2
return Some{Any}(Core.compilerbarrier(@lookup(frame, args[2]), @lookup(frame, args[3])))
else
return Some{Any}(Core.compilerbarrier(getargs(args, frame)...))
end
elseif f === Core.const_arrayref
return Some{Any}(Core.const_arrayref(getargs(args, frame)...))
elseif @static isdefined(Core, :donotdelete) && f === Core.donotdelete
Expand Down
7 changes: 5 additions & 2 deletions test/check_builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ using Test, DeepDiffs
@testset "Check builtin.jl consistency" begin
builtins_path = joinpath(@__DIR__, "..", "src", "builtins.jl")
old_builtins = read(builtins_path, String)
include("../bin/generate_builtins.jl")
new_builtins = read(builtins_path, String)
new_builtins_dir = mktempdir()
withenv("JULIAINTERPRETER_BUILTINS_DIR" => new_builtins_dir) do
include("../bin/generate_builtins.jl")
end
new_builtins = read(joinpath(new_builtins_dir, "builtins.jl"), String)
consistent = old_builtins == new_builtins
if !consistent
println(deepdiff(old_builtins, new_builtins))
Expand Down