Skip to content

refactors interpreter_exec.jl further #53246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions test/compiler/interpreter_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ let m = Meta.@lower 1 + 1
src.ssavaluetypes = nstmts
src.ssaflags = fill(UInt8(0x00), nstmts)
src.codelocs = fill(Int32(1), nstmts)
@assert !src.inferred
@test !src.inferred
Core.Compiler.verify_ir(Core.Compiler.inflate_ir(src))
global test29262 = true
@test :a === @eval $m
compile_mode = @ccall jl_get_module_compile(@__MODULE__()::Module)::Cint
if compile_mode == 3
# implies `Base.Experimental.@compiler_options compile=min`
@test !src.inferred
end
global test29262 = false
@test :b === @eval $m
end
Expand Down Expand Up @@ -64,9 +69,15 @@ let m = Meta.@lower 1 + 1
src.ssavaluetypes = nstmts
src.ssaflags = fill(UInt8(0x00), nstmts)
src.codelocs = fill(Int32(1), nstmts)
@test !src.inferred
Core.Compiler.verify_ir(Core.Compiler.inflate_ir(src))
global test29262 = true
@test (:b, :a, :c, :c) === @eval $m
compile_mode = @ccall jl_get_module_compile(@__MODULE__()::Module)::Cint
if compile_mode == 3
# implies `Base.Experimental.@compiler_options compile=min`
@test !src.inferred
end
src.ssavaluetypes = nstmts
global test29262 = false
@test (:b, :a, :c, :b) === @eval $m
Expand Down Expand Up @@ -101,23 +112,15 @@ let m = Meta.@lower 1 + 1
src.ssavaluetypes = nstmts
src.ssaflags = fill(UInt8(0x00), nstmts)
src.codelocs = fill(Int32(1), nstmts)
@test !src.inferred
Core.Compiler.verify_ir(Core.Compiler.inflate_ir(src))
global test29262 = true
@test :a === @eval $m
compile_mode = @ccall jl_get_module_compile(@__MODULE__()::Module)::Cint
if compile_mode == 3
# implies `Base.Experimental.@compiler_options compile=min`
@test !src.inferred
end
global test29262 = false
@test :b === @eval $m
end

# https://github.com/JuliaLang/julia/issues/47065
# `Core.Compiler.sort!` should be able to handle a big list
let n = 1000
ex = :(return 1)
for _ in 1:n
ex = :(rand() < .1 && $(ex))
end
@eval global function f_1000_blocks()
$ex
return 0
end
end
@test f_1000_blocks() == 0
14 changes: 14 additions & 0 deletions test/compiler/irpasses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1787,3 +1787,17 @@ let code = Any[
@test !any(iscall((ir, getfield)), ir.stmts.stmt)
@test length(ir.cfg.blocks[end].stmts) == 1
end

# https://github.com/JuliaLang/julia/issues/47065
# `Core.Compiler.sort!` should be able to handle a big list
let n = 1000
ex = :(return 1)
for _ in 1:n
ex = :(rand() < .1 && $(ex))
end
@eval global function f_1000_blocks()
$ex
return 0
end
end
@test f_1000_blocks() == 0
14 changes: 9 additions & 5 deletions test/compiler/ssair.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ let cfg = CFG(BasicBlock[
end
end

for compile in ("min", "yes")
cmd = `$(Base.julia_cmd()) --compile=$compile interpreter_exec.jl`
if !success(pipeline(Cmd(cmd, dir=@__DIR__); stdout=stdout, stderr=stderr))
error("Interpreter test failed, cmd : $cmd")
end
# test code execution with the default compile-mode
module CompilerExecTest
include("interpreter_exec.jl")
end

# test code execution with the interpreter mode (compile=min)
module InterpreterExecTest
Base.Experimental.@compiler_options compile=min
include("interpreter_exec.jl")
end

# PR #32145
Expand Down