Skip to content

Commit e4f6cd7

Browse files
authored
Merge pull request #34461 from JuliaLang/backports-release-1.4
Backports for Julia 1.4 RC 1
2 parents a718746 + adb7c7e commit e4f6cd7

File tree

7 files changed

+36
-15
lines changed

7 files changed

+36
-15
lines changed

base/gcutils.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,24 @@ Module with garbage collection utilities.
4949
"""
5050
module GC
5151

52+
# mirrored from julia.h
53+
const GC_AUTO = 0
54+
const GC_FULL = 1
55+
const GC_INCREMENTAL = 2
56+
5257
"""
53-
GC.gc()
54-
GC.gc(full::Bool)
58+
GC.gc([full=true])
5559
56-
Perform garbage collection. The argument `full` determines the kind of collection: A full
57-
collection scans all objects, while an incremental collection only scans so-called young
58-
objects and is much quicker. If called without an argument, heuristics are used to determine
59-
which type of collection is needed.
60+
Perform garbage collection. The argument `full` determines the kind of
61+
collection: A full collection (default) sweeps all objects, which makes the
62+
next GC scan much slower, while an incremental collection may only sweep
63+
so-called young objects.
6064
6165
!!! warning
6266
Excessive use will likely lead to poor performance.
6367
"""
64-
gc() = ccall(:jl_gc_collect, Cvoid, (Cint,), 0)
65-
gc(full::Bool) = ccall(:jl_gc_collect, Cvoid, (Cint,), full ? 1 : 2)
68+
gc(full::Bool=true) =
69+
ccall(:jl_gc_collect, Cvoid, (Cint,), full ? GC_FULL : GC_INCREMENTAL)
6670

6771
"""
6872
GC.enable(on::Bool)

base/libc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,6 @@ rand(::Type{Float64}) = rand(UInt32) * 2.0^-32
398398
399399
Interface to the C `srand(seed)` function.
400400
"""
401-
srand(seed=floor(time())) = ccall(:srand, Cvoid, (Cuint,), seed)
401+
srand(seed=floor(Int, time()) % Cuint) = ccall(:srand, Cvoid, (Cuint,), seed)
402402

403403
end # module

src/ast.scm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@
273273

274274
;; predicates and accessors
275275

276-
(define (quoted? e) (memq (car e) '(quote top core globalref outerref line break inert meta)))
276+
(define (quoted? e)
277+
(memq (car e) '(quote top core globalref outerref line break inert meta inbounds loopinfo)))
277278
(define (quotify e) `',e)
278279
(define (unquote e)
279280
(if (and (pair? e) (memq (car e) '(quote inert)))

src/dump.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ static void jl_serialize_datatype(jl_serializer_state *s, jl_datatype_t *dt) JL_
403403
uint32_t np = dt->layout->npointers;
404404
size_t fieldsize = jl_fielddesc_size(dt->layout->fielddesc_type);
405405
ios_write(s->s, (const char*)dt->layout, sizeof(*dt->layout));
406-
ios_write(s->s, (const char*)(dt->layout + 1), nf * fieldsize + (np << dt->layout->fielddesc_type));
406+
size_t fldsize = nf * fieldsize;
407+
if (dt->layout->first_ptr != -1)
408+
fldsize += np << dt->layout->fielddesc_type;
409+
ios_write(s->s, (const char*)(dt->layout + 1), fldsize);
407410
}
408411
}
409412

@@ -1484,11 +1487,14 @@ static jl_value_t *jl_deserialize_datatype(jl_serializer_state *s, int pos, jl_v
14841487
uint32_t np = buffer.npointers;
14851488
uint8_t fielddesc_type = buffer.fielddesc_type;
14861489
size_t fielddesc_size = nf > 0 ? jl_fielddesc_size(fielddesc_type) : 0;
1490+
size_t fldsize = nf * fielddesc_size;
1491+
if (buffer.first_ptr != -1)
1492+
fldsize += np << fielddesc_type;
14871493
jl_datatype_layout_t *layout = (jl_datatype_layout_t*)jl_gc_perm_alloc(
1488-
sizeof(jl_datatype_layout_t) + nf * fielddesc_size + (np << fielddesc_type),
1494+
sizeof(jl_datatype_layout_t) + fldsize,
14891495
0, 4, 0);
14901496
*layout = buffer;
1491-
ios_read(s->s, (char*)(layout + 1), nf * fielddesc_size + (np << fielddesc_type));
1497+
ios_read(s->s, (char*)(layout + 1), fldsize);
14921498
dt->layout = layout;
14931499
}
14941500
}

src/julia_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ jl_value_t *jl_permbox32(jl_datatype_t *t, int32_t x);
290290
jl_value_t *jl_permbox64(jl_datatype_t *t, int64_t x);
291291
jl_svec_t *jl_perm_symsvec(size_t n, ...);
292292

293-
#if !defined(__clang_analyzer__) // this sizeof(__VA_ARGS__) trick can't be computed until C11, but only the analyzer seems to care
293+
#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
294294
#ifdef __GNUC__
295295
#define jl_perm_symsvec(n, ...) \
296296
(jl_perm_symsvec)(__extension__({ \

src/staticdata.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,9 @@ static void jl_write_values(jl_serializer_state *s)
871871
size_t np = dt->layout->npointers;
872872
size_t fieldsize = jl_fielddesc_size(dt->layout->fielddesc_type);
873873
char *flddesc = (char*)dt->layout;
874-
size_t fldsize = sizeof(jl_datatype_layout_t) + nf * fieldsize + (np << dt->layout->fielddesc_type);
874+
size_t fldsize = sizeof(jl_datatype_layout_t) + nf * fieldsize;
875+
if (dt->layout->first_ptr != -1)
876+
fldsize += np << dt->layout->fielddesc_type;
875877
uintptr_t layout = LLT_ALIGN(ios_pos(s->const_data), sizeof(void*));
876878
write_padding(s->const_data, layout - ios_pos(s->const_data)); // realign stream
877879
newdt->layout = NULL; // relocation offset

test/syntax.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,3 +1971,11 @@ end
19711971
# issue #33987
19721972
f33987(args::(Vararg{Any, N} where N); kwargs...) = args
19731973
@test f33987(1,2,3) === (1,2,3)
1974+
1975+
@test @eval let
1976+
(z,)->begin
1977+
$(Expr(:inbounds, true))
1978+
$(Expr(:inbounds, :pop))
1979+
end
1980+
pop = 1
1981+
end == 1

0 commit comments

Comments
 (0)