diff --git a/bin/generate_builtins.jl b/bin/generate_builtins.jl index b1792abfc4d4a9..bc6da0d7efa32f 100644 --- a/bin/generate_builtins.jl +++ b/bin/generate_builtins.jl @@ -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) @@ -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")) diff --git a/src/builtins.jl b/src/builtins.jl index d9f4637383f382..90fb6ad92c537f 100644 --- a/src/builtins.jl +++ b/src/builtins.jl @@ -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 @@ -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 @@ -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 diff --git a/test/check_builtins.jl b/test/check_builtins.jl index 7c51d323fe533c..ab1b2c0245db22 100644 --- a/test/check_builtins.jl +++ b/test/check_builtins.jl @@ -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))