From 88902880d7cddde2873f94138e18e8fea8691417 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 26 Oct 2015 23:31:12 -0400 Subject: [PATCH] --- yaml --- r: 301322 b: refs/heads/anj/transpose c: 5287930780545fba8a05a53970f5ddf49cd1e053 h: refs/heads/master --- [refs] | 2 +- branches/anj/transpose/base/complex.jl | 3 + branches/anj/transpose/base/inference.jl | 8 ++ branches/anj/transpose/base/loading.jl | 40 ++++++---- branches/anj/transpose/base/options.jl | 15 ++++ branches/anj/transpose/base/pkg/entry.jl | 1 + branches/anj/transpose/deps/Makefile | 2 +- branches/anj/transpose/doc/man/julia.1 | 77 ++++++++++++------- .../transpose/doc/manual/getting-started.rst | 1 + branches/anj/transpose/doc/manual/modules.rst | 6 ++ branches/anj/transpose/src/init.c | 1 + branches/anj/transpose/src/julia.h | 4 + branches/anj/transpose/test/cmdlineargs.jl | 6 ++ branches/anj/transpose/test/compile.jl | 47 +++++++++++ branches/anj/transpose/test/complex.jl | 7 ++ branches/anj/transpose/ui/repl.c | 11 +++ 16 files changed, 183 insertions(+), 48 deletions(-) diff --git a/[refs] b/[refs] index ddee6a42b8e7a..f7a3d5709499c 100644 --- a/[refs] +++ b/[refs] @@ -35,7 +35,7 @@ refs/heads/kf/uvint32: eaeee720ed1d4109801549813c7bdbe5d16c75e4 "refs/heads/sjk/return_type": bea6a57566034aaf880b7f380e9e4e7cea9733a3 refs/heads/tan/sparse: 27e4b6914cdc5ef685cb832dd194348164caec10 refs/heads/kf/mmap: 64facb8fd791faf0a5f0768be2e2e2f320e1f2eb -refs/heads/anj/transpose: d61a09ad8ae6c5d3f9f2a9902f638f3eafdae938 +refs/heads/anj/transpose: 5287930780545fba8a05a53970f5ddf49cd1e053 "refs/heads/jn/cond_module": 687ae19896c164292399bb73c19154bf68976ee5 refs/heads/teh/multiprocloading: eabdd0f2c48ad31007266c46fe3aad7f987c6d41 refs/heads/kf/replfixes: 1c345c7d9598b0ae5d4818ecdba1eb25a170bd77 diff --git a/branches/anj/transpose/base/complex.jl b/branches/anj/transpose/base/complex.jl index f1cc868cf468a..b005d728ef87c 100644 --- a/branches/anj/transpose/base/complex.jl +++ b/branches/anj/transpose/base/complex.jl @@ -37,6 +37,9 @@ reim(z) = (real(z), imag(z)) real{T<:Real}(::Type{T}) = T real{T<:Real}(::Type{Complex{T}}) = T +complex{T<:Real}(::Type{T}) = Complex{T} +complex{T<:Real}(::Type{Complex{T}}) = Complex{T} + isreal(x::Real) = true isreal(z::Complex) = imag(z) == 0 isimag(z::Number) = real(z) == 0 diff --git a/branches/anj/transpose/base/inference.jl b/branches/anj/transpose/base/inference.jl index e3161c389c51f..b28f36de6223b 100644 --- a/branches/anj/transpose/base/inference.jl +++ b/branches/anj/transpose/base/inference.jl @@ -2721,6 +2721,14 @@ function inlineable(f::ANY, e::Expr, atype::ANY, sv::StaticVarInfo, enclosing_as expr = lastexpr.args[1] end + if length(stmts) == 1 + # remove line number when inlining a single expression. see issue #13725 + s = stmts[1] + if isa(s,Expr)&&is(s.head,:line) || isa(s,LineNumberNode) + pop!(stmts) + end + end + if isa(expr,Expr) old_t = e.typ if old_t <: expr.typ diff --git a/branches/anj/transpose/base/loading.jl b/branches/anj/transpose/base/loading.jl index f2a90cb224acb..d6d113cd6a794 100644 --- a/branches/anj/transpose/base/loading.jl +++ b/branches/anj/transpose/base/loading.jl @@ -138,6 +138,9 @@ end # returns an array of modules loaded, or nothing if failed function _require_from_serialized(node::Int, mod::Symbol, path_to_try::ByteString, toplevel_load::Bool) + if JLOptions().use_compilecache == 0 + return nothing + end restored = nothing if toplevel_load && myid() == 1 && nprocs() > 1 recompile_stale(mod, path_to_try) @@ -177,6 +180,9 @@ function _require_from_serialized(node::Int, mod::Symbol, path_to_try::ByteStrin end function _require_from_serialized(node::Int, mod::Symbol, toplevel_load::Bool) + if JLOptions().use_compilecache == 0 + return nothing + end if node == myid() paths = find_all_in_cache_path(mod) else @@ -234,8 +240,10 @@ precompilableerror(ex, c) = false # to be prevent it from being precompiled (false). __precompile__(true) is # ignored except within "require" call. function __precompile__(isprecompilable::Bool=true) - if myid() == 1 && isprecompilable != (0 != ccall(:jl_generating_output, Cint, ())) && - !(isprecompilable && toplevel_load::Bool) + if (myid() == 1 && + JLOptions().use_compilecache != 0 && + isprecompilable != (0 != ccall(:jl_generating_output, Cint, ())) && + !(isprecompilable && toplevel_load::Bool)) throw(PrecompilableError(isprecompilable)) end end @@ -246,19 +254,21 @@ function require_modname(name::AbstractString) # While we could also strip off the absolute path, the user may be # deliberately directing to a different file than what got # cached. So this takes a conservative approach. - if endswith(name, ".jl") - tmp = name[1:end-3] - for prefix in LOAD_CACHE_PATH - path = joinpath(prefix, tmp*".ji") - if isfile(path) - return tmp + if Bool(JLOptions().use_compilecache) + if endswith(name, ".jl") + tmp = name[1:end-3] + for prefix in LOAD_CACHE_PATH + path = joinpath(prefix, tmp*".ji") + if isfile(path) + return tmp + end end end end - name + return name end -doc""" +""" reload(name::AbstractString) Force reloading of a package, even if it has been loaded before. This is intended for use @@ -305,7 +315,6 @@ function require(mod::Symbol) end return end - name = string(mod) path = find_in_node_path(name, nothing, 1) if path === nothing @@ -347,9 +356,8 @@ include_string(txt::ByteString, fname::ByteString) = ccall(:jl_load_file_string, Any, (Ptr{UInt8},Csize_t,Ptr{UInt8},Csize_t), txt, sizeof(txt), fname, sizeof(fname)) -include_string(txt::AbstractString, fname::AbstractString) = include_string(bytestring(txt), bytestring(fname)) - -include_string(txt::AbstractString) = include_string(txt, "string") +include_string(txt::AbstractString, fname::AbstractString="string") = + include_string(bytestring(txt), bytestring(fname)) function source_path(default::Union{AbstractString,Void}="") t = current_task() @@ -436,9 +444,7 @@ function create_expr_cache(input::AbstractString, output::AbstractString) serialize(io, :(Base._track_dependencies[1] = true)) serialize(io, :(Base.include($(abspath(input))))) if source !== nothing - serialize(io, quote - delete!(task_local_storage(), :SOURCE_PATH) - end) + serialize(io, :(delete!(task_local_storage(), :SOURCE_PATH))) end close(io) wait(pobj) diff --git a/branches/anj/transpose/base/options.jl b/branches/anj/transpose/base/options.jl index fd4f7c3211b38..f48abdb314210 100644 --- a/branches/anj/transpose/base/options.jl +++ b/branches/anj/transpose/base/options.jl @@ -28,6 +28,7 @@ immutable JLOptions worker::Int8 handle_signals::Int8 use_precompiled::Int8 + use_compilecache::Int8 bindto::Ptr{UInt8} outputbc::Ptr{UInt8} outputo::Ptr{UInt8} @@ -36,3 +37,17 @@ immutable JLOptions end JLOptions() = unsafe_load(cglobal(:jl_options, JLOptions)) + +function show(io::IO, opt::JLOptions) + println(io, "JLOptions(") + fields = fieldnames(opt) + nfields = length(fields) + for (i,f) in enumerate(fieldnames(opt)) + v = getfield(opt,f) + if isa(v, Ptr{UInt8}) + v = v != C_NULL ? bytestring(v) : "" + end + println(io, " ", f, " = ", repr(v), i < nfields ? "," : "") + end + print(io,")") +end diff --git a/branches/anj/transpose/base/pkg/entry.jl b/branches/anj/transpose/base/pkg/entry.jl index 195441d2d3021..037b609341af6 100644 --- a/branches/anj/transpose/base/pkg/entry.jl +++ b/branches/anj/transpose/base/pkg/entry.jl @@ -543,6 +543,7 @@ function build!(pkgs::Vector, errs::Dict, seen::Set=Set()) end """ io, pobj = open(detach(`$(Base.julia_cmd()) + --compilecache=$(Bool(Base.JLOptions().use_compilecache) ? "yes" : "no") --history-file=no --color=$(Base.have_color ? "yes" : "no") --eval $code`), "w", STDOUT) diff --git a/branches/anj/transpose/deps/Makefile b/branches/anj/transpose/deps/Makefile index 5ea57f3c16c71..5d47f760981fe 100644 --- a/branches/anj/transpose/deps/Makefile +++ b/branches/anj/transpose/deps/Makefile @@ -645,7 +645,7 @@ ifeq ($(BUILD_LLDB),1) (cd $(LLVM_SRC_DIR)/tools/lldb && \ git pull --ff-only) ifneq ($(LLVM_GIT_VER_LLDB),) - (cd $(LLVM_SRC_DIR)/tools/LLDB && \ + (cd $(LLVM_SRC_DIR)/tools/lldb && \ git checkout $(LLVM_GIT_VER_LLDB)) endif # LLVM_GIT_VER_CLANG endif # BUILD_LLDB diff --git a/branches/anj/transpose/doc/man/julia.1 b/branches/anj/transpose/doc/man/julia.1 index abca45488014e..65772848c802f 100644 --- a/branches/anj/transpose/doc/man/julia.1 +++ b/branches/anj/transpose/doc/man/julia.1 @@ -54,7 +54,6 @@ If a Julia source file is given as a \fIprogram\fP (optionally followed by .\" This section was taken nearly verbatim from the output of `julia --help` .SH "COMMAND-LINE OPTIONS" -.TP 25 .TP -v, --version @@ -65,13 +64,25 @@ Display version information Print help message .TP --q, --quiet -Quiet startup without banner +-J, --sysimage +Start up with the given system image file + +.TP +-precompiled={yes|no} +Use precompiled code from system image if available .TP -H, --home Set location of julia executable +.TP +--startup-file={yes|no} +Load ~/.juliarc.jl + +.TP +--handle-signals={yes|no} +Enable or disable Julia's default signal handlers + .TP -e, --eval Evaluate @@ -88,14 +99,6 @@ Evaluate , but don't disable interactive mode -L, --load Load immediately on all processors -.TP --J, --sysimage -Start up with the given system image file - -.TP --C, --cpu-target -Limit usage of cpu features up to - .TP -p, --procs Run n local processes @@ -108,6 +111,10 @@ Run processes on hosts listed in -i Force isinteractive() to be true +.TP +-q, --quiet +Quiet startup without banner + .TP --color={yes|no} Enable or disable color text @@ -117,45 +124,57 @@ Enable or disable color text Load or save history .TP ---startup-file={yes|no} -Load ~/.juliarc.jl - -.TP ---compile={yes|no|all} + --compile={yes|no|all} Enable or disable compiler, or request exhaustive compilation .TP ---code-coverage={none|user|all}, --code-coverage -Count executions of source lines (omitting setting is equivalent to 'user') - -.TP ---track-allocation={none|user|all}, --track-allocation -Count bytes allocated by each source line +-C, --cpu-target +Limit usage of cpu features up to .TP -O, --optimize Run time-intensive code optimizations +.TP +--inline={yes|no} +Control whether inlining is permitted (overrides functions declared as @inline) + .TP --check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations) .TP ---dump-bitcode={yes|no} -Dump bitcode for the system image (used with --build) +--math-mode={ieee|user} +Always use IEEE semantics for math (ignoring declarations), +or adhere to declarations in source code .TP --depwarn={yes|no|error} Enable or disable syntax and method deprecation warnings ('error' turns warnings into errors) .TP ---inline={yes|no} -Control whether inlining is permitted (overrides functions declared as @inline) + --output-o name +Generate an object file (including system image data) .TP ---math-mode={ieee|user} -Always use IEEE semantics for math (ignoring declarations), -or adhere to declarations in source code +--output-ji name +Generate a system image data file (.ji) + +.TP +--output-bc name +Generate LLVM bitcode (.bc) + +.TP + --output-incremental=no +Generate an incremental output file (rather than complete) + +.TP +--code-coverage={none|user|all}, --code-coverage +Count executions of source lines (omitting setting is equivalent to 'user') + +.TP +--track-allocation={none|user|all}, --track-allocation +Count bytes allocated by each source line .SH FILES .I ~/.juliarc.jl diff --git a/branches/anj/transpose/doc/manual/getting-started.rst b/branches/anj/transpose/doc/manual/getting-started.rst index 5b31ed3079383..14c42585bd075 100644 --- a/branches/anj/transpose/doc/manual/getting-started.rst +++ b/branches/anj/transpose/doc/manual/getting-started.rst @@ -112,6 +112,7 @@ those available for the ``perl`` and ``ruby`` programs:: -J, --sysimage Start up with the given system image file --precompiled={yes|no} Use precompiled code from system image if available + --compilecache={yes|no} Enable/disable incremental precompilation of modules\n" -H, --home Set location of julia executable --startup-file={yes|no} Load ~/.juliarc.jl -f, --no-startup Don't load ~/.juliarc (deprecated, use --startup-file=no) diff --git a/branches/anj/transpose/doc/manual/modules.rst b/branches/anj/transpose/doc/manual/modules.rst index 6b988f50d80ad..a797d213a0c7e 100644 --- a/branches/anj/transpose/doc/manual/modules.rst +++ b/branches/anj/transpose/doc/manual/modules.rst @@ -419,3 +419,9 @@ A few other points to be aware of: 4. WeakRef objects and finalizers are not currently handled properly by the serializer (this will be fixed in an upcoming release). + +It is sometimes helpful during module development to turn off incremental precompilation. +The command line flag ``--compilecache={yes|no}`` enables you to toggle module precompilation on and off. +When Julia is started with ``--compilecache=no`` the serialized modules in the compile cache are ignored when loading modules and module dependencies. +``Base.compilecache()`` can still be called manually and it will respect ``__precompile__()`` directives for the module. +The state of this command line flag is passed to ``Pkg.build()`` to disable automatic precompilation triggering when installing, updating, and explicitly building packages. diff --git a/branches/anj/transpose/src/init.c b/branches/anj/transpose/src/init.c index 0ebcb048c5a80..caf52c6a49d6b 100644 --- a/branches/anj/transpose/src/init.c +++ b/branches/anj/transpose/src/init.c @@ -76,6 +76,7 @@ jl_options_t jl_options = { 0, // quiet #else JL_OPTIONS_USE_PRECOMPILED_YES, #endif + JL_OPTIONS_USE_COMPILECACHE_YES, NULL, // bindto NULL, // outputbc NULL, // outputo diff --git a/branches/anj/transpose/src/julia.h b/branches/anj/transpose/src/julia.h index b5efdd8af06a4..28bbd4a6236b5 100644 --- a/branches/anj/transpose/src/julia.h +++ b/branches/anj/transpose/src/julia.h @@ -1572,6 +1572,7 @@ typedef struct { int8_t worker; int8_t handle_signals; int8_t use_precompiled; + int8_t use_compilecache; const char *bindto; const char *outputbc; const char *outputo; @@ -1621,6 +1622,9 @@ DLLEXPORT int jl_generating_output(void); #define JL_OPTIONS_USE_PRECOMPILED_YES 1 #define JL_OPTIONS_USE_PRECOMPILED_NO 0 +#define JL_OPTIONS_USE_COMPILECACHE_YES 1 +#define JL_OPTIONS_USE_COMPILECACHE_NO 0 + // Version information #include diff --git a/branches/anj/transpose/test/cmdlineargs.jl b/branches/anj/transpose/test/cmdlineargs.jl index 9a8e9396aed1a..175e8bc6f735d 100644 --- a/branches/anj/transpose/test/cmdlineargs.jl +++ b/branches/anj/transpose/test/cmdlineargs.jl @@ -232,4 +232,10 @@ let exename = `$(joinpath(JULIA_HOME, Base.julia_exename())) --precompiled=yes` @test readchomp(pipeline(ignorestatus(`$exename -f -p`),stderr=`cat`)) == "ERROR: option `-p/--procs` is missing an argument" @test readchomp(pipeline(ignorestatus(`$exename -f --inline`),stderr=`cat`)) == "ERROR: option `--inline` is missing an argument" @test readchomp(pipeline(ignorestatus(`$exename -f -e "@show ARGS" -now -- julia RUN.jl`),stderr=`cat`)) == "ERROR: unknown option `-n`" + + # --compilecache={yes|no} + @test readchomp(`$exename -E "Bool(Base.JLOptions().use_compilecache)"`) == "true" + @test readchomp(`$exename --compilecache=yes -E "Bool(Base.JLOptions().use_compilecache)"`) == "true" + @test readchomp(`$exename --compilecache=no -E "Bool(Base.JLOptions().use_compilecache)"`) == "false" + @test !success(`$exename --compilecache=foo -e "exit(0)"`) end diff --git a/branches/anj/transpose/test/compile.jl b/branches/anj/transpose/test/compile.jl index 49b6c5cfdc57b..4e4da3dcb733a 100644 --- a/branches/anj/transpose/test/compile.jl +++ b/branches/anj/transpose/test/compile.jl @@ -81,8 +81,55 @@ try end println(STDERR, "\nNOTE: The following 'LoadError: break me' indicates normal operation") @test_throws ErrorException Base.require(:FooBar) + finally splice!(Base.LOAD_CACHE_PATH, 1) splice!(LOAD_PATH, 1) rm(dir, recursive=true) end + +# test --compilecache=no command line option +dir = mktempdir() +let dir = mktempdir(), + Time_module = :Time4b3a94a1a081a8cb + + try + open(joinpath(dir, "$Time_module.jl"), "w") do io + write(io, """ + module $Time_module + __precompile__(true) + time = Base.time() + end + """) + end + + eval(quote + insert!(LOAD_PATH, 1, $(dir)) + insert!(Base.LOAD_CACHE_PATH, 1, $(dir)) + Base.compilecache(:Time4b3a94a1a081a8cb) + end) + + exename = `$(joinpath(JULIA_HOME, Base.julia_exename())) --precompiled=yes` + + testcode = """ + insert!(LOAD_PATH, 1, $(repr(dir))) + insert!(Base.LOAD_CACHE_PATH, 1, $(repr(dir))) + using $Time_module + getfield($Time_module, :time) + """ + + t1_yes = readchomp(`$exename --compilecache=yes -E $(testcode)`) + t2_yes = readchomp(`$exename --compilecache=yes -E $(testcode)`) + @test t1_yes == t2_yes + + t1_no = readchomp(`$exename --compilecache=no -E $(testcode)`) + t2_no = readchomp(`$exename --compilecache=no -E $(testcode)`) + @test t1_no != t2_no + @test parse(Float64, t1_no) < parse(Float64, t2_no) + + finally + splice!(Base.LOAD_CACHE_PATH, 1) + splice!(LOAD_PATH, 1) + rm(dir, recursive=true) + end +end diff --git a/branches/anj/transpose/test/complex.jl b/branches/anj/transpose/test/complex.jl index de1aaeb506c80..d9fe38d12ae22 100644 --- a/branches/anj/transpose/test/complex.jl +++ b/branches/anj/transpose/test/complex.jl @@ -2,6 +2,13 @@ @test reim(2 + 3im) == (2, 3) +for T in (Int64, Float64) + @test real(T) == T + @test real(Complex{T}) == T + @test complex(T) == Complex{T} + @test complex(Complex{T}) == Complex{T} +end + # Basic arithmetic for T in (Float16, Float32, Float64, BigFloat) t = true diff --git a/branches/anj/transpose/ui/repl.c b/branches/anj/transpose/ui/repl.c index ea9cab2f85440..30cd1dfab149f 100644 --- a/branches/anj/transpose/ui/repl.c +++ b/branches/anj/transpose/ui/repl.c @@ -47,6 +47,7 @@ static const char opts[] = // startup options " -J, --sysimage Start up with the given system image file\n" " --precompiled={yes|no} Use precompiled code from system image if available\n" + " --compilecache={yes|no} Enable/disable incremental precompilation of modules\n" " -H, --home Set location of julia executable\n" " --startup-file={yes|no} Load ~/.juliarc.jl\n" " -f, --no-startup Don't load ~/.juliarc (deprecated, use --startup-file=no)\n" @@ -115,6 +116,7 @@ void parse_opts(int *argcp, char ***argvp) opt_output_o, opt_output_ji, opt_use_precompiled, + opt_use_compilecache, opt_incremental }; static char* shortopts = "+vhqFfH:e:E:P:L:J:C:ip:O"; @@ -132,6 +134,7 @@ void parse_opts(int *argcp, char ***argvp) { "load", required_argument, 0, 'L' }, { "sysimage", required_argument, 0, 'J' }, { "precompiled", required_argument, 0, opt_use_precompiled }, + { "compilecache", required_argument, 0, opt_use_compilecache }, { "cpu-target", required_argument, 0, 'C' }, { "procs", required_argument, 0, 'p' }, { "machinefile", required_argument, 0, opt_machinefile }, @@ -231,6 +234,14 @@ void parse_opts(int *argcp, char ***argvp) else jl_errorf("julia: invalid argument to --precompiled={yes|no} (%s)", optarg); break; + case opt_use_compilecache: + if (!strcmp(optarg,"yes")) + jl_options.use_compilecache = JL_OPTIONS_USE_COMPILECACHE_YES; + else if (!strcmp(optarg,"no")) + jl_options.use_compilecache = JL_OPTIONS_USE_COMPILECACHE_NO; + else + jl_errorf("julia: invalid argument to --compilecache={yes|no} (%s)", optarg); + break; case 'C': // cpu-target jl_options.cpu_target = strdup(optarg); break;