before_code stringlengths 30 149k | reviewer_comment stringlengths 16 20.6k | after_code stringlengths 30 163k | diff_context stringlengths 0 22.4k | file_path stringlengths 6 155 | comment_line int64 0 26 | language stringclasses 19
values | quality_score float64 0.07 1 | comment_type stringclasses 9
values | comment_length int64 16 20.6k | before_lines int64 2 4.61k | after_lines int64 2 4.4k | is_negative bool 2
classes | pr_title stringlengths 7 140 | pr_number int64 18 61.2k | repo_name stringclasses 29
values | repo_stars int64 321 56k | repo_language stringclasses 14
values | reviewer_username stringclasses 378
values | author_username stringclasses 739
values | user stringlengths 361 200k | assistant stringlengths 16 20.6k | system stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
```
"""
randsubseq!(S::AbstractArray, A::AbstractArray, p::Real) = randsubseq!(default_rng(), S, A, p)
randsubseq(r::AbstractRNG, A::AbstractArray{T}, p::Real) where {T} =
randsubseq!(r, T[], A, p)
"""
randsubseq([rng=default_rng(),] A, p) -> Vector
Return a vector consisting of a random subsequence of the g... | Although this is not exported, I see that it is referenced in at least two packages:
SimpleChains.jl: https://github.com/PumasAI/SimpleChains.jl/blob/f028d69679d47f11d35e7f311abdf0d1d3bfab9c/src/utils.jl#L114
REPLference.jl: https://github.com/udohjeremiah/REPLference.jl/blob/f3801aac2713ee5f19705513d8318e0923e0b... | randsubseq(r::AbstractRNG, A::AbstractArray{T}, p::Real) where {T} =
randsubseq!(r, T[], A, p)
"""
randsubseq([rng=default_rng(),] A, p) -> Vector
Return a vector consisting of a random subsequence of the given array `A`, where each
element of `A` is included (in order) with independent probability `p`. (Comp... | @@ -182,11 +182,6 @@ julia> randsubseq(rng, 1:8, 0.3)
randsubseq(A::AbstractArray, p::Real) = randsubseq(default_rng(), A, p)
-## rand Less Than Masked 52 bits (helper function)
-
-"Return a sampler generating a random `Int` (masked with `mask`) in ``[0, n)``, when `n <= 2^52`."
-ltm52(n::Int, mask::Int=nextpow(2,... | stdlib/Random/src/misc.jl | 26 | Julia | 0.5 | question | 464 | 51 | 51 | false | speed-up `randperm` by using our current `rand(1:n)` | 50,509 | JuliaLang/julia | 35,573 | Julia | stevengj | rfourquet | Review this pull request change.
Language: Julia
File: stdlib/Random/src/misc.jl
PR Title: speed-up `randperm` by using our current `rand(1:n)`
BEFORE CODE: ```
"""
randsubseq!(S::AbstractArray, A::AbstractArray, p::Real) = randsubseq!(default_rng(), S, A, p)
randsubseq(r::AbstractRNG, A::AbstractArray{T}, p::Real... | Although this is not exported, I see that it is referenced in at least two packages:
SimpleChains.jl: https://github.com/PumasAI/SimpleChains.jl/blob/f028d69679d47f11d35e7f311abdf0d1d3bfab9c/src/utils.jl#L114
REPLference.jl: https://github.com/udohjeremiah/REPLference.jl/blob/f3801aac2713ee5f19705513d8318e0923e0b... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
return a
end
function shuffle!(r::AbstractRNG, a::AbstractArray{Bool})
old_count = count(a)
len = length(a)
uncommon_value = 2old_count <= len
fuel = uncommon_value ? old_count : len - old_count
fuel == 0 && return a
a .= !uncommon_value
while fuel > 0
k = rand(r, eachin... | Can we delete this `@inbounds`, given that this is out-of-bounds for OffsetArrays? Benchmarking in #57771 suggests this `@inbounds` has almost no effect on speed.
Edit: Ah, there is a `require_one_based_indexing` above. Nonetheless. | ntuple(closure, Val{N}())
end
end
"""
shuffle!([rng=default_rng(),] v::AbstractArray)
In-place version of [`shuffle`](@ref): randomly permute `v` in-place,
optionally supplying the random-number generator `rng`.
# Examples
```jldoctest
julia> shuffle!(Xoshiro(0), Vector(1:6))
6-element Vector{Int64}:... | @@ -191,31 +186,22 @@ optionally supplying the random-number generator `rng`.
# Examples
```jldoctest
-julia> shuffle!(Xoshiro(123), Vector(1:10))
-10-element Vector{Int64}:
- 5
- 4
- 2
- 3
- 6
- 10
- 8
- 1
- 9
- 7
+julia> shuffle!(Xoshiro(0), Vector(1:6))
+6-element Vector{Int64}:
+ 5
+ 1
+ 2
+ 6
+ 3
+ 4
... | stdlib/Random/src/misc.jl | 26 | Julia | 0.571 | question | 233 | 51 | 51 | false | speed-up `randperm` by using our current `rand(1:n)` | 50,509 | JuliaLang/julia | 35,573 | Julia | jakobnissen | rfourquet | Review this pull request change.
Language: Julia
File: stdlib/Random/src/misc.jl
PR Title: speed-up `randperm` by using our current `rand(1:n)`
BEFORE CODE: end
return a
end
function shuffle!(r::AbstractRNG, a::AbstractArray{Bool})
old_count = count(a)
len = length(a)
uncommon_value = 2old_coun... | Can we delete this `@inbounds`, given that this is out-of-bounds for OffsetArrays? Benchmarking in #57771 suggests this `@inbounds` has almost no effect on speed.
Edit: Ah, there is a `require_one_based_indexing` above. Nonetheless. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
return a
end
function shuffle!(r::AbstractRNG, a::AbstractArray{Bool})
old_count = count(a)
len = length(a)
uncommon_value = 2old_count <= len
fuel = uncommon_value ? old_count : len - old_count
fuel == 0 && return a
a .= !uncommon_value
while fuel > 0
k = rand(r, eachin... | ```suggestion
for i = 2:length(a)
``` | ntuple(closure, Val{N}())
end
end
"""
shuffle!([rng=default_rng(),] v::AbstractArray)
In-place version of [`shuffle`](@ref): randomly permute `v` in-place,
optionally supplying the random-number generator `rng`.
# Examples
```jldoctest
julia> shuffle!(Xoshiro(0), Vector(1:6))
6-element Vector{Int64}:... | @@ -191,31 +186,22 @@ optionally supplying the random-number generator `rng`.
# Examples
```jldoctest
-julia> shuffle!(Xoshiro(123), Vector(1:10))
-10-element Vector{Int64}:
- 5
- 4
- 2
- 3
- 6
- 10
- 8
- 1
- 9
- 7
+julia> shuffle!(Xoshiro(0), Vector(1:6))
+6-element Vector{Int64}:
+ 5
+ 1
+ 2
+ 6
+ 3
+ 4
... | stdlib/Random/src/misc.jl | 26 | Julia | 0.429 | suggestion | 43 | 51 | 51 | false | speed-up `randperm` by using our current `rand(1:n)` | 50,509 | JuliaLang/julia | 35,573 | Julia | jakobnissen | rfourquet | Review this pull request change.
Language: Julia
File: stdlib/Random/src/misc.jl
PR Title: speed-up `randperm` by using our current `rand(1:n)`
BEFORE CODE: end
return a
end
function shuffle!(r::AbstractRNG, a::AbstractArray{Bool})
old_count = count(a)
len = length(a)
uncommon_value = 2old_coun... | ```suggestion
for i = 2:length(a)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
```
"""
randperm(r::AbstractRNG, n::T) where {T <: Integer} = randperm!(r, Vector{T}(undef, n))
randperm(n::Integer) = randperm(default_rng(), n)
"""
randperm!([rng=default_rng(),] A::Array{<:Integer})
Construct in `A` a random permutation of length `length(A)`. The
optional `rng` argument specifies a random numb... | Any reason this, and `randcycle!` are not defined for `AbstractArray`? |
shuffle(r::AbstractRNG, a::AbstractArray) = shuffle!(r, copymutable(a))
shuffle(a::Union{NTuple, AbstractArray}) = shuffle(default_rng(), a)
shuffle(r::AbstractRNG, a::Base.OneTo) = randperm(r, last(a))
## randperm & randperm!
"""
randperm([rng=default_rng(),] n::Integer)
Construct a random permutation of leng... | @@ -306,28 +290,27 @@ optional `rng` argument specifies a random number generator (see
# Examples
```jldoctest
-julia> randperm!(Xoshiro(123), Vector{Int}(undef, 4))
-4-element Vector{Int64}:
+julia> randperm!(Xoshiro(0), Vector{Int}(undef, 6))
+6-element Vector{Int64}:
+ 5
1
- 4
2
+ 6
3
+ 4
```
"""
-functi... | stdlib/Random/src/misc.jl | 26 | Julia | 0.357 | refactor | 70 | 51 | 51 | false | speed-up `randperm` by using our current `rand(1:n)` | 50,509 | JuliaLang/julia | 35,573 | Julia | jakobnissen | rfourquet | Review this pull request change.
Language: Julia
File: stdlib/Random/src/misc.jl
PR Title: speed-up `randperm` by using our current `rand(1:n)`
BEFORE CODE: ```
"""
randperm(r::AbstractRNG, n::T) where {T <: Integer} = randperm!(r, Vector{T}(undef, n))
randperm(n::Integer) = randperm(default_rng(), n)
"""
rand... | Any reason this, and `randcycle!` are not defined for `AbstractArray`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
function getindex(v::AbstractRange{T}, i::Integer) where T
@inline
i isa Bool && throw(ArgumentError("invalid index: $i of type Bool"))
@boundscheck checkbounds(v, i)
convert(T, first(v) + (i - oneunit(i))*step_hp(v))
end
let BitInteger64 = Union{Int8,Int16,Int32,Int64,UInt8,UInt16,UInt32,UInt64} # for... | I wonder if a better fix would be
```julia
u = oftype(r.offset, i) - r.offset
```
since if the number wasn't representable as the type of the offset, then it was out of bounds anyways. and this cast should typically be free. | function getindex(v::AbstractRange{T}, i::Integer) where T
@inline
i isa Bool && throw(ArgumentError("invalid index: $i of type Bool"))
@boundscheck checkbounds(v, i)
convert(T, first(v) + (i - oneunit(i))*step_hp(v))
end
let BitInteger64 = Union{Int8,Int16,Int32,Int64,UInt8,UInt16,UInt32,UInt64} # for... | @@ -963,14 +963,24 @@ end
# This is separate to make it useful even when running with --check-bounds=yes
function unsafe_getindex(r::StepRangeLen{T}, i::Integer) where T
i isa Bool && throw(ArgumentError("invalid index: $i of type Bool"))
- u = i - r.offset | base/range.jl | 26 | Julia | 1 | suggestion | 228 | 51 | 51 | false | Make ranges more robust with unsigned indexes. | 50,823 | JuliaLang/julia | 35,573 | Julia | vtjnash | gbaraldi | Review this pull request change.
Language: Julia
File: base/range.jl
PR Title: Make ranges more robust with unsigned indexes.
BEFORE CODE: function getindex(v::AbstractRange{T}, i::Integer) where T
@inline
i isa Bool && throw(ArgumentError("invalid index: $i of type Bool"))
@boundscheck checkbounds(v, i... | I wonder if a better fix would be
```julia
u = oftype(r.offset, i) - r.offset
```
since if the number wasn't representable as the type of the offset, then it was out of bounds anyways. and this cast should typically be free. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earlier versions of Julia, Channel used keyword arguments to set `size` and `T`, but
those constructors are deprecated.
!!! compat "Julia 1.9"
The `threadpool=` parameter was added in Julia 1.9.
```jldoctest
jul... | ```suggestion
Threads._spawn_set_thrpool(task, threadpool)
``` |
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earlier versions of Julia, Channel used keyword arguments to set `size` and `T`, but
those constructors are deprecated.
!!! compat "Julia 1.9"
The `threadpool=` argument was added in Julia... | @@ -129,12 +135,13 @@ julia> String(collect(chnl))
"hello world"
```
"""
-function Channel{T}(func::Function, size=0; taskref=nothing, spawn=false) where T
+function Channel{T}(func::Function, size=0; taskref=nothing, spawn=false, threadpool=:default) where T
chnl = Channel{T}(size)
task = Task(() -> func(... | base/channels.jl | 26 | Julia | 0.714 | suggestion | 72 | 51 | 51 | false | Add a `threadpool` parameter to `Channel` constructor | 50,858 | JuliaLang/julia | 35,573 | Julia | nickrobinson251 | kpamnany | Review this pull request change.
Language: Julia
File: base/channels.jl
PR Title: Add a `threadpool` parameter to `Channel` constructor
BEFORE CODE: The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earlier versions of Julia, Channel used keyword arguments to set `si... | ```suggestion
Threads._spawn_set_thrpool(task, threadpool)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earlier versions of Julia, Channel used keyword arguments to set `size` and `T`, but
those constructors are deprecated.
!!! compat "Julia 1.9"
The `t... | Please add a few unit tests.
At least:
- testing that the task is created on the expected threadpool, for both options
- testing the default, if it's not set
- testing what happens if you set threadpool but spawn=false.
- testing garbage values for this flag | julia> put!(chnl, "Hello");
Hello
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earlier versions of Julia, Channel used keyword arguments to set `size` and `T`, but
those constructors are deprecated.
... | @@ -129,12 +135,13 @@ julia> String(collect(chnl))
"hello world"
```
"""
-function Channel{T}(func::Function, size=0; taskref=nothing, spawn=false) where T
+function Channel{T}(func::Function, size=0; taskref=nothing, spawn=false, threadpool=:default) where T | base/channels.jl | 26 | Julia | 0.571 | nitpick | 265 | 51 | 51 | false | Add a `threadpool` parameter to `Channel` constructor | 50,858 | JuliaLang/julia | 35,573 | Julia | NHDaly | kpamnany | Review this pull request change.
Language: Julia
File: base/channels.jl
PR Title: Add a `threadpool` parameter to `Channel` constructor
BEFORE CODE:
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earli... | Please add a few unit tests.
At least:
- testing that the task is created on the expected threadpool, for both options
- testing the default, if it's not set
- testing what happens if you set threadpool but spawn=false.
- testing garbage values for this flag | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earlier versions of Julia, Channel used keyword arguments to set `size` and `T`, but
those constructors are deprecated.
!!! compat "Julia 1.9"
The `t... | What should we do if someone sets `threadpool=:interactive` or `threadpool=:default` but forgets to set `spawn=true`? Right now, it'll be silently ignored, which isn't very user-friendly.
An alternative could be to default to `threadpool=nothing`, which allows us to detect _whether it was explicitly set by the calle... | julia> put!(chnl, "Hello");
Hello
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earlier versions of Julia, Channel used keyword arguments to set `size` and `T`, but
those constructors are deprecated.
... | @@ -129,12 +135,13 @@ julia> String(collect(chnl))
"hello world"
```
"""
-function Channel{T}(func::Function, size=0; taskref=nothing, spawn=false) where T
+function Channel{T}(func::Function, size=0; taskref=nothing, spawn=false, threadpool=:default) where T | base/channels.jl | 26 | Julia | 1 | question | 812 | 51 | 51 | false | Add a `threadpool` parameter to `Channel` constructor | 50,858 | JuliaLang/julia | 35,573 | Julia | NHDaly | kpamnany | Review this pull request change.
Language: Julia
File: base/channels.jl
PR Title: Add a `threadpool` parameter to `Channel` constructor
BEFORE CODE:
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earli... | What should we do if someone sets `threadpool=:interactive` or `threadpool=:default` but forgets to set `spawn=true`? Right now, it'll be silently ignored, which isn't very user-friendly.
An alternative could be to default to `threadpool=nothing`, which allows us to detect _whether it was explicitly set by the calle... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earlier versions of Julia, Channel used keyword arguments to set `size` and `T`, but
those constructors are deprecated.
!!! compat "Julia 1.9"
The `t... | Also also: do we need to do error-checking for other flag values besides `:default` and `:interactive`? or does that happen inside _spawn_set_thrpool? | julia> put!(chnl, "Hello");
Hello
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earlier versions of Julia, Channel used keyword arguments to set `size` and `T`, but
those constructors are deprecated.
... | @@ -129,12 +135,13 @@ julia> String(collect(chnl))
"hello world"
```
"""
-function Channel{T}(func::Function, size=0; taskref=nothing, spawn=false) where T
+function Channel{T}(func::Function, size=0; taskref=nothing, spawn=false, threadpool=:default) where T | base/channels.jl | 26 | Julia | 0.643 | question | 150 | 51 | 51 | false | Add a `threadpool` parameter to `Channel` constructor | 50,858 | JuliaLang/julia | 35,573 | Julia | NHDaly | kpamnany | Review this pull request change.
Language: Julia
File: base/channels.jl
PR Title: Add a `threadpool` parameter to `Channel` constructor
BEFORE CODE:
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` parameter was added in Julia 1.3. This constructor was added in Julia 1.3.
In earli... | Also also: do we need to do error-checking for other flag values besides `:default` and `:interactive`? or does that happen inside _spawn_set_thrpool? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Referencing the created task:
```jldoctest
julia> taskref = Ref{Task}();
julia> chnl = Channel(taskref=taskref) do ch
println(take!(ch))
end;
julia> istaskdone(taskref[])
false
julia> put!(chnl, "Hello");
Hello
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` paramet... | ```suggestion
The `threadpool` argument was added in Julia 1.9.
``` | ```
Referencing the created task:
```jldoctest
julia> taskref = Ref{Task}();
julia> chnl = Channel(taskref=taskref) do ch
println(take!(ch))
end;
julia> istaskdone(taskref[])
false
julia> put!(chnl, "Hello");
Hello
julia> istaskdone(taskref[])
true
```
!!! compat "Julia 1.3"
The `spawn=` pa... | @@ -117,6 +120,9 @@ true
In earlier versions of Julia, Channel used keyword arguments to set `size` and `T`, but
those constructors are deprecated.
+!!! compat "Julia 1.9"
+ The `threadpool=` parameter was added in Julia 1.9. | base/channels.jl | 26 | Julia | 0.714 | suggestion | 73 | 51 | 51 | false | Add a `threadpool` parameter to `Channel` constructor | 50,858 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | kpamnany | Review this pull request change.
Language: Julia
File: base/channels.jl
PR Title: Add a `threadpool` parameter to `Channel` constructor
BEFORE CODE: Referencing the created task:
```jldoctest
julia> taskref = Ref{Task}();
julia> chnl = Channel(taskref=taskref) do ch
println(take!(ch))
end;
juli... | ```suggestion
The `threadpool` argument was added in Julia 1.9.
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
chnl = Channel{T}(size)
task = Task(() -> func(chnl))
if threadpool === nothing
threadpool = :default
else
spawn = true
end
task.sticky = !spawn
bind(chnl, task)
if spawn
Threads._spawn_set_thrpool(task, threadpool)
schedule(task) # start it on (potentiall... | This whole constructor is deprecated. It's probably easiest to just leave the new parameter off, so that people will get a method error if they try to set it, and that will move them to the new API.
Or you could change line 170 to also throw if they set threadpool. | chnl = Channel{T}(size)
task = Task(() -> func(chnl))
if threadpool === nothing
threadpool = :default
else
spawn = true
end
task.sticky = !spawn
bind(chnl, task)
if spawn
Threads._spawn_set_thrpool(task, threadpool)
schedule(task) # start it on (potentiall... | @@ -149,7 +163,7 @@ Channel(func::Function, args...; kwargs...) = Channel{Any}(func, args...; kwargs
# of course not deprecated.)
# We use `nothing` default values to check which arguments were set in order to throw the
# deprecation warning if users try to use `spawn=` with `ctype=` or `csize=`.
-function Channel(f... | base/channels.jl | 26 | Julia | 0.643 | suggestion | 268 | 51 | 51 | false | Add a `threadpool` parameter to `Channel` constructor | 50,858 | JuliaLang/julia | 35,573 | Julia | NHDaly | kpamnany | Review this pull request change.
Language: Julia
File: base/channels.jl
PR Title: Add a `threadpool` parameter to `Channel` constructor
BEFORE CODE: chnl = Channel{T}(size)
task = Task(() -> func(chnl))
if threadpool === nothing
threadpool = :default
else
spawn = true
end
tas... | This whole constructor is deprecated. It's probably easiest to just leave the new parameter off, so that people will get a method error if they try to set it, and that will move them to the new API.
Or you could change line 170 to also throw if they set threadpool. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
tpid = ccall(:jl_threadpoolid, Int8, (Int16,), tid-1)
return _tpid_to_sym(tpid)
end
"""
Threads.nthreadpools() -> Int
Returns the number of threadpools currently configured.
"""
nthreadpools() = Int(unsafe_load(cglobal(:jl_n_threadpools, Cint)))
"""
Threads.threadpoolsize(pool::Symbol = :default) -> ... | either "not determinable" or "indeterminant" (this current spelling is archaic) | tpid = ccall(:jl_threadpoolid, Int8, (Int16,), tid-1)
return _tpid_to_sym(tpid)
end
"""
Threads.nthreadpools() -> Int
Returns the number of threadpools currently configured.
"""
nthreadpools() = Int(unsafe_load(cglobal(:jl_n_threadpools, Cint)))
"""
Threads.threadpoolsize(pool::Symbol = :default) -> ... | @@ -108,6 +112,8 @@ See also: `BLAS.get_num_threads` and `BLAS.set_num_threads` in the
function threadpoolsize(pool::Symbol = :default)
if pool === :default || pool === :interactive
tpid = _sym_to_tpid(pool)
+ elseif pool == :unassociated
+ error("Threadpool size of `:unassociated` is indetermi... | base/threadingconstructs.jl | 26 | Julia | 0.214 | nitpick | 79 | 51 | 51 | false | Separate foreign threads into a :foreign threadpool | 50,912 | JuliaLang/julia | 35,573 | Julia | vtjnash | vchuravy | Review this pull request change.
Language: Julia
File: base/threadingconstructs.jl
PR Title: Separate foreign threads into a :foreign threadpool
BEFORE CODE: tpid = ccall(:jl_threadpoolid, Int8, (Int16,), tid-1)
return _tpid_to_sym(tpid)
end
"""
Threads.nthreadpools() -> Int
Returns the number of thre... | either "not determinable" or "indeterminant" (this current spelling is archaic) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Returns the number of GC threads currently configured.
This includes both mark threads and concurrent sweep threads.
"""
ngcthreads() = Int(unsafe_load(cglobal(:jl_n_gcthreads, Cint))) + 1
function threading_run(fun, static)
ccall(:jl_enter_threaded_region, Cvoid, ())
n = threadpoolsize()
tid_offset = thre... | This is a behavior change, which probably shouldn't be in the same PR as a bugfix (we should backport this PR).
```suggestion
``` | Returns the number of GC threads currently configured.
This includes both mark threads and concurrent sweep threads.
"""
ngcthreads() = Int(unsafe_load(cglobal(:jl_n_gcthreads, Cint))) + 1
function threading_run(fun, static)
ccall(:jl_enter_threaded_region, Cvoid, ())
n = threadpoolsize()
tid_offset = thre... | @@ -151,11 +159,12 @@ function threading_run(fun, static)
else
# TODO: this should be the current pool (except interactive) if there
# are ever more than two pools.
- ccall(:jl_set_task_threadpoolid, Cint, (Any, Int8), t, _sym_to_tpid(:default))
+ @assert ccall(:... | base/threadingconstructs.jl | 26 | Julia | 0.929 | bug | 131 | 51 | 51 | false | Separate foreign threads into a :foreign threadpool | 50,912 | JuliaLang/julia | 35,573 | Julia | vtjnash | vchuravy | Review this pull request change.
Language: Julia
File: base/threadingconstructs.jl
PR Title: Separate foreign threads into a :foreign threadpool
BEFORE CODE: Returns the number of GC threads currently configured.
This includes both mark threads and concurrent sweep threads.
"""
ngcthreads() = Int(unsafe_load(cgloba... | This is a behavior change, which probably shouldn't be in the same PR as a bugfix (we should backport this PR).
```suggestion
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
DomainError(val, msg)
The argument `val` to a function or constructor is outside the valid domain.
# Examples
```jldoctest
julia> sqrt(-1)
ERROR: DomainError with -1.0:
sqrt was called with a negative real argument but will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stac... | ```suggestion
historic default for [`@async`](@ref). Sticky tasks can only be run on the thread
they are first scheduled on. To obtain the behavior of [`Threads.@spawn`](@ref) set the sticky
``` | DomainError(val, msg)
The argument `val` to a function or constructor is outside the valid domain.
# Examples
```jldoctest
julia> sqrt(-1)
ERROR: DomainError with -1.0:
sqrt was called with a negative real argument but will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stac... | @@ -1748,6 +1748,12 @@ Create a `Task` (i.e. coroutine) to execute the given function `func` (which
must be callable with no arguments). The task exits when this function returns.
The task will run in the "world age" from the parent at construction when [`schedule`](@ref)d.
+!!! warning
+ By default tasks will h... | base/docs/basedocs.jl | 26 | Julia | 0.929 | suggestion | 205 | 51 | 51 | false | Separate foreign threads into a :foreign threadpool | 50,912 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | vchuravy | Review this pull request change.
Language: Julia
File: base/docs/basedocs.jl
PR Title: Separate foreign threads into a :foreign threadpool
BEFORE CODE: DomainError(val, msg)
The argument `val` to a function or constructor is outside the valid domain.
# Examples
```jldoctest
julia> sqrt(-1)
ERROR: DomainError ... | ```suggestion
historic default for [`@async`](@ref). Sticky tasks can only be run on the thread
they are first scheduled on. To obtain the behavior of [`Threads.@spawn`](@ref) set the sticky
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
function _clear_input_area(terminal::AbstractTerminal, state::InputAreaState)
# Go to the last line
if state.curs_row < state.num_rows
cmove_down(terminal, state.num_rows - state.curs_row)
end
# Clear lines one by one going up
for j = 2:state.num_rows
clear_line(terminal)
cm... | what does this do? I assume `s.hint == ""` means that a possible previous hint should be deleted? a short comment explaining this would be useful | end
_clear_input_area(terminal, s.ias)
s.ias = InputAreaState(0, 0)
end
clear_input_area(terminal::AbstractTerminal, s::ModeState) = (_clear_input_area(terminal, s.ias); s.ias = InputAreaState(0, 0))
clear_input_area(s::ModeState) = clear_input_area(s.terminal, s)
function _clear_input_area(terminal::Abstr... | @@ -432,12 +456,27 @@ prompt_string(p::Prompt) = prompt_string(p.prompt)
prompt_string(s::AbstractString) = s
prompt_string(f::Function) = Base.invokelatest(f)
+function maybe_show_hint(s::PromptState)
+ isa(s.hint, String) || return nothing
+ if isempty(s.hint)
+ print(terminal(s), "\e[0K") | stdlib/REPL/src/LineEdit.jl | 26 | Julia | 0.571 | question | 146 | 51 | 51 | false | Add repl tab complete hints while typing | 51,229 | JuliaLang/julia | 35,573 | Julia | rfourquet | IanButterworth | Review this pull request change.
Language: Julia
File: stdlib/REPL/src/LineEdit.jl
PR Title: Add repl tab complete hints while typing
BEFORE CODE: function _clear_input_area(terminal::AbstractTerminal, state::InputAreaState)
# Go to the last line
if state.curs_row < state.num_rows
cmove_down(termina... | what does this do? I assume `s.hint == ""` means that a possible previous hint should be deleted? a short comment explaining this would be useful | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
function refresh_multi_line(termbuf::TerminalBuffer, terminal::UnixTerminal, buf::IOBuffer,
state::InputAreaState, prompt = "";
indent::Int = 0, region_active::Bool = false)
_clear_input_area(termbuf, state)
cols = width(terminal)
rows = height(termin... | I am experiencing frequent REPL corruption now where I lose part of the line or it prints wrong. For example, if you type
```
julia> using Cthu, REPL
```
then mouse back and change that to
```
julia> using Cthulhu, REPL
```
when you start typing, it will garble the rest of the line. Then when you type the final... | if state.curs_row < state.num_rows
cmove_down(terminal, state.num_rows - state.curs_row)
end
# Clear lines one by one going up
for j = 2:state.num_rows
clear_line(terminal)
cmove_up(terminal)
end
# Clear top line
clear_line(terminal)
nothing
end
prompt_string(s... | @@ -432,12 +463,29 @@ prompt_string(p::Prompt) = prompt_string(p.prompt)
prompt_string(s::AbstractString) = s
prompt_string(f::Function) = Base.invokelatest(f)
+function maybe_show_hint(s::PromptState)
+ isa(s.hint, String) || return nothing
+ # The hint being "" then nothing is used to first clear a previous... | stdlib/REPL/src/LineEdit.jl | 26 | Julia | 1 | bug | 420 | 51 | 51 | false | Add repl tab complete hints while typing | 51,229 | JuliaLang/julia | 35,573 | Julia | vtjnash | IanButterworth | Review this pull request change.
Language: Julia
File: stdlib/REPL/src/LineEdit.jl
PR Title: Add repl tab complete hints while typing
BEFORE CODE: function refresh_multi_line(termbuf::TerminalBuffer, terminal::UnixTerminal, buf::IOBuffer,
state::InputAreaState, prompt = "";
... | I am experiencing frequent REPL corruption now where I lose part of the line or it prints wrong. For example, if you type
```
julia> using Cthu, REPL
```
then mouse back and change that to
```
julia> using Cthulhu, REPL
```
when you start typing, it will garble the rest of the line. Then when you type the final... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
(void)info;
if (jl_get_safe_restore()) { // restarting jl_ or profile
jl_call_in_ctx(NULL, &jl_sig_throw, sig, context);
return;
}
jl_task_t *ct = jl_get_current_task();
if (ct == NULL || ct->eh == NULL) // exception on foreign thread is fatal
sigdie_handler(sig, info, contex... | ```suggestion
signal(sig, SIG_DFL);
sig = SIGILL; // redefine this as as an "unreachable reached" error message
sigdie_handler(sig, info, context);
``` | (void)info;
if (jl_get_safe_restore()) { // restarting jl_ or profile
jl_call_in_ctx(NULL, &jl_sig_throw, sig, context);
return;
}
jl_task_t *ct = jl_get_current_task();
if (ct == NULL || ct->eh == NULL) // exception on foreign thread is fatal
sigdie_handler(sig, info, contex... | @@ -994,6 +994,17 @@ static void sigint_handler(int sig)
jl_sigint_passed = 1;
}
+#if defined(_OS_DARWIN_) && defined(_CPU_AARCH64_)
+static void sigtrap_handler(int sig, siginfo_t *info, void *context)
+{
+ uintptr_t pc = ((ucontext_t*)context)->uc_mcontext->__ss.__pc; // TODO: Do this in linux as well
+ ... | src/signals-unix.c | 26 | C | 0.857 | suggestion | 179 | 51 | 51 | false | Avoid infinite loop when doing SIGTRAP in arm64-apple | 51,284 | JuliaLang/julia | 35,573 | Julia | vtjnash | gbaraldi | Review this pull request change.
Language: C
File: src/signals-unix.c
PR Title: Avoid infinite loop when doing SIGTRAP in arm64-apple
BEFORE CODE: (void)info;
if (jl_get_safe_restore()) { // restarting jl_ or profile
jl_call_in_ctx(NULL, &jl_sig_throw, sig, context);
return;
}
jl_tas... | ```suggestion
signal(sig, SIG_DFL);
sig = SIGILL; // redefine this as as an "unreachable reached" error message
sigdie_handler(sig, info, context);
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import Markdown
import StyledStrings
## Debugging options
# Disable parallel precompiles generation by setting `false`
const PARALLEL_PRECOMPILATION = true
# View the code sent to the repl by setting this to `stdout`
const debug_output = devnull # or stdout
CTRL_C = '\x03'
CTRL_D = '\x04'
CTRL_R = '\x12'
UP_ARROW =... | Why is this needed? Isn't the banner printed when the REPL is started? | function repl_workload()
# these are intentionally triggered
allowed_errors = [
"BoundsError: attempt to access 0-element Vector{Any} at index [1]",
"MethodError: no method matching f(::$Int, ::$Int)",
"Padding of type", # reinterpret docstring has ERROR examples
]
function check... | @@ -31,11 +32,14 @@ UP_ARROW = "\e[A"
DOWN_ARROW = "\e[B"
repl_script = """
+Base.load_terminfo("xterm")
2+2
print("")
printstyled("a", "b")
display([1])
display([1 2; 3 4])
+import REPL.banner
+banner() | stdlib/REPL/src/precompile.jl | 26 | Julia | 0.214 | question | 70 | 51 | 51 | false | Make banner size depend on terminal size | 51,811 | JuliaLang/julia | 35,573 | Julia | KristofferC | tecosaur | Review this pull request change.
Language: Julia
File: stdlib/REPL/src/precompile.jl
PR Title: Make banner size depend on terminal size
BEFORE CODE:
import Markdown
import StyledStrings
## Debugging options
# Disable parallel precompiles generation by setting `false`
const PARALLEL_PRECOMPILATION = true
# View t... | Why is this needed? Isn't the banner printed when the REPL is started? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
jl_options.cmds = cmds;
break;
}
case 'J': // sysimage
jl_options.image_file = strdup(optarg);
if (!jl_options.image_file)
jl_errorf("fatal error: failed to allocate memory: %s", strerror(errno));
jl_options.image_file_specified... | The 0-100 option is not self explanatory, it should be documented.
If we're making banner size adaptive then maybe we should remove the short option without replacement. | { "version", no_argument, 0, 'v' },
{ "help", no_argument, 0, 'h' },
{ "help-hidden", no_argument, 0, opt_help_hidden },
{ "interactive", no_argument, 0, 'i' },
{ "quiet", no_argument, 0, 'q' },
{ "banner"... | @@ -439,15 +439,20 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
break;
case opt_banner: // banner
if (!strcmp(optarg, "yes"))
- jl_options.banner = 1;
+ jl_options.banner = 10;
else if (!strcmp(optarg, "no"))
... | src/jloptions.c | 26 | C | 0.429 | suggestion | 172 | 51 | 51 | false | Make banner size depend on terminal size | 51,811 | JuliaLang/julia | 35,573 | Julia | LilithHafner | tecosaur | Review this pull request change.
Language: C
File: src/jloptions.c
PR Title: Make banner size depend on terminal size
BEFORE CODE: jl_options.cmds = cmds;
break;
}
case 'J': // sysimage
jl_options.image_file = strdup(optarg);
if (!jl_options.image_file... | The 0-100 option is not self explanatory, it should be documented.
If we're making banner size adaptive then maybe we should remove the short option without replacement. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
end
isnothing(j) && break
if match[1] == '#'
print(buf, SubString(code, pos, prevind(code, first(i))))
else
print(buf, SubString(code, pos, last(i)), ' ', SubString(code, j))
end
pos = nextind(cod... | What is size measured in? Is it rows/why custom rows and not custom columns? | transition(s, help_mode) do
LineEdit.state(s, help_mode).input_buffer = buf
end
else
edit_insert(s, '?')
LineEdit.check_show_hint(s)
end
end,
']' => function (s::MIState,o...)
if isemp... | @@ -1479,11 +1479,17 @@ ends_with_semicolon(code::AbstractString) = ends_with_semicolon(String(code))
ends_with_semicolon(code::Union{String,SubString{String}}) =
contains(_rm_strings_and_comments(code), r";\s*$")
-function banner(io::IO = stdout; short = false)
- if Base.GIT_VERSION_INFO.tagged_commit
- ... | stdlib/REPL/src/REPL.jl | 26 | Julia | 0.214 | question | 76 | 51 | 51 | false | Make banner size depend on terminal size | 51,811 | JuliaLang/julia | 35,573 | Julia | LilithHafner | tecosaur | Review this pull request change.
Language: Julia
File: stdlib/REPL/src/REPL.jl
PR Title: Make banner size depend on terminal size
BEFORE CODE: end
end
isnothing(j) && break
if match[1] == '#'
print(buf, SubString(code, pos, prevind(code, first(i)))... | What is size measured in? Is it rows/why custom rows and not custom columns? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# load interactive-only libraries
try
return Base.require(PkgId(UUID(0x3fa0cd96_eef1_5676_8a61_b3b8758bbffb), "REPL"))
catch ex
@warn "Failed to import REPL" exception=(ex, catch_backtrace())
end
return nothing
end
global active_repl
# run the requested sort of evaluation loop on s... | If auto -1, will this prevent the banner from showing by default? | for f in repl_hooks
try
f(repl)
catch err
showerror(stderr, err)
println(stderr)
end
end
end
_atreplinit(repl) = invokelatest(__atreplinit, repl)
function load_InteractiveUtils(mod::Module=Main)
# load interactive-only libraries
if !isdefined(... | @@ -424,7 +424,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_f
invokelatest(REPL_MODULE_REF[]) do REPL
term_env = get(ENV, "TERM", @static Sys.iswindows() ? "" : "dumb")
term = REPL.Terminals.TTYTerminal(term_env, stdin, stdout, stderr)
- ... | base/client.jl | 26 | Julia | 0.214 | question | 65 | 51 | 51 | false | Make banner size depend on terminal size | 51,811 | JuliaLang/julia | 35,573 | Julia | LilithHafner | tecosaur | Review this pull request change.
Language: Julia
File: base/client.jl
PR Title: Make banner size depend on terminal size
BEFORE CODE: # load interactive-only libraries
try
return Base.require(PkgId(UUID(0x3fa0cd96_eef1_5676_8a61_b3b8758bbffb), "REPL"))
catch ex
@warn "Failed to import RE... | If auto -1, will this prevent the banner from showing by default? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
days = Int(floor((ccall(:jl_clock_now, Float64, ()) - Base.GIT_VERSION_INFO.fork_master_timestamp) / (60 * 60 * 24)))
days = max(0, days)
unit = days == 1 ? "day" : "days"
distance = Base.GIT_VERSION_INFO.fork_master_distance
commit = Base.GIT_VERSION_INFO.commit_short
i... | IIUC currently the banner size is always adaptive and the min of what fits on screen and what a user asked for. I think auto being adaptive is good. However, if I ask for `julia --banner=7`, I think I should get banner 7 regardless of screen size. | end
return :ok
end
)
end
end
Base.errormonitor(t_replswitch)
else
# Use bracket insertion if enabled, otherwise just insert
... | @@ -1492,60 +1498,63 @@ function banner(io::IO = stdout; short = false)
commit = Base.GIT_VERSION_INFO.commit_short
if distance == 0
- commit_string = "Commit $(commit) ($(days) $(unit) old master)"
+ styled"""Commit {grey:$commit} \
+ ({warning:⌛ {italic:$d... | stdlib/REPL/src/REPL.jl | 26 | Julia | 0.643 | suggestion | 247 | 51 | 51 | false | Make banner size depend on terminal size | 51,811 | JuliaLang/julia | 35,573 | Julia | LilithHafner | tecosaur | Review this pull request change.
Language: Julia
File: stdlib/REPL/src/REPL.jl
PR Title: Make banner size depend on terminal size
BEFORE CODE: days = Int(floor((ccall(:jl_clock_now, Float64, ()) - Base.GIT_VERSION_INFO.fork_master_timestamp) / (60 * 60 * 24)))
days = max(0, days)
unit = days... | IIUC currently the banner size is always adaptive and the min of what fits on screen and what a user asked for. I think auto being adaptive is good. However, if I ask for `julia --banner=7`, I think I should get banner 7 regardless of screen size. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
" -t, --threads {auto|N[,auto|M]} Enable N[+M] threads; N threads are assigned to the\n"
" `default` threadpool, and if M is specified, M\n"
" threads are assigned to the `interactive`\n"
" ... | Can't one also specify `full` here?
```suggestion
" preferred <size> (tiny, short, narrow, or full).\n"
``` | 0, // image-codegen
0, // rr-detach
0, // strip-metadata
0, // strip-ir
0, // permalloc_pkgimg
0, // heap-size-hint
0, // hard-heap-limit
... | @@ -171,7 +171,8 @@ static const char opts[] =
" -i, --interactive Interactive mode; REPL runs and\n"
" `isinteractive()` is true.\n"
" -q, --quiet Quiet startup: no banner, suppress REPL warnings... | src/jloptions.c | 26 | C | 0.786 | suggestion | 160 | 51 | 51 | false | Make banner size depend on terminal size | 51,811 | JuliaLang/julia | 35,573 | Julia | fingolfin | tecosaur | Review this pull request change.
Language: C
File: src/jloptions.c
PR Title: Make banner size depend on terminal size
BEFORE CODE: " -t, --threads {auto|N[,auto|M]} Enable N[+M] threads; N threads are assigned to the\n"
" `default` threadpool, and ... | Can't one also specify `full` here?
```suggestion
" preferred <size> (tiny, short, narrow, or full).\n"
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// the system will probably free this stack memory soon
// so prevent any other thread from accessing it later
jl_task_frame_noreturn(ptls->root_task);
}
else {
// Uh oh. The user cleared the sticky bit so it started running
// elsewhere, then called pthread_exit on this ... | I thought local function declarations are either a gcc extension or a new feature still | // the system will probably free this stack memory soon
// so prevent any other thread from accessing it later
jl_task_frame_noreturn(ptls->root_task);
}
else {
// Uh oh. The user cleared the sticky bit so it started running
// elsewhere, then called pthread_exit on this ... | @@ -510,6 +510,11 @@ static void jl_delete_thread(void *value) JL_NOTSAFEPOINT_ENTER
#else
pthread_mutex_unlock(&in_signal_lock);
#endif
+ free(ptls->bt_data);
+ // allow the page root_task is on to be freed
+ ptls->root_task = NULL;
+ void jl_free_thread_gc_state(jl_ptls_t ptls); | src/threading.c | 26 | C | 0.214 | suggestion | 87 | 51 | 51 | false | free more thread state in jl_delete_thread and GC | 52,198 | JuliaLang/julia | 35,573 | Julia | vtjnash | JeffBezanson | Review this pull request change.
Language: C
File: src/threading.c
PR Title: free more thread state in jl_delete_thread and GC
BEFORE CODE: // the system will probably free this stack memory soon
// so prevent any other thread from accessing it later
jl_task_frame_noreturn(ptls->root_task);
... | I thought local function declarations are either a gcc extension or a new feature still | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for (int i = 0; i < ptls2->heap.remset->len; i++) {
void *ptr = ptls2->heap.remset->items[i];
jl_astaggedvalue(ptr)->bits.gc = GC_MARKED;
}
}
else {
ptls2->heap.remset->len = 0;
}
// free empty GC state for threads that ... | I think this introduces a data race, which might be pretty tricky to solve, and is better done in its own PR
```suggestion
``` | // 1. fix GC bits of objects in the remset.
assert(gc_n_threads);
for (int t_i = 0; t_i < gc_n_threads; t_i++) {
jl_ptls_t ptls2 = gc_all_tls_states[t_i];
if (ptls2 != NULL)
gc_premark(ptls2);
}
assert(gc_n_threads);
int single_thr... | @@ -3499,6 +3515,27 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
else {
ptls2->heap.remset->len = 0;
}
+ // free empty GC state for threads that have exited
+ if (jl_atomic_load_relaxed(&ptls2->current_task) == NULL) {
+ jl_thread_he... | src/gc.c | 26 | C | 0.786 | bug | 126 | 51 | 51 | false | free more thread state in jl_delete_thread and GC | 52,198 | JuliaLang/julia | 35,573 | Julia | vtjnash | JeffBezanson | Review this pull request change.
Language: C
File: src/gc.c
PR Title: free more thread state in jl_delete_thread and GC
BEFORE CODE: for (int i = 0; i < ptls2->heap.remset->len; i++) {
void *ptr = ptls2->heap.remset->items[i];
jl_astaggedvalue(ptr)->bits.gc = GC_MARKED;
... | I think this introduces a data race, which might be pretty tricky to solve, and is better done in its own PR
```suggestion
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
void gc_move_to_global_page_pool(jl_gc_page_stack_t *pgstack)
{
while (1) {
jl_gc_pagemeta_t *pg = pop_lf_back(pgstack);
if (pg == NULL) {
break;
}
jl_gc_free_page(pg);
push_lf_back(&global_page_pool_freed, pg);
}
}
// setup the data-structures for a sweep o... | Perhaps use `malloc_s`, since that version does some error handling in case `malloc` fails (which should be fatal either way). |
// wake up all threads to sweep the pages
void gc_sweep_wake_all(jl_ptls_t ptls, jl_gc_padded_page_stack_t *new_gc_allocd_scratch)
{
int parallel_sweep_worthwhile = gc_sweep_prescan(ptls, new_gc_allocd_scratch);
jl_atomic_store(&gc_allocd_scratch, new_gc_allocd_scratch);
if (!parallel_sweep_worthwhile) {
... | @@ -1667,7 +1679,7 @@ static void gc_sweep_pool(void)
// allocate enough space to hold the end of the free list chain
// for every thread and pool size
- jl_taggedvalue_t ***pfl = (jl_taggedvalue_t ***) alloca(n_threads * JL_GC_N_POOLS * sizeof(jl_taggedvalue_t**));
+ jl_taggedvalue_t ***pfl = (jl_tag... | src/gc.c | 26 | C | 0.714 | bug | 126 | 51 | 51 | false | free more thread state in jl_delete_thread and GC | 52,198 | JuliaLang/julia | 35,573 | Julia | d-netto | JeffBezanson | Review this pull request change.
Language: C
File: src/gc.c
PR Title: free more thread state in jl_delete_thread and GC
BEFORE CODE:
void gc_move_to_global_page_pool(jl_gc_page_stack_t *pgstack)
{
while (1) {
jl_gc_pagemeta_t *pg = pop_lf_back(pgstack);
if (pg == NULL) {
break;
... | Perhaps use `malloc_s`, since that version does some error handling in case `malloc` fails (which should be fatal either way). | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
jl_gc_pool_t *p = &ptls2->heap.norm_pools[i];
p->newpages = NULL;
}
}
}
free(tmp);
// merge free lists
for (int t_i = 0; t_i < n_threads; t_i++) {
jl_ptls_t ptls2 = gc_all_tls_states[t_i];
if (ptls2 == NULL) {
continue;
... | We likely need to subtract the memory we freed from `gc_heap_stats.heap_size`, as we do [here](https://github.com/JuliaLang/julia/blob/a6c656e6c47ff2b1237c92e90ba73ac267fc1dc0/src/gc.c#L1556C11-L1556C11). | // free all pages (i.e. through `madvise` on Linux) that were lazily freed
void gc_free_pages(void)
{
while (1) {
jl_gc_pagemeta_t *pg = pop_lf_back(&global_page_pool_lazily_freed);
if (pg == NULL) {
break;
}
jl_gc_free_page(pg);
push_lf_back(&global_page_pool_fre... | @@ -1655,6 +1655,18 @@ void gc_free_pages(void)
}
}
+void gc_move_to_global_page_pool(jl_gc_page_stack_t *pgstack)
+{
+ while (1) {
+ jl_gc_pagemeta_t *pg = pop_lf_back(pgstack);
+ if (pg == NULL) {
+ break;
+ }
+ jl_gc_free_page(pg);
+ push_lf_back(&global_page_... | src/gc.c | 26 | C | 0.714 | suggestion | 204 | 51 | 51 | false | free more thread state in jl_delete_thread and GC | 52,198 | JuliaLang/julia | 35,573 | Julia | d-netto | JeffBezanson | Review this pull request change.
Language: C
File: src/gc.c
PR Title: free more thread state in jl_delete_thread and GC
BEFORE CODE: jl_gc_pool_t *p = &ptls2->heap.norm_pools[i];
p->newpages = NULL;
}
}
}
free(tmp);
// merge free lists
for (int t_... | We likely need to subtract the memory we freed from `gc_heap_stats.heap_size`, as we do [here](https://github.com/JuliaLang/julia/blob/a6c656e6c47ff2b1237c92e90ba73ac267fc1dc0/src/gc.c#L1556C11-L1556C11). | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
double old_ratio = (double)promoted_bytes/(double)heap_size;
if (heap_size > max_total_memory * 0.8 || old_ratio > 0.15)
next_sweep_full = 1;
else
next_sweep_full = 0;
if (heap_size > max_total_memory * 0.8 || thrashing)
under_pressure = 1;
// sweeping is over
// 7. if it... | We probably need to check that the thread for which we're doing the cleanup is actually a mutator thread (i.e. `ptls2->tid < gc_first_tid || ptls2->tid >= gc_first_tid + jl_n_gcthreads`).
Note that, since GC threads have no tasks associated with them, this version is also doing the cleanup for the GC threads, and w... |
// We separate the update of the graph from the update of live_bytes here
// so that the sweep shows a downward trend in memory usage.
jl_timing_counter_inc(JL_TIMING_COUNTER_HeapSize, gc_num.allocd);
jl_gc_markqueue_t *mq = &ptls->mark_queue;
uint64_t gc_start_time = jl_hrtime();
uint64_t mu... | @@ -3499,6 +3515,27 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
else {
ptls2->heap.remset->len = 0;
}
+ // free empty GC state for threads that have exited
+ if (jl_atomic_load_relaxed(&ptls2->current_task) == NULL) { | src/gc.c | 26 | C | 0.714 | suggestion | 417 | 51 | 51 | false | free more thread state in jl_delete_thread and GC | 52,198 | JuliaLang/julia | 35,573 | Julia | d-netto | JeffBezanson | Review this pull request change.
Language: C
File: src/gc.c
PR Title: free more thread state in jl_delete_thread and GC
BEFORE CODE: double old_ratio = (double)promoted_bytes/(double)heap_size;
if (heap_size > max_total_memory * 0.8 || old_ratio > 0.15)
next_sweep_full = 1;
else
next_swe... | We probably need to check that the thread for which we're doing the cleanup is actually a mutator thread (i.e. `ptls2->tid < gc_first_tid || ptls2->tid >= gc_first_tid + jl_n_gcthreads`).
Note that, since GC threads have no tasks associated with them, this version is also doing the cleanup for the GC threads, and w... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
end
for (op,chop) in ((:rem,:rem), (:mod,:mod))
@eval begin
function ($op)(y::Integer, x::Rational)
Rational(($chop)(checked_mul(x.den, y), x.num), x.den)
end
end
end
function *(x::Rational, y::Rational)
xn, yd = divgcd(promote(x.num, y.den)...)
xd, yn = divgcd(promo... | ```suggestion
inv(x::Rational{T}) where {T} = checked_den(x.den, x.num)
```
This change is not related, right? IMO unrelated cosmetic changes should go separate from bugfix PRs, making both reviewing and `git` cherry-picking easier. | end
end
for (op,chop) in ((:+,:checked_add), (:-,:checked_sub))
@eval begin
function ($op)(y::Integer, x::Rational)
unsafe_rational(($chop)(checked_mul(x.den, y), x.num), x.den)
end
end
end
for (op,chop) in ((:rem,:rem), (:mod,:mod))
@eval begin
function ($op)(y::Inte... | @@ -408,9 +408,9 @@ function *(y::Integer, x::Rational)
yn, xd = divgcd(promote(y, x.den)...)
unsafe_rational(checked_mul(yn, x.num), xd)
end
-/(x::Rational, y::Union{Rational, Integer, Complex{<:Union{Integer,Rational}}}) = x//y
-/(x::Union{Integer, Complex{<:Union{Integer,Rational}}}, y::Rational) = x//y
-... | base/rational.jl | 26 | Julia | 1 | bug | 237 | 51 | 51 | false | Avoid silent overflow in `/(x::Rational, y::Complex{Int})` | 53,453 | JuliaLang/julia | 35,573 | Julia | nsajko | nhz2 | Review this pull request change.
Language: Julia
File: base/rational.jl
PR Title: Avoid silent overflow in `/(x::Rational, y::Complex{Int})`
BEFORE CODE: end
end
for (op,chop) in ((:rem,:rem), (:mod,:mod))
@eval begin
function ($op)(y::Integer, x::Rational)
Rational(($chop)(checked_mul(x... | ```suggestion
inv(x::Rational{T}) where {T} = checked_den(x.den, x.num)
```
This change is not related, right? IMO unrelated cosmetic changes should go separate from bugfix PRs, making both reviewing and `git` cherry-picking easier. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@test widen(Rational{T}) == Rational{widen(T)}
end
@test iszero(typemin(Rational{UInt}))
@test Rational(Float32(rand_int)) == Rational(rand_int)
@test Rational(Rational(rand_int)) == Rational(rand_int)
@test begin
var = -Rational(UInt32(0))
var == UInt32(0)
end
@... | This is wrong. The correct result is positive infinity, just like here:
```julia-repl
julia> (1 // 1) / 0
1//0
``` | @test widen(Rational{T}) == Rational{widen(T)}
end
@test iszero(typemin(Rational{UInt}))
@test Rational(Float32(rand_int)) == Rational(rand_int)
@test Rational(Rational(rand_int)) == Rational(rand_int)
@test begin
var = -Rational(UInt32(0))
var == UInt32(0)
end
@... | @@ -203,6 +203,21 @@ end
end
@test Rational(rand_int, 3)/Complex(3, 2) == Complex(Rational(rand_int, 13), -Rational(rand_int*2, 39))
+ @test (true//true) / complex(false, true) === 0//1 - 1//1*im
+ @test (false//true) / complex(false, true) === 0//1 + 0//1*im
+ @test (false//true) / complex(true, f... | test/rational.jl | 26 | Julia | 0.714 | bug | 120 | 51 | 51 | false | Avoid silent overflow in `/(x::Rational, y::Complex{Int})` | 53,453 | JuliaLang/julia | 35,573 | Julia | nsajko | nhz2 | Review this pull request change.
Language: Julia
File: test/rational.jl
PR Title: Avoid silent overflow in `/(x::Rational, y::Complex{Int})`
BEFORE CODE: @test widen(Rational{T}) == Rational{widen(T)}
end
@test iszero(typemin(Rational{UInt}))
@test Rational(Float32(rand_int)) == Rational(rand_... | This is wrong. The correct result is positive infinity, just like here:
```julia-repl
julia> (1 // 1) / 0
1//0
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
const ScopeStorage = Base.PersistentDict{ScopedValue, Any}
struct Scope
values::ScopeStorage
end
function Scope(parent::Union{Nothing, Scope}, key::ScopedValue{T}, value) where T
val = convert(T, value)
if parent === nothing
return Scope(ScopeStorage(key=>val))
end
return Scope(ScopeS... | I just PR'd this fix specifically https://github.com/JuliaLang/julia/pull/56019 | end
const ScopeStorage = Base.PersistentDict{ScopedValue, Any}
struct Scope
values::ScopeStorage
end
Scope(scope::Scope) = scope
function Scope(parent::Union{Nothing, Scope}, key::ScopedValue{T}, value) where T
val = convert(T, value)
if parent === nothing
return Scope(ScopeStorage(key=>val))
... | @@ -102,6 +102,7 @@ function Scope(scope, pair1::Pair{<:ScopedValue}, pair2::Pair{<:ScopedValue}, pa
# our compiler optimization support works
return Scope(Scope(scope, pair1...), pair2, pairs...)
end
+Scope(scope::Scope) = scope | base/scopedvalues.jl | 26 | Julia | 0.214 | suggestion | 79 | 51 | 51 | false | use ScopedValues for TestSets | 53,462 | JuliaLang/julia | 35,573 | Julia | IanButterworth | simonbyrne | Review this pull request change.
Language: Julia
File: base/scopedvalues.jl
PR Title: use ScopedValues for TestSets
BEFORE CODE: end
const ScopeStorage = Base.PersistentDict{ScopedValue, Any}
struct Scope
values::ScopeStorage
end
function Scope(parent::Union{Nothing, Scope}, key::ScopedValue{T}, value) where... | I just PR'd this fix specifically https://github.com/JuliaLang/julia/pull/56019 | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
cmd = `$(Base.julia_cmd()) --startup-file=no --color=no $f`
result = read(pipeline(ignorestatus(cmd), stderr=devnull), String)
@test occursin(expected, result)
end
end
@testset "failfast via env var" begin
expected = r"""
Test Summary: \| Fail Tota... | Min nit: this can be simplified to
```suggestion
cmd = addenv(`$(Base.julia_cmd()) --startup-file=no --color=no $f`, "JULIA_TEST_FAILFAST"=>"true")
``` | @test 1 == 1
end
@testset "Child 2.2" begin
@test 1 == 1
end
@testset "Child 2.3" begin
@test 1 == 1
end
end
@testset "Child 3" verbose = true begin
... | @@ -1419,7 +1419,7 @@ end
end
end
""")
- cmd = `$(Base.julia_cmd()) --startup-file=no --color=no $f`
+ cmd = Cmd(`$(Base.julia_cmd()) --startup-file=no --color=no $f`, env=Dict("JULIA_TEST_FAILFAST"=>true)) | stdlib/Test/test/runtests.jl | 26 | Julia | 0.714 | bug | 169 | 51 | 51 | false | use ScopedValues for TestSets | 53,462 | JuliaLang/julia | 35,573 | Julia | giordano | simonbyrne | Review this pull request change.
Language: Julia
File: stdlib/Test/test/runtests.jl
PR Title: use ScopedValues for TestSets
BEFORE CODE: cmd = `$(Base.julia_cmd()) --startup-file=no --color=no $f`
result = read(pipeline(ignorestatus(cmd), stderr=devnull), String)
@test occursi... | Min nit: this can be simplified to
```suggestion
cmd = addenv(`$(Base.julia_cmd()) --startup-file=no --color=no $f`, "JULIA_TEST_FAILFAST"=>"true")
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
desc, testsettype, options = parse_testset_args(args[1:end-1])
if desc === nothing
# No description provided. Generate from the loop variable names
v = loopvars[1].args[1]
desc = Expr(:string, "$v = ", esc(v)) # first variable
for l = loopvars[2:end]
v = l.a... | Does this comment still make sense after removing the code below? | julia> @testset let logi = log(im), op = !iszero
@test imag(logi) == π/2
@test op(real(logi))
end
Test Failed at none:3
Expression: op(real(logi))
Evaluated: op(0.0)
Context: logi = 0.0 + 1.5707963267948966im
op = !iszero
ERROR: There was an error during testing
```
... | @@ -1842,22 +1836,17 @@ function testset_forloop(args, testloop, source)
_check_testset($testsettype, $(QuoteNode(testsettype.args[1])))
# Trick to handle `break` and `continue` in the test code before
# they can be handled properly by `finally` lowering. | stdlib/Test/src/Test.jl | 26 | Julia | 0.214 | question | 65 | 51 | 51 | false | use ScopedValues for TestSets | 53,462 | JuliaLang/julia | 35,573 | Julia | giordano | simonbyrne | Review this pull request change.
Language: Julia
File: stdlib/Test/src/Test.jl
PR Title: use ScopedValues for TestSets
BEFORE CODE: end
desc, testsettype, options = parse_testset_args(args[1:end-1])
if desc === nothing
# No description provided. Generate from the loop variable names
v ... | Does this comment still make sense after removing the code below? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@test a[] == 2
@test a[] isa Int
end
a = ScopedValue(1.0)
with(a => 2) do
@test a[] == 2.0
@test a[] isa Float64
end
end
import Base.Threads: @spawn
@testset "tasks" begin
@test fetch(@spawn begin
sval[]
end) == 1
with(sval => 2) do
@test fetc... | Why was this test commented out? Can we move it at the top-level, outside of any testset, to keep the test, or that's still within an implicit scope? | @test a[] isa Int
end
a = ScopedValue(1.0)
with(a => 2) do
@test a[] == 2.0
@test a[] isa Float64
end
end
import Base.Threads: @spawn
@testset "tasks" begin
@test fetch(@spawn begin
sval[]
end) == 1
with(sval => 2) do
@test fetch(@spawn begin
... | @@ -80,13 +81,13 @@ import Base.Threads: @spawn
end
@testset "show" begin
- @test sprint(show, ScopedValue{Int}()) == "Base.ScopedValues.ScopedValue{$Int}(undefined)"
- @test sprint(show, sval) == "Base.ScopedValues.ScopedValue{$Int}(1)"
- @test sprint(show, Core.current_scope()) == "nothing"
+ @test sp... | test/scopedvalues.jl | 26 | Julia | 0.429 | question | 150 | 51 | 51 | false | use ScopedValues for TestSets | 53,462 | JuliaLang/julia | 35,573 | Julia | giordano | simonbyrne | Review this pull request change.
Language: Julia
File: test/scopedvalues.jl
PR Title: use ScopedValues for TestSets
BEFORE CODE: @test a[] == 2
@test a[] isa Int
end
a = ScopedValue(1.0)
with(a => 2) do
@test a[] == 2.0
@test a[] isa Float64
end
end
import Base.Threa... | Why was this test commented out? Can we move it at the top-level, outside of any testset, to keep the test, or that's still within an implicit scope? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
with(a => 2) do
@test a[] == 2.0
@test a[] isa Float64
end
end
import Base.Threads: @spawn
@testset "tasks" begin
@test fetch(@spawn begin
sval[]
end) == 1
with(sval => 2) do
@test fetch(@spawn begin
sval[]
end) == 2
end
end
@testset "show" b... | Also this: why was it removed? | @test a[] == 2.0
@test a[] isa Float64
end
end
import Base.Threads: @spawn
@testset "tasks" begin
@test fetch(@spawn begin
sval[]
end) == 1
with(sval => 2) do
@test fetch(@spawn begin
sval[]
end) == 2
end
end
@testset "show" begin
@test sprin... | @@ -80,13 +81,13 @@ import Base.Threads: @spawn
end
@testset "show" begin
- @test sprint(show, ScopedValue{Int}()) == "Base.ScopedValues.ScopedValue{$Int}(undefined)"
- @test sprint(show, sval) == "Base.ScopedValues.ScopedValue{$Int}(1)"
- @test sprint(show, Core.current_scope()) == "nothing"
+ @test sp... | test/scopedvalues.jl | 26 | Julia | 0.143 | question | 30 | 51 | 51 | false | use ScopedValues for TestSets | 53,462 | JuliaLang/julia | 35,573 | Julia | giordano | simonbyrne | Review this pull request change.
Language: Julia
File: test/scopedvalues.jl
PR Title: use ScopedValues for TestSets
BEFORE CODE: with(a => 2) do
@test a[] == 2.0
@test a[] isa Float64
end
end
import Base.Threads: @spawn
@testset "tasks" begin
@test fetch(@spawn begin
sval[]
... | Also this: why was it removed? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
f = Base.unwrap_unionall(getfield(mod, n))
if isa(f, Module) && f !== mod && parentmodule(f) === mod && nameof(f) === n
push!(work, f)
elseif isa(f, DataType) && isdefined(f.name, :mt) && parentmodule(f) === mod && nameof(f) === n && f.name.mt !== Symb... | Apparently some (testing) packages were using this: https://juliahub.com/ui/Search?type=symbols&q=push_testset&u=use. Presumably it's ok to ask them to adapt their use of internal functions? [These aren't documented](https://docs.julialang.org/en/v1/stdlib/Test/). | _args_and_call((args..., f)...; kwargs...) = (args, kwargs, f(args...; kwargs...))
_materialize_broadcasted(f, args...) = Broadcast.materialize(Broadcast.broadcasted(f, args...))
"""
@inferred [AllowedType] f(x)
Tests that the call expression `f(x)` returns a value of the same type inferred by the
compiler. It is... | @@ -1938,39 +1918,21 @@ end
#-----------------------------------------------------------------------
# Various helper methods for test sets
+const CURRENT_TESTSET = ScopedValue{AbstractTestSet}(FallbackTestSet())
+const TESTSET_DEPTH = ScopedValue{Int}(0)
+
+macro with_testset(ts, expr)
+ :(@with(CURRENT_TESTSET... | stdlib/Test/src/Test.jl | 26 | Julia | 0.643 | suggestion | 266 | 51 | 51 | false | use ScopedValues for TestSets | 53,462 | JuliaLang/julia | 35,573 | Julia | giordano | simonbyrne | Review this pull request change.
Language: Julia
File: stdlib/Test/src/Test.jl
PR Title: use ScopedValues for TestSets
BEFORE CODE: end
f = Base.unwrap_unionall(getfield(mod, n))
if isa(f, Module) && f !== mod && parentmodule(f) === mod && nameof(f) === n
push!(wo... | Apparently some (testing) packages were using this: https://juliahub.com/ui/Search?type=symbols&q=push_testset&u=use. Presumably it's ok to ask them to adapt their use of internal functions? [These aren't documented](https://docs.julialang.org/en/v1/stdlib/Test/). | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
test set is active, use the fallback default test set.
"""
function get_testset()
something(Base.ScopedValues.get(CURRENT_TESTSET))
end
"""
get_testset_depth()
Return the number of active test sets, not including the default test set
"""
function get_testset_depth()
something(Base.ScopedValues.get(TESTSET... | I can't immediately tell the motivation for this change, could you please elaborate? | $(testsettype)($desc; $options...)
end
# we reproduce the logic of guardseed, but this function
# cannot be used as it changes slightly the semantic of @testset,
# by wrapping the body in a function
local default_rng_orig = copy(default_rng())
local tls_seed_... | @@ -1756,34 +1749,35 @@ function testset_beginend_call(args, tests, source)
else
$(testsettype)($desc; $options...)
end
- push_testset(ts)
+
# we reproduce the logic of guardseed, but this function
# cannot be used as it changes slightly the semantic of @testset,
... | stdlib/Test/src/Test.jl | 26 | Julia | 0.286 | question | 84 | 51 | 51 | false | use ScopedValues for TestSets | 53,462 | JuliaLang/julia | 35,573 | Julia | giordano | simonbyrne | Review this pull request change.
Language: Julia
File: stdlib/Test/src/Test.jl
PR Title: use ScopedValues for TestSets
BEFORE CODE: test set is active, use the fallback default test set.
"""
function get_testset()
something(Base.ScopedValues.get(CURRENT_TESTSET))
end
"""
get_testset_depth()
Return the num... | I can't immediately tell the motivation for this change, could you please elaborate? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
export @test, @test_throws, @test_broken, @test_skip,
@test_warn, @test_nowarn,
@test_logs, @test_deprecated
export @testset
export @inferred
export detect_ambiguities, detect_unbound_args
export GenericString, GenericSet, GenericDict, GenericArray, GenericOrder
export TestSetException
export TestLogger, LogRe... | I guess the extra newlines are here by accident?
```suggestion
``` | export @test, @test_throws, @test_broken, @test_skip,
@test_warn, @test_nowarn,
@test_logs, @test_deprecated
export @testset
export @inferred
export detect_ambiguities, detect_unbound_args
export GenericString, GenericSet, GenericDict, GenericArray, GenericOrder
export TestSetException
export TestLogger, LogRe... | @@ -41,8 +42,15 @@ const DISPLAY_FAILED = (
:contains
)
+
const FAIL_FAST = Ref{Bool}(false)
+function __init__()
+ FAIL_FAST[] = Base.get_bool_env("JULIA_TEST_FAILFAST", false)
+end
+
+
+ | stdlib/Test/src/Test.jl | 26 | Julia | 0.571 | suggestion | 70 | 51 | 51 | false | use ScopedValues for TestSets | 53,462 | JuliaLang/julia | 35,573 | Julia | nsajko | simonbyrne | Review this pull request change.
Language: Julia
File: stdlib/Test/src/Test.jl
PR Title: use ScopedValues for TestSets
BEFORE CODE: export @test, @test_throws, @test_broken, @test_skip,
@test_warn, @test_nowarn,
@test_logs, @test_deprecated
export @testset
export @inferred
export detect_ambiguities, detect... | I guess the extra newlines are here by accident?
```suggestion
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
(void)tosymbol(fl_ctx, args[0], "nothrow-julia-global");
var = scmsym_to_julia(fl_ctx, args[0]);
}
else {
argcount(fl_ctx, "nothrow-julia-global", nargs, 2);
value_t argmod = args[0];
if (iscvalue(argmod) && cv_class((cvalue_t*)ptr(argmod)) == jl_ast_ctx(fl_ctx)->jvtype) ... | This could go into `jl_module_t`, which already has a lock (and an atomic field called `counter`; not sure if that's related?). I think that will reduce a lookup here and let us avoid having yet another couple of globals. | jl_module_t *mod = ctx->module;
jl_sym_t *var = NULL;
if (nargs == 1) {
(void)tosymbol(fl_ctx, args[0], "nothrow-julia-global");
var = scmsym_to_julia(fl_ctx, args[0]);
}
else {
argcount(fl_ctx, "nothrow-julia-global", nargs, 2);
value_t argmod = args[0];
if (... | @@ -208,11 +208,54 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
+arraylist_t parsed_method_stack; // for keeping track of which methods are being parsed
+uv_mutex_t counter_table_lock;... | src/ast.c | 26 | C | 0.643 | suggestion | 221 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | kpamnany | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: (void)tosymbol(fl_ctx, args[0], "nothrow-julia-global");
var = scmsym_to_julia(fl_ctx, args[0]);
}
... | This could go into `jl_module_t`, which already has a lock (and an atomic field called `counter`; not sure if that's related?). I think that will reduce a lookup here and let us avoid having yet another couple of globals. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
jl_sym_t *var = NULL;
if (nargs == 1) {
(void)tosymbol(fl_ctx, args[0], "nothrow-julia-global");
var = scmsym_to_julia(fl_ctx, args[0]);
}
else {
argcount(fl_ctx, "nothrow-julia-global", nargs, 2);
value_t argmod = args[0];
if (iscvalue(argmod) && cv_class((cvalue... | Question for reviewers (@vtjnash and @JeffBezanson): may multiple threads be parsing at the same time? If so, this should probably be thread local or flisp context local. | // can take either a symbol or a module and a symbol
jl_ast_context_t *ctx = jl_ast_ctx(fl_ctx);
jl_module_t *mod = ctx->module;
jl_sym_t *var = NULL;
if (nargs == 1) {
(void)tosymbol(fl_ctx, args[0], "nothrow-julia-global");
var = scmsym_to_julia(fl_ctx, args[0]);
}
else {
... | @@ -208,11 +208,54 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
+arraylist_t parsed_method_stack; // for keeping track of which methods are being parsed | src/ast.c | 26 | C | 0.571 | suggestion | 170 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | d-netto | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: jl_sym_t *var = NULL;
if (nargs == 1) {
(void)tosymbol(fl_ctx, args[0], "nothrow-julia-global");
... | Question for reviewers (@vtjnash and @JeffBezanson): may multiple threads be parsing at the same time? If so, this should probably be thread local or flisp context local. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
} else {
(void)tosymbol(fl_ctx, argmod, "nothrow-julia-global");
if (scmsym_to_julia(fl_ctx, argmod) != jl_thismodule_sym) {
lerrorf(fl_ctx, fl_ctx->ArgError, "nothrow-julia-global: Unknown globalref module kind");
}
}
(void)tosymbol(fl_ctx, ar... | This should probably be done by Module and not by Module name, as Kiran recommended above. It's not uncommon to do something like this:
```julia
julia> mod = Module(); Core.eval(mod, quote
function plus(x)
return (y)->(x + y)
end
end)
```
in which case I believe t... | if (iscvalue(argmod) && cv_class((cvalue_t*)ptr(argmod)) == jl_ast_ctx(fl_ctx)->jvtype) {
mod = *(jl_module_t**)cv_data((cvalue_t*)ptr(argmod));
JL_GC_PROMISE_ROOTED(mod);
} else {
if (!iscons(argmod) || !issymbol(car_(argmod)) || scmsym_to_julia(fl_ctx, car_(argmod))... | @@ -208,11 +208,54 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
+arraylist_t parsed_method_stack; // for keeping track of which methods are being parsed
+uv_mutex_t counter_table_lock;... | src/ast.c | 26 | C | 0.857 | suggestion | 411 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: } else {
(void)tosymbol(fl_ctx, argmod, "nothrow-julia-global");
if (scmsym_to_julia(fl_... | This should probably be done by Module and not by Module name, as Kiran recommended above. It's not uncommon to do something like this:
```julia
julia> mod = Module(); Core.eval(mod, quote
function plus(x)
return (y)->(x + y)
end
end)
```
in which case I believe t... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if (jl_is_number(v) || jl_is_string(v))
return fl_ctx->T;
}
return fl_ctx->F;
}
static value_t fl_julia_push_closure_expr(fl_context_t *fl_ctx, value_t *args, uint32_t nargs)
{
argcount(fl_ctx, "julia-push-closure-expr", nargs, 1);
// Check if the head of the symbol at `args[0]` is ... | I think it'd be preferable to throw an error here - Otherwise, this silently does nothing if the argument is not of the expected form.
The boolean return value help prevents that from breaking the stack discipline, but it's still very easy to get bugs here.
| if (jl_is_number(v) || jl_is_string(v))
return fl_ctx->T;
}
return fl_ctx->F;
}
static jl_value_t *scm_to_julia_(fl_context_t *fl_ctx, value_t e, jl_module_t *mod);
static const builtinspec_t julia_flisp_ast_ext[] = {
{ "defined-julia-global", fl_defined_julia_global }, // TODO: can we... | @@ -240,13 +283,51 @@ static value_t fl_julia_scalar(fl_context_t *fl_ctx, value_t *args, uint32_t nar
return fl_ctx->F;
}
+static value_t fl_julia_push_closure_expr(fl_context_t *fl_ctx, value_t *args, uint32_t nargs)
+{
+ argcount(fl_ctx, "julia-push-closure-expr", nargs, 1);
+ // Check if the head of t... | src/ast.c | 26 | C | 0.643 | bug | 262 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: if (jl_is_number(v) || jl_is_string(v))
return fl_ctx->T;
}
return fl_ctx->F;
}
static valu... | I think it'd be preferable to throw an error here - Otherwise, this silently does nothing if the argument is not of the expected form.
The boolean return value help prevents that from breaking the stack discipline, but it's still very easy to get bugs here.
| You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// scalar. When in doubt, return false, since this is only an optimization.
static value_t fl_julia_scalar(fl_context_t *fl_ctx, value_t *args, uint32_t nargs)
{
argcount(fl_ctx, "julia-scalar?", nargs, 1);
if (fl_isnumber(fl_ctx, args[0]) || fl_isstring(fl_ctx, args[0]))
return fl_ctx->T;
else if ... | I think we try to avoid creating symbols like this dynamically except on error paths or if the symbol is not compile-time-known | // scalar. When in doubt, return false, since this is only an optimization.
static value_t fl_julia_scalar(fl_context_t *fl_ctx, value_t *args, uint32_t nargs)
{
argcount(fl_ctx, "julia-scalar?", nargs, 1);
if (fl_isnumber(fl_ctx, args[0]) || fl_isstring(fl_ctx, args[0]))
return fl_ctx->T;
else if ... | @@ -240,13 +283,51 @@ static value_t fl_julia_scalar(fl_context_t *fl_ctx, value_t *args, uint32_t nar
return fl_ctx->F;
}
+static value_t fl_julia_push_closure_expr(fl_context_t *fl_ctx, value_t *args, uint32_t nargs)
+{
+ argcount(fl_ctx, "julia-push-closure-expr", nargs, 1);
+ // Check if the head of t... | src/ast.c | 26 | C | 0.571 | suggestion | 127 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: // scalar. When in doubt, return false, since this is only an optimization.
static value_t fl_julia_scalar(fl_context_t... | I think we try to avoid creating symbols like this dynamically except on error paths or if the symbol is not compile-time-known | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#ifdef __cplusplus
extern "C" {
#endif
// allocating TypeNames -----------------------------------------------------------
static int is10digit(char c) JL_NOTSAFEPOINT
{
return (c >= '0' && c <= '9');
}
static jl_sym_t *jl_demangle_typename(jl_sym_t *s) JL_NOTSAFEPOINT
{
char *n = jl_symbol_name(s);
if ... | Does this conflict with operators?
```julia
julia> Base.:(<)
< (generic function with 76 methods)
``` |
#ifdef __cplusplus
extern "C" {
#endif
// allocating TypeNames -----------------------------------------------------------
static jl_sym_t *jl_demangle_typename(jl_sym_t *s) JL_NOTSAFEPOINT
{
char *n = jl_symbol_name(s);
if (n[0] != '#')
return s;
char *end = strchr(&n[1], '#');
// handle `#f... | @@ -36,8 +36,9 @@ static jl_sym_t *jl_demangle_typename(jl_sym_t *s) JL_NOTSAFEPOINT
len = strlen(n) - 1;
else
len = (end-n) - 1; // extract `f` from `#f#...`
- if (is10digit(n[1]))
+ if (is10digit(n[1]) || n[1] == '<') {
return _jl_symbol(n, len+1);
+ } | src/datatype.c | 26 | C | 0.714 | question | 105 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/datatype.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE:
#ifdef __cplusplus
extern "C" {
#endif
// allocating TypeNames --------------------------------------------------... | Does this conflict with operators?
```julia
julia> Base.:(<)
< (generic function with 76 methods)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// allocating TypeNames -----------------------------------------------------------
static int is10digit(char c) JL_NOTSAFEPOINT
{
return (c >= '0' && c <= '9');
}
static int is_canonicalized_anonfn_typename(char *name) JL_NOTSAFEPOINT
{
assert(strlen(name) > 1);
// first character after '#' is a digit: ... | Does this still work for names like `do_foo`?
If so, it would be good to explain in the comments why it's OK. |
// allocating TypeNames -----------------------------------------------------------
static jl_sym_t *jl_demangle_typename(jl_sym_t *s) JL_NOTSAFEPOINT
{
char *n = jl_symbol_name(s);
if (n[0] != '#')
return s;
char *end = strchr(&n[1], '#');
// handle `#f...##...#...`
if (end != NULL && end... | @@ -25,6 +25,39 @@ static int is10digit(char c) JL_NOTSAFEPOINT
return (c >= '0' && c <= '9');
}
+static int is_canonicalized_anonfn_typename(char *name) JL_NOTSAFEPOINT
+{
+ assert(strlen(name) > 1);
+ // first character after '#' is a digit: canonicalized anonymous function name
+ if (is10digit(name[... | src/datatype.c | 26 | C | 0.5 | question | 112 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/datatype.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE:
// allocating TypeNames -----------------------------------------------------------
static int is10digit(char c) ... | Does this still work for names like `do_foo`?
If so, it would be good to explain in the comments why it's OK. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// This file is a part of Julia. License is MIT: https://julialang.org/license
/*
AST
components of the front-end, for obtaining and translating syntax trees
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef _OS_WINDOWS_
#include <malloc.h>
#endif
#include "julia.h"
#include "julia_internal.h"
#... | I still think that this PR should have unit tests, testing all the corner cases that you're covering here, not least to ensure that these decisions are clearly documented in the PR.
Something like
```
function foo(x)
function bar(y)
return x + y
end
return bar
end
@test repr(foo(42)) == "... | // This file is a part of Julia. License is MIT: https://julialang.org/license
/*
AST
components of the front-end, for obtaining and translating syntax trees
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef _OS_WINDOWS_
#include <malloc.h>
#endif
#include "julia.h"
#include "julia_internal.h"
... | src/ast.c | 1 | C | 0.857 | nitpick | 360 | 26 | 26 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | NHDaly | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: // This file is a part of Julia. License is MIT: https://julialang.org/license
/*
AST
components of the front-end, ... | I still think that this PR should have unit tests, testing all the corner cases that you're covering here, not least to ensure that these decisions are clearly documented in the PR.
Something like
```
function foo(x)
function bar(y)
return x + y
end
return bar
end
@test repr(foo(42)) == "... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
STATIC_INLINE int is_canonicalized_anonfn_typename(char *name) JL_NOTSAFEPOINT
{
if (is10digit(name[1]))
return 1;
char *delim = strchr(&name[1], '#');
if (delim == NULL)
return 0;
if (delim[1] != '#')
return 0;
if (!is10digit(delim[2]))
return 0;
return 1;
}
st... | I don't think it's possible to hit the `end == n` condition any more | return s;
char *end = strchr(&n[1], '#');
// handle `#f...##...#...`
if (end != NULL && end[1] == '#')
end = strchr(&end[2], '#');
int32_t len;
if (end == NULL || end == n+1)
len = strlen(n) - 1;
else
len = (end-n) - 1; // extract `f` from `#f#...`
if (isdigi... | @@ -25,18 +25,35 @@ static int is10digit(char c) JL_NOTSAFEPOINT
return (c >= '0' && c <= '9');
}
+STATIC_INLINE int is_canonicalized_anonfn_typename(char *name) JL_NOTSAFEPOINT
+{
+ if (is10digit(name[1]))
+ return 1;
+ char *delim = strchr(&name[1], '#');
+ if (delim == NULL)
+ return 0... | src/datatype.c | 26 | C | 0.357 | suggestion | 68 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/datatype.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE:
STATIC_INLINE int is_canonicalized_anonfn_typename(char *name) JL_NOTSAFEPOINT
{
if (is10digit(name[1]))
... | I don't think it's possible to hit the `end == n` condition any more | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
JL_DLLEXPORT jl_value_t *jl_nth_slot_type(jl_value_t *sig JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT;
void jl_compute_field_offsets(jl_datatype_t *st);
void jl_module_run_initializer(jl_module_t *m);
JL_DLLEXPORT jl_binding_t *jl_get_module_binding(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var, int alloc);
JL_DLL... | Would this be correct for `#bar##foo2`? Or is that form not possible? |
jl_value_t *jl_gf_invoke_by_method(jl_method_t *method, jl_value_t *gf, jl_value_t **args, size_t nargs);
jl_value_t *jl_gf_invoke(jl_value_t *types, jl_value_t *f, jl_value_t **args, size_t nargs);
JL_DLLEXPORT jl_value_t *jl_gf_invoke_lookup_worlds(jl_value_t *types, jl_value_t *mt, size_t world, size_t *min_world, ... | @@ -842,12 +843,13 @@ jl_method_t *jl_make_opaque_closure_method(jl_module_t *module, jl_value_t *name
int nargs, jl_value_t *functionloc, jl_code_info_t *ci, int isva, int isinferred);
JL_DLLEXPORT int jl_is_valid_oc_argtype(jl_tupletype_t *argt, jl_method_t *source);
-STATIC_INLINE int is_anonfn_typename(char... | src/julia_internal.h | 26 | C/C++ | 0.357 | question | 69 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C/C++
File: src/julia_internal.h
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: JL_DLLEXPORT jl_value_t *jl_nth_slot_type(jl_value_t *sig JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT;
... | Would this be correct for `#bar##foo2`? Or is that form not possible? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
function bar(y)
function baz(z)
return x + y + z
end
return baz
end
return bar
end
function foo2(x)
function bar2(y)
return z -> x + y + z
end
return bar2
end
end
# typeof(M53719.f) should be pri... | The repetition of the name here is surprising to me - Can you walk me through the rationale for it? | function bar(y)
function baz(z)
return x + y + z
end
return baz
end
return bar
end
function foo2(x)
function bar2(y)
return z -> x + y + z
end
return bar2
end
lambda1 = (x)->begin
func... | @@ -755,6 +755,37 @@ end
@test startswith(sprint(show, typeof(x->x), context = :module=>@__MODULE__), "var\"")
+# PR 53719
+module M53719
+ f = x -> x + 1
+ function foo(x)
+ function bar(y)
+ function baz(z)
+ return x + y + z
+ end
+ return baz
+ ... | test/show.jl | 26 | Julia | 0.214 | question | 99 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: Julia
File: test/show.jl
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: function bar(y)
function baz(z)
return x + y + z
end
... | The repetition of the name here is surprising to me - Can you walk me through the rationale for it? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
assert(m != NULL);
// Get the outermost function name from the `parsed_method_stack` top
char *funcname = NULL;
value_t parsed_method_stack = args[0];
if (parsed_method_stack != fl_ctx->NIL) {
value_t bottom_stack_symbol = fl_applyn(fl_ctx, 1, symbol_value(symbol(fl_ctx, "last")), parsed_met... | I think it'd be better to make the dependence on `HT_NOTFOUND` explicit here
A similar encoding is used in staticdata_utils.c where the value is encoded as `x + HT_NOTFOUND + 1` and decoded as `x - HT_NOTFOUND - 1` | // such that the resulting name is not already defined in the current module's bindings.
// If the top of the stack is NIL, we simply return the current module's counter.
// This ensures that precompile statements are a bit more stable across different versions
// of a codebase. see #53719
static value_t fl_module_uniq... | @@ -208,11 +208,51 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
+// used to generate a unique suffix for a given symbol (e.g. variable or type name)
+// first argument contains a stack... | src/ast.c | 26 | C | 0.643 | suggestion | 217 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: assert(m != NULL);
// Get the outermost function name from the `parsed_method_stack` top
char *funcname = NU... | I think it'd be better to make the dependence on `HT_NOTFOUND` explicit here
A similar encoding is used in staticdata_utils.c where the value is encoded as `x + HT_NOTFOUND + 1` and decoded as `x - HT_NOTFOUND - 1` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
defining DataTypes
basic operations on struct and bits values
*/
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdalign.h>
#include "julia.h"
#include "julia_internal.h"
#include "julia_assert.h"
#include "julia_gcext.h"
#ifdef __cplusplus
extern "C" {
#endif
// allocating TypeNames -----... | ```suggestion
// Returns true for typenames in the form "#[0-9]+" or "#.*##[0-9]+"
STATIC_INLINE int is_canonicalized_anonfn_typename(char *name) JL_NOTSAFEPOINT
``` | defining DataTypes
basic operations on struct and bits values
*/
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdalign.h>
#include "julia.h"
#include "julia_internal.h"
#include "julia_assert.h"
#include "julia_gcext.h"
#ifdef __cplusplus
extern "C" {
#endif
// allocating TypeNames -----... | @@ -25,18 +25,35 @@ static int is10digit(char c) JL_NOTSAFEPOINT
return (c >= '0' && c <= '9');
}
+STATIC_INLINE int is_canonicalized_anonfn_typename(char *name) JL_NOTSAFEPOINT | src/datatype.c | 26 | C | 0.857 | suggestion | 168 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/datatype.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: defining DataTypes
basic operations on struct and bits values
*/
#include <stdlib.h>
#include <string.h>
#incl... | ```suggestion
// Returns true for typenames in the form "#[0-9]+" or "#.*##[0-9]+"
STATIC_INLINE int is_canonicalized_anonfn_typename(char *name) JL_NOTSAFEPOINT
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if (funcname != NULL && funcname[0] != '#') {
int should_check_binding_table = 0;
jl_mutex_lock_nogc(&m->lock);
htable_t *mod_table = m->counter_table;
if (mod_table == NULL) {
mod_table = m->counter_table = htable_new((htable_t *)malloc_s(sizeof(htable_t)), 0);
}... | Why `strstr` instead of `strcmp`? | assert(m != NULL);
// Get the outermost function name from the `parsed_method_stack` top
char *funcname = NULL;
value_t parsed_method_stack = args[0];
if (parsed_method_stack != fl_ctx->NIL) {
value_t bottom_stack_symbol = fl_applyn(fl_ctx, 1, symbol_value(symbol(fl_ctx, "last")), parsed_met... | @@ -208,11 +208,66 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
+// used to generate a unique suffix for a given symbol (e.g. variable or type name)
+// first argument contains a stack... | src/ast.c | 26 | C | 0.286 | question | 33 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: if (funcname != NULL && funcname[0] != '#') {
int should_check_binding_table = 0;
jl_mutex_lock_nogc... | Why `strstr` instead of `strcmp`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
ptrhash_put(mod_table, funcname, (void*)((uintptr_t)HT_NOTFOUND + 1));
should_check_binding_table = 1;
}
while (1) {
uint32_t nxt = ((uint32_t)(uintptr_t)ptrhash_get(mod_table, funcname) - (uintptr_t)HT_NOTFOUND - 1);
snprintf(buf, sizeof(buf), "%s##%d", f... | It looks like if this makes it through the check successfully, we still end up iterating one more time?
Which is bad, since that means the check is then stale. | char *buf = (char*)alloca(sz);
if (funcname != NULL && strchr(funcname, '#') == NULL) {
for (int i = 0; ; i++) {
snprintf(buf, sz, "%s##%d", funcname, i);
jl_sym_t *sym = jl_symbol(buf);
JL_LOCK(&m->lock);
if (jl_get_module_binding(m, sym, 0) == NULL) { //... | @@ -208,11 +208,66 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
+// used to generate a unique suffix for a given symbol (e.g. variable or type name)
+// first argument contains a stack... | src/ast.c | 26 | C | 0.357 | suggestion | 162 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: ptrhash_put(mod_table, funcname, (void*)((uintptr_t)HT_NOTFOUND + 1));
should_check_binding_tabl... | It looks like if this makes it through the check successfully, we still end up iterating one more time?
Which is bad, since that means the check is then stale. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// of a codebase. see #53719
static value_t fl_current_module_counter(fl_context_t *fl_ctx, value_t *args, uint32_t nargs) JL_NOTSAFEPOINT
{
argcount(fl_ctx, "current-julia-module-counter", nargs, 1);
jl_ast_context_t *ctx = jl_ast_ctx(fl_ctx);
jl_module_t *m = ctx->module;
assert(m != NULL);
// Get... | ```suggestion
int collision_found = 0;
```
Probably a good idea to add a comment explaining that the `counter_table` is dropped during serialization, so we always have to check for conflicts here. | }
// Used to generate a unique suffix for a given symbol (e.g. variable or type name)
// first argument contains a stack of method definitions seen so far by `closure-convert` in flisp.
// if the top of the stack is non-NIL, we use it to augment the suffix so that it becomes
// of the form $top_level_method_name##$cou... | @@ -208,11 +208,62 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
+// used to generate a unique suffix for a given symbol (e.g. variable or type name)
+// first argument contains a stack... | src/ast.c | 26 | C | 0.786 | suggestion | 209 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | topolarity | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: // of a codebase. see #53719
static value_t fl_current_module_counter(fl_context_t *fl_ctx, value_t *args, uint32_t narg... | ```suggestion
int collision_found = 0;
```
Probably a good idea to add a comment explaining that the `counter_table` is dropped during serialization, so we always have to check for conflicts here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if (parsed_method_stack != fl_ctx->NIL) {
value_t bottom_stack_symbol = fl_applyn(fl_ctx, 1, symbol_value(symbol(fl_ctx, "last")), parsed_method_stack);
funcname = symbol_name(fl_ctx, bottom_stack_symbol);
}
char buf[(funcname != NULL ? strlen(funcname) : 0) + 20];
if (funcname != NULL &... | This is potentially O(n^2) in the number of bindings, which I hope is unnecessary. Why is only checking for exact matches not sufficient? | static value_t fl_module_unique_name(fl_context_t *fl_ctx, value_t *args, uint32_t nargs)
{
argcount(fl_ctx, "julia-module-unique-name", nargs, 1);
jl_ast_context_t *ctx = jl_ast_ctx(fl_ctx);
jl_module_t *m = ctx->module;
assert(m != NULL);
// Get the outermost function name from the `parsed_method_... | @@ -208,11 +208,64 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
+// used to generate a unique suffix for a given symbol (e.g. variable or type name)
+// first argument contains a stack... | src/ast.c | 26 | C | 0.357 | performance | 137 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: if (parsed_method_stack != fl_ctx->NIL) {
value_t bottom_stack_symbol = fl_applyn(fl_ctx, 1, symbol_value(sy... | This is potentially O(n^2) in the number of bindings, which I hope is unnecessary. Why is only checking for exact matches not sufficient? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
function bar(y)
function baz(z)
return x + y + z
end
return baz
end
return bar
end
function foo2(x)
function bar2(y)
return z -> x + y + z
end
return bar2
end
end
# typeof(M53719.f) should be pri... | You currently only have tests for the `typeof(f)`, but your PR also makes adjustments to the printing for `f` itself. Can you please add test cases for those too? | function bar(y)
function baz(z)
return x + y + z
end
return baz
end
return bar
end
function foo2(x)
function bar2(y)
return z -> x + y + z
end
return bar2
end
lambda1 = (x)->begin
func... | @@ -755,6 +755,37 @@ end
@test startswith(sprint(show, typeof(x->x), context = :module=>@__MODULE__), "var\"")
+# PR 53719
+module M53719
+ f = x -> x + 1
+ function foo(x)
+ function bar(y)
+ function baz(z)
+ return x + y + z
+ end
+ return baz
+ ... | test/show.jl | 26 | Julia | 0.643 | question | 162 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | NHDaly | d-netto | Review this pull request change.
Language: Julia
File: test/show.jl
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: function bar(y)
function baz(z)
return x + y + z
end
... | You currently only have tests for the `typeof(f)`, but your PR also makes adjustments to the printing for `f` itself. Can you please add test cases for those too? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
argcount(fl_ctx, "nothrow-julia-global", nargs, 2);
value_t argmod = args[0];
if (iscvalue(argmod) && cv_class((cvalue_t*)ptr(argmod)) == jl_ast_ctx(fl_ctx)->jvtype) {
mod = *(jl_module_t**)cv_data((cvalue_t*)ptr(argmod));
JL_GC_PROMISE_ROOTED(mod);
} else {
... | This should be renamed since it no longer just returns a counter; maybe `module-unique-name`? | else {
argcount(fl_ctx, "nothrow-julia-global", nargs, 2);
value_t argmod = args[0];
if (iscvalue(argmod) && cv_class((cvalue_t*)ptr(argmod)) == jl_ast_ctx(fl_ctx)->jvtype) {
mod = *(jl_module_t**)cv_data((cvalue_t*)ptr(argmod));
JL_GC_PROMISE_ROOTED(mod);
} e... | @@ -208,11 +209,41 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
-static value_t fl_current_module_counter(fl_context_t *fl_ctx, value_t *args, uint32_t nargs) JL_NOTSAFEPOINT
+// used ... | src/ast.c | 26 | C | 0.429 | question | 93 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: argcount(fl_ctx, "nothrow-julia-global", nargs, 2);
value_t argmod = args[0];
if (iscvalue(argmo... | This should be renamed since it no longer just returns a counter; maybe `module-unique-name`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
jl_ast_context_t *ctx = jl_ast_ctx(fl_ctx);
jl_module_t *m = ctx->module;
assert(m != NULL);
// Get the outermost function name from the `parsed_method_stack` top
char *funcname = NULL;
value_t parsed_method_stack = args[0];
if (parsed_method_stack != fl_ctx->NIL) {
value_t bottom_st... | This becomes a world-age affecting operation with #54654, which is a bit of a problem. Sorry to throw an additional wrench in things. Let me discuss with some folks and get back to you. | // of the form $top_level_method_name##$counter, where `counter` is the smallest integer
// such that the resulting name is not already defined in the current module's bindings.
// If the top of the stack is NIL, we simply return the current module's counter.
// This ensures that precompile statements are a bit more st... | @@ -208,11 +209,41 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
-static value_t fl_current_module_counter(fl_context_t *fl_ctx, value_t *args, uint32_t nargs) JL_NOTSAFEPOINT
+// used ... | src/ast.c | 26 | C | 0.357 | suggestion | 185 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | Keno | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: jl_ast_context_t *ctx = jl_ast_ctx(fl_ctx);
jl_module_t *m = ctx->module;
assert(m != NULL);
// Get the ... | This becomes a world-age affecting operation with #54654, which is a bit of a problem. Sorry to throw an additional wrench in things. Let me discuss with some folks and get back to you. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
jl_binding_t *b = jl_get_module_binding(mod, var, 0);
b = b ? jl_atomic_load_relaxed(&b->owner) : NULL;
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
// used to generate a unique suffix for a given symbol (e.g. variable or type name)
// first argument contains a s... | VLA's are pretty unreliable (IIRC, that is why they got removed from the C standard), so best not to use them, and use either a fixed size or alloca/malloc directly | }
jl_binding_t *b = jl_get_module_binding(mod, var, 0);
jl_binding_partition_t *bpart = jl_get_binding_partition(b, jl_current_task->world_age);
jl_ptr_kind_union_t pku = jl_walk_binding_inplace(&b, &bpart, jl_current_task->world_age);
if (!bpart)
return fl_ctx->F;
if (jl_bkind_is_some_g... | @@ -208,11 +209,41 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
return b != NULL && jl_atomic_load_relaxed(&b->value) != NULL ? fl_ctx->T : fl_ctx->F;
}
-static value_t fl_current_module_counter(fl_context_t *fl_ctx, value_t *args, uint32_t nargs) JL_NOTSAFEPOINT
+// used ... | src/ast.c | 26 | C | 0.429 | suggestion | 164 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | vtjnash | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: jl_binding_t *b = jl_get_module_binding(mod, var, 0);
b = b ? jl_atomic_load_relaxed(&b->owner) : NULL;
retu... | VLA's are pretty unreliable (IIRC, that is why they got removed from the C standard), so best not to use them, and use either a fixed size or alloca/malloc directly | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
JL_DLLEXPORT int jl_pointer_egal(jl_value_t *t);
JL_DLLEXPORT jl_value_t *jl_nth_slot_type(jl_value_t *sig JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT;
void jl_compute_field_offsets(jl_datatype_t *st);
void jl_module_run_initializer(jl_module_t *m);
JL_DLLEXPORT jl_binding_t *jl_get_module_binding(jl_module_t *m JL_... | Same bug being introduced here |
JL_DLLEXPORT int jl_pointer_egal(jl_value_t *t);
JL_DLLEXPORT jl_value_t *jl_nth_slot_type(jl_value_t *sig JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT;
void jl_compute_field_offsets(jl_datatype_t *st);
void jl_module_run_initializer(jl_module_t *m);
JL_DLLEXPORT jl_binding_t *jl_get_module_binding(jl_module_t *m JL_... | @@ -861,12 +862,26 @@ jl_method_t *jl_make_opaque_closure_method(jl_module_t *module, jl_value_t *name
int nargs, jl_value_t *functionloc, jl_code_info_t *ci, int isva, int isinferred);
JL_DLLEXPORT int jl_is_valid_oc_argtype(jl_tupletype_t *argt, jl_method_t *source);
-STATIC_INLINE int is_anonfn_typename(char... | src/julia_internal.h | 26 | C/C++ | 0.214 | bug | 30 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | vtjnash | d-netto | Review this pull request change.
Language: C/C++
File: src/julia_internal.h
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE:
JL_DLLEXPORT int jl_pointer_egal(jl_value_t *t);
JL_DLLEXPORT jl_value_t *jl_nth_slot_type(jl_value_t *s... | Same bug being introduced here | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if (jl_bkind_is_some_guard(decode_restriction_kind(pku)))
return fl_ctx->F;
return (jl_bkind_is_some_constant(decode_restriction_kind(pku)) ?
decode_restriction_value(pku) : jl_atomic_load_relaxed(&b->value)) != NULL ? fl_ctx->T : fl_ctx->F;
}
// Used to generate a unique suffix for a given sy... | ```suggestion
funcname = tosymbol(fl_ctx, bottom_stack_symbol, "current-julia-module-counter")->name;
``` | if (jl_bkind_is_some_guard(decode_restriction_kind(pku)))
return fl_ctx->F;
return (jl_bkind_is_some_constant(decode_restriction_kind(pku)) ?
decode_restriction_value(pku) : jl_atomic_load_relaxed(&b->value)) != NULL ? fl_ctx->T : fl_ctx->F;
}
// Used to generate a unique suffix for a given sy... | @@ -215,11 +216,43 @@ static value_t fl_nothrow_julia_global(fl_context_t *fl_ctx, value_t *args, uint
decode_restriction_value(pku) : jl_atomic_load_relaxed(&b->value)) != NULL ? fl_ctx->T : fl_ctx->F;
}
-static value_t fl_current_module_counter(fl_context_t *fl_ctx, value_t *args, uint32_t nargs) JL_NOTSA... | src/ast.c | 26 | C | 0.714 | suggestion | 115 | 51 | 51 | false | Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair | 53,719 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | d-netto | Review this pull request change.
Language: C
File: src/ast.c
PR Title: Canonicalize names of nested functions by keeping a more fine grained counter -- per (module, method name) pair
BEFORE CODE: if (jl_bkind_is_some_guard(decode_restriction_kind(pku)))
return fl_ctx->F;
return (jl_bkind_is_some_co... | ```suggestion
funcname = tosymbol(fl_ctx, bottom_stack_symbol, "current-julia-module-counter")->name;
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
clamp, clamp!, modf, ^, mod2pi, rem2pi,
@evalpoly, evalpoly
import .Base: log, exp, sin, cos, tan, sinh, cosh, tanh, asin,
acos, atan, asinh, acosh, atanh, sqrt, log2, log10,
max, min, minmax, ^, exp2, muladd, rem,
exp10, expm1, log1p, @constprop, @assume_effects
u... | Is this really necessary? Throwing an error really should be known to terminate. Is LazyString getting in the way somehow? If so, IMO, this should be fixed on the LazyString side, not here. | clamp, clamp!, modf, ^, mod2pi, rem2pi,
@evalpoly, evalpoly
import .Base: log, exp, sin, cos, tan, sinh, cosh, tanh, asin,
acos, atan, asinh, acosh, atanh, sqrt, log2, log10,
max, min, minmax, ^, exp2, muladd, rem,
exp10, expm1, log1p, @constprop, @assume_effects
u... | @@ -37,7 +37,7 @@ end
throw(DomainError(x,
LazyString(f," was called with a real argument < -1 but will only return a complex result if called with a complex argument. Try ", f,"(Complex(x)).")))
end
-@noinline function throw_exp_domainerror(x)
+@assume_effects :terminates_globally @noinline function thr... | base/math.jl | 26 | Julia | 0.571 | question | 189 | 51 | 51 | false | power uses Float64 exponents for integers | 53,967 | JuliaLang/julia | 35,573 | Julia | oscardssmith | KlausC | Review this pull request change.
Language: Julia
File: base/math.jl
PR Title: power uses Float64 exponents for integers
BEFORE CODE: clamp, clamp!, modf, ^, mod2pi, rem2pi,
@evalpoly, evalpoly
import .Base: log, exp, sin, cos, tan, sinh, cosh, tanh, asin,
acos, atan, asinh, acosh, atanh,... | Is this really necessary? Throwing an error really should be known to terminate. Is LazyString getting in the way somehow? If so, IMO, this should be fixed on the LazyString side, not here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""
modf(x)
Return a tuple `(fpart, ipart)` of the fractional and integral parts of a number. Both parts
have the same sign as the argument.
# Examples
```jldoctest
julia> modf(3.5)
(0.5, 3.0)
julia> modf(-3.5)
(-0.5, -3.0)
```
"""
modf(x) = isinf(x) ? (flipsign(zero(x), x), x) : (rem(x, one(x)), trunc(x))
fun... | is this function really used during bootstrap? | end
end
end
return flipsign(x, oldx)
end
"""
modf(x)
Return a tuple `(fpart, ipart)` of the fractional and integral parts of a number. Both parts
have the same sign as the argument.
# Examples
```jldoctest
julia> modf(3.5)
(0.5, 3.0)
julia> modf(-3.5)
(-0.5, -3.0)
```
"""
modf(x) = ... | @@ -1255,6 +1255,15 @@ function modf(x::T) where T<:IEEEFloat
return (rx, ix)
end
+@inline function use_power_by_squaring(n::Union{Int32,Int64,Int128,UInt32,UInt64,UInt128}) | base/math.jl | 26 | Julia | 0.143 | question | 46 | 51 | 51 | false | power uses Float64 exponents for integers | 53,967 | JuliaLang/julia | 35,573 | Julia | oscardssmith | KlausC | Review this pull request change.
Language: Julia
File: base/math.jl
PR Title: power uses Float64 exponents for integers
BEFORE CODE:
"""
modf(x)
Return a tuple `(fpart, ipart)` of the fractional and integral parts of a number. Both parts
have the same sign as the argument.
# Examples
```jldoctest
julia> modf... | is this function really used during bootstrap? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@constprop :aggressive function ^(x::Float64, y::Float64)
xu = reinterpret(UInt64, x)
xu == reinterpret(UInt64, 1.0) && return 1.0
# Exponents greater than this will always overflow or underflow.
# Note that NaN can pass through this, but that will end up fine.
if !(abs(y)<0x1.8p62)
isnan(y)... | why is this assume_effects needed? It really shouldn't be. | # variants for callers with constant `y`
@constprop :aggressive function ^(x::Float64, y::Float64)
xu = reinterpret(UInt64, x)
xu == reinterpret(UInt64, 1.0) && return 1.0
# Exponents greater than this will always overflow or underflow.
# Note that NaN can pass through this, but that will end up fine.
... | @@ -1267,19 +1276,28 @@ end
y = sign(y)*0x1.8p62
end
yint = unsafe_trunc(Int64, y) # This is actually safe since julia freezes the result
- y == yint && return @noinline x^yint
- 2*xu==0 && return abs(y)*Inf*(!(y>0)) # if x==0
- x<0 && throw_exp_domainerror(x) # |y| is small enough that y is... | base/math.jl | 26 | Julia | 0.286 | question | 58 | 51 | 51 | false | power uses Float64 exponents for integers | 53,967 | JuliaLang/julia | 35,573 | Julia | oscardssmith | KlausC | Review this pull request change.
Language: Julia
File: base/math.jl
PR Title: power uses Float64 exponents for integers
BEFORE CODE: @constprop :aggressive function ^(x::Float64, y::Float64)
xu = reinterpret(UInt64, x)
xu == reinterpret(UInt64, 1.0) && return 1.0
# Exponents greater than this will alway... | why is this assume_effects needed? It really shouldn't be. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@constprop :aggressive function ^(x::T, y::T) where T <: Union{Float16, Float32}
x == 1 && return one(T)
# Exponents greater than this will always overflow or underflow.
# Note that NaN can pass through this, but that will end up fine.
max_exp = T == Float16 ? T(3<<14) : T(0x1.Ap30)
if !(abs(y)<max_... | ```suggestion
return x^clamp(n, Int64)
``` |
@constprop :aggressive function ^(x::T, y::T) where T <: Union{Float16, Float32}
x == 1 && return one(T)
# Exponents greater than this will always overflow or underflow.
# Note that NaN can pass through this, but that will end up fine.
max_exp = T == Float16 ? T(3<<14) : T(0x1.Ap30)
if !(abs(y)<max... | @@ -1308,14 +1326,37 @@ end
return T(exp2(log2(abs(widen(x))) * y))
end
-# compensated power by squaring
@constprop :aggressive @inline function ^(x::Float64, n::Integer)
+ T = Int64
+ m = n >= typemax(T) ? typemax(T) : n <= typemin(T) ? typemin(T) : n
+ x^(m%Int64)
+end | base/math.jl | 26 | Julia | 0.429 | suggestion | 44 | 51 | 51 | false | power uses Float64 exponents for integers | 53,967 | JuliaLang/julia | 35,573 | Julia | oscardssmith | KlausC | Review this pull request change.
Language: Julia
File: base/math.jl
PR Title: power uses Float64 exponents for integers
BEFORE CODE: @constprop :aggressive function ^(x::T, y::T) where T <: Union{Float16, Float32}
x == 1 && return one(T)
# Exponents greater than this will always overflow or underflow.
#... | ```suggestion
return x^clamp(n, Int64)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if !(abs(y)<max_exp)
isnan(y) && return y
y = sign(y)*max_exp
end
yint = unsafe_trunc(Int32, y) # This is actually safe since julia freezes the result
y == yint && return x^yint
x < 0 && throw_exp_domainerror(x)
!isfinite(x) && return x*(y>0 || isnan(x))
x==0 && return abs(y)... | can't this just be `pow_body(x, Float64(n))`? | max_exp = T == Float16 ? T(3<<14) : T(0x1.Ap30)
if !(abs(y)<max_exp)
isnan(y) && return y
y = sign(y)*max_exp
end
yint = unsafe_trunc(Int32, y) # This is actually safe since julia freezes the result
y == yint && return x^yint
x < 0 && throw_exp_domainerror(x)
!isfinite(x) && ... | @@ -1308,14 +1326,37 @@ end
return T(exp2(log2(abs(widen(x))) * y))
end
-# compensated power by squaring
@constprop :aggressive @inline function ^(x::Float64, n::Integer)
+ T = Int64
+ m = n >= typemax(T) ? typemax(T) : n <= typemin(T) ? typemin(T) : n
+ x^(m%Int64)
+end
+# compensated power by squari... | base/math.jl | 26 | Julia | 0.214 | question | 45 | 51 | 51 | false | power uses Float64 exponents for integers | 53,967 | JuliaLang/julia | 35,573 | Julia | oscardssmith | KlausC | Review this pull request change.
Language: Julia
File: base/math.jl
PR Title: power uses Float64 exponents for integers
BEFORE CODE: if !(abs(y)<max_exp)
isnan(y) && return y
y = sign(y)*max_exp
end
yint = unsafe_trunc(Int32, y) # This is actually safe since julia freezes the result
... | can't this just be `pow_body(x, Float64(n))`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@evalpoly, evalpoly
import .Base: log, exp, sin, cos, tan, sinh, cosh, tanh, asin,
acos, atan, asinh, acosh, atanh, sqrt, log2, log10,
max, min, minmax, ^, exp2, muladd, rem,
exp10, expm1, log1p, @constprop, @assume_effects
using .Base: sign_mask, exponent_mask, exponent_... | ```suggestion
@noinline function throw_exp_domainerror(x)
throw(DomainError(x,
``` | @evalpoly, evalpoly
import .Base: log, exp, sin, cos, tan, sinh, cosh, tanh, asin,
acos, atan, asinh, acosh, atanh, sqrt, log2, log10,
max, min, minmax, ^, exp2, muladd, rem,
exp10, expm1, log1p, @constprop, @assume_effects
using .Base: sign_mask, exponent_mask, exponent_... | @@ -37,7 +37,7 @@ end
throw(DomainError(x,
LazyString(f," was called with a real argument < -1 but will only return a complex result if called with a complex argument. Try ", f,"(Complex(x)).")))
end
-@noinline function throw_exp_domainerror(x)
+@assume_effects :terminates_globally @noinline function thr... | base/math.jl | 26 | Julia | 0.714 | suggestion | 89 | 51 | 51 | false | power uses Float64 exponents for integers | 53,967 | JuliaLang/julia | 35,573 | Julia | oscardssmith | KlausC | Review this pull request change.
Language: Julia
File: base/math.jl
PR Title: power uses Float64 exponents for integers
BEFORE CODE: @evalpoly, evalpoly
import .Base: log, exp, sin, cos, tan, sinh, cosh, tanh, asin,
acos, atan, asinh, acosh, atanh, sqrt, log2, log10,
max, min, minm... | ```suggestion
@noinline function throw_exp_domainerror(x)
throw(DomainError(x,
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@constprop :aggressive function ^(x::Float64, y::Float64)
xu = reinterpret(UInt64, x)
xu == reinterpret(UInt64, 1.0) && return 1.0
# Exponents greater than this will always overflow or underflow.
# Note that NaN can pass through this, but that will end up fine.
if !(abs(y)<0x1.8p62)
isnan(y)... | I think we don't want this `@inline` but we do want the one on `exp_impl`. (because we want the `^`to inline so the compiler can const prop the `int` conversion etc. | @constprop :aggressive function ^(x::Float64, y::Float64)
xu = reinterpret(UInt64, x)
xu == reinterpret(UInt64, 1.0) && return 1.0
# Exponents greater than this will always overflow or underflow.
# Note that NaN can pass through this, but that will end up fine.
if !(abs(y)<0x1.8p62)
isnan(y)... | @@ -1292,7 +1292,7 @@ end
return copysign(pow_body(abs(x), y), s)
end
-@assume_effects :foldable @noinline function pow_body(x::Float64, y::Float64)
+@assume_effects :foldable @inline function pow_body(x::Float64, y::Float64) | base/math.jl | 26 | Julia | 0.571 | suggestion | 165 | 51 | 51 | false | power uses Float64 exponents for integers | 53,967 | JuliaLang/julia | 35,573 | Julia | oscardssmith | KlausC | Review this pull request change.
Language: Julia
File: base/math.jl
PR Title: power uses Float64 exponents for integers
BEFORE CODE: @constprop :aggressive function ^(x::Float64, y::Float64)
xu = reinterpret(UInt64, x)
xu == reinterpret(UInt64, 1.0) && return 1.0
# Exponents greater than this will alway... | I think we don't want this `@inline` but we do want the one on `exp_impl`. (because we want the `^`to inline so the compiler can const prop the `int` conversion etc. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@constprop :aggressive @inline function ^(x::Float64, n::Integer)
x^clamp(n, Int64)
end
@constprop :aggressive @inline function ^(x::Float64, n::Int64)
n == 0 && return one(x)
if use_power_by_squaring(n)
return pow_body(x, n)
else
s = ifelse(x < 0 && isodd(n), -1.0, 1.0)
x = abs(... | given that `n==0` is explicitly checked for in both versions of `^`, I'm pretty sure this is always redundant. | @constprop :aggressive @inline function ^(x::Float64, n::Integer)
x^clamp(n, Int64)
end
@constprop :aggressive @inline function ^(x::Float64, n::Int64)
n == 0 && return one(x)
if use_power_by_squaring(n)
return pow_body(x, n)
else
s = ifelse(x < 0 && isodd(n), -1.0, 1.0)
x = abs(... | @@ -1314,14 +1327,32 @@ end
return T(exp2(log2(abs(widen(x))) * y))
end
-# compensated power by squaring
@constprop :aggressive @inline function ^(x::Float64, n::Integer)
+ x^clamp(n, Int64)
+end
+@constprop :aggressive @inline function ^(x::Float64, n::Int64)
n == 0 && return one(x)
- return pow_bo... | base/math.jl | 26 | Julia | 0.5 | suggestion | 110 | 51 | 51 | false | power uses Float64 exponents for integers | 53,967 | JuliaLang/julia | 35,573 | Julia | oscardssmith | KlausC | Review this pull request change.
Language: Julia
File: base/math.jl
PR Title: power uses Float64 exponents for integers
BEFORE CODE: @constprop :aggressive @inline function ^(x::Float64, n::Integer)
x^clamp(n, Int64)
end
@constprop :aggressive @inline function ^(x::Float64, n::Int64)
n == 0 && return one(x)... | given that `n==0` is explicitly checked for in both versions of `^`, I'm pretty sure this is always redundant. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@test abs(expected-got) <= POW_TOLS[T][1]*eps(T(expected)) || (x,y)
end
end
end
for _ in 1:2^14
# test subnormal(x), y in -1.2, 1.8 since anything larger just overflows.
x=rand(T)*floatmin(T); y=rand(T)*3-T(1.2)
got, exp... | this test is slightly overspecified. I would change it to `≈` | @test abs(expected-got) <= POW_TOLS[T][1]*eps(T(expected)) || (x,y)
end
end
end
for _ in 1:2^14
# test subnormal(x), y in -1.2, 1.8 since anything larger just overflows.
x=rand(T)*floatmin(T); y=rand(T)*3-T(1.2)
got, exp... | @@ -1470,6 +1470,24 @@ end
# two cases where we have observed > 1 ULP in the past
@test 0.0013653274095082324^-97.60372292227069 == 4.088393948750035e279
@test 8.758520413376658e-5^70.55863059215994 == 5.052076767078296e-287
+
+ # issue #53881
+ @test prevfloat(1.0) ^ -Int64(2)^62 == 2.284413586539... | test/math.jl | 26 | Julia | 0.429 | suggestion | 61 | 51 | 51 | false | power uses Float64 exponents for integers | 53,967 | JuliaLang/julia | 35,573 | Julia | oscardssmith | KlausC | Review this pull request change.
Language: Julia
File: test/math.jl
PR Title: power uses Float64 exponents for integers
BEFORE CODE: @test abs(expected-got) <= POW_TOLS[T][1]*eps(T(expected)) || (x,y)
end
end
end
for _ in 1:2^14
# test subn... | this test is slightly overspecified. I would change it to `≈` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@test Base.IteratorEltype(typeof(takewhile(<(4),Iterators.map(identity, 1:10)))) isa Base.EltypeUnknown
end
# dropwhile
# --------
@testset begin
@test collect(dropwhile(<(4), 1:10)) == 4:10
@test collect(dropwhile(<(4), 1:10)) isa Vector{Int}
@test isempty(dropwhile(<(4), []))
@test collect(dropwh... | Could you comment on this testcase? Is it not the same (but more cryptic imho) as the test on the following line, `@test isempty(f)`? | @test (@inferred Base.IteratorEltype(typeof(takewhile(<(4),Iterators.map(identity, 1:10))))) isa Base.EltypeUnknown
end
# dropwhile
# --------
@testset begin
@test collect(dropwhile(<(4), 1:10)) == 4:10
@test collect(dropwhile(<(4), 1:10)) isa Vector{Int}
@test @inferred isempty(dropwhile(<(4), []))
... | @@ -242,6 +242,23 @@ end
@test Base.IteratorEltype(typeof(dropwhile(<(4),Iterators.map(identity, 1:10)))) isa Base.EltypeUnknown
end
+# findall
+# ----------------
+@testset "Iterators.findall" begin
+ let findall = Iterators.findall
+ f = findall(isnumeric, "abc257wf")
+ @test !(f isa Abstract... | test/iterators.jl | 26 | Julia | 0.571 | question | 133 | 51 | 51 | false | Add `Iterators.findeach` | 54,124 | JuliaLang/julia | 35,573 | Julia | barucden | jakobnissen | Review this pull request change.
Language: Julia
File: test/iterators.jl
PR Title: Add `Iterators.findeach`
BEFORE CODE: @test Base.IteratorEltype(typeof(takewhile(<(4),Iterators.map(identity, 1:10)))) isa Base.EltypeUnknown
end
# dropwhile
# --------
@testset begin
@test collect(dropwhile(<(4), 1:10)) == ... | Could you comment on this testcase? Is it not the same (but more cryptic imho) as the test on the following line, `@test isempty(f)`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
IteratorSize(::Type{<:DropWhile}) = SizeUnknown()
eltype(::Type{DropWhile{I,P}}) where {I,P} = eltype(I)
IteratorEltype(::Type{DropWhile{I,P}}) where {I,P} = IteratorEltype(I)
"""
findall(f, it)
An iterator that generates every key from the key/value pairs of `pairs(it)`,
where `f(value)` returns `true`.
`Iterat... | composition can be used here:
```suggestion
findall(f, it) = map(first, filter(f ∘ last, pairs(it)))
``` | dropwhile(pred,itr) = DropWhile(pred,itr)
iterate(ibl::DropWhile,itr) = iterate(ibl.xs, itr)
function iterate(ibl::DropWhile)
y = iterate(ibl.xs)
while y !== nothing
ibl.pred(y[1]) || break
y = iterate(ibl.xs,y[2])
end
y
end
IteratorSize(::Type{<:DropWhile}) = SizeUnknown()
eltype(::Ty... | @@ -934,6 +934,28 @@ IteratorSize(::Type{<:DropWhile}) = SizeUnknown()
eltype(::Type{DropWhile{I,P}}) where {I,P} = eltype(I)
IteratorEltype(::Type{DropWhile{I,P}}) where {I,P} = IteratorEltype(I)
+"""
+ findall(f, it)
+
+An iterator that generates every key from the key/value pairs of `pairs(it)`,
+where `f(val... | base/iterators.jl | 26 | Julia | 0.786 | suggestion | 109 | 51 | 51 | false | Add `Iterators.findeach` | 54,124 | JuliaLang/julia | 35,573 | Julia | nsajko | jakobnissen | Review this pull request change.
Language: Julia
File: base/iterators.jl
PR Title: Add `Iterators.findeach`
BEFORE CODE:
IteratorSize(::Type{<:DropWhile}) = SizeUnknown()
eltype(::Type{DropWhile{I,P}}) where {I,P} = eltype(I)
IteratorEltype(::Type{DropWhile{I,P}}) where {I,P} = IteratorEltype(I)
"""
findall(f... | composition can be used here:
```suggestion
findall(f, it) = map(first, filter(f ∘ last, pairs(it)))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
const Base = parentmodule(@__MODULE__)
using .Base:
@inline, Pair, Pairs, AbstractDict, IndexLinear, IndexStyle, AbstractVector, Vector,
SizeUnknown, HasLength, HasShape, IsInfinite, EltypeUnknown, HasEltype, OneTo,
@propagate_inbounds, @isdefined, @boundscheck, @inbounds, Generator, IdDict,
AbstractRan... | All these exports are bad because they conflict with Base exports. There's no use (unless you use `baremodule`). Let's not add another export (make it public :) ) | const Base = parentmodule(@__MODULE__)
using .Base:
@inline, Pair, Pairs, AbstractDict, IndexLinear, IndexStyle, AbstractVector, Vector,
SizeUnknown, HasLength, HasShape, IsInfinite, EltypeUnknown, HasEltype, OneTo,
@propagate_inbounds, @isdefined, @boundscheck, @inbounds, Generator, IdDict,
AbstractRan... | @@ -32,7 +32,7 @@ import Base:
getindex, setindex!, get, iterate,
popfirst!, isdone, peek, intersect
-export enumerate, zip, rest, countfrom, take, drop, takewhile, dropwhile, cycle, repeated, product, flatten, flatmap, partition
+export enumerate, zip, rest, countfrom, take, drop, takewhile, dropwhile, cyc... | base/iterators.jl | 26 | Julia | 0.571 | suggestion | 162 | 51 | 51 | false | Add `Iterators.findeach` | 54,124 | JuliaLang/julia | 35,573 | Julia | LilithHafner | jakobnissen | Review this pull request change.
Language: Julia
File: base/iterators.jl
PR Title: Add `Iterators.findeach`
BEFORE CODE: const Base = parentmodule(@__MODULE__)
using .Base:
@inline, Pair, Pairs, AbstractDict, IndexLinear, IndexStyle, AbstractVector, Vector,
SizeUnknown, HasLength, HasShape, IsInfinite, Elty... | All these exports are bad because they conflict with Base exports. There's no use (unless you use `baremodule`). Let's not add another export (make it public :) ) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
julia> collect(Iterators.dropwhile(<(3),s))
3-element Vector{Int64}:
3
4
5
```
"""
dropwhile(pred,itr) = DropWhile(pred,itr)
iterate(ibl::DropWhile,itr) = iterate(ibl.xs, itr)
function iterate(ibl::DropWhile)
y = iterate(ibl.xs)
while y !== nothing
ibl.pred(y[1]) || break
y = iterate(ibl.xs... | ```suggestion
findall(f, it)
findall(it)
```
To be consistent with the Base version |
# Examples
```jldoctest
julia> s = collect(1:5)
5-element Vector{Int64}:
1
2
3
4
5
julia> collect(Iterators.dropwhile(<(3),s))
3-element Vector{Int64}:
3
4
5
```
"""
dropwhile(pred,itr) = DropWhile(pred,itr)
iterate(ibl::DropWhile,itr) = iterate(ibl.xs, itr)
function iterate(ibl::DropWhile)
y = iterate(... | @@ -934,6 +934,28 @@ IteratorSize(::Type{<:DropWhile}) = SizeUnknown()
eltype(::Type{DropWhile{I,P}}) where {I,P} = eltype(I)
IteratorEltype(::Type{DropWhile{I,P}}) where {I,P} = IteratorEltype(I)
+"""
+ findall(f, it) | base/iterators.jl | 26 | Julia | 0.571 | suggestion | 95 | 51 | 51 | false | Add `Iterators.findeach` | 54,124 | JuliaLang/julia | 35,573 | Julia | LilithHafner | jakobnissen | Review this pull request change.
Language: Julia
File: base/iterators.jl
PR Title: Add `Iterators.findeach`
BEFORE CODE:
julia> collect(Iterators.dropwhile(<(3),s))
3-element Vector{Int64}:
3
4
5
```
"""
dropwhile(pred,itr) = DropWhile(pred,itr)
iterate(ibl::DropWhile,itr) = iterate(ibl.xs, itr)
function itera... | ```suggestion
findall(f, it)
findall(it)
```
To be consistent with the Base version | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""
findeach(f, it)
findeach(it)
An iterator that generates every key from the key/value pairs of `pairs(it)`,
where `f(value)` returns `true`.
If `f` is not specified, default to `identity`.
`Iterators.findeach` is the lazy equivalent of `findall`.
!!! compat "Julia 1.13"
Lazy `findeach` requires at l... | Could also write this a bit more succinctly as
```suggestion
findeach(f, it) = (k for (k, v) in pairs(it) if f(v))
``` |
"""
findeach(f, it)
findeach(it)
An iterator that generates every key from the key/value pairs of `pairs(it)`,
where `f(value)` returns `true`.
If `f` is not specified, default to `identity`.
`Iterators.findeach` is the lazy equivalent of `findall`.
!!! compat "Julia 1.13"
`findeach` requires at least ... | @@ -945,6 +945,34 @@ IteratorSize(::Type{<:DropWhile}) = SizeUnknown()
eltype(::Type{DropWhile{I,P}}) where {I,P} = eltype(I)
IteratorEltype(::Type{DropWhile{I,P}}) where {I,P} = IteratorEltype(I)
+"""
+ findeach(f, it)
+ findeach(it)
+
+An iterator that generates every key from the key/value pairs of `pairs(... | base/iterators.jl | 26 | Julia | 0.786 | suggestion | 121 | 51 | 51 | false | Add `Iterators.findeach` | 54,124 | JuliaLang/julia | 35,573 | Julia | ararslan | jakobnissen | Review this pull request change.
Language: Julia
File: base/iterators.jl
PR Title: Add `Iterators.findeach`
BEFORE CODE:
"""
findeach(f, it)
findeach(it)
An iterator that generates every key from the key/value pairs of `pairs(it)`,
where `f(value)` returns `true`.
If `f` is not specified, default to `ide... | Could also write this a bit more succinctly as
```suggestion
findeach(f, it) = (k for (k, v) in pairs(it) if f(v))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# takewhile
# --------
@testset begin
@test collect(takewhile(<(4),1:10)) == [1,2,3]
@test collect(takewhile(<(4),Iterators.countfrom(1))) == [1,2,3]
@test collect(takewhile(<(4),5:10)) == []
@test collect(takewhile(Returns(true),5:10)) == 5:10
@test collect(takewhile(isodd,[1,1,2,3])) == [1,1]
... | ```suggestion
# findeach
``` | # takewhile
# --------
@testset begin
@test collect(takewhile(<(4),1:10)) == [1,2,3]
@test collect(takewhile(<(4),Iterators.countfrom(1))) == [1,2,3]
@test collect(takewhile(<(4),5:10)) == []
@test collect(takewhile(Returns(true),5:10)) == 5:10
@test collect(takewhile(isodd,[1,1,2,3])) == [1,1]
... | @@ -242,6 +242,23 @@ end
@test (@inferred Base.IteratorEltype(typeof(dropwhile(<(4),Iterators.map(identity, 1:10))))) isa Base.EltypeUnknown
end
+# findall | test/iterators.jl | 26 | Julia | 0.429 | suggestion | 30 | 51 | 51 | false | Add `Iterators.findeach` | 54,124 | JuliaLang/julia | 35,573 | Julia | ararslan | jakobnissen | Review this pull request change.
Language: Julia
File: test/iterators.jl
PR Title: Add `Iterators.findeach`
BEFORE CODE: # takewhile
# --------
@testset begin
@test collect(takewhile(<(4),1:10)) == [1,2,3]
@test collect(takewhile(<(4),Iterators.countfrom(1))) == [1,2,3]
@test collect(takewhile(<(4),5:10... | ```suggestion
# findeach
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
function iterate(ibl::DropWhile)
y = iterate(ibl.xs)
while y !== nothing
ibl.pred(y[1]) || break
y = iterate(ibl.xs,y[2])
end
y
end
IteratorSize(::Type{<:DropWhile}) = SizeUnknown()
eltype(::Type{DropWhile{I,P}}) where {I,P} = eltype(I)
IteratorEltype(::Type{DropWhile{I,P}}) where {I,P}... | The "lazy" qualifier here makes it sound like there's a differently behaving `findeach` in another version.
```suggestion
`findeach` requires at least Julia 1.13.
``` | function iterate(ibl::DropWhile)
y = iterate(ibl.xs)
while y !== nothing
ibl.pred(y[1]) || break
y = iterate(ibl.xs,y[2])
end
y
end
IteratorSize(::Type{<:DropWhile}) = SizeUnknown()
eltype(::Type{DropWhile{I,P}}) where {I,P} = eltype(I)
IteratorEltype(::Type{DropWhile{I,P}}) where {I,P}... | @@ -945,6 +945,34 @@ IteratorSize(::Type{<:DropWhile}) = SizeUnknown()
eltype(::Type{DropWhile{I,P}}) where {I,P} = eltype(I)
IteratorEltype(::Type{DropWhile{I,P}}) where {I,P} = IteratorEltype(I)
+"""
+ findeach(f, it)
+ findeach(it)
+
+An iterator that generates every key from the key/value pairs of `pairs(... | base/iterators.jl | 26 | Julia | 0.714 | suggestion | 173 | 51 | 51 | false | Add `Iterators.findeach` | 54,124 | JuliaLang/julia | 35,573 | Julia | ararslan | jakobnissen | Review this pull request change.
Language: Julia
File: base/iterators.jl
PR Title: Add `Iterators.findeach`
BEFORE CODE: function iterate(ibl::DropWhile)
y = iterate(ibl.xs)
while y !== nothing
ibl.pred(y[1]) || break
y = iterate(ibl.xs,y[2])
end
y
end
IteratorSize(::Type{<:DropWhil... | The "lazy" qualifier here makes it sound like there's a differently behaving `findeach` in another version.
```suggestion
`findeach` requires at least Julia 1.13.
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
number generator, see [Random Numbers](@ref).
# Examples
```jldoctest
julia> Random.seed!(3); randstring()
"Lxz5hUwn"
julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia> randstring("ACGT")
"TGCTCCTC"
```
!!! note
`chars` can be any collection of characters, of type `Char` or
`UInt8` (more efficient), ... | I am not sure it is worth doing in this specific instance but presumably structuring it like:
```julia
f(x::Integer) = f(convert(Int, n))
f(x::Int) = ...
```
would reduce compilation time since you would not compile the main function body for multiple integer types. | number generator, see [Random Numbers](@ref).
# Examples
```jldoctest
julia> Random.seed!(3); randstring()
"Lxz5hUwn"
julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia> randstring("ACGT")
"TGCTCCTC"
```
!!! note
`chars` can be any collection of characters, of type `Char` or
`UInt8` (more efficient), ... | @@ -71,13 +71,14 @@ let b = UInt8['0':'9';'A':'Z';'a':'z']
global randstring
function randstring(r::AbstractRNG, chars=b, n::Integer=8)
+ _n = convert(Int, n) | stdlib/Random/src/misc.jl | 26 | Julia | 0.929 | suggestion | 276 | 51 | 51 | false | Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method | 54,402 | JuliaLang/julia | 35,573 | Julia | KristofferC | Seelengrab | Review this pull request change.
Language: Julia
File: stdlib/Random/src/misc.jl
PR Title: Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method
BEFORE CODE: number generator, see [Random Numbers](@ref).
# Examples
```jldoctest
julia> Random.seed!(3); randstring()... | I am not sure it is worth doing in this specific instance but presumably structuring it like:
```julia
f(x::Integer) = f(convert(Int, n))
f(x::Int) = ...
```
would reduce compilation time since you would not compile the main function body for multiple integer types. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
number generator, see [Random Numbers](@ref).
# Examples
```jldoctest
julia> Random.seed!(3); randstring()
"Lxz5hUwn"
julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia> randstring("ACGT")
"TGCTCCTC"
```
!!! note
`chars` can be any collection of characters, of type `Char` or
`UInt8` (more efficient), ... | How about this:
```suggestion
n = convert(Int, n)::Int
```
Then the rest of the diff can be dropped. | number generator, see [Random Numbers](@ref).
# Examples
```jldoctest
julia> Random.seed!(3); randstring()
"Lxz5hUwn"
julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia> randstring("ACGT")
"TGCTCCTC"
```
!!! note
`chars` can be any collection of characters, of type `Char` or
`UInt8` (more efficient), ... | @@ -71,13 +71,14 @@ let b = UInt8['0':'9';'A':'Z';'a':'z']
global randstring
function randstring(r::AbstractRNG, chars=b, n::Integer=8)
+ _n = convert(Int, n) | stdlib/Random/src/misc.jl | 26 | Julia | 0.714 | suggestion | 116 | 51 | 51 | false | Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method | 54,402 | JuliaLang/julia | 35,573 | Julia | nsajko | Seelengrab | Review this pull request change.
Language: Julia
File: stdlib/Random/src/misc.jl
PR Title: Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method
BEFORE CODE: number generator, see [Random Numbers](@ref).
# Examples
```jldoctest
julia> Random.seed!(3); randstring()... | How about this:
```suggestion
n = convert(Int, n)::Int
```
Then the rest of the diff can be dropped. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia> randstring("ACGT")
"TGCTCCTC"
```
!!! note
`chars` can be any collection of characters, of type `Char` or
`UInt8` (more efficient), provided [`rand`](@ref) can randomly
pick characters from it.
"""
function randstring end
let b = UInt8['0':'9';'A'... | ```suggestion
v = Vector{T}(undef, n)
``` | julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia> randstring("ACGT")
"TGCTCCTC"
```
!!! note
`chars` can be any collection of characters, of type `Char` or
`UInt8` (more efficient), provided [`rand`](@ref) can randomly
pick characters from it.
"""
function randstring end
let b = UInt8['0':'9';'A'... | @@ -71,13 +71,14 @@ let b = UInt8['0':'9';'A':'Z';'a':'z']
global randstring
function randstring(r::AbstractRNG, chars=b, n::Integer=8)
+ _n = convert(Int, n)
T = eltype(chars)
if T === UInt8
- str = Base._string_n(n)
- GC.@preserve str rand!(r, UnsafeView(poin... | stdlib/Random/src/misc.jl | 26 | Julia | 0.571 | suggestion | 55 | 51 | 51 | false | Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method | 54,402 | JuliaLang/julia | 35,573 | Julia | nsajko | Seelengrab | Review this pull request change.
Language: Julia
File: stdlib/Random/src/misc.jl
PR Title: Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method
BEFORE CODE: julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia> randstring("ACGT")
"TGCTCCTC"
```
!!! note
... | ```suggestion
v = Vector{T}(undef, n)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
julia> Random.seed!(3); randstring()
"Lxz5hUwn"
julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia> randstring("ACGT")
"TGCTCCTC"
```
!!! note
`chars` can be any collection of characters, of type `Char` or
`UInt8` (more efficient), provided [`rand`](@ref) can randomly
pick characters from it.
"""
f... | ```suggestion
str = Base._string_n(n)
GC.@preserve str rand!(r, UnsafeView(pointer(str), n), chars)
``` | julia> Random.seed!(3); randstring()
"Lxz5hUwn"
julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia> randstring("ACGT")
"TGCTCCTC"
```
!!! note
`chars` can be any collection of characters, of type `Char` or
`UInt8` (more efficient), provided [`rand`](@ref) can randomly
pick characters from it.
"""
f... | @@ -71,13 +71,14 @@ let b = UInt8['0':'9';'A':'Z';'a':'z']
global randstring
function randstring(r::AbstractRNG, chars=b, n::Integer=8)
+ _n = convert(Int, n)
T = eltype(chars)
if T === UInt8
- str = Base._string_n(n)
- GC.@preserve str rand!(r, UnsafeView(poin... | stdlib/Random/src/misc.jl | 26 | Julia | 0.714 | suggestion | 130 | 51 | 51 | false | Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method | 54,402 | JuliaLang/julia | 35,573 | Julia | nsajko | Seelengrab | Review this pull request change.
Language: Julia
File: stdlib/Random/src/misc.jl
PR Title: Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method
BEFORE CODE: julia> Random.seed!(3); randstring()
"Lxz5hUwn"
julia> randstring(Xoshiro(3), 'a':'z', 6)
"iyzcsm"
julia>... | ```suggestion
str = Base._string_n(n)
GC.@preserve str rand!(r, UnsafeView(pointer(str), n), chars)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let b = UInt8['0':'9';'A':'Z';'a':'z']
global randstring
function randstring(r::AbstractRNG, chars, n::Int)
T = eltype(chars)
if T === UInt8
str = Base._string_n(n)
GC.@preserve str rand!(r, UnsafeView(pointer(str), n), chars)
return str
else
... | ```suggestion
randstring(chars, n::Integer) = randstring(default_rng(), chars, convert(Int, n))
``` | let b = UInt8['0':'9';'A':'Z';'a':'z']
global randstring
function randstring(r::AbstractRNG, chars, n::Int)
T = eltype(chars)
if T === UInt8
str = Base._string_n(n)
GC.@preserve str rand!(r, UnsafeView(pointer(str), n), chars)
return str
else
... | @@ -83,9 +83,18 @@ let b = UInt8['0':'9';'A':'Z';'a':'z']
end
end
- randstring(r::AbstractRNG, n::Integer) = randstring(r, b, n)
- randstring(chars=b, n::Integer=8) = randstring(default_rng(), chars, n)
- randstring(n::Integer) = randstring(default_rng(), b, n)
+ # Zero-arg methods:
+ ran... | stdlib/Random/src/misc.jl | 26 | Julia | 0.714 | suggestion | 103 | 51 | 51 | false | Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method | 54,402 | JuliaLang/julia | 35,573 | Julia | adienes | Seelengrab | Review this pull request change.
Language: Julia
File: stdlib/Random/src/misc.jl
PR Title: Support types other than `Int` in `randstring`, but convert to `Int` prior to entering the "main" method
BEFORE CODE: let b = UInt8['0':'9';'A':'Z';'a':'z']
global randstring
function randstring(r::AbstractRNG, chars... | ```suggestion
randstring(chars, n::Integer) = randstring(default_rng(), chars, convert(Int, n))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
JL_DLLEXPORT jl_value_t *jl_cpu_has_fma(int bits)
{
TargetData<feature_sz> target = jit_targets.front();
FeatureList<feature_sz> features = target.en.features;
if ((bits == 32 || bits == 64) && (test_nbit(features, Feature::fma) || test_nbit(features, Feature::fma4)))
return jl_true;
else
... | I think we need to test that we still pick the right/one for all.
I have a unsubstantiated fear about loading images with mismatched ABI. Previously this code said to pick one and then ensured that everyone is consistent. | JL_GC_POP();
if (match_idx == UINT32_MAX)
return rejection_reason;
return jl_nothing;
}
JL_DLLEXPORT jl_value_t *jl_cpu_has_fma(int bits)
{
TargetData<feature_sz> target = jit_targets.front();
FeatureList<feature_sz> features = target.en.features;
if ((bits == 32 || bits == 64) && (test... | @@ -1084,16 +1082,14 @@ jl_image_t jl_init_processor_pkgimg(void *hdl)
{
if (jit_targets.empty())
jl_error("JIT targets not initialized");
- if (jit_targets.size() > 1) | src/processor_x86.cpp | 26 | C++ | 0.429 | suggestion | 224 | 51 | 51 | false | Actually setup jit targets when compiling packageimages instead of targeting only one | 54,471 | JuliaLang/julia | 35,573 | Julia | vchuravy | gbaraldi | Review this pull request change.
Language: C++
File: src/processor_x86.cpp
PR Title: Actually setup jit targets when compiling packageimages instead of targeting only one
BEFORE CODE: }
JL_DLLEXPORT jl_value_t *jl_cpu_has_fma(int bits)
{
TargetData<feature_sz> target = jit_targets.front();
FeatureList<feat... | I think we need to test that we still pick the right/one for all.
I have a unsubstantiated fear about loading images with mismatched ABI. Previously this code said to pick one and then ensured that everyone is consistent. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
std::pair<std::string,llvm::SmallVector<std::string, 0>> jl_get_llvm_target(bool imaging, uint32_t &flags)
{
ensure_jit_target(imaging);
flags = jit_targets[0].en.flags;
return get_llvm_target_vec(jit_targets[0]);
}
const std::pair<std::string,std::string> &jl_get_llvm_disasm_target(void)
{
auto max_f... | There seems to be error-prone duplication between this file and `src/processor_x86.cpp`, no? |
std::pair<std::string,llvm::SmallVector<std::string, 0>> jl_get_llvm_target(bool imaging, uint32_t &flags)
{
ensure_jit_target(imaging);
flags = jit_targets[0].en.flags;
return get_llvm_target_vec(jit_targets[0]);
}
const std::pair<std::string,std::string> &jl_get_llvm_disasm_target(void)
{
auto max_f... | @@ -1890,12 +1890,56 @@ const std::pair<std::string,std::string> &jl_get_llvm_disasm_target(void)
return res;
}
+#ifndef __clang_gcanalyzer__
llvm::SmallVector<jl_target_spec_t, 0> jl_get_llvm_clone_targets(void)
{
- if (jit_targets.empty())
- jl_error("JIT targets not initialized");
+
+ auto &cm... | src/processor_arm.cpp | 26 | C++ | 0.5 | question | 92 | 51 | 51 | false | Actually setup jit targets when compiling packageimages instead of targeting only one | 54,471 | JuliaLang/julia | 35,573 | Julia | giordano | gbaraldi | Review this pull request change.
Language: C++
File: src/processor_arm.cpp
PR Title: Actually setup jit targets when compiling packageimages instead of targeting only one
BEFORE CODE:
std::pair<std::string,llvm::SmallVector<std::string, 0>> jl_get_llvm_target(bool imaging, uint32_t &flags)
{
ensure_jit_target(... | There seems to be error-prone duplication between this file and `src/processor_x86.cpp`, no? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
{
auto max_feature = get_max_feature();
static const auto res = get_llvm_target_str(TargetData<feature_sz>{host_cpu_name(),
#ifdef _CPU_AARCH64_
"+ecv,+tme,+am,+specrestrict,+predres,+lor,+perfmon,+spe,+tracev8.4",
#else
"+dotprod",
#endif
{max_feature, 0}, {featu... | ```suggestion
jl_error("No targets specified");
``` | {
auto max_feature = get_max_feature();
static const auto res = get_llvm_target_str(TargetData<feature_sz>{host_cpu_name(),
#ifdef _CPU_AARCH64_
"+ecv,+tme,+am,+specrestrict,+predres,+lor,+perfmon,+spe,+tracev8.4",
#else
"+dotprod",
#endif
{max_feature, 0}, {featu... | @@ -1890,12 +1890,56 @@ const std::pair<std::string,std::string> &jl_get_llvm_disasm_target(void)
return res;
}
+#ifndef __clang_gcanalyzer__
llvm::SmallVector<jl_target_spec_t, 0> jl_get_llvm_clone_targets(void)
{
- if (jit_targets.empty())
- jl_error("JIT targets not initialized");
+
+ auto &cm... | src/processor_arm.cpp | 26 | C++ | 0.714 | suggestion | 61 | 51 | 51 | false | Actually setup jit targets when compiling packageimages instead of targeting only one | 54,471 | JuliaLang/julia | 35,573 | Julia | IanButterworth | gbaraldi | Review this pull request change.
Language: C++
File: src/processor_arm.cpp
PR Title: Actually setup jit targets when compiling packageimages instead of targeting only one
BEFORE CODE: {
auto max_feature = get_max_feature();
static const auto res = get_llvm_target_str(TargetData<feature_sz>{host_cpu_name(),
... | ```suggestion
jl_error("No targets specified");
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
break;
}
}
for (auto fe: clone_simd) {
if (!test_nbit(features0, fe) && test_nbit(t.en.features, fe)) {
t.en.flags |= JL_TARGET_CLONE_SIMD;
break;
}
}
static constexpr uint32_t clone_fp16[] = {Feature::av... | ```suggestion
jl_error("No targets specified");
``` | break;
}
}
for (auto fe: clone_simd) {
if (!test_nbit(features0, fe) && test_nbit(t.en.features, fe)) {
t.en.flags |= JL_TARGET_CLONE_SIMD;
break;
}
}
static constexpr uint32_t clone_fp16[] = {Feature::av... | @@ -1102,13 +1104,82 @@ const std::pair<std::string,std::string> &jl_get_llvm_disasm_target(void)
{feature_masks, 0}, {{}, 0}, 0});
return res;
}
-
+//This function parses the -C command line to figure out which targets to multiversion to.
+#ifndef __clang_gcanalyzer__
llvm::SmallVector<jl_target_sp... | src/processor_x86.cpp | 26 | C++ | 0.714 | suggestion | 61 | 51 | 51 | false | Actually setup jit targets when compiling packageimages instead of targeting only one | 54,471 | JuliaLang/julia | 35,573 | Julia | IanButterworth | gbaraldi | Review this pull request change.
Language: C++
File: src/processor_x86.cpp
PR Title: Actually setup jit targets when compiling packageimages instead of targeting only one
BEFORE CODE: break;
}
}
for (auto fe: clone_simd) {
if (!test_nbit(features0, fe) && test... | ```suggestion
jl_error("No targets specified");
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
JL_GC_POP();
return (jl_value_t*)a;
}
uint8_t _binding_is_from_explicit_using(jl_binding_t *b) {
jl_binding_t *owner = jl_atomic_load_relaxed(&b->owner);
return (owner != NULL && owner != b && !b->imported);
}
void _append_symbol_to_bindings_array(jl_array_t* a, jl_sym_t *name) {
jl_array_grow_end... | I think this should be based on the name instead of the value? | JL_GC_POP();
return (jl_value_t*)a;
}
uint8_t _binding_is_from_explicit_using(jl_binding_t *b) {
jl_binding_t *owner = jl_atomic_load_relaxed(&b->owner);
return (owner != NULL && owner != b && !b->imported);
}
void _append_symbol_to_bindings_array(jl_array_t* a, jl_sym_t *name) {
jl_array_grow_end... | @@ -1003,16 +1012,39 @@ JL_DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported)
jl_sym_t *asname = b->globalref->name;
int hidden = jl_symbol_name(asname)[0]=='#';
int main_public = (m == jl_main_module && !(asname == jl_eval_sym || asname == jl_include_sym));
- ... | src/module.c | 26 | C | 0.286 | question | 62 | 51 | 51 | false | reflection: allow `names` to return `using`-ed names | 54,609 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | aviatesk | Review this pull request change.
Language: C
File: src/module.c
PR Title: reflection: allow `names` to return `using`-ed names
BEFORE CODE: JL_GC_POP();
return (jl_value_t*)a;
}
uint8_t _binding_is_from_explicit_using(jl_binding_t *b) {
jl_binding_t *owner = jl_atomic_load_relaxed(&b->owner);
retur... | I think this should be based on the name instead of the value? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
jl_array_t *a = jl_alloc_array_1d(jl_array_symbol_type, 0);
JL_GC_PUSH1(&a);
// First, encode the module's name
_append_symbol_to_bindings_array(a, m->name);
_jl_module_names_into_array(a, m, all, imported, usings, /*exported*/0);
if (usings) {
// If `usings` is specified, traverse the l... | I'm not sure this is enough to avoid duplicates. For example the name might also be exported. We could also de-duplicate in the caller though. | if ((void*)b == jl_nothing)
break;
if (b->exportp && (all || !b->deprecated))
_append_symbol_to_bindings_array(a, b->globalref->name);
}
}
JL_DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported, int usings)
{
jl_array_t *a = jl_alloc_array_1d(jl_a... | @@ -1003,16 +1012,39 @@ JL_DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported)
jl_sym_t *asname = b->globalref->name;
int hidden = jl_symbol_name(asname)[0]=='#';
int main_public = (m == jl_main_module && !(asname == jl_eval_sym || asname == jl_include_sym));
- ... | src/module.c | 26 | C | 0.429 | refactor | 142 | 51 | 51 | false | reflection: allow `names` to return `using`-ed names | 54,609 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | aviatesk | Review this pull request change.
Language: C
File: src/module.c
PR Title: reflection: allow `names` to return `using`-ed names
BEFORE CODE: jl_array_t *a = jl_alloc_array_1d(jl_array_symbol_type, 0);
JL_GC_PUSH1(&a);
// First, encode the module's name
_append_symbol_to_bindings_array(a, m->name);
... | I'm not sure this is enough to avoid duplicates. For example the name might also be exported. We could also de-duplicate in the caller though. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
s->bm = bm_none;
if (fd == STDOUT_FILENO)
s->bm = bm_line;
return s;
}
ios_t *ios_stdin = NULL;
ios_t *ios_stdout = NULL;
ios_t *ios_stderr = NULL;
ios_t *ios_safe_stdout = NULL;
ios_t *ios_safe_stderr = NULL;
void ios_init_stdstreams(void)
{
ios_stdin = (ios_t*)malloc_s(sizeof(ios_t));
... | `bm_line` seems likely very, very unsafe, so only `bm_none` is okay here. Only when allocated as a local variable, then bm_line is good and works to make something like stderr much faster without sacrificing safety. | s->bm = bm_none;
if (fd == STDOUT_FILENO)
s->bm = bm_line;
return s;
}
ios_t *ios_stdin = NULL;
ios_t *ios_stdout = NULL;
ios_t *ios_stderr = NULL;
ios_t *ios_safe_stderr = NULL;
void ios_init_stdstreams(void)
{
ios_stdin = (ios_t*)malloc_s(sizeof(ios_t));
ios_fd(ios_stdin, STDIN_FILEN... | @@ -1074,6 +1076,17 @@ void ios_init_stdstreams(void)
ios_stderr = (ios_t*)malloc_s(sizeof(ios_t));
ios_fd(ios_stderr, STDERR_FILENO, 0, 0);
ios_stderr->bm = bm_none;
+
+ // the following 'safe' variants must use `bm_line` / `bm_none` | src/support/ios.c | 26 | C | 0.571 | suggestion | 215 | 51 | 51 | false | NFC: Add `fprint` variants of internal print functions | 54,835 | JuliaLang/julia | 35,573 | Julia | vtjnash | topolarity | Review this pull request change.
Language: C
File: src/support/ios.c
PR Title: NFC: Add `fprint` variants of internal print functions
BEFORE CODE: s->bm = bm_none;
if (fd == STDOUT_FILENO)
s->bm = bm_line;
return s;
}
ios_t *ios_stdin = NULL;
ios_t *ios_stdout = NULL;
ios_t *ios_stderr = NU... | `bm_line` seems likely very, very unsafe, so only `bm_none` is okay here. Only when allocated as a local variable, then bm_line is good and works to make something like stderr much faster without sacrificing safety. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if (sig == SIGSEGV && jl_get_safe_restore()) {
signal(sig, (void (__cdecl *)(int))crt_sig_handler);
jl_sig_throw();
}
memset(&Context, 0, sizeof(Context));
RtlCaptureContext(&Context);
ios_t s;
ios_mem(&s, 1024);
if (sig == SIGILL)
... | I know very little about Windows, so my apologies if these questions are dumb, but: 1. Is this call async, or does it block?
2. Is this really safe to call here? In particular,
3. I am slightly worried about situations I experienced in an entirely different context were broadly similar code could lead to hundreds o... | if (sig == SIGSEGV) { // restarting jl_ or profile
jl_jmp_buf *saferestore = jl_get_safe_restore();
if (saferestore) {
signal(sig, (void (__cdecl *)(int))crt_sig_handler);
jl_longjmp(*saferestore, 1);
return;
}
}
... | @@ -92,9 +92,29 @@ void __cdecl crt_sig_handler(int sig, int num)
}
memset(&Context, 0, sizeof(Context));
RtlCaptureContext(&Context);
+
+ ios_t s;
+ ios_mem(&s, 1024);
if (sig == SIGILL)
- jl_fprint_sigill(ios_stderr, &Context);
- jl_fprint_critical_e... | src/signals-win.c | 26 | C | 0.5 | bug | 639 | 51 | 51 | false | Add error dialog for critical errors on Windows | 54,836 | JuliaLang/julia | 35,573 | Julia | fingolfin | topolarity | Review this pull request change.
Language: C
File: src/signals-win.c
PR Title: Add error dialog for critical errors on Windows
BEFORE CODE: if (sig == SIGSEGV && jl_get_safe_restore()) {
signal(sig, (void (__cdecl *)(int))crt_sig_handler);
jl_sig_throw();
}
memset(&Co... | I know very little about Windows, so my apologies if these questions are dumb, but: 1. Is this call async, or does it block?
2. Is this really safe to call here? In particular,
3. I am slightly worried about situations I experienced in an entirely different context were broadly similar code could lead to hundreds o... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return EXCEPTION_CONTINUE_EXECUTION;
if (ptls->defer_signal) {
jl_safepoint_defer_sigint();
}
else if (jl_safepoint_consume_sigint()) {
jl_clear_force_sigint();
jl_throw_in_ctx(ct, jl_interrup... | calling malloc unconditionally here is a bit wasteful, since we will call it on demand when actually needed
```suggestion
ios_mem(&full_error, 0);
``` | jl_throw_in_ctx(ct, jl_stackovf_exception, ExceptionInfo->ContextRecord);
return EXCEPTION_CONTINUE_EXECUTION;
}
break;
case EXCEPTION_ACCESS_VIOLATION:
if (jl_addr_is_safepoint(ExceptionInfo->ExceptionRecord->ExceptionInformation[1])) {
... | @@ -278,59 +298,88 @@ LONG WINAPI jl_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
break;
}
}
+ ios_t full_error, summary;
+ ios_mem(&full_error, 1024); | src/signals-win.c | 26 | C | 0.857 | suggestion | 157 | 51 | 51 | false | Add error dialog for critical errors on Windows | 54,836 | JuliaLang/julia | 35,573 | Julia | vtjnash | topolarity | Review this pull request change.
Language: C
File: src/signals-win.c
PR Title: Add error dialog for critical errors on Windows
BEFORE CODE: return EXCEPTION_CONTINUE_EXECUTION;
if (ptls->defer_signal) {
jl_safepoint_defer_sigint();
}
... | calling malloc unconditionally here is a bit wasteful, since we will call it on demand when actually needed
```suggestion
ios_mem(&full_error, 0);
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
s->fpos = 0;
if (!rd)
s->readable = 0;
if (!wr)
s->writable = 0;
return s;
open_file_err:
s->fd = -1;
return NULL;
}
#ifdef _OS_WINDOWS_
const wchar_t *ios_utf8_to_wchar(const char *str) {
/* Fast-path empty strings, as MultiByteToWideChar() returns zero for them. */
if... | ```suggestion
ssize_t wlen = uv_wtf8_length_as_utf16(str);
wchar_t *wstr = (wchar_t *)malloc_s(sizeof(wchar_t) * wlen);
uv_wtf8_to_utf16(str, wstr, wlen);
return wstr;
```
This is a more reliable (and concise) version of MultiByteToWideChar now provided by libuv | s = ios_fd(s, fd, 1, 1);
s->fpos = 0;
if (!rd)
s->readable = 0;
if (!wr)
s->writable = 0;
return s;
open_file_err:
s->fd = -1;
return NULL;
}
#ifdef _OS_WINDOWS_
const wchar_t *ios_utf8_to_wchar(const char *str) {
ssize_t wlen = uv_wtf8_length_as_utf16(str);
wchar_t... | @@ -988,6 +988,24 @@ ios_t *ios_file(ios_t *s, const char *fname, int rd, int wr, int create, int tru
return NULL;
}
+#ifdef _OS_WINDOWS_
+const wchar_t *ios_utf8_to_wchar(const char *str) {
+ /* Fast-path empty strings, as MultiByteToWideChar() returns zero for them. */
+ if (str[0] == '\0') {
+ w... | src/support/ios.c | 26 | C | 0.786 | suggestion | 284 | 51 | 51 | false | Add error dialog for critical errors on Windows | 54,836 | JuliaLang/julia | 35,573 | Julia | vtjnash | topolarity | Review this pull request change.
Language: C
File: src/support/ios.c
PR Title: Add error dialog for critical errors on Windows
BEFORE CODE: s->fpos = 0;
if (!rd)
s->readable = 0;
if (!wr)
s->writable = 0;
return s;
open_file_err:
s->fd = -1;
return NULL;
}
#ifdef _OS_WINDOW... | ```suggestion
ssize_t wlen = uv_wtf8_length_as_utf16(str);
wchar_t *wstr = (wchar_t *)malloc_s(sizeof(wchar_t) * wlen);
uv_wtf8_to_utf16(str, wstr, wlen);
return wstr;
```
This is a more reliable (and concise) version of MultiByteToWideChar now provided by libuv | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
u = bitcast(UInt32, c)
is_overlong_enc(u)
end
# fallback: other AbstractChar types, by default, are assumed
# not to support malformed or overlong encodings.
"""
Base.ismalformed(c::AbstractChar) -> Bool
Return `true` if `c` represents malformed (non-Unicode) data according to the
encoding used... | This belongs in `base/public.jl` |
function isoverlong(c::Char)
u = bitcast(UInt32, c)
is_overlong_enc(u)
end
# fallback: other AbstractChar types, by default, are assumed
# not to support malformed or overlong encodings.
"""
ismalformed(c::AbstractChar)::Bool
Return `true` if `c` represents malformed (non-codepoint / mis-encod... | @@ -112,24 +125,35 @@ end
# not to support malformed or overlong encodings.
"""
- ismalformed(c::AbstractChar) -> Bool
+ Base.ismalformed(c::AbstractChar) -> Bool
Return `true` if `c` represents malformed (non-Unicode) data according to the
encoding used by `c`. Defaults to `false` for non-`Char... | base/char.jl | 26 | Julia | 0.214 | suggestion | 32 | 51 | 51 | false | make codepoint(c) work for overlong chars | 55,152 | JuliaLang/julia | 35,573 | Julia | LilithHafner | stevengj | Review this pull request change.
Language: Julia
File: base/char.jl
PR Title: make codepoint(c) work for overlong chars
BEFORE CODE: u = bitcast(UInt32, c)
is_overlong_enc(u)
end
# fallback: other AbstractChar types, by default, are assumed
# not to support malformed or overlong encodings.
"""
... | This belongs in `base/public.jl` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""
ncodeunits(c::Char) -> Int
Return the number of code units required to encode a character as UTF-8.
This is the number of bytes which will be printed if the character is written
to an output stream, or `ncodeunits(string(c))` but computed efficiently.
!!! compat "Julia 1.1"
This method requires at least J... | Would this be equivalent?
```suggestion
to the character `c` (or throw an exception if `c` represents
a malformed character). For `Char`, this is a `UInt32` value, bu
```
If so, I think it is more clear because `malformed` more clearly refers to `ismalformed`. | (::Type{T})(x::T) where {T<:AbstractChar} = x
"""
ncodeunits(c::Char)::Int
Return the number of code units required to encode a character as UTF-8.
This is the number of bytes which will be printed if the character is written
to an output stream, or `ncodeunits(string(c))` but computed efficiently.
!!! compat "J... | @@ -76,9 +80,18 @@ end
Return the Unicode codepoint (an unsigned integer) corresponding
to the character `c` (or throw an exception if `c` does not represent
-a valid character). For `Char`, this is a `UInt32` value, but
+a well-formed character). For `Char`, this is a `UInt32` value, but | base/char.jl | 26 | Julia | 1 | suggestion | 265 | 51 | 51 | false | make codepoint(c) work for overlong chars | 55,152 | JuliaLang/julia | 35,573 | Julia | LilithHafner | stevengj | Review this pull request change.
Language: Julia
File: base/char.jl
PR Title: make codepoint(c) work for overlong chars
BEFORE CODE: """
ncodeunits(c::Char) -> Int
Return the number of code units required to encode a character as UTF-8.
This is the number of bytes which will be printed if the character is writ... | Would this be equivalent?
```suggestion
to the character `c` (or throw an exception if `c` represents
a malformed character). For `Char`, this is a `UInt32` value, bu
```
If so, I think it is more clear because `malformed` more clearly refers to `ismalformed`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
@noinline throw_invalid_char(c::AbstractChar) = throw(InvalidCharError(c))
@noinline throw_code_point_err(u::Integer) = throw(CodePointError(u))
function ismalformed(c::Char)
u = bitcast(UInt32, c)
l1 = leading_ones(u) << 3
t0 = trailing_zeros(u) & 56
(l1 == 8) | (l1 + t0 > 32) |
(((u & 0x00c0c... | I would interpret "non-Unicode" to mean "not valid according to the Unicode spec" which IIUC is what `Base.isvalid` checks. | struct CodePointError{T<:Integer} <: Exception
code::T
end
@noinline throw_invalid_char(c::AbstractChar) = throw(InvalidCharError(c))
@noinline throw_code_point_err(u::Integer) = throw(CodePointError(u))
function ismalformed(c::Char)
u = bitcast(UInt32, c)
l1 = leading_ones(u) << 3
t0 = trailing_zeros(... | @@ -112,22 +125,31 @@ end
# not to support malformed or overlong encodings.
"""
- ismalformed(c::AbstractChar) -> Bool
+ Base.ismalformed(c::AbstractChar) -> Bool
Return `true` if `c` represents malformed (non-Unicode) data according to the | base/char.jl | 26 | Julia | 0.5 | suggestion | 123 | 51 | 51 | false | make codepoint(c) work for overlong chars | 55,152 | JuliaLang/julia | 35,573 | Julia | LilithHafner | stevengj | Review this pull request change.
Language: Julia
File: base/char.jl
PR Title: make codepoint(c) work for overlong chars
BEFORE CODE: end
@noinline throw_invalid_char(c::AbstractChar) = throw(InvalidCharError(c))
@noinline throw_code_point_err(u::Integer) = throw(CodePointError(u))
function ismalformed(c::Char)
... | I would interpret "non-Unicode" to mean "not valid according to the Unicode spec" which IIUC is what `Base.isvalid` checks. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@inline is_overlong_enc(u::UInt32) = (u >> 24 == 0xc0) | (u >> 24 == 0xc1) | (u >> 21 == 0x0704) | (u >> 20 == 0x0f08)
function isoverlong(c::Char)
u = bitcast(UInt32, c)
is_overlong_enc(u)
end
# fallback: other AbstractChar types, by default, are assumed
# not to support malformed or overlong encod... | IIUC Unicode does not define a notion of malformedness separate from validity. Is this the only place that the distinction between malformed and wellformed invalid unicode is defined? | end
@inline is_overlong_enc(u::UInt32) = (u >> 24 == 0xc0) | (u >> 24 == 0xc1) | (u >> 21 == 0x0704) | (u >> 20 == 0x0f08)
function isoverlong(c::Char)
u = bitcast(UInt32, c)
is_overlong_enc(u)
end
# fallback: other AbstractChar types, by default, are assumed
# not to support malformed or overlong ... | @@ -112,22 +125,31 @@ end
# not to support malformed or overlong encodings.
"""
- ismalformed(c::AbstractChar) -> Bool
+ Base.ismalformed(c::AbstractChar) -> Bool
Return `true` if `c` represents malformed (non-Unicode) data according to the
encoding used by `c`. Defaults to `false` for non-`Char... | base/char.jl | 26 | Julia | 0.357 | question | 183 | 51 | 51 | false | make codepoint(c) work for overlong chars | 55,152 | JuliaLang/julia | 35,573 | Julia | LilithHafner | stevengj | Review this pull request change.
Language: Julia
File: base/char.jl
PR Title: make codepoint(c) work for overlong chars
BEFORE CODE: @inline is_overlong_enc(u::UInt32) = (u >> 24 == 0xc0) | (u >> 24 == 0xc1) | (u >> 21 == 0x0704) | (u >> 20 == 0x0f08)
function isoverlong(c::Char)
u = bitcast(UInt32, c)
is_... | IIUC Unicode does not define a notion of malformedness separate from validity. Is this the only place that the distinction between malformed and wellformed invalid unicode is defined? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
break;
}
}
}
if (has_refaggr) {
REMARK([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "Escaped", orig)
<< "GC allocation has unusual object reference, unable to move to stack " << ore::NV("GC Allocation"... | ```suggestion
// The move to stack code below, if has_ref is set, changes the allocation to an array of jlvalue_t's. This is fine
// if all objects are jlvalue_t's. However, if part of the allocation is an unboxed value (e.g. it is a { float, jlvaluet }),
// then moveToStack will create a [2 ... | break;
}
}
}
if (has_refaggr) {
REMARK([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "Escaped", orig)
<< "GC allocation has unusual object reference, unable to move to stack " << ore::NV("GC Allocation"... | @@ -284,6 +286,19 @@ void Optimizer::optimizeAll()
splitOnStack(orig);
continue;
}
+ // The move to stack code below, if has_ref is set, changes the allocation to an array of jlvalue_t's. This is fine
+ // if all objects are jlvalue_t's. However, if part of the allocatio... | src/llvm-alloc-opt.cpp | 26 | C++ | 1 | suggestion | 478 | 51 | 51 | false | AllocOpt: Fix stack lowering where alloca continas boxed and unboxed data | 55,306 | JuliaLang/julia | 35,573 | Julia | vchuravy | wsmoses | Review this pull request change.
Language: C++
File: src/llvm-alloc-opt.cpp
PR Title: AllocOpt: Fix stack lowering where alloca continas boxed and unboxed data
BEFORE CODE: break;
}
}
}
if (has_refaggr) {
REMARK([&]() {
retu... | ```suggestion
// The move to stack code below, if has_ref is set, changes the allocation to an array of jlvalue_t's. This is fine
// if all objects are jlvalue_t's. However, if part of the allocation is an unboxed value (e.g. it is a { float, jlvaluet }),
// then moveToStack will create a [2 ... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if (has_refaggr) {
REMARK([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "Escaped", orig)
<< "GC allocation has unusual object reference, unable to move to stack " << ore::NV("GC Allocation", orig);
});
if (use_info.hastypeof)
... | ```suggestion
<< "GC allocation could not be split since it contains both boxed and unboxed values, unable to move to stack " << ore::NV("GC Allocation", orig);
``` | if (has_refaggr) {
REMARK([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "Escaped", orig)
<< "GC allocation has unusual object reference, unable to move to stack " << ore::NV("GC Allocation", orig);
});
if (use_info.hastypeof)
... | @@ -284,6 +286,19 @@ void Optimizer::optimizeAll()
splitOnStack(orig);
continue;
}
+ // The move to stack code below, if has_ref is set, changes the allocation to an array of jlvalue_t's. This is fine
+ // if all objects are jlvalue_t's. However, if part of the allocatio... | src/llvm-alloc-opt.cpp | 26 | C++ | 0.786 | suggestion | 186 | 51 | 51 | false | AllocOpt: Fix stack lowering where alloca continas boxed and unboxed data | 55,306 | JuliaLang/julia | 35,573 | Julia | vchuravy | wsmoses | Review this pull request change.
Language: C++
File: src/llvm-alloc-opt.cpp
PR Title: AllocOpt: Fix stack lowering where alloca continas boxed and unboxed data
BEFORE CODE: if (has_refaggr) {
REMARK([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "Escaped", orig)
... | ```suggestion
<< "GC allocation could not be split since it contains both boxed and unboxed values, unable to move to stack " << ore::NV("GC Allocation", orig);
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
has_refaggr = true;
break;
}
}
}
if (has_refaggr) {
REMARK([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "Escaped", orig)
<< "GC allocation has unusual object reference, unable to mo... | ```suggestion
// then moveToStack will create a [2 x jlvaluet] bitcast to { float, jlvaluet }.
``` | has_refaggr = true;
break;
}
}
}
if (has_refaggr) {
REMARK([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "Escaped", orig)
<< "GC allocation has unusual object reference, unable to mo... | @@ -284,6 +286,19 @@ void Optimizer::optimizeAll()
splitOnStack(orig);
continue;
}
+ // The move to stack code below, if has_ref is set, changes the allocation to an array of jlvalue_t's. This is fine
+ // if all objects are jlvalue_t's. However, if part of the allocatio... | src/llvm-alloc-opt.cpp | 26 | C++ | 0.929 | suggestion | 108 | 51 | 51 | false | AllocOpt: Fix stack lowering where alloca continas boxed and unboxed data | 55,306 | JuliaLang/julia | 35,573 | Julia | giordano | wsmoses | Review this pull request change.
Language: C++
File: src/llvm-alloc-opt.cpp
PR Title: AllocOpt: Fix stack lowering where alloca continas boxed and unboxed data
BEFORE CODE: has_refaggr = true;
break;
}
}
}
if (has_refaggr) {
... | ```suggestion
// then moveToStack will create a [2 x jlvaluet] bitcast to { float, jlvaluet }.
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
:default
end
title = if isempty(md.title) md.category else md.title end
print(io, ' '^margin, styled"{$accent,markdown_admonition:│ $title}",
'\n', ' '^margin, styled"{$accent,markdown_admonition:│}", '\n')
content = annotprint(term, md.content, columns - 10)
lines = split(rstrip(c... | Maybe imitate what GitHub uses?
```suggestion
const _list_bullets = ["• ", "◦ ", "▪︎ "]
``` | :default
end
title = if isempty(md.title) md.category else md.title end
print(io, ' '^margin, styled"{$accent,markdown_admonition:│ $title}",
'\n', ' '^margin, styled"{$accent,markdown_admonition:│}", '\n')
content = annotprint(term, md.content, columns - 10)
lines = split(rstrip(c... | @@ -70,15 +70,40 @@ function term(io::IO, f::Footnote, columns)
end
end
-function term(io::IO, md::List, columns)
+const _list_bullets = ["• ", "➤ ", "– "] | stdlib/Markdown/src/render/terminal/render.jl | 26 | Julia | 0.643 | suggestion | 94 | 51 | 51 | false | Cycle bullets when printing nested Markdown list | 55,456 | JuliaLang/julia | 35,573 | Julia | fingolfin | tecosaur | Review this pull request change.
Language: Julia
File: stdlib/Markdown/src/render/terminal/render.jl
PR Title: Cycle bullets when printing nested Markdown list
BEFORE CODE: :default
end
title = if isempty(md.title) md.category else md.title end
print(io, ' '^margin, styled"{$accent,markdown_admo... | Maybe imitate what GitHub uses?
```suggestion
const _list_bullets = ["• ", "◦ ", "▪︎ "]
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.