From 0aee462646f3b2307c5a90955e7aab79882fc8ce Mon Sep 17 00:00:00 2001 From: jake bolewski Date: Fri, 2 Jan 2015 15:04:24 -0500 Subject: [PATCH] move JLCompilerOpts type to own file, rename compileropts to JLCompilerOpts --- base/client.jl | 1 - base/compileropts.jl | 19 +++++++++++++++++++ base/deprecated.jl | 2 +- base/inference.jl | 22 +--------------------- base/sysimg.jl | 1 + base/util.jl | 2 +- test/cmdlineargs.jl | 28 ++++++++++++++-------------- 7 files changed, 37 insertions(+), 38 deletions(-) create mode 100644 base/compileropts.jl diff --git a/base/client.jl b/base/client.jl index 30601a5117108..27400c3fbb01d 100644 --- a/base/client.jl +++ b/base/client.jl @@ -1,6 +1,5 @@ ## client.jl - frontend handling command line options, environment setup, ## and REPL - immutable JLOptions version::Int8 quiet::Int8 diff --git a/base/compileropts.jl b/base/compileropts.jl new file mode 100644 index 0000000000000..be7fab7b9a7f2 --- /dev/null +++ b/base/compileropts.jl @@ -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)) diff --git a/base/deprecated.jl b/base/deprecated.jl index 1904a0d267bf3..51309d2ee7ee0 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -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) diff --git a/base/inference.jl b/base/inference.jl index a7b75de64670f..5d8fed8f55ff7 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -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) @@ -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]) diff --git a/base/sysimg.jl b/base/sysimg.jl index 868885f62d075..272f43ba2a032 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -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") diff --git a/base/util.jl b/base/util.jl index af7ac1495332e..b2c0fa4c86e34 100644 --- a/base/util.jl +++ b/base/util.jl @@ -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` diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 8b6ccc3a12f3c..6a44ee50c1bbb 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -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"