Skip to content

Commit 6e05524

Browse files
committed
Merge remote-tracking branch 'upstream/master' into local-names-linking
2 parents f81c77b + 9f1cc44 commit 6e05524

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+314
-158
lines changed

Compiler/src/abstractlattice.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ end
183183
"""
184184
has_nontrivial_extended_info(𝕃::AbstractLattice, t)::Bool
185185
186-
Determines whether the given lattice element `t` of `𝕃` has non-trivial extended lattice
186+
Determine whether the given lattice element `t` of `𝕃` has non-trivial extended lattice
187187
information that would not be available from the type itself.
188188
"""
189189
@nospecializeinfer has_nontrivial_extended_info(𝕃::AbstractLattice, @nospecialize t) =
@@ -206,7 +206,7 @@ end
206206
"""
207207
is_const_prop_profitable_arg(𝕃::AbstractLattice, t)::Bool
208208
209-
Determines whether the given lattice element `t` of `𝕃` has new extended lattice information
209+
Determine whether the given lattice element `t` of `𝕃` has new extended lattice information
210210
that should be forwarded along with constant propagation.
211211
"""
212212
@nospecializeinfer is_const_prop_profitable_arg(𝕃::AbstractLattice, @nospecialize t) =

Compiler/src/ssair/EscapeAnalysis.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ end
415415
"""
416416
iridx(x, estate::EscapeState) -> xidx::Union{Int,Nothing}
417417
418-
Tries to convert analyzable IR element `x::Union{Argument,SSAValue}` to
418+
Try to convert analyzable IR element `x::Union{Argument,SSAValue}` to
419419
its unique identifier number `xidx` that is valid in the analysis context of `estate`.
420420
Returns `nothing` if `x` isn't maintained by `estate` and thus unanalyzable (e.g. `x::GlobalRef`).
421421

Compiler/src/ssair/domtree.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ end
597597
"""
598598
dominates(domtree::DomTree, bb1::Int, bb2::Int)::Bool
599599
600-
Checks if `bb1` dominates `bb2`.
600+
Check if `bb1` dominates `bb2`.
601601
`bb1` and `bb2` are indexes into the `CFG` blocks.
602602
`bb1` dominates `bb2` if the only way to enter `bb2` is via `bb1`.
603603
(Other blocks may be in between, e.g `bb1->bbx->bb2`).
@@ -608,7 +608,7 @@ dominates(domtree::DomTree, bb1::BBNumber, bb2::BBNumber) =
608608
"""
609609
postdominates(domtree::PostDomTree, bb1::Int, bb2::Int)::Bool
610610
611-
Checks if `bb1` post-dominates `bb2`.
611+
Check if `bb1` post-dominates `bb2`.
612612
`bb1` and `bb2` are indexes into the `CFG` blocks.
613613
`bb1` post-dominates `bb2` if every pass from `bb2` to the exit is via `bb1`.
614614
(Other blocks may be in between, e.g `bb2->bbx->bb1->exit`).

JuliaLowering/src/macro_expansion.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ function expand_macro(ctx, ex)
300300
else
301301
# Compat: attempt to invoke an old-style macro if there's no applicable
302302
# method for new-style macro arguments.
303-
macro_args = Any[macro_loc, current_layer(ctx).mod]
303+
macro_args = Any[macro_loc, ctx.scope_layers[1].mod]
304304
for arg in raw_args
305305
# For hygiene in old-style macros, we omit any additional scope
306306
# layer information from macro arguments. Old-style macros will
@@ -335,7 +335,6 @@ function expand_macro(ctx, ex)
335335
# method was defined (may be different from `parentmodule(macfunc)`)
336336
mod_for_ast = lookup_method_instance(macfunc, macro_args,
337337
ctx.macro_world).def.module
338-
expanded = fix_toplevel_expansion(ctx, expanded, mod_for_ast, macro_loc)
339338
new_layer = ScopeLayer(length(ctx.scope_layers)+1, mod_for_ast,
340339
current_layer_id(ctx), true)
341340
push_layer!(ctx, mod_for_ast, true)
@@ -454,6 +453,9 @@ function expand_forms_1(ctx::MacroExpansionContext, ex::SyntaxTree)
454453
end
455454
elseif k == K"macrocall"
456455
expand_macro(ctx, ex)
456+
elseif k == K"toplevel" && length(ctx.scope_layer_stack) > 1
457+
fix_toplevel_expansion(ctx, ex, current_layer(ctx).mod,
458+
source_location(LineNumberNode, ex))
457459
elseif k == K"module" || k == K"toplevel" || k == K"inert"
458460
# Remove scope layer information from any inert syntax which survives
459461
# macro expansion so that it doesn't contaminate lowering passes which

JuliaLowering/test/macros.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,37 @@ end
483483
@test_broken JuliaLowering.eval(test_mod, code) == ("outer x", "inner x")
484484
end
485485

486+
@testset "toplevel macro hygiene" begin
487+
@eval test_mod global mod = $test_mod
488+
@eval test_mod module MacroMod
489+
global mod = MacroMod
490+
macro escaped_toplevel()
491+
esc(Expr(:toplevel, :(mod)))
492+
end
493+
macro inner_escaped_toplevel()
494+
Expr(:toplevel, esc(:(mod)))
495+
end
496+
macro unescaped_toplevel()
497+
Expr(:toplevel, :(mod))
498+
end
499+
end
500+
@test JuliaLowering.include_string(test_mod, "MacroMod.@escaped_toplevel") === test_mod
501+
@test JuliaLowering.include_string(test_mod, "MacroMod.@inner_escaped_toplevel") === test_mod
502+
@test JuliaLowering.include_string(test_mod, "MacroMod.@unescaped_toplevel") === test_mod.MacroMod
503+
end
504+
505+
# JuliaLang/JuliaLowering.jl#120
506+
#
507+
# `__module__` should be expanded as the lexical module containing the expanded
508+
# code, not the module corresponding to the current hygienic scope
509+
JuliaLowering.include_string(test_mod, raw"""
510+
module Mod1
511+
macro indirect_MODULE()
512+
return :(@__MODULE__())
513+
end
514+
end
515+
""")
516+
code = JuliaLowering.include_string(test_mod, """Mod1.@indirect_MODULE()""")
517+
@test JuliaLowering.eval(test_mod, code) === test_mod # !== test_mod.Mod1
518+
486519
end

Make.inc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,11 +1508,9 @@ RPATH_LIB := $(RPATH_ORIGIN)
15081508

15091509
# --whole-archive
15101510
ifeq ($(OS), Darwin)
1511-
WHOLE_ARCHIVE := -Xlinker -all_load
1512-
NO_WHOLE_ARCHIVE :=
1511+
whole_archive = -Xlinker -force_load $(1)
15131512
else
1514-
WHOLE_ARCHIVE := -Wl,--whole-archive
1515-
NO_WHOLE_ARCHIVE := -Wl,--no-whole-archive
1513+
whole_archive = -Wl,--whole-archive $(1) -Wl,--no-whole-archive
15161514
endif
15171515

15181516
# Initialize these once, then add to them in OS-specific blocks
@@ -1558,8 +1556,7 @@ ifeq (,$(findstring aarch64,$(ARCH)))
15581556
OSLIBS += -lgcc_s
15591557
endif
15601558

1561-
OSLIBS += -Wl,--export-dynamic -Wl,--version-script=$(BUILDROOT)/src/julia.expmap \
1562-
$(NO_WHOLE_ARCHIVE)
1559+
OSLIBS += -Wl,--export-dynamic -Wl,--version-script=$(BUILDROOT)/src/julia.expmap -Wl,--no-whole-archive
15631560
endif
15641561

15651562
ifeq ($(OS), OpenBSD)
@@ -1578,16 +1575,14 @@ endif
15781575
ifeq ($(OS), Darwin)
15791576
SHLIB_EXT := dylib
15801577
OSLIBS += -framework CoreFoundation
1581-
WHOLE_ARCHIVE := -Xlinker -all_load
1582-
NO_WHOLE_ARCHIVE :=
15831578
HAVE_SSP := 1
15841579
JLIBLDFLAGS += -Wl,-compatibility_version,$(SOMAJOR) -Wl,-current_version,$(JULIA_MAJOR_VERSION).$(JULIA_MINOR_VERSION).$(JULIA_PATCH_VERSION)
15851580
endif
15861581

15871582
ifeq ($(OS), WINNT)
15881583
HAVE_SSP := 1
15891584
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(BUILDROOT)/src/julia.expmap \
1590-
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic -lole32
1585+
-Wl,--no-whole-archive -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic -lole32
15911586
# N.B.: Unlike in the sysimage, we cannot -Wl,--disable-auto-import -Wl,--disable-runtime-pseudo-reloc here, because libstdc++/LLVM are not fully correct under
15921587
# enforced visibility at this point.
15931588
JLDFLAGS += -Wl,--stack,8388608

base/abstractset.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ function ⊋ end
401401
⊊(a, b)::Bool
402402
⊋(b, a)::Bool
403403
404-
Determines if `a` is a subset of, but not equal to, `b`.
404+
Determine if `a` is a subset of, but not equal to, `b`.
405405
406406
See also [`issubset`](@ref) (`⊆`), [`⊈`](@ref).
407407

base/channels.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ popfirst!(c::AbstractChannel) = take!(c)
1313
"""
1414
Channel{T=Any}(size::Int=0)
1515
16-
Constructs a `Channel` with an internal buffer that can hold a maximum of `size` objects
16+
Construct a `Channel` with an internal buffer that can hold a maximum of `size` objects
1717
of type `T`.
1818
[`put!`](@ref) calls on a full channel block until an object is removed with [`take!`](@ref).
1919
@@ -214,7 +214,7 @@ end
214214
"""
215215
isopen(c::Channel)
216216
217-
Determines whether a [`Channel`](@ref) is open for new [`put!`](@ref) operations.
217+
Determine whether a [`Channel`](@ref) is open for new [`put!`](@ref) operations.
218218
Notice that a `Channel` can be closed and still have buffered elements which can be
219219
consumed with [`take!`](@ref).
220220
@@ -555,7 +555,7 @@ end
555555
"""
556556
isready(c::Channel)
557557
558-
Determines whether a [`Channel`](@ref) has a value stored in it.
558+
Determine whether a [`Channel`](@ref) has a value stored in it.
559559
Returns immediately, does not block.
560560
561561
For unbuffered channels, return `true` if there are tasks waiting on a [`put!`](@ref).
@@ -600,7 +600,7 @@ end
600600
"""
601601
isfull(c::Channel)
602602
603-
Determines if a [`Channel`](@ref) is full, in the sense
603+
Determine if a [`Channel`](@ref) is full, in the sense
604604
that calling `put!(c, some_value)` would have blocked.
605605
Returns immediately, does not block.
606606
@@ -646,7 +646,7 @@ trylock(c::Channel) = trylock(c.cond_take)
646646
"""
647647
wait(c::Channel)
648648
649-
Blocks until the `Channel` [`isready`](@ref).
649+
Block until the `Channel` [`isready`](@ref).
650650
651651
```jldoctest
652652
julia> c = Channel(1);

base/deprecated.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ end
538538
"""
539539
isbindingresolved(m::Module, s::Symbol) -> Bool
540540
541-
Returns whether the binding of a symbol in a module is resolved.
541+
Return whether the binding of a symbol in a module is resolved.
542542
543543
See also: [`isexported`](@ref), [`ispublic`](@ref), [`isdeprecated`](@ref)
544544

base/docs/basedocs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3199,7 +3199,7 @@ undef
31993199
"""
32003200
Ptr{T}()
32013201
3202-
Creates a null pointer to type `T`.
3202+
Create a null pointer to type `T`.
32033203
"""
32043204
Ptr{T}()
32053205

0 commit comments

Comments
 (0)