Skip to content

Commit

Permalink
move JLCompilerOpts type to own file, rename compileropts to JLCompil…
Browse files Browse the repository at this point in the history
…erOpts
  • Loading branch information
jakebolewski committed Jan 2, 2015
1 parent 5d1c326 commit 0aee462
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 38 deletions.
1 change: 0 additions & 1 deletion base/client.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
## client.jl - frontend handling command line options, environment setup,
## and REPL

immutable JLOptions
version::Int8
quiet::Int8
Expand Down
19 changes: 19 additions & 0 deletions base/compileropts.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Julia compiler options struct (see jl_compileropts_t in src/julia.h)
immutable JLCompilerOpts
julia_home::Ptr{Cchar}
julia_bin::Ptr{Cchar}
build_path::Ptr{Cchar}
image_file::Ptr{Cchar}
cpu_target::Ptr{Cchar}
code_coverage::Int8
malloc_log::Int8
check_bounds::Int8
dumpbitcode::Int8
int_literals::Cint
compile_enabled::Int8
opt_level::Int8
depwarn::Int8
can_inline::Int8
end

JLCompilerOpts() = unsafe_load(cglobal(:jl_compileropts, JLCompilerOpts))
2 changes: 1 addition & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ macro deprecate(old,new)
end

function depwarn(msg, funcsym)
if bool(compileropts().depwarn)
if bool(JLCompilerOpts().depwarn)
bt = backtrace()
caller = firstcaller(bt, funcsym)
warn(msg, once=(caller!=C_NULL), key=caller, bt=bt)
Expand Down
22 changes: 1 addition & 21 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,6 @@ end

inference_stack = EmptyCallStack()

# Julia compiler options struct (see jl_compileropts_t in src/julia.h)
immutable JLCompilerOpts
julia_home::Ptr{Cchar}
julia_bin::Ptr{Cchar}
build_path::Ptr{Cchar}
image_file::Ptr{Cchar}
cpu_target::Ptr{Cchar}
code_coverage::Int8
malloc_log::Int8
check_bounds::Int8
dumpbitcode::Int8
int_literals::Cint
compile_enabled::Int8
opt_level::Int8
depwarn::Int8
can_inline::Int8
end

compileropts() = unsafe_load(cglobal(:jl_compileropts, JLCompilerOpts))

function is_static_parameter(sv::StaticVarInfo, s::Symbol)
sp = sv.sp
for i=1:2:length(sp)
Expand Down Expand Up @@ -1593,7 +1573,7 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)

if !rec
@assert fulltree.args[3].head === :body
if compileropts().can_inline == 1
if JLCompilerOpts().can_inline == 1
fulltree.args[3] = inlining_pass(fulltree.args[3], sv, fulltree)[1]
# inlining can add variables
sv.vars = append_any(f_argnames(fulltree), fulltree.args[2][1])
Expand Down
1 change: 1 addition & 0 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ include("reflection.jl")
include("build_h.jl")
include("version_git.jl")
include("c.jl")
include("compileropts.jl")

# core operations & types
include("promotion.jl")
Expand Down
2 changes: 1 addition & 1 deletion base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ warn(err::Exception; prefix="ERROR: ", kw...) =
warn(sprint(io->showerror(io,err)), prefix=prefix; kw...)

function julia_cmd(julia=joinpath(JULIA_HOME, "julia"))
opts = compileropts()
opts = JLCompilerOpts()
cpu_target = bytestring(opts.cpu_target)
image_file = bytestring(opts.image_file)
`$julia -C$cpu_target -J$image_file`
Expand Down
28 changes: 14 additions & 14 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,29 @@ end
# readchomp(`$exename --int-literals=64 -E "sizeof(Int)"`)

# --code-coverage
@test readchomp(`$exename -E "bool(Base.compileropts().code_coverage)"`) == "false"
@test readchomp(`$exename -E "bool(Base.compileropts().code_coverage)" --code-coverage=none`) == "false"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().code_coverage)"`) == "false"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().code_coverage)" --code-coverage=none`) == "false"

@test readchomp(`$exename -E "bool(Base.compileropts().code_coverage)" --code-coverage`) == "true"
@test readchomp(`$exename -E "bool(Base.compileropts().code_coverage)" --code-coverage=user`) == "true"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().code_coverage)" --code-coverage`) == "true"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().code_coverage)" --code-coverage=user`) == "true"

# --track-allocation
@test readchomp(`$exename -E "bool(Base.compileropts().malloc_log)"`) == "false"
@test readchomp(`$exename -E "bool(Base.compileropts().malloc_log)" --track-allocation=none`) == "false"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().malloc_log)"`) == "false"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().malloc_log)" --track-allocation=none`) == "false"

@test readchomp(`$exename -E "bool(Base.compileropts().malloc_log)" --track-allocation`) == "true"
@test readchomp(`$exename -E "bool(Base.compileropts().malloc_log)" --track-allocation=user`) == "true"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().malloc_log)" --track-allocation`) == "true"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().malloc_log)" --track-allocation=user`) == "true"

# --check-bounds
@test int(readchomp(`$exename -E "int(Base.compileropts().check_bounds)"`)) == 0
@test int(readchomp(`$exename -E "int(Base.compileropts().check_bounds)" --check-bounds=yes`)) == 1
@test int(readchomp(`$exename -E "int(Base.compileropts().check_bounds)" --check-bounds=no`)) == 2
@test int(readchomp(`$exename -E "int(Base.JLCompilerOpts().check_bounds)"`)) == 0
@test int(readchomp(`$exename -E "int(Base.JLCompilerOpts().check_bounds)" --check-bounds=yes`)) == 1
@test int(readchomp(`$exename -E "int(Base.JLCompilerOpts().check_bounds)" --check-bounds=no`)) == 2
@test !success(`$exename -E "exit(0)" --check-bounds=false`)

# --optimize
@test readchomp(`$exename -E "bool(Base.compileropts().opt_level)"`) == "false"
@test readchomp(`$exename -E "bool(Base.compileropts().opt_level)" -O`) == "true"
@test readchomp(`$exename -E "bool(Base.compileropts().opt_level)" --optimize`) == "true"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().opt_level)"`) == "false"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().opt_level)" -O`) == "true"
@test readchomp(`$exename -E "bool(Base.JLCompilerOpts().opt_level)" --optimize`) == "true"

# --depwarn
@test readchomp(`$exename --depwarn=no -E "Base.syntax_deprecation_warnings(true)"`) == "false"
Expand Down

0 comments on commit 0aee462

Please sign in to comment.