diff --git a/base/compiler/ssair/inlining.jl b/base/compiler/ssair/inlining.jl index 019df328ab9a1..75e63f5c6b2e4 100644 --- a/base/compiler/ssair/inlining.jl +++ b/base/compiler/ssair/inlining.jl @@ -1811,7 +1811,9 @@ function ssa_substitute!(insert_node!::Inserter, spvals_ssa::Union{Nothing, SSAValue}, linetable_offset::Int32, boundscheck::Symbol) subst_inst[:flag] &= ~IR_FLAG_INBOUNDS - subst_inst[:line] += linetable_offset + if subst_inst[:line] != 0 + subst_inst[:line] += linetable_offset + end return ssa_substitute_op!(insert_node!, subst_inst, val, arg_replacements, spsig, spvals, spvals_ssa, boundscheck) end diff --git a/base/compiler/ssair/passes.jl b/base/compiler/ssair/passes.jl index 3df55e38b3512..39f1445d8c02d 100644 --- a/base/compiler/ssair/passes.jl +++ b/base/compiler/ssair/passes.jl @@ -1205,8 +1205,12 @@ function try_inline_finalizer!(ir::IRCode, argexprs::Vector{Any}, idx::Int, ssa_rename[ssa.id] end stmt′ = ssa_substitute_op!(InsertBefore(ir, SSAValue(idx)), inst, stmt′, argexprs, mi.specTypes, mi.sparam_vals, sp_ssa, :default) + newline = inst[:line] + if newline != 0 + newline += linetable_offset + end ssa_rename[idx′] = insert_node!(ir, idx, - NewInstruction(inst; stmt=stmt′, line=inst[:line]+linetable_offset), + NewInstruction(inst; stmt=stmt′, line=newline), attach_after) end diff --git a/base/subarray.jl b/base/subarray.jl index 901410e908d1e..3fdabca88e79f 100644 --- a/base/subarray.jl +++ b/base/subarray.jl @@ -127,6 +127,11 @@ _maybe_reshape_parent(A::AbstractArray, ::NTuple{1, Bool}) = reshape(A, Val(1)) _maybe_reshape_parent(A::AbstractArray{<:Any,1}, ::NTuple{1, Bool}) = reshape(A, Val(1)) _maybe_reshape_parent(A::AbstractArray{<:Any,N}, ::NTuple{N, Bool}) where {N} = A _maybe_reshape_parent(A::AbstractArray, ::NTuple{N, Bool}) where {N} = reshape(A, Val(N)) +# The trailing singleton indices could be eliminated after bounds checking. +rm_singleton_indices(ndims::Tuple, J1, Js...) = (J1, rm_singleton_indices(IteratorsMD._splitrest(ndims, index_ndims(J1)), Js...)...) +rm_singleton_indices(::Tuple{}, ::ScalarIndex, Js...) = rm_singleton_indices((), Js...) +rm_singleton_indices(::Tuple) = () + """ view(A, inds...) @@ -173,15 +178,12 @@ julia> view(2:5, 2:3) # returns a range as type is immutable 3:4 ``` """ -function view(A::AbstractArray{<:Any,N}, I::Vararg{Any,M}) where {N,M} +function view(A::AbstractArray, I::Vararg{Any,M}) where {M} @inline J = map(i->unalias(A,i), to_indices(A, I)) @boundscheck checkbounds(A, J...) - if length(J) > ndims(A) && J[N+1:end] isa Tuple{Vararg{Int}} - # view([1,2,3], :, 1) does not need to reshape - return unsafe_view(A, J[1:N]...) - end - unsafe_view(_maybe_reshape_parent(A, index_ndims(J...)), J...) + J′ = rm_singleton_indices(ntuple(Returns(true), Val(ndims(A))), J...) + unsafe_view(_maybe_reshape_parent(A, index_ndims(J′...)), J′...) end # Ranges implement getindex to return recomputed ranges; use that for views, too (when possible) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 2c962088484e7..235cf04382bc1 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -276,7 +276,7 @@ free_memory() = ccall(:uv_get_available_memory, UInt64, ()) Get the total memory in RAM (including that which is currently used) in bytes. This amount may be constrained, e.g., by Linux control groups. For the unconstrained -amount, see `Sys.physical_memory()`. +amount, see `Sys.total_physical_memory()`. """ function total_memory() constrained = ccall(:uv_get_constrained_memory, UInt64, ()) diff --git a/cli/Makefile b/cli/Makefile index b6a2b48ebf044..911e8ff54e246 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -47,7 +47,7 @@ LIB_DOBJS := $(BUILDDIR)/loader_lib.dbg.obj # If this is an architecture that supports dynamic linking, link in a trampoline definition ifneq (,$(wildcard $(SRCDIR)/trampolines/trampolines_$(ARCH).S)) LIB_OBJS += $(BUILDDIR)/loader_trampolines.o -LIB_DOBJS += $(BUILDDIR)/loader_trampolines.o +LIB_DOBJS += $(BUILDDIR)/loader_trampolines.dbg.obj endif default: release @@ -64,6 +64,8 @@ $(BUILDDIR)/loader_exe.dbg.obj : $(SRCDIR)/loader_exe.c $(HEADERS) $(JULIAHOME)/ @$(call PRINT_CC, $(CC) $(DEBUGFLAGS) $(LOADER_CFLAGS) -c $< -o $@) $(BUILDDIR)/loader_trampolines.o : $(SRCDIR)/trampolines/trampolines_$(ARCH).S $(HEADERS) $(SRCDIR)/trampolines/common.h @$(call PRINT_CC, $(CC) $(SHIPFLAGS) $(LOADER_CFLAGS) $< -c -o $@) +$(BUILDDIR)/loader_trampolines.dbg.obj : $(SRCDIR)/trampolines/trampolines_$(ARCH).S $(HEADERS) $(SRCDIR)/trampolines/common.h + @$(call PRINT_CC, $(CC) $(DEBUGFLAGS) $(LOADER_CFLAGS) $< -c -o $@) # Debugging target to help us see what kind of code is being generated for our trampolines dump-trampolines: $(SRCDIR)/trampolines/trampolines_$(ARCH).S diff --git a/deps/checksums/NetworkOptions-0bd33455cf3c77f2f87bf64167b64611dc5ff128.tar.gz/md5 b/deps/checksums/NetworkOptions-0bd33455cf3c77f2f87bf64167b64611dc5ff128.tar.gz/md5 new file mode 100644 index 0000000000000..36c148c3deeba --- /dev/null +++ b/deps/checksums/NetworkOptions-0bd33455cf3c77f2f87bf64167b64611dc5ff128.tar.gz/md5 @@ -0,0 +1 @@ +193abc96d1ea3a83096ba8401acbc5fa diff --git a/deps/checksums/NetworkOptions-0bd33455cf3c77f2f87bf64167b64611dc5ff128.tar.gz/sha512 b/deps/checksums/NetworkOptions-0bd33455cf3c77f2f87bf64167b64611dc5ff128.tar.gz/sha512 new file mode 100644 index 0000000000000..26f1e116e4e6f --- /dev/null +++ b/deps/checksums/NetworkOptions-0bd33455cf3c77f2f87bf64167b64611dc5ff128.tar.gz/sha512 @@ -0,0 +1 @@ +17f7567be44c2ff3e2c567311cd716191127d0d0f9a4a226d7c06003a5b455343dd8e308032f942bb0a5b95e4b5defc530cc2cda9dfff482aab6f688080c20e7 diff --git a/deps/checksums/NetworkOptions-aab83e5dd900c874826d430e25158dff43559d78.tar.gz/md5 b/deps/checksums/NetworkOptions-aab83e5dd900c874826d430e25158dff43559d78.tar.gz/md5 deleted file mode 100644 index 433b89eaedcc2..0000000000000 --- a/deps/checksums/NetworkOptions-aab83e5dd900c874826d430e25158dff43559d78.tar.gz/md5 +++ /dev/null @@ -1 +0,0 @@ -73b81916dc08382ad34b8110983b61ad diff --git a/deps/checksums/NetworkOptions-aab83e5dd900c874826d430e25158dff43559d78.tar.gz/sha512 b/deps/checksums/NetworkOptions-aab83e5dd900c874826d430e25158dff43559d78.tar.gz/sha512 deleted file mode 100644 index 01f34b83dc80b..0000000000000 --- a/deps/checksums/NetworkOptions-aab83e5dd900c874826d430e25158dff43559d78.tar.gz/sha512 +++ /dev/null @@ -1 +0,0 @@ -a860163ef4fa5c2ff8d8712fff5ad5bb16e7697acc53538a0dda4435b910f4ad94f9c206e0d81864762361fdbcfbc57eb2e1708b33326f4f1c8d95997a495fe3 diff --git a/doc/src/manual/command-line-interface.md b/doc/src/manual/command-line-interface.md index 0210e81520998..fdf165d411f5e 100644 --- a/doc/src/manual/command-line-interface.md +++ b/doc/src/manual/command-line-interface.md @@ -142,6 +142,7 @@ The following is a complete list of command-line switches available when launchi |`--output-incremental={yes\|no*}` |Generate an incremental output file (rather than complete)| |`--trace-compile={stderr,name}` |Print precompile statements for methods compiled during execution or save to a path| |`--image-codegen` |Force generate code in imaging mode| +|`--heap-size-hint=` |Forces garbage collection if memory usage is higher than that value. The memory hint might be specified in megabytes (e.g., 500M) or gigabytes (e.g., 1G)| !!! compat "Julia 1.1" diff --git a/doc/src/manual/multi-threading.md b/doc/src/manual/multi-threading.md index 63902f1b7902b..2d4af4cde5a17 100644 --- a/doc/src/manual/multi-threading.md +++ b/doc/src/manual/multi-threading.md @@ -116,8 +116,8 @@ julia> using Base.Threads julia> nthreadpools() 2 -julia> threadpool() -:default +julia> threadpool() # the main thread is in the interactive thread pool +:interactive julia> nthreads(:default) 3 @@ -133,6 +133,10 @@ julia> nthreads() The zero-argument version of `nthreads` returns the number of threads in the default pool. +!!! note + Depending on whether Julia has been started with interactive threads, + the main thread is either in the default or interactive thread pool. + Either or both numbers can be replaced with the word `auto`, which causes Julia to choose a reasonable default. diff --git a/doc/src/manual/variables-and-scoping.md b/doc/src/manual/variables-and-scoping.md index c763d62680091..cc15dc32b82bd 100644 --- a/doc/src/manual/variables-and-scoping.md +++ b/doc/src/manual/variables-and-scoping.md @@ -67,31 +67,7 @@ Each module introduces a new global scope, separate from the global scope of all is no all-encompassing global scope. Modules can introduce variables of other modules into their scope through the [using or import](@ref modules) statements or through qualified access using the dot-notation, i.e. each module is a so-called *namespace* as well as a first-class data structure -associating names with values. Note that while variable bindings can be read externally, they can only -be changed within the module to which they belong. As an escape hatch, you can always evaluate code -inside that module to modify a variable; this guarantees, in particular, that module bindings cannot -be modified externally by code that never calls `eval`. - -```jldoctest -julia> module A - a = 1 # a global in A's scope - end; - -julia> module B - module C - c = 2 - end - b = C.c # can access the namespace of a nested global scope - # through a qualified access - import ..A # makes module A available - d = A.a - end; - -julia> module D - b = a # errors as D's global scope is separate from A's - end; -ERROR: UndefVarError: `a` not defined -``` +associating names with values. If a top-level expression contains a variable declaration with keyword `local`, then that variable is not accessible outside that expression. diff --git a/src/jltypes.c b/src/jltypes.c index d61a06b06f159..66db26a575e90 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -215,7 +215,7 @@ JL_DLLEXPORT jl_array_t *jl_find_free_typevars(jl_value_t *v) } // test whether a type has vars bound by the given environment -static int jl_has_bound_typevars(jl_value_t *v, jl_typeenv_t *env) JL_NOTSAFEPOINT +int jl_has_bound_typevars(jl_value_t *v, jl_typeenv_t *env) JL_NOTSAFEPOINT { while (1) { if (jl_is_typevar(v)) { diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index b5705c55b6e61..756012b364b33 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -4338,7 +4338,7 @@ f(x) = yt(x) (car s) (loop (cdr s)))))) `(pop_exception ,restore-token)))) - (define (emit-return x) + (define (emit-return tail x) (define (emit- x) (let* ((tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x) #f @@ -4347,8 +4347,12 @@ f(x) = yt(x) (begin (emit `(= ,tmp ,x)) tmp) x))) (define (actually-return x) - (let* ((x (if rett - (compile (convert-for-type-decl (emit- x) rett #t lam) '() #t #f) + (let* ((x (begin0 (emit- x) + ;; if we are adding an implicit return then mark it as having no location + (if (not (eq? tail 'explicit)) + (emit '(line #f))))) + (x (if rett + (compile (convert-for-type-decl x rett #t lam) '() #t #f) x)) (x (emit- x))) (let ((pexc (pop-exc-expr catch-token-stack '()))) @@ -4487,7 +4491,7 @@ f(x) = yt(x) (eq? (car e) 'globalref)) (underscore-symbol? (cadr e))))) (error (string "all-underscore identifier used as rvalue" (format-loc current-loc)))) - (cond (tail (emit-return e1)) + (cond (tail (emit-return tail e1)) (value e1) ((symbol? e1) (emit e1) #f) ;; keep symbols for undefined-var checking ((and (pair? e1) (eq? (car e1) 'outerref)) (emit e1) #f) ;; keep globals for undefined-var checking @@ -4533,7 +4537,7 @@ f(x) = yt(x) (else (compile-args (cdr e) break-labels)))) (callex (cons (car e) args))) - (cond (tail (emit-return callex)) + (cond (tail (emit-return tail callex)) (value callex) (else (emit callex))))) ((=) @@ -4550,7 +4554,7 @@ f(x) = yt(x) (if (not (eq? rr rhs)) (emit `(= ,rr ,rhs))) (emit `(= ,lhs ,rr)) - (if tail (emit-return rr)) + (if tail (emit-return tail rr)) rr) (emit-assignment lhs rhs)))))) ((block) @@ -4603,7 +4607,7 @@ f(x) = yt(x) (if file-diff (set! filename last-fname)) v))) ((return) - (compile (cadr e) break-labels #t #t) + (compile (cadr e) break-labels #t 'explicit) #f) ((unnecessary) ;; `unnecessary` marks expressions generated by lowering that @@ -4618,7 +4622,8 @@ f(x) = yt(x) (let ((v1 (compile (caddr e) break-labels value tail))) (if val (emit-assignment val v1)) (if (and (not tail) (or (length> e 3) val)) - (emit end-jump)) + (begin (emit `(line #f)) + (emit end-jump))) (let ((elselabel (make&mark-label))) (for-each (lambda (test) (set-car! (cddr test) elselabel)) @@ -4630,7 +4635,7 @@ f(x) = yt(x) (if (not tail) (set-car! (cdr end-jump) (make&mark-label)) (if (length= e 3) - (emit-return v2))) + (emit-return tail v2))) val)))) ((_while) (let* ((endl (make-label)) @@ -4672,7 +4677,7 @@ f(x) = yt(x) (emit `(label ,m)) (put! label-map (cadr e) (make&mark-label))) (if tail - (emit-return '(null)) + (emit-return tail '(null)) (if value (error "misplaced label"))))) ((symbolicgoto) (let* ((m (get label-map (cadr e) #f)) @@ -4712,7 +4717,7 @@ f(x) = yt(x) (begin (if els (begin (if (and (not val) v1) (emit v1)) (emit '(leave 1))) - (if v1 (emit-return v1))) + (if v1 (emit-return tail v1))) (if (not finally) (set! endl #f))) (begin (emit '(leave 1)) (emit `(goto ,(or els endl))))) @@ -4744,7 +4749,7 @@ f(x) = yt(x) (emit `(= ,tmp (call (core ===) ,finally ,(caar actions)))) (emit `(gotoifnot ,tmp ,skip)))) (let ((ac (cdar actions))) - (cond ((eq? (car ac) 'return) (emit-return (cadr ac))) + (cond ((eq? (car ac) 'return) (emit-return tail (cadr ac))) ((eq? (car ac) 'break) (emit-break (cadr ac))) (else ;; assumed to be a rethrow (emit ac)))) @@ -4783,8 +4788,8 @@ f(x) = yt(x) (set! global-const-error current-loc)) (emit e)))) ((atomic) (error "misplaced atomic declaration")) - ((isdefined) (if tail (emit-return e) e)) - ((boundscheck) (if tail (emit-return e) e)) + ((isdefined) (if tail (emit-return tail e) e)) + ((boundscheck) (if tail (emit-return tail e) e)) ((method) (if (not (null? (cadr lam))) @@ -4805,12 +4810,12 @@ f(x) = yt(x) l)))) (emit `(method ,(or (cadr e) '(false)) ,sig ,lam)) (if value (compile '(null) break-labels value tail))) - (cond (tail (emit-return e)) + (cond (tail (emit-return tail e)) (value e) (else (emit e))))) ((lambda) (let ((temp (linearize e))) - (cond (tail (emit-return temp)) + (cond (tail (emit-return tail temp)) (value temp) (else (emit temp))))) @@ -4818,7 +4823,7 @@ f(x) = yt(x) ((thunk module) (check-top-level e) (emit e) - (if tail (emit-return '(null))) + (if tail (emit-return tail '(null))) '(null)) ((toplevel-only) (check-top-level (cdr e)) @@ -4828,7 +4833,7 @@ f(x) = yt(x) (check-top-level e) (let ((val (make-ssavalue))) (emit `(= ,val ,e)) - (if tail (emit-return val)) + (if tail (emit-return tail val)) val)) ;; other top level expressions @@ -4837,7 +4842,7 @@ f(x) = yt(x) (emit e) (let ((have-ret? (and (pair? code) (pair? (car code)) (eq? (caar code) 'return)))) (if (and tail (not have-ret?)) - (emit-return '(null)))) + (emit-return tail '(null)))) '(null)) ((gc_preserve_begin) @@ -4861,7 +4866,7 @@ f(x) = yt(x) (else (emit e))) (if (and tail (not have-ret?)) - (emit-return '(null))) + (emit-return tail '(null))) '(null))) ;; unsupported assignment operators @@ -4979,6 +4984,7 @@ f(x) = yt(x) (labltable (table)) (ssavtable (table)) (current-loc 0) + (nowhere #f) (current-file file) (current-line line) (locstack '()) @@ -4991,25 +4997,32 @@ f(x) = yt(x) (set! current-loc 1))) (set! code (cons e code)) (set! i (+ i 1)) - (set! locs (cons current-loc locs))) + (set! locs (cons (if nowhere 0 current-loc) locs)) + (set! nowhere #f)) (let loop ((stmts (cdr body))) (if (pair? stmts) (let ((e (car stmts))) (cond ((atom? e) (emit e)) ((eq? (car e) 'line) - (if (and (= current-line 0) (length= e 2) (pair? linetable)) - ;; (line n) after push_loc just updates the line for the new file - (begin (set-lineno! (car linetable) (cadr e)) - (set! current-line (cadr e))) - (begin - (set! current-line (cadr e)) - (if (pair? (cddr e)) - (set! current-file (caddr e))) - (set! linetable (cons (if (null? locstack) - (make-lineinfo name current-file current-line) - (make-lineinfo name current-file current-line (caar locstack))) - linetable)) - (set! current-loc (- (length linetable) 1))))) + (cond ((and (length= e 2) (not (cadr e))) + ;; (line #f) marks that we are entering a generated statement + ;; that should not be counted as belonging to the previous marked location, + ;; for example `return` after a not-executed `if` arm in tail position. + (set! nowhere #t)) + ((and (= current-line 0) (length= e 2) (pair? linetable)) + ;; (line n) after push_loc just updates the line for the new file + (begin (set-lineno! (car linetable) (cadr e)) + (set! current-line (cadr e)))) + (else + (begin + (set! current-line (cadr e)) + (if (pair? (cddr e)) + (set! current-file (caddr e))) + (set! linetable (cons (if (null? locstack) + (make-lineinfo name current-file current-line) + (make-lineinfo name current-file current-line (caar locstack))) + linetable)) + (set! current-loc (- (length linetable) 1)))))) ((and (length> e 2) (eq? (car e) 'meta) (eq? (cadr e) 'push_loc)) (set! locstack (cons (list current-loc current-line current-file) locstack)) (set! current-file (caddr e)) diff --git a/src/julia_internal.h b/src/julia_internal.h index 89f31f1702db7..4fa3154b765d1 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -696,6 +696,7 @@ jl_tupletype_t *jl_lookup_arg_tuple_type(jl_value_t *arg1 JL_PROPAGATES_ROOT, jl JL_DLLEXPORT void jl_method_table_insert(jl_methtable_t *mt, jl_method_t *method, jl_tupletype_t *simpletype); jl_datatype_t *jl_mk_builtin_func(jl_datatype_t *dt, const char *name, jl_fptr_args_t fptr) JL_GC_DISABLED; int jl_obviously_unequal(jl_value_t *a, jl_value_t *b); +int jl_has_bound_typevars(jl_value_t *v, jl_typeenv_t *env) JL_NOTSAFEPOINT; JL_DLLEXPORT jl_array_t *jl_find_free_typevars(jl_value_t *v); int jl_has_fixed_layout(jl_datatype_t *t); JL_DLLEXPORT int jl_struct_try_layout(jl_datatype_t *dt); diff --git a/src/subtype.c b/src/subtype.c index 86b441f9aaec0..3d874872d6b44 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -1506,6 +1506,23 @@ static int may_contain_union_decision(jl_value_t *x, jl_stenv_t *e, jl_typeenv_t may_contain_union_decision(xb ? xb->ub : ((jl_tvar_t *)x)->ub, e, &newlog); } +static int has_exists_typevar(jl_value_t *x, jl_stenv_t *e) JL_NOTSAFEPOINT +{ + jl_typeenv_t *env = NULL; + jl_varbinding_t *v = e->vars; + while (v != NULL) { + if (v->right) { + jl_typeenv_t *newenv = (jl_typeenv_t*)alloca(sizeof(jl_typeenv_t)); + newenv->var = v->var; + newenv->val = NULL; + newenv->prev = env; + env = newenv; + } + v = v->prev; + } + return env != NULL && jl_has_bound_typevars(x, env); +} + static int local_forall_exists_subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int param, int limit_slow) { int16_t oldRmore = e->Runions.more; @@ -1525,13 +1542,19 @@ static int local_forall_exists_subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t int count = 0, noRmore = 0; sub = _forall_exists_subtype(x, y, e, param, &count, &noRmore); pop_unionstate(&e->Runions, &oldRunions); - // we should not try the slow path if `forall_exists_subtype` has tested all cases; - // Once limit_slow == 1, also skip it if - // 1) `forall_exists_subtype` return false + // We could skip the slow path safely if + // 1) `_∀_∃_subtype` has tested all cases + // 2) `_∀_∃_subtype` returns 1 && `x` and `y` contain no ∃ typevar + // Once `limit_slow == 1`, also skip it if + // 1) `_∀_∃_subtype` returns 0 // 2) the left `Union` looks big + // TODO: `limit_slow` ignores complexity from inner `local_∀_exists_subtype`. if (limit_slow == -1) limit_slow = kindx || kindy; - if (noRmore || (limit_slow && (count > 3 || !sub))) + int skip = noRmore || (limit_slow && (count > 3 || !sub)) || + (sub && (kindx || !has_exists_typevar(x, e)) && + (kindy || !has_exists_typevar(y, e))); + if (skip) e->Runions.more = oldRmore; } else { diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index d8cc052967d50..2444695f90afd 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -92,7 +92,7 @@ mutable struct WorkerConfig end end -@enum WorkerState W_CREATED W_CONNECTED W_TERMINATING W_TERMINATED +@enum WorkerState W_CREATED W_CONNECTED W_TERMINATING W_TERMINATED W_UNKNOWN_STATE mutable struct Worker id::Int msg_lock::Threads.ReentrantLock # Lock for del_msgs, add_msgs, and gcflag diff --git a/stdlib/Distributed/src/process_messages.jl b/stdlib/Distributed/src/process_messages.jl index e68e05b9db52b..3032917e49f93 100644 --- a/stdlib/Distributed/src/process_messages.jl +++ b/stdlib/Distributed/src/process_messages.jl @@ -210,8 +210,7 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool) handle_msg(msg, header, r_stream, w_stream, version) end catch e - werr = worker_from_id(wpid) - oldstate = werr.state + oldstate = W_UNKNOWN_STATE # Check again as it may have been set in a message handler but not propagated to the calling block above if wpid < 1 @@ -222,6 +221,8 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool) println(stderr, e, CapturedException(e, catch_backtrace())) println(stderr, "Process($(myid())) - Unknown remote, closing connection.") elseif !(wpid in map_del_wrkr) + werr = worker_from_id(wpid) + oldstate = werr.state set_worker_state(werr, W_TERMINATED) # If unhandleable error occurred talking to pid 1, exit diff --git a/stdlib/InteractiveUtils/src/codeview.jl b/stdlib/InteractiveUtils/src/codeview.jl index 646028575d052..a30734f16c9ab 100644 --- a/stdlib/InteractiveUtils/src/codeview.jl +++ b/stdlib/InteractiveUtils/src/codeview.jl @@ -70,7 +70,7 @@ Small unions of concrete types are usually not a concern, so these are highlight Keyword argument `debuginfo` may be one of `:source` or `:none` (default), to specify the verbosity of code comments. -See [`@code_warntype`](@ref man-code-warntype) for more information. +See the [`@code_warntype`](@ref man-code-warntype) section in the Performance Tips page of the manual for more information. """ function code_warntype(io::IO, @nospecialize(f), @nospecialize(t=Base.default_tt(f)); debuginfo::Symbol=:default, optimize::Bool=false, kwargs...) diff --git a/stdlib/NetworkOptions.version b/stdlib/NetworkOptions.version index be36f14f526dc..7f93eadcf7264 100644 --- a/stdlib/NetworkOptions.version +++ b/stdlib/NetworkOptions.version @@ -1,4 +1,4 @@ NETWORKOPTIONS_BRANCH = master -NETWORKOPTIONS_SHA1 = aab83e5dd900c874826d430e25158dff43559d78 +NETWORKOPTIONS_SHA1 = 0bd33455cf3c77f2f87bf64167b64611dc5ff128 NETWORKOPTIONS_GIT_URL := https://github.com/JuliaLang/NetworkOptions.jl.git NETWORKOPTIONS_TAR_URL = https://api.github.com/repos/JuliaLang/NetworkOptions.jl/tarball/$1 diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index 716cd7c14b904..690d0465b3ec0 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -201,6 +201,13 @@ The keyword arguments can be any combination of: - `tasks::Union{Int,AbstractVector{Int}}` -- Specify which tasks to include snapshots from in the report. Note that this does not control which tasks samples are collected within. + +!!! compat "Julia 1.8" + The `groupby`, `threads`, and `tasks` keyword arguments were introduced in Julia 1.8. + +!!! note + Profiling on windows is limited to the main thread. Other threads have not been sampled and will not show in the report. + """ function print(io::IO, data::Vector{<:Unsigned} = fetch(), diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 1730fe8179857..12e0c1fe2d502 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -520,6 +520,69 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no` got = read(covfile, String) @test isempty(got) rm(covfile) + + function coverage_info_for(src::String) + mktemp(dir) do srcfile, io + write(io, src); close(io) + outfile = tempname(dir, cleanup=false)*".info" + run(`$exename --code-coverage=$outfile $srcfile`) + result = read(outfile, String) + rm(outfile, force=true) + result + end + end + @test contains(coverage_info_for(""" + function cov_bug(x, p) + if p > 2 + print("") # runs + end + if Base.compilerbarrier(:const, false) + println("Does not run") + end + end + function do_test() + cov_bug(5, 3) + end + do_test() + """), """ + DA:1,1 + DA:2,1 + DA:3,1 + DA:5,1 + DA:6,0 + DA:9,1 + DA:10,1 + LH:6 + LF:7 + """) + @test contains(coverage_info_for(""" + function cov_bug() + if Base.compilerbarrier(:const, true) + if Base.compilerbarrier(:const, true) + if Base.compilerbarrier(:const, false) + println("Does not run") + end + else + print("Does not run either") + end + else + print("") + end + return nothing + end + cov_bug() + """), """ + DA:1,1 + DA:2,1 + DA:3,1 + DA:4,1 + DA:5,0 + DA:8,0 + DA:11,0 + DA:13,1 + LH:5 + LF:8 + """) end # --track-allocation diff --git a/test/show.jl b/test/show.jl index 688ee452a4813..9b6becbf95b1d 100644 --- a/test/show.jl +++ b/test/show.jl @@ -2081,7 +2081,7 @@ let src = code_typed(my_fun28173, (Int,), debuginfo=:source)[1][1] io = IOBuffer() Base.IRShow.show_ir(io, ir, Base.IRShow.default_config(ir; verbose_linetable=true)) seekstart(io) - @test count(contains(r"@ a{80}:\d+ within `my_fun28173"), eachline(io)) == 10 + @test count(contains(r"@ a{80}:\d+ within `my_fun28173"), eachline(io)) == 9 # Test that a bad :invoke doesn't cause an error during printing Core.Compiler.insert_node!(ir, 1, Core.Compiler.NewInstruction(Expr(:invoke, nothing, sin), Any), false) diff --git a/test/subarray.jl b/test/subarray.jl index e22c1394cbfc2..11d18185dd753 100644 --- a/test/subarray.jl +++ b/test/subarray.jl @@ -762,9 +762,9 @@ end @testset "issue #41221: view(::Vector, :, 1)" begin v = randn(3) - @test view(v,:,1) == v - @test parent(view(v,:,1)) === v - @test parent(view(v,2:3,1,1)) === v + @test @inferred(view(v,:,1)) == v + @test parent(@inferred(view(v,:,1))) === v + @test parent(@inferred(view(v,2:3,1,1))) === v @test_throws BoundsError view(v,:,2) @test_throws BoundsError view(v,:,1,2) @@ -772,3 +772,10 @@ end @test view(m, 1:2, 3, 1, 1) == m[1:2, 3] @test parent(view(m, 1:2, 3, 1, 1)) === m end + +@testset "issue #53209: avoid invalid elimination of singleton indices" begin + A = randn(4,5) + @test A[CartesianIndices(()), :, 3] == @inferred(view(A, CartesianIndices(()), :, 3)) + @test parent(@inferred(view(A, :, 3, 1, CartesianIndices(()), 1))) === A + @test_throws BoundsError view(A, :, 3, 2, CartesianIndices(()), 1) +end diff --git a/test/subtype.jl b/test/subtype.jl index 19901897ebaaa..cd856b0b7a2ff 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -2562,3 +2562,12 @@ let a = Tuple{Union{Nothing, Type{Pair{T1}} where T1}} b = Tuple{Type{X2} where X2<:(Pair{T2, Y2} where {Src, Z2<:Src, Y2<:Union{Val{Z2}, Z2}})} where T2 @test !Base.has_free_typevars(typeintersect(a, b)) end + +#issue 53371 +struct T53371{A,B,C,D,E} end +S53371{A} = Union{Int, <:A} +R53371{A} = Val{V} where V<:(T53371{B,C,D,E,F} where {B<:Val{A}, C<:S53371{B}, D<:S53371{B}, E<:S53371{B}, F<:S53371{B}}) +let S = Type{T53371{A, B, C, D, E}} where {A, B<:R53371{A}, C<:R53371{A}, D<:R53371{A}, E<:R53371{A}}, + T = Type{T53371{A, B, C, D, E} where {A, B<:R53371{A}, C<:R53371{A}, D<:R53371{A}, E<:R53371{A}}} + @test !(S <: T) +end diff --git a/test/syntax.jl b/test/syntax.jl index 3516c306c42d4..e529e0f292df1 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -713,7 +713,7 @@ m1_exprs = get_expr_list(Meta.lower(@__MODULE__, quote @m1 end)) let low3 = Meta.lower(@__MODULE__, quote @m3 end) m3_exprs = get_expr_list(low3) ci = low3.args[1]::Core.CodeInfo - @test ci.codelocs == [4, 2] + @test ci.codelocs == [4, 0] @test is_return_ssavalue(m3_exprs[end]) end