Skip to content

Commit c4dfacf

Browse files
committed
refactors interpreter_exec.jl further
This commit refines `interpreter_exec.jl` further, on top of #53218. In detail, by using `Base.Experimental.@compiler_options compile=min`, it's now possible to mimic the effect of `julia --compile=[min|yes]`. This commit is leveraging it and includes `interpreter_exec.jl` from `test/compiler/ssair.jl`, allowing us to get better stack traces and test summaries. In addition, I've introduced several tests concerning the `src.inferred` values and have relocated the tests from #47066 within `interpreter_exec.jl` to `test/compiler/irpasses.jl`, since it is related to Julia-level compilation and not to interpreter execution.
1 parent dfdb1d7 commit c4dfacf

File tree

3 files changed

+41
-19
lines changed

3 files changed

+41
-19
lines changed

test/compiler/interpreter_exec.jl

+18-14
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ let m = Meta.@lower 1 + 1
2323
src.ssavaluetypes = nstmts
2424
src.ssaflags = fill(UInt8(0x00), nstmts)
2525
src.codelocs = fill(Int32(1), nstmts)
26+
@test !src.inferred
2627
Core.Compiler.verify_ir(Core.Compiler.inflate_ir(src))
2728
global test29262 = true
2829
@test :a === @eval $m
30+
compile_mode = @ccall jl_get_module_compile(@__MODULE__()::Module)::Cint
31+
if compile_mode == 3
32+
# implies `Base.Experimental.@compiler_options compile=min`
33+
@test !src.inferred
34+
end
2935
global test29262 = false
3036
@test :b === @eval $m
3137
end
@@ -63,9 +69,15 @@ let m = Meta.@lower 1 + 1
6369
src.ssavaluetypes = nstmts
6470
src.ssaflags = fill(UInt8(0x00), nstmts)
6571
src.codelocs = fill(Int32(1), nstmts)
72+
@test !src.inferred
6673
Core.Compiler.verify_ir(Core.Compiler.inflate_ir(src))
6774
global test29262 = true
6875
@test (:b, :a, :c, :c) === @eval $m
76+
compile_mode = @ccall jl_get_module_compile(@__MODULE__()::Module)::Cint
77+
if compile_mode == 3
78+
# implies `Base.Experimental.@compiler_options compile=min`
79+
@test !src.inferred
80+
end
6981
src.ssavaluetypes = nstmts
7082
global test29262 = false
7183
@test (:b, :a, :c, :b) === @eval $m
@@ -100,23 +112,15 @@ let m = Meta.@lower 1 + 1
100112
src.ssavaluetypes = nstmts
101113
src.ssaflags = fill(UInt8(0x00), nstmts)
102114
src.codelocs = fill(Int32(1), nstmts)
115+
@test !src.inferred
103116
Core.Compiler.verify_ir(Core.Compiler.inflate_ir(src))
104117
global test29262 = true
105118
@test :a === @eval $m
119+
compile_mode = @ccall jl_get_module_compile(@__MODULE__()::Module)::Cint
120+
if compile_mode == 3
121+
# implies `Base.Experimental.@compiler_options compile=min`
122+
@test !src.inferred
123+
end
106124
global test29262 = false
107125
@test :b === @eval $m
108126
end
109-
110-
# https://github.com/JuliaLang/julia/issues/47065
111-
# `Core.Compiler.sort!` should be able to handle a big list
112-
let n = 1000
113-
ex = :(return 1)
114-
for _ in 1:n
115-
ex = :(rand() < .1 && $(ex))
116-
end
117-
@eval global function f_1000_blocks()
118-
$ex
119-
return 0
120-
end
121-
end
122-
@test f_1000_blocks() == 0

test/compiler/irpasses.jl

+14
Original file line numberDiff line numberDiff line change
@@ -1787,3 +1787,17 @@ let code = Any[
17871787
@test !any(iscall((ir, getfield)), ir.stmts.stmt)
17881788
@test length(ir.cfg.blocks[end].stmts) == 1
17891789
end
1790+
1791+
# https://github.com/JuliaLang/julia/issues/47065
1792+
# `Core.Compiler.sort!` should be able to handle a big list
1793+
let n = 1000
1794+
ex = :(return 1)
1795+
for _ in 1:n
1796+
ex = :(rand() < .1 && $(ex))
1797+
end
1798+
@eval global function f_1000_blocks()
1799+
$ex
1800+
return 0
1801+
end
1802+
end
1803+
@test f_1000_blocks() == 0

test/compiler/ssair.jl

+9-5
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ let
9999
# XXX: missing @test
100100
end
101101

102-
for compile in ("min", "yes")
103-
cmd = `$(Base.julia_cmd()) --compile=$compile interpreter_exec.jl`
104-
if !success(pipeline(Cmd(cmd, dir=@__DIR__); stdout=stdout, stderr=stderr))
105-
error("Interpreter test failed, cmd : $cmd")
106-
end
102+
# test code execution with the default compile-mode
103+
module CompilerExecTest
104+
include("interpreter_exec.jl")
105+
end
106+
107+
# test code execution with the interpreter mode (compile=min)
108+
module InterpreterExecTest
109+
Base.Experimental.@compiler_options compile=min
110+
include("interpreter_exec.jl")
107111
end
108112

109113
# PR #32145

0 commit comments

Comments
 (0)