Skip to content

Commit 872aae0

Browse files
Make generate_builtins path customizable for testing. Update builtins (#559)
1 parent b48b839 commit 872aae0

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

bin/generate_builtins.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const RECENTLY_ADDED = Core.Builtin[
88
Core.get_binding_type, Core.set_binding_type!,
99
Core.getglobal, Core.setglobal!,
1010
Core.modifyfield!, Core.replacefield!, Core.swapfield!,
11-
Core.finalizer
11+
Core.finalizer, Core._compute_sparams, Core._svec_ref,
12+
Core.compilerbarrier
1213
]
1314
const kwinvoke = Core.kwfunc(Core.invoke)
1415

@@ -316,4 +317,5 @@ end
316317
""")
317318
end
318319

319-
generate_builtins(joinpath(@__DIR__, "..", "src", "builtins.jl"))
320+
builtins_dir = get(ENV, "JULIAINTERPRETER_BUILTINS_DIR", joinpath(@__DIR__, "..", "src"))
321+
generate_builtins(joinpath(builtins_dir, "builtins.jl"))

src/builtins.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
9696
return maybe_recurse_expanded_builtin(frame, new_expr)
9797
elseif f === Core._call_latest
9898
return Some{Any}(Core._call_latest(getargs(args, frame)...))
99+
elseif @static isdefined(Core, :_compute_sparams) && f === Core._compute_sparams
100+
return Some{Any}(Core._compute_sparams(getargs(args, frame)...))
99101
elseif f === Core._equiv_typedef
100102
return Some{Any}(Core._equiv_typedef(getargs(args, frame)...))
101103
elseif f === Core._expr
@@ -106,6 +108,8 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
106108
return Some{Any}(Core._setsuper!(getargs(args, frame)...))
107109
elseif f === Core._structtype
108110
return Some{Any}(Core._structtype(getargs(args, frame)...))
111+
elseif @static isdefined(Core, :_svec_ref) && f === Core._svec_ref
112+
return Some{Any}(Core._svec_ref(getargs(args, frame)...))
109113
elseif f === Core._typebody!
110114
return Some{Any}(Core._typebody!(getargs(args, frame)...))
111115
elseif f === Core._typevar
@@ -142,6 +146,12 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
142146
else
143147
return Some{Any}(Core.arraysize(getargs(args, frame)...))
144148
end
149+
elseif @static isdefined(Core, :compilerbarrier) && f === Core.compilerbarrier
150+
if nargs == 2
151+
return Some{Any}(Core.compilerbarrier(@lookup(frame, args[2]), @lookup(frame, args[3])))
152+
else
153+
return Some{Any}(Core.compilerbarrier(getargs(args, frame)...))
154+
end
145155
elseif f === Core.const_arrayref
146156
return Some{Any}(Core.const_arrayref(getargs(args, frame)...))
147157
elseif @static isdefined(Core, :donotdelete) && f === Core.donotdelete

test/check_builtins.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ using Test, DeepDiffs
55
@testset "Check builtin.jl consistency" begin
66
builtins_path = joinpath(@__DIR__, "..", "src", "builtins.jl")
77
old_builtins = read(builtins_path, String)
8-
include("../bin/generate_builtins.jl")
9-
new_builtins = read(builtins_path, String)
8+
new_builtins_dir = mktempdir()
9+
withenv("JULIAINTERPRETER_BUILTINS_DIR" => new_builtins_dir) do
10+
include("../bin/generate_builtins.jl")
11+
end
12+
new_builtins = read(joinpath(new_builtins_dir, "builtins.jl"), String)
1013
consistent = old_builtins == new_builtins
1114
if !consistent
1215
println(deepdiff(old_builtins, new_builtins))

0 commit comments

Comments
 (0)