Skip to content

Commit 0250222

Browse files
committed
Merge commit '279f82b97865a976a7e13b0bf2b62e0c8c92e45c'
2 parents cab196e + 279f82b commit 0250222

File tree

9 files changed

+42
-61
lines changed

9 files changed

+42
-61
lines changed

packages/JuliaInterpreter/.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@v5
44+
- uses: actions/checkout@v6
4545
- uses: julia-actions/setup-julia@v2
4646
with:
4747
version: ${{ matrix.version }}

packages/JuliaInterpreter/.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@v5
18+
- uses: actions/checkout@v6
1919
- uses: julia-actions/julia-buildpkg@latest
2020
- uses: julia-actions/julia-docdeploy@latest
2121
env:

packages/JuliaInterpreter/.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@v5
13+
- uses: actions/checkout@v6
1414
- uses: julia-actions/setup-julia@v2
1515
with:
1616
version: nightly

packages/JuliaInterpreter/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.7"
3+
version = "0.10.9"
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 = "2"
13+
CodeTracking = "2, 3"
1414
julia = "1.10"
1515

1616
[extras]

packages/JuliaInterpreter/docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
99
[compat]
1010
CodeTracking = "2"
1111
Documenter = "1"
12+
julia = "~1.10"

packages/JuliaInterpreter/docs/src/ast.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ branching into `@goto/@label` equivalents:
8282

8383
This has very close correspondence to the lowered representation:
8484

85-
```julia
85+
```julia-repl
8686
julia> code = @code_lowered debuginfo=:source summer(A)
8787
CodeInfo(
8888
@ REPL[1]:2 within `summer'
@@ -136,9 +136,9 @@ similar to how we named it in our alternative implementation above.)
136136

137137
Let's look at a couple of the fields of the `CodeInfo`. First, the statements themselves:
138138

139-
```julia
139+
```julia-repl
140140
julia> code.code
141-
16-element Array{Any,1}:
141+
16-element Vector{Any}:
142142
:(_3 = Main.zero($(Expr(:static_parameter, 1))))
143143
:(_2)
144144
:(_4 = Base.iterate(%2))
@@ -162,9 +162,9 @@ present in the statement list.
162162
The most noteworthy change here is the appearance of more objects like `_3`, which are
163163
references that index into local variable slots:
164164

165-
```julia
165+
```julia-repl
166166
julia> code.slotnames
167-
5-element Array{Any,1}:
167+
5-element Vector{Any}:
168168
Symbol("#self#")
169169
:A
170170
:s

packages/JuliaInterpreter/docs/src/internals.md

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ evaluate these statements one-by-one, branching via the `goto` statements as app
77
Using the `summer` example described in [Lowered representation](@ref),
88
let's build a frame:
99

10-
```julia
10+
```julia-repl
1111
julia> frame = JuliaInterpreter.enter_call(summer, A)
1212
Frame for summer(A::AbstractArray{T,N} where N) where T in Main at REPL[2]:2
1313
1* 2 1 ─ s = (zero)($(Expr(:static_parameter, 1)))
@@ -26,9 +26,9 @@ in that it has been processed by [`JuliaInterpreter.optimize!`](@ref) to speed u
2626
`frame` has another field, `framedata`, that holds values needed for or generated by execution.
2727
The input arguments and local variables are in `locals`:
2828

29-
```julia
29+
```julia-repl
3030
julia> frame.framedata.locals
31-
5-element Array{Union{Nothing, Some{Any}},1}:
31+
5-element Vector{Union{Nothing, Some{Any}}}:
3232
Some(summer)
3333
Some([1, 2, 5])
3434
nothing
@@ -41,19 +41,19 @@ is the input array. The remaining local variables (e.g., `s` and `a`), have not
4141
only built the frame, but we haven't yet begun to execute it.
4242
The static parameter, `T`, is stored in `frame.framedata.sparams`:
4343

44-
```julia
44+
```julia-repl
4545
julia> frame.framedata.sparams
46-
1-element Array{Any,1}:
46+
1-element Vector{Any}:
4747
Int64
4848
```
4949

5050
The `Expr(:static_parameter, 1)` statement refers to this value.
5151

5252
The other main storage is for the generated SSA values:
5353

54-
```julia
54+
```julia-repl
5555
julia> frame.framedata.ssavalues
56-
16-element Array{Any,1}:
56+
16-element Vector{Any}:
5757
#undef
5858
#undef
5959
#undef
@@ -77,14 +77,14 @@ Since we haven't executed any statements yet, these are all undefined.
7777
The other main entity is the so-called [program counter](https://en.wikipedia.org/wiki/Program_counter),
7878
which just indicates the next statement to be executed:
7979

80-
```julia
80+
```julia-repl
8181
julia> frame.pc
8282
1
8383
```
8484

8585
Let's try executing the first statement:
8686

87-
```julia
87+
```julia-repl
8888
julia> JuliaInterpreter.step_expr!(frame)
8989
2
9090
```
@@ -96,9 +96,9 @@ back to `frame`.)
9696
Since the first statement is an assignment of a local variable, let's check the
9797
locals again:
9898

99-
```julia
99+
```julia-repl
100100
julia> frame.framedata.locals
101-
5-element Array{Union{Nothing, Some{Any}},1}:
101+
5-element Vector{Union{Nothing, Some{Any}}}:
102102
Some(summer)
103103
Some([1, 2, 5])
104104
Some(0)
@@ -111,12 +111,12 @@ You can see that the entry corresponding to `s` has been initialized.
111111
The next statement just retrieves one of the slots (the input argument `A`) and stores
112112
it in an SSA value:
113113

114-
```julia
114+
```julia-repl
115115
julia> JuliaInterpreter.step_expr!(frame)
116116
3
117117
118118
julia> frame.framedata.ssavalues
119-
16-element Array{Any,1}:
119+
16-element Vector{Any}:
120120
#undef
121121
[1, 2, 5]
122122
#undef
@@ -179,45 +179,23 @@ such expressions.
179179

180180
Here's a demonstration of the problem:
181181

182-
```julia
183-
ex = :(map(x->x^2, [1, 2, 3]))
184-
frame = Frame(Main, ex)
182+
```julia-repl
183+
julia> ex = :(map(x->x^2, [1, 2, 3]));
184+
185+
julia> frame = Frame(Main, ex);
186+
185187
julia> JuliaInterpreter.finish_and_return!(frame)
186188
ERROR: this frame needs to be run a top level
187189
```
188190

189191
The reason for this error becomes clearer if we examine `frame` or look directly at the lowered code:
190192

191-
```julia
192-
julia> Meta.lower(Main, ex)
193-
:($(Expr(:thunk, CodeInfo(
194-
@ none within `top-level scope`
195-
1$(Expr(:thunk, CodeInfo(
196-
@ none within `top-level scope`
197-
1global var"#3#4"
198-
const var"#3#4"
199-
%3 = Core._structtype(Main, Symbol("#3#4"), Core.svec(), Core.svec(), Core.svec(), false, 0)
200-
var"#3#4" = %3
201-
│ Core._setsuper!(var"#3#4", Core.Function)
202-
│ Core._typebody!(var"#3#4", Core.svec())
203-
└── return nothing
204-
)))
205-
%2 = Core.svec(var"#3#4", Core.Any)
206-
%3 = Core.svec()
207-
%4 = Core.svec(%2, %3, $(QuoteNode(:(#= REPL[18]:1 =#))))
208-
$(Expr(:method, false, :(%4), CodeInfo(
209-
@ REPL[18]:1 within `none`
210-
1%1 = Core.apply_type(Base.Val, 2)
211-
%2 = (%1)()
212-
%3 = Base.literal_pow(^, x, %2)
213-
└── return %3
214-
)))
215-
#3 = %new(var"#3#4")
216-
%7 = #3
217-
%8 = Base.vect(1, 2, 3)
218-
%9 = map(%7, %8)
219-
└── return %9
220-
))))
193+
```@setup world-age-example
194+
ex = :(map(x->x^2, [1, 2, 3]))
195+
```
196+
197+
```@repl world-age-example
198+
Meta.lower(Main, ex)
221199
```
222200

223201
All of the code before the `%7` line is devoted to defining the anonymous function `x->x^2`:
@@ -226,9 +204,9 @@ function" for this type, equivalent to `(var"#3#4")(x) = x^2`.
226204

227205
In some cases one can fix this simply by indicating that we want to run this frame at top level:
228206

229-
```julia
207+
```julia-repl
230208
julia> JuliaInterpreter.finish_and_return!(frame, true)
231-
3-element Array{Int64,1}:
209+
3-element Vector{Int64}:
232210
1
233211
4
234212
9

packages/JuliaInterpreter/src/construct.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ Optionally supply an initial `LineNumberNode` `lnn`.
362362
363363
In a fresh session,
364364
365-
```
365+
```julia-repl
366366
julia> expr = quote
367367
public_fn(x::Integer) = true
368368
module Private
@@ -412,7 +412,7 @@ For evaluation by JuliaInterpreter, the returned module/expression pairs can be
412412
the `Frame` constructor. However, some expressions cannot be converted into `Frame`s and may need
413413
special handling:
414414
415-
```julia
415+
```julia-repl
416416
julia> for (mod, ex) in ExprSplitter(Main, expr)
417417
if ex.head === :global
418418
# global declarations can't be lowered to a CodeInfo.

packages/JuliaInterpreter/src/optimize.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ function lookup_stmt(stmts::Vector{Any}, @nospecialize arg)
1919
if isa(q, QuoteNode) && (qval = q.value; qval isa Symbol)
2020
mod = lookup_stmt(stmts, arg.args[2])
2121
if isa(mod, GlobalRef)
22-
mod = @invokelatest getglobal(mod.mod, mod.name)
22+
if @invokelatest isdefinedglobal(mod.mod, mod.name)
23+
mod = @invokelatest getglobal(mod.mod, mod.name)
24+
end
2325
end
2426
if isa(mod, Module)
2527
if @invokelatest isdefinedglobal(mod, qval)

0 commit comments

Comments
 (0)