Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some nospecialization hacks #43087

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/idset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ IdSet{T}(itr) where {T} = union!(IdSet{T}(), itr)
IdSet() = IdSet{Any}()

copymutable(s::IdSet) = typeof(s)(s)
emptymutable(s::IdSet{T}, ::Type{U}=T) where {T,U} = IdSet{U}()
copy(s::IdSet) = typeof(s)(s)

isempty(s::IdSet) = isempty(s.dict)
Expand Down
16 changes: 8 additions & 8 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ Determine whether type `T` was declared as a mutable type
!!! compat "Julia 1.7"
This function requires at least Julia 1.7.
"""
function ismutabletype(@nospecialize(t::Type))
function ismutabletype(@nospecialize t)
t = unwrap_unionall(t)
# TODO: what to do for `Union`?
return isa(t, DataType) && t.name.flags & 0x2 == 0x2
Expand All @@ -496,7 +496,7 @@ end
Determine whether type `T` was declared as a struct type
(i.e. using the `struct` or `mutable struct` keyword).
"""
function isstructtype(@nospecialize(t::Type))
function isstructtype(@nospecialize t)
@_pure_meta
t = unwrap_unionall(t)
# TODO: what to do for `Union`?
Expand All @@ -511,7 +511,7 @@ end
Determine whether type `T` was declared as a primitive type
(i.e. using the `primitive` keyword).
"""
function isprimitivetype(@nospecialize(t::Type))
function isprimitivetype(@nospecialize t)
@_pure_meta
t = unwrap_unionall(t)
# TODO: what to do for `Union`?
Expand Down Expand Up @@ -543,7 +543,7 @@ julia> isbitstype(Complex)
false
```
"""
isbitstype(@nospecialize(t::Type)) = (@_pure_meta; isa(t, DataType) && (t.flags & 0x8) == 0x8)
isbitstype(@nospecialize t) = (@_pure_meta; isa(t, DataType) && (t.flags & 0x8) == 0x8)

"""
isbits(x)
Expand Down Expand Up @@ -1199,7 +1199,7 @@ end
Similar to [`code_typed`](@ref), except the argument is a tuple type describing
a full signature to query.
"""
function code_typed_by_type(@nospecialize(tt::Type);
function code_typed_by_type(@nospecialize(tt#=::Type=#);
optimize=true,
debuginfo::Symbol=:default,
world = get_world_counter(),
Expand Down Expand Up @@ -1276,7 +1276,7 @@ function print_statement_costs(io::IO, @nospecialize(f), @nospecialize(t); kwarg
print_statement_costs(io, tt; kwargs...)
end

function print_statement_costs(io::IO, @nospecialize(tt::Type);
function print_statement_costs(io::IO, @nospecialize(tt#=::Type=#);
world = get_world_counter(),
interp = Core.Compiler.NativeInterpreter(world))
matches = _methods_by_ftype(tt, -1, world)
Expand Down Expand Up @@ -1306,7 +1306,7 @@ end

print_statement_costs(args...; kwargs...) = print_statement_costs(stdout, args...; kwargs...)

function _which(@nospecialize(tt::Type), world=get_world_counter())
function _which(@nospecialize(tt#=::Type=#), world=get_world_counter())
min_valid = RefValue{UInt}(typemin(UInt))
max_valid = RefValue{UInt}(typemax(UInt))
match = ccall(:jl_gf_invoke_lookup_worlds, Any,
Expand Down Expand Up @@ -1341,7 +1341,7 @@ end

Returns the method that would be called by the given type signature (as a tuple type).
"""
function which(@nospecialize(tt::Type))
function which(@nospecialize(tt#=::Type=#))
return _which(tt).method
end

Expand Down