Skip to content

Commit 145bf9f

Browse files
committed
Squashed 'packages/JuliaInterpreter/' changes from 0b17ba7..e432c0c
e432c0c version 0.10.6 95fc29f minor code cleanup 16b44cd make dynamic-ccall detection more correct (#700) 5a2af25 Add Core.declare_const and Core.declare_global (#699) da88837 Bump actions/checkout from 4 to 5 (#698) 4120381 version 0.10.5 518a90c `evaluate_methoddef`: add `@invokelatest` to avoid world age error (#697) b429971 Version 0.10.4 (#693) 1c5e32d Change `==` test for `deepcopy(::QuoteNode)` (#694) 3b14198 check_builtins only via the action on CI (#695) e66fa6d Update compat bound for CodeTracking 2.0.0 (#692) 8802ba7 avoid going into subtyping for checking if a function is a `Core.Builtin` (#691) 870e01a minor updates (#690) d1a674e avoid `args` getting boxed in `maybe_evaluate_builtin` (#689) 1570acd minor `ExprSplitter` optimization f9bdad5 some minor cleanups git-subtree-dir: packages/JuliaInterpreter git-subtree-split: e432c0cf76fa29edd767285e179c488563f9b86a
1 parent e99ea2e commit 145bf9f

File tree

16 files changed

+117
-83
lines changed

16 files changed

+117
-83
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
env:
4242
PYTHON: ""
4343
steps:
44-
- uses: actions/checkout@v4
44+
- uses: actions/checkout@v5
4545
- uses: julia-actions/setup-julia@v2
4646
with:
4747
version: ${{ matrix.version }}

.github/workflows/Documenter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
with:
1616
version: 'lts'
1717
show-versioninfo: true # print versioninfo in the action log
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
1919
- uses: julia-actions/julia-buildpkg@latest
2020
- uses: julia-actions/julia-docdeploy@latest
2121
env:

.github/workflows/check_builtins.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: 'Check builtins.jl consistency'
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v5
1414
- uses: julia-actions/setup-julia@v2
1515
with:
1616
version: nightly

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "JuliaInterpreter"
22
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
3-
version = "0.10.3"
3+
version = "0.10.6"
44
authors = ["Tim Holy <[email protected]>, Kristoffer Carlsson <[email protected]>, Shuhei Kadowaki <[email protected]> and contributors"]
55

66
[deps]
@@ -10,7 +10,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1010
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1111

1212
[compat]
13-
CodeTracking = "1.3.9"
13+
CodeTracking = "2"
1414
julia = "1.10"
1515

1616
[extras]

bin/generate_builtins.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ using InteractiveUtils
55
# Builtins not present in 1.10 (the lowest supported version)
66
const RECENTLY_ADDED = Core.Builtin[
77
Core.current_scope,
8+
Core.declare_const,
9+
Core.declare_global,
810
isdefinedglobal,
911
Core.memorynew,
1012
Core.memoryref_isassigned,
@@ -155,7 +157,7 @@ const kwinvoke = Core.kwfunc(Core.invoke)
155157
156158
function maybe_recurse_expanded_builtin(interp::Interpreter, frame::Frame, new_expr::Expr)
157159
f = new_expr.args[1]
158-
if isa(f, Core.Builtin) || isa(f, Core.IntrinsicFunction)
160+
if supertype(typeof(f)) === Core.Builtin || isa(f, Core.IntrinsicFunction)
159161
return maybe_evaluate_builtin(interp, frame, new_expr, true)
160162
else
161163
return new_expr
@@ -190,7 +192,7 @@ function maybe_evaluate_builtin(interp::Interpreter, frame::Frame, call_expr::Ex
190192
end
191193
return Some{Any}(f(args...))
192194
end
193-
if !(isa(f, Core.Builtin) || isa(f, Core.IntrinsicFunction))
195+
if !(supertype(typeof(f)) === Core.Builtin || isa(f, Core.IntrinsicFunction))
194196
return call_expr
195197
end
196198
# By having each call appearing statically in the "switch" block below,
@@ -210,7 +212,9 @@ function maybe_evaluate_builtin(interp::Interpreter, frame::Frame, call_expr::Ex
210212
print(io,
211213
"""
212214
$head f === tuple
213-
return Some{Any}(ntupleany(i::Int->lookup(interp, frame, args[i+1]), length(args)-1))
215+
let args=args
216+
return Some{Any}(ntupleany(i::Int->lookup(interp, frame, args[i+1]), length(args)-1))
217+
end
214218
""")
215219
continue
216220
elseif f === Core._apply_iterate

docs/Manifest.toml

Lines changed: 27 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
55
JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
66
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
77
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
8+
9+
[compat]
10+
CodeTracking = "2"
11+
Documenter = "1"

src/builtins.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const kwinvoke = Core.kwfunc(Core.invoke)
1313

1414
function maybe_recurse_expanded_builtin(interp::Interpreter, frame::Frame, new_expr::Expr)
1515
f = new_expr.args[1]
16-
if isa(f, Core.Builtin) || isa(f, Core.IntrinsicFunction)
16+
if supertype(typeof(f)) === Core.Builtin || isa(f, Core.IntrinsicFunction)
1717
return maybe_evaluate_builtin(interp, frame, new_expr, true)
1818
else
1919
return new_expr
@@ -48,7 +48,7 @@ function maybe_evaluate_builtin(interp::Interpreter, frame::Frame, call_expr::Ex
4848
end
4949
return Some{Any}(f(args...))
5050
end
51-
if !(isa(f, Core.Builtin) || isa(f, Core.IntrinsicFunction))
51+
if !(supertype(typeof(f)) === Core.Builtin || isa(f, Core.IntrinsicFunction))
5252
return call_expr
5353
end
5454
# By having each call appearing statically in the "switch" block below,
@@ -134,6 +134,10 @@ function maybe_evaluate_builtin(interp::Interpreter, frame::Frame, call_expr::Ex
134134
else
135135
return Some{Any}(Core.current_scope(getargs(interp, args, frame)...))
136136
end
137+
elseif @static isdefinedglobal(Core, :declare_const) && f === Core.declare_const
138+
return Some{Any}(Core.declare_const(getargs(interp, args, frame)...))
139+
elseif @static isdefinedglobal(Core, :declare_global) && f === Core.declare_global
140+
return Some{Any}(Core.declare_global(getargs(interp, args, frame)...))
137141
elseif f === Core.donotdelete
138142
return Some{Any}(Core.donotdelete(getargs(interp, args, frame)...))
139143
elseif f === Core.finalizer
@@ -403,7 +407,9 @@ function maybe_evaluate_builtin(interp::Interpreter, frame::Frame, call_expr::Ex
403407
return Some{Any}(throw(getargs(interp, args, frame)...))
404408
end
405409
elseif f === tuple
406-
return Some{Any}(ntupleany(i::Int->lookup(interp, frame, args[i+1]), length(args)-1))
410+
let args=args
411+
return Some{Any}(ntupleany(i::Int->lookup(interp, frame, args[i+1]), length(args)-1))
412+
end
407413
elseif f === typeassert
408414
if nargs == 2
409415
return Some{Any}(typeassert(lookup(interp, frame, args[2]), lookup(interp, frame, args[3])))

src/construct.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ See [`Frame(mod::Module, ex::Expr)`](@ref) for more information about frame crea
438438
"""
439439
mutable struct ExprSplitter
440440
# Non-mutating fields
441-
stack::Vector{Tuple{Module,Expr}} # mod[i] is module of evaluation for
442-
index::Vector{Int} # next-to-handle argument index for :block or :toplevel exprs
441+
const stack::Vector{Tuple{Module,Expr}} # mod[i] is module of evaluation for
442+
const index::Vector{Int} # next-to-handle argument index for :block or :toplevel exprs
443443
# Mutating fields
444444
lnn::Union{LineNumberNode,Nothing}
445445
end
@@ -487,8 +487,8 @@ function queuenext!(iter::ExprSplitter)
487487
if head === :module
488488
# Find or create the module
489489
newname = ex.args[2]::Symbol
490-
if invokelatest(isdefined, mod, newname)
491-
newmod = invokelatest(getfield, mod, newname)
490+
if invokelatest(isdefinedglobal, mod, newname)
491+
newmod = invokelatest(getglobal, mod, newname)
492492
newmod isa Module || throw(ErrorException("invalid redefinition of constant $(newname)"))
493493
mod = newmod
494494
else
@@ -508,7 +508,7 @@ function queuenext!(iter::ExprSplitter)
508508
mod = Base.root_module(id)::Module
509509
else
510510
loc = firstline(ex)
511-
mod = Core.eval(mod, Expr(:module, ex.args[1], ex.args[2], Expr(:block, loc, loc)))::Module
511+
mod = Core.eval(mod, Expr(:module, ex.args[1], newname, Expr(:block, loc)))::Module
512512
end
513513
end
514514
# We've handled the module declaration, remove it and queue the body

src/interpret.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ function eval_rhs(interp::Interpreter, frame::Frame, node::Expr)
409409
head === :aliasscope || head === :popaliasscope
410410
return nothing
411411
elseif head === :method && length(node.args) == 1
412-
return evaluate_methoddef(interp, frame, node)
412+
return @invokelatest evaluate_methoddef(interp, frame, node)
413413
end
414414
return lookup_expr(interp, frame, node)
415415
end
@@ -514,7 +514,7 @@ function step_expr!(interp::Interpreter, frame::Frame, @nospecialize(node), isto
514514
# (https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/591)
515515
elseif istoplevel
516516
if node.head === :method && length(node.args) > 1
517-
rhs = evaluate_methoddef(interp, frame, node)
517+
rhs = @invokelatest evaluate_methoddef(interp, frame, node)
518518
elseif node.head === :module
519519
error("this should have been handled by split_expressions")
520520
elseif node.head === :using || node.head === :import || node.head === :export

0 commit comments

Comments
 (0)