From 7ef63281c8d69b2ef45392acf4d70ef4ea10249f Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 15 Jan 2020 13:13:21 -0500 Subject: [PATCH 1/6] revert breaking change to GC.gc() (#34336) Removes the breaking part of b0ed147c5cf0566019ff08755af71eb5649411bc from PR #34303 (cherry picked from commit 15d693b0ec4bf620e7d594b08063ce60a6954f07) --- base/gcutils.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/gcutils.jl b/base/gcutils.jl index f9edb5441edb8..5b0e97d9f4434 100644 --- a/base/gcutils.jl +++ b/base/gcutils.jl @@ -53,15 +53,15 @@ module GC GC.gc() GC.gc(full::Bool) -Perform garbage collection. The argument `full` determines the kind of collection: A full -collection scans all objects, while an incremental collection only scans so-called young -objects and is much quicker. If called without an argument, heuristics are used to determine -which type of collection is needed. +Perform garbage collection. The argument `full` determines the kind of +collection: A full collection (default) sweeps all objects, which makes the +next GC scan much slower, while an incremental collection may only sweep +so-called young objects. !!! warning Excessive use will likely lead to poor performance. """ -gc() = ccall(:jl_gc_collect, Cvoid, (Cint,), 0) +gc() = ccall(:jl_gc_collect, Cvoid, (Cint,), 1) gc(full::Bool) = ccall(:jl_gc_collect, Cvoid, (Cint,), full ? 1 : 2) """ From 8683bfc026ea011ed73f3849148baa139fd060f1 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Thu, 16 Jan 2020 22:49:16 +0100 Subject: [PATCH 2/6] Clean-up the GC.gc interface. (#34401) (cherry picked from commit 270fcffeb8e1217958536ab3ef5baf24e3d621ee) --- base/gcutils.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/base/gcutils.jl b/base/gcutils.jl index 5b0e97d9f4434..bd7d904fc8309 100644 --- a/base/gcutils.jl +++ b/base/gcutils.jl @@ -49,9 +49,13 @@ Module with garbage collection utilities. """ module GC +# mirrored from julia.h +const GC_AUTO = 0 +const GC_FULL = 1 +const GC_INCREMENTAL = 2 + """ - GC.gc() - GC.gc(full::Bool) + GC.gc([full=true]) Perform garbage collection. The argument `full` determines the kind of collection: A full collection (default) sweeps all objects, which makes the @@ -61,8 +65,8 @@ so-called young objects. !!! warning Excessive use will likely lead to poor performance. """ -gc() = ccall(:jl_gc_collect, Cvoid, (Cint,), 1) -gc(full::Bool) = ccall(:jl_gc_collect, Cvoid, (Cint,), full ? 1 : 2) +gc(full::Bool=true) = + ccall(:jl_gc_collect, Cvoid, (Cint,), full ? GC_FULL : GC_INCREMENTAL) """ GC.enable(on::Bool) From 1596175f1e7d3db84aa31f2b5808628f0ca11e46 Mon Sep 17 00:00:00 2001 From: Jeffrey Lin Date: Mon, 20 Jan 2020 19:57:58 +0000 Subject: [PATCH 3/6] base/libc.jl: fix crash when run before epoch (#34056) (#34442) (cherry picked from commit f68753cc677676ef56dc3d9a78c415fbc8cff2b4) --- base/libc.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/libc.jl b/base/libc.jl index 7ed0e937fde09..379c76dfd8c60 100644 --- a/base/libc.jl +++ b/base/libc.jl @@ -398,6 +398,6 @@ rand(::Type{Float64}) = rand(UInt32) * 2.0^-32 Interface to the C `srand(seed)` function. """ -srand(seed=floor(time())) = ccall(:srand, Cvoid, (Cuint,), seed) +srand(seed=floor(Int, time()) % Cuint) = ccall(:srand, Cvoid, (Cuint,), seed) end # module From f39772adf321f896bc933054c938d51d8d27c392 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Wed, 15 Jan 2020 15:46:04 +0100 Subject: [PATCH 4/6] Don't have jl_svec statically verify the argcount with ASAN. (cherry picked from commit 64b9da168a56d4b1171286f427af2c246ab27e74) --- src/julia_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/julia_internal.h b/src/julia_internal.h index 057081c0e37ad..2d87a95ceac3d 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -290,7 +290,7 @@ jl_value_t *jl_permbox32(jl_datatype_t *t, int32_t x); jl_value_t *jl_permbox64(jl_datatype_t *t, int64_t x); jl_svec_t *jl_perm_symsvec(size_t n, ...); -#if !defined(__clang_analyzer__) // this sizeof(__VA_ARGS__) trick can't be computed until C11, but only the analyzer seems to care +#if !defined(__clang_analyzer__) && !defined(JL_ASAN_ENABLED) // this sizeof(__VA_ARGS__) trick can't be computed until C11, but that only matters to Clang in some situations #ifdef __GNUC__ #define jl_perm_symsvec(n, ...) \ (jl_perm_symsvec)(__extension__({ \ From fe8aeb83b34acff417b7192eb676a2e727f207e0 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Wed, 15 Jan 2020 16:49:31 +0100 Subject: [PATCH 5/6] Don't read trailing datatype layout bytes when first_ptr==-1. (cherry picked from commit 8e1ad64eb7e4cd914dbd6f477c217987209c1950) --- src/dump.c | 12 +++++++++--- src/staticdata.c | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/dump.c b/src/dump.c index a0ddd5de89786..ee15e193910d3 100644 --- a/src/dump.c +++ b/src/dump.c @@ -403,7 +403,10 @@ static void jl_serialize_datatype(jl_serializer_state *s, jl_datatype_t *dt) JL_ uint32_t np = dt->layout->npointers; size_t fieldsize = jl_fielddesc_size(dt->layout->fielddesc_type); ios_write(s->s, (const char*)dt->layout, sizeof(*dt->layout)); - ios_write(s->s, (const char*)(dt->layout + 1), nf * fieldsize + (np << dt->layout->fielddesc_type)); + size_t fldsize = nf * fieldsize; + if (dt->layout->first_ptr != -1) + fldsize += np << dt->layout->fielddesc_type; + ios_write(s->s, (const char*)(dt->layout + 1), fldsize); } } @@ -1484,11 +1487,14 @@ static jl_value_t *jl_deserialize_datatype(jl_serializer_state *s, int pos, jl_v uint32_t np = buffer.npointers; uint8_t fielddesc_type = buffer.fielddesc_type; size_t fielddesc_size = nf > 0 ? jl_fielddesc_size(fielddesc_type) : 0; + size_t fldsize = nf * fielddesc_size; + if (buffer.first_ptr != -1) + fldsize += np << fielddesc_type; jl_datatype_layout_t *layout = (jl_datatype_layout_t*)jl_gc_perm_alloc( - sizeof(jl_datatype_layout_t) + nf * fielddesc_size + (np << fielddesc_type), + sizeof(jl_datatype_layout_t) + fldsize, 0, 4, 0); *layout = buffer; - ios_read(s->s, (char*)(layout + 1), nf * fielddesc_size + (np << fielddesc_type)); + ios_read(s->s, (char*)(layout + 1), fldsize); dt->layout = layout; } } diff --git a/src/staticdata.c b/src/staticdata.c index a59168c63716d..e789713d4f39b 100644 --- a/src/staticdata.c +++ b/src/staticdata.c @@ -871,7 +871,9 @@ static void jl_write_values(jl_serializer_state *s) size_t np = dt->layout->npointers; size_t fieldsize = jl_fielddesc_size(dt->layout->fielddesc_type); char *flddesc = (char*)dt->layout; - size_t fldsize = sizeof(jl_datatype_layout_t) + nf * fieldsize + (np << dt->layout->fielddesc_type); + size_t fldsize = sizeof(jl_datatype_layout_t) + nf * fieldsize; + if (dt->layout->first_ptr != -1) + fldsize += np << dt->layout->fielddesc_type; uintptr_t layout = LLT_ALIGN(ios_pos(s->const_data), sizeof(void*)); write_padding(s->const_data, layout - ios_pos(s->const_data)); // realign stream newdt->layout = NULL; // relocation offset From adb7c7ef2e213a7da869b4bdc513de301aa2c29a Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 16 Jan 2020 04:22:35 -0500 Subject: [PATCH 6/6] mark `inbounds` and `loopinfo` as quoted during lowering (#34397) (cherry picked from commit a7cd97a293df20b0f05c5ad864556938d91dcdea) --- src/ast.scm | 3 ++- test/syntax.jl | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ast.scm b/src/ast.scm index 3ca6e652cd626..82c7cd5d38c0f 100644 --- a/src/ast.scm +++ b/src/ast.scm @@ -273,7 +273,8 @@ ;; predicates and accessors -(define (quoted? e) (memq (car e) '(quote top core globalref outerref line break inert meta))) +(define (quoted? e) + (memq (car e) '(quote top core globalref outerref line break inert meta inbounds loopinfo))) (define (quotify e) `',e) (define (unquote e) (if (and (pair? e) (memq (car e) '(quote inert))) diff --git a/test/syntax.jl b/test/syntax.jl index 0a2c44c5ef936..724b5c109d6a9 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -1971,3 +1971,11 @@ end # issue #33987 f33987(args::(Vararg{Any, N} where N); kwargs...) = args @test f33987(1,2,3) === (1,2,3) + +@test @eval let + (z,)->begin + $(Expr(:inbounds, true)) + $(Expr(:inbounds, :pop)) + end + pop = 1 +end == 1