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
/* outputs */ /* .min_valid = */ *min_valid, /* .max_valid = */ *max_valid, /* .ti = */ NULL, /* .env = */ jl_emptysvec, /* .issubty = */ 0 }, /* inputs */ intersections, world, lim, include_ambiguou...
```suggestion // first check the leaf cache if the type might have been put in there ``` There are lot of different definitions of type "size", so it is not a useful term. It is legal and valid to check any type here against the cache, but since we (currently) only construct it with dispatch tuples, it is sl...
} if (entry) { // mfunc was found in slow path, so log --trace-dispatch jl_method_instance_t *mfunc = entry->func.linfo; record_dispatch_statement_on_first_dispatch(mfunc); } } jl_method_instance_t *mfunc; if (entry) { have_entry: mfunc = ...
@@ -4223,21 +4254,47 @@ static jl_value_t *ml_matches(jl_methtable_t *mt, else va = NULL; } - struct ml_matches_env env = {{ml_matches_visitor, (jl_value_t*)type, va, /* .search_slurp = */ 0, - /* .min_valid = */ *min_valid, /* .max_valid = */ *max_valid, - /* .ti = *...
src/gf.c
26
C
1
performance
381
51
51
false
gf.c: Add some comments to `ml_matches` (NFC)
58,304
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C File: src/gf.c PR Title: gf.c: Add some comments to `ml_matches` (NFC) BEFORE CODE: /* outputs */ /* .min_valid = */ *min_valid, /* .max_valid = */ *max_valid, /* .ti = */ NULL, /* .env = */ jl_emptysvec, ...
```suggestion // first check the leaf cache if the type might have been put in there ``` There are lot of different definitions of type "size", so it is not a useful term. It is legal and valid to check any type here against the cache, but since we (currently) only construct it with dispatch tuples, it is sl...
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.
env.match.ti = unw; } else if (jl_egal((jl_value_t*)type, mi->specTypes)) { env.match.env = mi->sparam_vals; env.match.ti = mi->specTypes; } else { // this just calls jl_subtyp...
I have no idea what "small enough" means in this context. I think you're just restating that it seemed profitable? These queries all look to me to have no dependency on being a dispatch tuple, they just become more cumbersome to implement, and thus likely slower and less likely to be profitable.
return mfunc; } JL_DLLEXPORT jl_value_t *jl_apply_generic(jl_value_t *F, jl_value_t **args, uint32_t nargs) { size_t world = jl_current_task->world_age; jl_method_instance_t *mfunc = jl_lookup_generic_(F, args, nargs, jl_int32hash_fast(jl_return_address...
@@ -4266,10 +4323,13 @@ static jl_value_t *ml_matches(jl_methtable_t *mt, return env.t; } } - // then check the full cache if it seems profitable + + // then check the full cache if it seems profitable (and the type is small enough)
src/gf.c
26
C
0.429
performance
296
51
51
false
gf.c: Add some comments to `ml_matches` (NFC)
58,304
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C File: src/gf.c PR Title: gf.c: Add some comments to `ml_matches` (NFC) BEFORE CODE: env.match.ti = unw; } else if (jl_egal((jl_value_t*)type, mi->specTypes)) { env.match.env = mi->sparam_vals; ...
I have no idea what "small enough" means in this context. I think you're just restating that it seemed profitable? These queries all look to me to have no dependency on being a dispatch tuple, they just become more cumbersome to implement, and thus likely slower and less likely to be profitable.
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_method_instance_t *mi = entry->func.linfo; jl_method_t *meth = mi->def.method; if (!jl_is_unionall(meth->sig) && ((jl_datatype_t*)unw)->isdispatchtuple) { env.match.env = jl_emptysvec; env.match.ti = unw; } ...
```suggestion // if neither cache worked (or was deemed unprofitable to check) visit all matching methods in the MethodTable ```
// Deprecated: Use jl_gf_invoke_lookup_worlds for future development size_t min_valid = 0; size_t max_valid = ~(size_t)0; if (mt == jl_nothing) mt = (jl_value_t*)jl_method_table; jl_method_match_t *matc = _gf_invoke_lookup(types, (jl_methtable_t*)mt, world, 1, &min_valid, &max_valid); if...
@@ -4294,16 +4354,24 @@ static jl_value_t *ml_matches(jl_methtable_t *mt, return env.t; } } + + // if neither cache worked (or was eligible / profitable) visit all matching methods in the MethodTable
src/gf.c
26
C
0.714
performance
138
51
51
false
gf.c: Add some comments to `ml_matches` (NFC)
58,304
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C File: src/gf.c PR Title: gf.c: Add some comments to `ml_matches` (NFC) BEFORE CODE: jl_method_instance_t *mi = entry->func.linfo; jl_method_t *meth = mi->def.method; if (!jl_is_unionall(meth->sig) && ((jl_datatype_t*)unw)->...
```suggestion // if neither cache worked (or was deemed unprofitable to check) visit all matching methods in the MethodTable ```
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.
size_t max_world = jl_atomic_load_relaxed(&entry->max_world); if (*min_valid < min_world) *min_valid = min_world; if (*max_valid > max_world) *max_valid = max_world; JL_GC_POP(); return env.t; ...
In v1.12, this will be gone (https://github.com/JuliaLang/julia/pull/58131)
mt = (jl_value_t*)jl_method_table; jl_method_match_t *matc = _gf_invoke_lookup(types, (jl_methtable_t*)mt, world, 1, min_world, max_world); if (matc == NULL) return jl_nothing; return (jl_value_t*)matc; } // invoke() // this does method dispatch with a set of types to match other than the /...
@@ -4294,16 +4354,24 @@ static jl_value_t *ml_matches(jl_methtable_t *mt, return env.t; } } + + // if neither cache worked (or was eligible / profitable) visit all matching methods in the MethodTable + // via the usual typemap visitor, recording any matches in closur...
src/gf.c
26
C
0.214
suggestion
75
51
51
false
gf.c: Add some comments to `ml_matches` (NFC)
58,304
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C File: src/gf.c PR Title: gf.c: Add some comments to `ml_matches` (NFC) BEFORE CODE: size_t max_world = jl_atomic_load_relaxed(&entry->max_world); if (*min_valid < min_world) *min_valid = min_world; if (*...
In v1.12, this will be gone (https://github.com/JuliaLang/julia/pull/58131)
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.
// next split may be on Type{T} as LeafTypes then TypeName's parents up to Any // next split may be on LeafType // next split may be on TypeName _Atomic(jl_genericmemory_t*) arg1; // contains LeafType (in a map of non-abstract TypeName) _Atomic(jl_genericmemory_t*) targ; // contains Type{LeafType} (...
```suggestion // cache for querying everything else (anything that didn't seem profitable to put into leafcache) ```
}; struct _jl_globalref_t { JL_DATA_TYPE jl_module_t *mod; jl_sym_t *name; jl_binding_t *binding; }; // one Type-to-Value entry struct _jl_typemap_entry_t { JL_DATA_TYPE _Atomic(struct _jl_typemap_entry_t*) next; // invasive linked list jl_tupletype_t *sig; // the type signature for this e...
@@ -878,9 +878,17 @@ typedef struct _jl_typemap_level_t { typedef struct _jl_methtable_t { JL_DATA_TYPE jl_sym_t *name; // sometimes used for debug printing + + // full set of entries _Atomic(jl_typemap_t*) defs; + + // hash map from dispatchtuple type to a linked-list of TypeMapEntry + // entr...
src/julia.h
26
C/C++
0.714
performance
122
51
51
false
gf.c: Add some comments to `ml_matches` (NFC)
58,304
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C/C++ File: src/julia.h PR Title: gf.c: Add some comments to `ml_matches` (NFC) BEFORE CODE: // next split may be on Type{T} as LeafTypes then TypeName's parents up to Any // next split may be on LeafType // next split may be on TypeName _Atomic(jl_genericm...
```suggestion // cache for querying everything else (anything that didn't seem profitable to put into leafcache) ```
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.
```jldoctest julia> io = IOBuffer(); julia> iob64_decode = Base64DecodePipe(io); julia> write(io, "SGVsbG8h") 8 julia> seekstart(io); julia> String(read(iob64_decode)) "Hello!" ``` """ struct Base64DecodePipe{T <: IO} <: IO io::T buffer::Buffer rest::Vector{UInt8} function Base64DecodePipe{T}(io::T...
```suggestion Base64DecodePipe(io::IO) = Base64DecodePipe{IO}(io) ``` Doesn't seem like this PR makes things faster, so by default it seems better to avoid making the compile slower and more complex?
```jldoctest julia> io = IOBuffer(); julia> iob64_decode = Base64DecodePipe(io); julia> write(io, "SGVsbG8h") 8 julia> seekstart(io); julia> String(read(iob64_decode)) "Hello!" ``` """ struct Base64DecodePipe{T <: IO} <: IO io::T buffer::Buffer rest::Vector{UInt8} function Base64DecodePipe{T}(io::T...
@@ -32,17 +32,19 @@ julia> String(read(iob64_decode)) "Hello!" ``` """ -struct Base64DecodePipe <: IO - io::IO +struct Base64DecodePipe{T <: IO} <: IO + io::T buffer::Buffer rest::Vector{UInt8} - function Base64DecodePipe(io::IO) + function Base64DecodePipe{T}(io::T) where {T <: IO} ...
stdlib/Base64/src/decode.jl
26
Julia
0.857
performance
204
51
51
false
Type stabilize Base64
58,352
JuliaLang/julia
35,573
Julia
vtjnash
jakobnissen
Review this pull request change. Language: Julia File: stdlib/Base64/src/decode.jl PR Title: Type stabilize Base64 BEFORE CODE: ```jldoctest julia> io = IOBuffer(); julia> iob64_decode = Base64DecodePipe(io); julia> write(io, "SGVsbG8h") 8 julia> seekstart(io); julia> String(read(iob64_decode)) "Hello!" ``` """...
```suggestion Base64DecodePipe(io::IO) = Base64DecodePipe{IO}(io) ``` Doesn't seem like this PR makes things faster, so by default it seems better to avoid making the compile slower and more complex?
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.
# Examples ```jldoctest julia> io = IOBuffer(); julia> iob64_encode = Base64EncodePipe(io); julia> write(iob64_encode, "Hello!") 6 julia> close(iob64_encode); julia> str = String(take!(io)) "SGVsbG8h" julia> String(base64decode(str)) "Hello!" ``` """ struct Base64EncodePipe{T <: IO} <: IO io::T buffer::Buf...
```suggestion pipe = new{T}(io, buffer) ```
# Examples ```jldoctest julia> io = IOBuffer(); julia> iob64_encode = Base64EncodePipe(io); julia> write(iob64_encode, "Hello!") 6 julia> close(iob64_encode); julia> str = takestring!(io) "SGVsbG8h" julia> String(base64decode(str)) "Hello!" ``` """ struct Base64EncodePipe{T <: IO} <: IO io::T buffer::Buffe...
@@ -31,19 +31,21 @@ julia> String(base64decode(str)) "Hello!" ``` """ -struct Base64EncodePipe <: IO - io::IO +struct Base64EncodePipe{T <: IO} <: IO + io::T buffer::Buffer - function Base64EncodePipe(io::IO) + function Base64EncodePipe{T}(io::T) where {T <: IO} # The buffer size must be ...
stdlib/Base64/src/encode.jl
26
Julia
0.571
suggestion
53
51
51
false
Type stabilize Base64
58,352
JuliaLang/julia
35,573
Julia
vtjnash
jakobnissen
Review this pull request change. Language: Julia File: stdlib/Base64/src/encode.jl PR Title: Type stabilize Base64 BEFORE CODE: # Examples ```jldoctest julia> io = IOBuffer(); julia> iob64_encode = Base64EncodePipe(io); julia> write(iob64_encode, "Hello!") 6 julia> close(iob64_encode); julia> str = String(take!...
```suggestion pipe = new{T}(io, buffer) ```
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> write(iob64_encode, "Hello!") 6 julia> close(iob64_encode); julia> str = String(take!(io)) "SGVsbG8h" julia> String(base64decode(str)) "Hello!" ``` """ struct Base64EncodePipe{T <: IO} <: IO io::T buffer::Buffer function Base64EncodePipe{T}(io::T) where {T <: IO} # The buffer size must be...
```suggestion Base64EncodePipe(io::IO) = Base64EncodePipe{IO}(io) ```
julia> write(iob64_encode, "Hello!") 6 julia> close(iob64_encode); julia> str = takestring!(io) "SGVsbG8h" julia> String(base64decode(str)) "Hello!" ``` """ struct Base64EncodePipe{T <: IO} <: IO io::T buffer::Buffer function Base64EncodePipe{T}(io::T) where {T <: IO} # The buffer size must be a...
@@ -31,19 +31,21 @@ julia> String(base64decode(str)) "Hello!" ``` """ -struct Base64EncodePipe <: IO - io::IO +struct Base64EncodePipe{T <: IO} <: IO + io::T buffer::Buffer - function Base64EncodePipe(io::IO) + function Base64EncodePipe{T}(io::T) where {T <: IO} # The buffer size must be ...
stdlib/Base64/src/encode.jl
26
Julia
0.571
suggestion
71
51
51
false
Type stabilize Base64
58,352
JuliaLang/julia
35,573
Julia
vtjnash
jakobnissen
Review this pull request change. Language: Julia File: stdlib/Base64/src/encode.jl PR Title: Type stabilize Base64 BEFORE CODE: julia> write(iob64_encode, "Hello!") 6 julia> close(iob64_encode); julia> str = String(take!(io)) "SGVsbG8h" julia> String(base64decode(str)) "Hello!" ``` """ struct Base64EncodePipe{T ...
```suggestion Base64EncodePipe(io::IO) = Base64EncodePipe{IO}(io) ```
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 # Updating this listing is fairly easy, assuming existence of a unix system, # posix shell, and `awk`. Just call this file with `sh`, and it will be # updated to the latest terminfo snapshot. This works because the file is a # bit of a quine...
Isn't this referring to this file? ```suggestion # updated to the latest terminfo snapshot. This works because this file is a ```
# This file is a part of Julia. License is MIT: https://julialang.org/license # Updating this listing is fairly easy, assuming existence of a unix system, # posix shell, and `awk`. Just call this file with `sh`, and it will be # updated to the latest terminfo snapshot. This works because this file is a # bit of a quin...
@@ -1,9 +1,9 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license # Updating this listing is fairly easy, assuming existence of a unix system, -# posix shell, and `awk`. Just update the version string in the commented out -# `NCURSES_VERSION` variable, and run this file. This works becau...
base/terminfo_data.jl
5
Julia
0.786
question
132
30
30
false
Update terminfo data
58,406
JuliaLang/julia
35,573
Julia
fingolfin
tecosaur
Review this pull request change. Language: Julia File: base/terminfo_data.jl PR Title: Update terminfo data BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license # Updating this listing is fairly easy, assuming existence of a unix system, # posix shell, and `awk`. Just call thi...
Isn't this referring to this file? ```suggestion # updated to the latest terminfo snapshot. This works because this file is 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.
for (name, shortcode, description) in list print(out, "\n TermCapability(:", name, ',', ' '^(namepad - textwidth(name)), ':', shortcode, ',', ' '^(codepad - textwidth(shortcode)), '"', escape_string(description), "\"),") end println(out, "\n]") end function getcustoma...
Could also do this to make future additions nicer (but obviously that's a matter of taste, too) ```suggestion "fe" => ":focus_enable", ) ```
for (name, shortcode, description) in list print(out, "\n TermCapability(:", name, ',', ' '^(namepad - textwidth(name)), ':', shortcode, ',', ' '^(codepad - textwidth(shortcode)), '"', escape_string(description), "\"),") end println(out, "\n]") end function getcustoma...
@@ -132,7 +133,9 @@ function getcustomalias(allterms::Vector{NTuple{3, String}}, type, short, descri "csl" => ":clear_status_line", "Ms" => ":set_host_clipboard", "Tc" => ":truecolor", - "XF" => ":xterm_focus") + "XF" => ":xterm_focus", + "fd" => ":focus_...
base/terminfo_data.jl
26
Julia
0.786
suggestion
163
51
51
false
Update terminfo data
58,406
JuliaLang/julia
35,573
Julia
fingolfin
tecosaur
Review this pull request change. Language: Julia File: base/terminfo_data.jl PR Title: Update terminfo data BEFORE CODE: for (name, shortcode, description) in list print(out, "\n TermCapability(:", name, ',', ' '^(namepad - textwidth(name)), ':', shortcode, ',', ' '^(codepad - textwidth...
Could also do this to make future additions nicer (but obviously that's a matter of taste, too) ```suggestion "fe" => ":focus_enable", ) ```
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.
using .M2 export x end @test M57638_3.x === 1 module GlobalBindingMulti module M export S module C export S struct A end S = A() # making S const makes the error go away end using .C end using .M using .M.C end @test GlobalBin...
```suggestion @test Base.datatype_haspadding(Tuple{ByteString58434}) == (length(Base.padding(Tuple{ByteString58434})) > 0) ``` Might be good as a sanity check to ensure that reflection stays consistent with this, since this fluctuated in the past.
using .M2 export x end @test M57638_3.x === 1 module GlobalBindingMulti module M export S module C export S struct A end S = A() # making S const makes the error go away end using .C end using .M using .M.C end @test GlobalBin...
@@ -8534,3 +8534,9 @@ module GlobalBindingMulti using .M.C end @test GlobalBindingMulti.S === GlobalBindingMulti.M.C.S + +#58434 bitsegal comparison of oddly sized fields +primitive type ByteString58434 (18 * 8) end + +@test Base.datatype_isbitsegal(Tuple{ByteString58434}) == false +@test Base.datatype_haspaddin...
test/core.jl
26
Julia
0.929
suggestion
253
27
27
false
Fix layout flags for types that have oddly sized primitive type fields
58,435
JuliaLang/julia
35,573
Julia
Seelengrab
gbaraldi
Review this pull request change. Language: Julia File: test/core.jl PR Title: Fix layout flags for types that have oddly sized primitive type fields BEFORE CODE: using .M2 export x end @test M57638_3.x === 1 module GlobalBindingMulti module M export S module C export S ...
```suggestion @test Base.datatype_haspadding(Tuple{ByteString58434}) == (length(Base.padding(Tuple{ByteString58434})) > 0) ``` Might be good as a sanity check to ensure that reflection stays consistent with this, since this fluctuated in the past.
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.
using .M2 export x end @test M57638_3.x === 1 module GlobalBindingMulti module M export S module C export S struct A end S = A() # making S const makes the error go away end using .C end using .M using .M.C end @test GlobalBin...
```suggestion @test Base.datatype_haspadding(Tuple{ByteString58434}) == (length(Base.padding(Tuple{ByteString58434})) > 0) ```
using .M2 export x end @test M57638_3.x === 1 module GlobalBindingMulti module M export S module C export S struct A end S = A() # making S const makes the error go away end using .C end using .M using .M.C end @test GlobalBin...
@@ -8534,3 +8534,9 @@ module GlobalBindingMulti using .M.C end @test GlobalBindingMulti.S === GlobalBindingMulti.M.C.S + +#58434 bitsegal comparison of oddly sized fields +primitive type ByteString58434 (18 * 8) end + +@test Base.datatype_isbitsegal(Tuple{ByteString58434}) == false +@test Base.datatype_haspaddin...
test/core.jl
26
Julia
0.857
suggestion
128
27
27
false
Fix layout flags for types that have oddly sized primitive type fields
58,435
JuliaLang/julia
35,573
Julia
giordano
gbaraldi
Review this pull request change. Language: Julia File: test/core.jl PR Title: Fix layout flags for types that have oddly sized primitive type fields BEFORE CODE: using .M2 export x end @test M57638_3.x === 1 module GlobalBindingMulti module M export S module C export S ...
```suggestion @test Base.datatype_haspadding(Tuple{ByteString58434}) == (length(Base.padding(Tuple{ByteString58434})) > 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.
len == 0 && return "" ref = v.ref if ref.ptr_or_offset == ref.mem.ptr str = ccall(:jl_genericmemory_to_string, Ref{String}, (Any, Int), ref.mem, len) else str = ccall(:jl_pchar_to_string, Ref{String}, (Ptr{UInt8}, Int), ref, len) end # optimized empty!(v); sizehint!(v, 0) calls ...
I believe this is invalid, because `String(::AbstractVector)` is documented to copy, unless the vector is a `Vector`. So you'd need to make a stringvector, then copy to it. ```suggestion function String(v::ReinterpretArray{UInt8, 1, S, Vector{S}, IsReshaped}) where {S, IsReshaped} len = length(v) iszero(l...
len == 0 && return "" ref = v.ref if ref.ptr_or_offset == ref.mem.ptr str = ccall(:jl_genericmemory_to_string, Ref{String}, (Any, Int), ref.mem, len) else str = ccall(:jl_pchar_to_string, Ref{String}, (Ptr{UInt8}, Int), ref, len) end # optimized empty!(v); sizehint!(v, 0) calls ...
@@ -77,6 +77,20 @@ function String(v::Vector{UInt8}) setfield!(v, :ref, memoryref(Memory{UInt8}())) return str end +function String(v::ReinterpretArray{UInt8, 1, S, Vector{S}, IsReshaped}) where {S, IsReshaped} + len = length(v) + len == 0 && return "" + ref = v.parent.ref + if ref.ptr_or_offset ...
base/strings/string.jl
26
Julia
1
refactor
655
51
51
false
Add a more efficient implementation for String(::ReinterpretArray)
58,438
JuliaLang/julia
35,573
Julia
jakobnissen
lntricate1
Review this pull request change. Language: Julia File: base/strings/string.jl PR Title: Add a more efficient implementation for String(::ReinterpretArray) BEFORE CODE: len == 0 && return "" ref = v.ref if ref.ptr_or_offset == ref.mem.ptr str = ccall(:jl_genericmemory_to_string, Ref{String}, (Any...
I believe this is invalid, because `String(::AbstractVector)` is documented to copy, unless the vector is a `Vector`. So you'd need to make a stringvector, then copy to it. ```suggestion function String(v::ReinterpretArray{UInt8, 1, S, Vector{S}, IsReshaped}) where {S, IsReshaped} len = length(v) iszero(l...
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_ppjlvalue = PointerType::get(T_pjlvalue, 0); T_pprjlvalue = PointerType::get(T_prjlvalue, 0); T_jlfunc = JuliaType::get_jlfunc_ty(context); assert(T_jlfunc != NULL); T_jlfuncparams = JuliaType::get_jlfuncparams_ty(context); assert(T_jlfuncparams != NULL); T_jl...
These comments are organized (and indentation is formatted) to represent the tree of the TBAA hierarchy, so any updates should preserve that
T_ppjlvalue = PointerType::get(T_pjlvalue, 0); T_pprjlvalue = PointerType::get(T_prjlvalue, 0); T_jlfunc = JuliaType::get_jlfunc_ty(context); assert(T_jlfunc != NULL); T_jlfuncparams = JuliaType::get_jlfuncparams_ty(context); assert(T_jlfuncparams != NULL); T_jl...
@@ -331,11 +331,12 @@ struct jl_tbaacache_t { // LLVM should have enough info for alias analysis of non-gcframe stack slot // this is mainly a place holder for `jl_cgval_t::tbaa` MDNode *tbaa_stack; // stack slot - MDNode *tbaa_unionselbyte; // a selector byte in isbits Union struct fields + ...
src/codegen.cpp
26
C++
0.429
style
140
51
51
false
Fix tbaa usage when storing into heap allocated immutable structs
58,483
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C++ File: src/codegen.cpp PR Title: Fix tbaa usage when storing into heap allocated immutable structs BEFORE CODE: T_ppjlvalue = PointerType::get(T_pjlvalue, 0); T_pprjlvalue = PointerType::get(T_prjlvalue, 0); T_jlfunc = JuliaType::get_jlfunc_ty(c...
These comments are organized (and indentation is formatted) to represent the tree of the TBAA hierarchy, so any updates should preserve that
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 initialize(llvm::LLVMContext &context) { if (initialized) { assert(&tbaa_root->getContext() == &context); return; } initialized = true; MDBuilder mbuilder(context); MDNode *jtbaa = mbuilder.createTBAARoot("jtbaa"); tbaa_root = mbuilder.cre...
This expresses that `tbaa_immut_unionselbyte` does not alias `tbaa_stack` - is that what you intended?
if (initialized) { assert(&tbaa_root->getContext() == &context); return; } initialized = true; MDBuilder mbuilder(context); MDNode *jtbaa = mbuilder.createTBAARoot("jtbaa"); tbaa_root = mbuilder.createTBAAScalarTypeNode("jtbaa", jtbaa); tba...
@@ -386,8 +386,11 @@ struct jl_tbaacache_t { MDNode *tbaa_mutab_scalar; std::tie(tbaa_mutab, tbaa_mutab_scalar) = tbaa_make_child(mbuilder, "jtbaa_mutab", tbaa_value_scalar); + MDNode *tbaa_immut_scalar; tbaa_datatype = tbaa_make_child(mbuilder, "jtbaa_datatype", tbaa_muta...
src/codegen.cpp
26
C++
0.5
question
102
51
51
false
Fix tbaa usage when storing into heap allocated immutable structs
58,483
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C++ File: src/codegen.cpp PR Title: Fix tbaa usage when storing into heap allocated immutable structs BEFORE CODE: void initialize(llvm::LLVMContext &context) { if (initialized) { assert(&tbaa_root->getContext() == &context); return; ...
This expresses that `tbaa_immut_unionselbyte` does not alias `tbaa_stack` - is that what you intended?
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.
inds2string(inds) = join(map(_indsstring,inds), '×') _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summary(io::IO, a::AbstractArray) = array_summary(io, a, axes(a)) function array_summary(io::IO, a, i...
[nitpick] This sentence is quite long and dense; consider breaking it into two or more shorter sentences for clarity and easier maintenance. ```suggestion Show the quasi-type of `x`. A quasi-type is either the type of `x` or an expression (possibly containing quasi-types) that would generate an object of the same type ...
showarg(io, parent(r), false) print(io, ')') end function showarg(io::IO, r::ReshapedReinterpretArray{T}, toplevel) where {T} print(io, "reinterpret(reshape, ", T, ", ") showarg(io, parent(r), false) print(io, ')') toplevel && print(io, " with eltype ", eltype(r)) return nothing end # prin...
@@ -3222,17 +3222,23 @@ end summary(io::IO, f::Function) = show(io, MIME"text/plain"(), f) """ - showarg(io::IO, x, toplevel) + Base.showarg(io::IO, x, toplevel) -Show `x` as if it were an argument to a function. This function is -used by [`summary`](@ref) to display type information in terms of sequences o...
base/show.jl
26
Julia
1
suggestion
373
51
51
false
Update showarg docstring
58,509
JuliaLang/julia
35,573
Julia
Copilot
LilithHafner
Review this pull request change. Language: Julia File: base/show.jl PR Title: Update showarg docstring BEFORE CODE: inds2string(inds) = join(map(_indsstring,inds), '×') _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-elem...
[nitpick] This sentence is quite long and dense; consider breaking it into two or more shorter sentences for clarity and easier maintenance. ```suggestion Show the quasi-type of `x`. A quasi-type is either the type of `x` or an expression (possibly containing quasi-types) that would generate an object of the same type ...
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 array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) print(io, " with indices ", inds2string(inds)) end ## `summary` for Function summary(io::IO, f::Function) = show(io, MIME"text/plain"(), f) """ Base.showarg(io::IO, x, toplevel) Show the quasi-type...
Might be worth mentioning that this is also useful if the API for the constructor is public but the specifics of the underlying type are not intended to be public facing.
# printing iterators from Base.Iterators function show(io::IO, e::Iterators.Enumerate) print(io, "enumerate(") show(io, e.itr) print(io, ')') end show(io::IO, z::Iterators.Zip) = show_delim_array(io, z.is, "zip(", ',', ')', false) # pretty printing for Iterators.Pairs function Base.showarg(io::IO, r::Ite...
@@ -3222,17 +3222,23 @@ end summary(io::IO, f::Function) = show(io, MIME"text/plain"(), f) """ - showarg(io::IO, x, toplevel) + Base.showarg(io::IO, x, toplevel) -Show `x` as if it were an argument to a function. This function is -used by [`summary`](@ref) to display type information in terms of sequences o...
base/show.jl
26
Julia
0.571
suggestion
170
51
51
false
Update showarg docstring
58,509
JuliaLang/julia
35,573
Julia
Tokazama
LilithHafner
Review this pull request change. Language: Julia File: base/show.jl PR Title: Update showarg docstring BEFORE CODE: function array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) print(io, " with indices ", inds2string(inds)) end ## `summary` for Function summar...
Might be worth mentioning that this is also useful if the API for the constructor is public but the specifics of the underlying type are not intended to be public facing.
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> x = MyStruct(1, (2,3)); julia> dump(x) MyStruct x: Int64 1 y: Tuple{Int64, Int64} 1: Int64 2 2: Int64 3 julia> dump(x; maxdepth = 1) MyStruct x: Int64 1 y: Tuple{Int64, Int64} ``` """ function dump(arg; maxdepth=DUMP_DEFAULT_MAXDEPTH) # this is typically used interactively, so default to b...
Should this be `Base.showarg(io::IO, x, toplevel::Bool)`?
# sizes such as 0-dimensional, 4-dimensional, 2x3 dims2string(d) = isempty(d) ? "0-dimensional" : length(d) == 1 ? "$(d[1])-element" : join(map(string,d), '×') inds2string(inds) = join(map(_indsstring,inds), '×') _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice...
@@ -3222,17 +3222,23 @@ end summary(io::IO, f::Function) = show(io, MIME"text/plain"(), f) """ - showarg(io::IO, x, toplevel) + Base.showarg(io::IO, x, toplevel)
base/show.jl
26
Julia
0.429
question
57
51
51
false
Update showarg docstring
58,509
JuliaLang/julia
35,573
Julia
Tokazama
LilithHafner
Review this pull request change. Language: Julia File: base/show.jl PR Title: Update showarg docstring BEFORE CODE: julia> x = MyStruct(1, (2,3)); julia> dump(x) MyStruct x: Int64 1 y: Tuple{Int64, Int64} 1: Int64 2 2: Int64 3 julia> dump(x; maxdepth = 1) MyStruct x: Int64 1 y: Tuple{Int64, Int64...
Should this be `Base.showarg(io::IO, x, toplevel::Bool)`?
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.
_indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summary(io::IO, a::AbstractArray) = array_summary(io, a, axes(a)) function array_summary(io::IO, a, inds::Tuple{Vararg{OneTo}}) print(io, dims2string(l...
```suggestion This function is used by `summary` to display type information in terms of sequences of ```
_indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summary(io::IO, a::AbstractArray) = array_summary(io, a, axes(a)) function array_summary(io::IO, a, inds::Tuple{Vararg{OneTo}}) print(io, dims2string(l...
@@ -3114,17 +3114,23 @@ end summary(io::IO, f::Function) = show(io, MIME"text/plain"(), f) """ - showarg(io::IO, x, toplevel) + Base.showarg(io::IO, x, toplevel) -Show `x` as if it were an argument to a function. This function is -used by [`summary`](@ref) to display type information in terms of sequences o...
base/show.jl
26
Julia
0.929
suggestion
107
51
51
false
Update showarg docstring
58,509
JuliaLang/julia
35,573
Julia
timholy
LilithHafner
Review this pull request change. Language: Julia File: base/show.jl PR Title: Update showarg docstring BEFORE CODE: _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summary(io::IO, a::AbstractArray) =...
```suggestion This function is used by `summary` to display type information in terms of sequences of ```
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.
print(io, dims2string(length.(inds)), " ") showarg(io, a, true) end function array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) print(io, " with indices ", inds2string(inds)) end ## `summary` for Function summary(io::IO, f::Function) = show(io, MIME"text/...
```suggestion The fallback definition is to print `x` as "::\\\$(typeof(x))", representing argument `x` in terms ```
print(io, dims2string(length.(inds)), " ") showarg(io, a, true) end function array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) print(io, " with indices ", inds2string(inds)) end ## `summary` for Function summary(io::IO, f::Function) = show(io, MIME"text/...
@@ -3114,17 +3114,23 @@ end summary(io::IO, f::Function) = show(io, MIME"text/plain"(), f) """ - showarg(io::IO, x, toplevel) + Base.showarg(io::IO, x, toplevel) -Show `x` as if it were an argument to a function. This function is -used by [`summary`](@ref) to display type information in terms of sequences o...
base/show.jl
26
Julia
0.857
suggestion
118
51
51
false
Update showarg docstring
58,509
JuliaLang/julia
35,573
Julia
timholy
LilithHafner
Review this pull request change. Language: Julia File: base/show.jl PR Title: Update showarg docstring BEFORE CODE: print(io, dims2string(length.(inds)), " ") showarg(io, a, true) end function array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) print(io...
```suggestion The fallback definition is to print `x` as "::\\\$(typeof(x))", representing argument `x` in terms ```
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.
showarg(io, a, true) end function array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) print(io, " with indices ", inds2string(inds)) end ## `summary` for Function summary(io::IO, f::Function) = show(io, MIME"text/plain"(), f) """ Base.showarg(io::IO, x, t...
```suggestion of its type. (The double-colon is omitted if `toplevel=true`.) However, you can specialize ``` This is partially redundant with the previous description of `toplevel`. I'm surely biased and thus unreliable (I wrote this initially, and docs always make sense to their author no matter how confusing they ...
showarg(io, a, true) end function array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) print(io, " with indices ", inds2string(inds)) end ## `summary` for Function summary(io::IO, f::Function) = show(io, MIME"text/plain"(), f) """ Base.showarg(io::IO, x, t...
@@ -3114,17 +3114,23 @@ end summary(io::IO, f::Function) = show(io, MIME"text/plain"(), f) """ - showarg(io::IO, x, toplevel) + Base.showarg(io::IO, x, toplevel) -Show `x` as if it were an argument to a function. This function is -used by [`summary`](@ref) to display type information in terms of sequences o...
base/show.jl
26
Julia
1
security
585
51
51
false
Update showarg docstring
58,509
JuliaLang/julia
35,573
Julia
timholy
LilithHafner
Review this pull request change. Language: Julia File: base/show.jl PR Title: Update showarg docstring BEFORE CODE: showarg(io, a, true) end function array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) print(io, " with indices ", inds2string(inds)) end ## ...
```suggestion of its type. (The double-colon is omitted if `toplevel=true`.) However, you can specialize ``` This is partially redundant with the previous description of `toplevel`. I'm surely biased and thus unreliable (I wrote this initially, and docs always make sense to their author no matter how confusing they ...
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.
precompile(f, (Int, Int)) end """) ji, ofile = Base.compilecache(Base.PkgId("NoBackEdges")) @eval using NoBackEdges invokelatest() do @test first(methods(NoBackEdges.f)).specializations.cache.max_world === typemax(UInt) end end # Test precompilation of generated fu...
```suggestion mi = first(Base.specializations(match.method)) ``` to be certain that you're not *generating* that `mi` with this call.
precompile(f, (Int, Int)) end """) ji, ofile = Base.compilecache(Base.PkgId("NoBackEdges")) @eval using NoBackEdges invokelatest() do @test first(methods(NoBackEdges.f)).specializations.cache.max_world === typemax(UInt) end end precompile_test_harness("Pre-compile ...
@@ -2145,6 +2145,29 @@ precompile_test_harness("No backedge precompile") do load_path end end +precompile_test_harness("Pre-compile Core methods") do load_path + # Core methods should support pre-compilation as external CI's like anything else + # https://github.com/JuliaLang/julia/issues/58497 + write...
test/precompile.jl
26
Julia
0.714
suggestion
148
51
51
false
Don't filter `Core` methods from newly-inferred list
58,510
JuliaLang/julia
35,573
Julia
timholy
topolarity
Review this pull request change. Language: Julia File: test/precompile.jl PR Title: Don't filter `Core` methods from newly-inferred list BEFORE CODE: precompile(f, (Int, Int)) end """) ji, ofile = Base.compilecache(Base.PkgId("NoBackEdges")) @eval using NoBackEdges invokela...
```suggestion mi = first(Base.specializations(match.method)) ``` to be certain that you're not *generating* that `mi` with this call.
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 { int special = 0; for (size_t i = 0; i < len; i++) { uint8_t c = str[i]; if (raw && ((c == '\\' && i == len-1) || c == '"')) { special = 1; break; } else if (!raw && (c < 32 || c == 0x7f || c == '\\...
You have to output a number of `\\` equal to the number proceeding this in both of these cases
} } else { int special = 0; for (size_t i = 0; i < len; i++) { uint8_t c = str[i]; if (raw && ((c == '\\' && i == len-1) || c == '"')) { special = 1; break; } else if (!raw && (c < 32 || c == 0x7f || c == '\\...
@@ -722,6 +728,17 @@ static size_t jl_static_show_string(JL_STREAM *out, const char *str, size_t len, jl_uv_puts(out, str, len); n += len; } + else if (raw) { + for (size_t i = 0; i < len; i++) { + uint8_t c = str[i]; + if (c == '"') + ...
src/rtutils.c
26
C
0.357
suggestion
94
51
51
false
Make more types jl_static_show readably
58,512
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/rtutils.c PR Title: Make more types jl_static_show readably BEFORE CODE: } } else { int special = 0; for (size_t i = 0; i < len; i++) { uint8_t c = str[i]; if (raw && ((c == '\\' && i == len-1) || c == '"'...
You have to output a number of `\\` equal to the number proceeding this in both of these cases
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 0; } else if (_iter_count > 10000) { // We are very likely stuck in a cyclic datastructure, so we assume this is // _not_ a Function. return 0; } else if (vt == jl_function_type) { return 1; } vt = vt->super; _ite...
These seem unlikely correct, since the standard given results are one higher for these: https://github.com/JuliaLang/julia/pull/57977/files#r2028868985 ```suggestion // Float16 5 // Float32 9 ```
// This function checks if `vt <: Function` without triggering GC. static int jl_static_is_function_(jl_datatype_t *vt) JL_NOTSAFEPOINT { if (!jl_function_type) { // Make sure there's a Function type defined. return 0; } int _iter_count = 0; // To prevent infinite loops from corrupt type objects. ...
@@ -777,6 +804,42 @@ static int jl_static_is_function_(jl_datatype_t *vt) JL_NOTSAFEPOINT { return 0; } +static size_t jl_static_show_float(JL_STREAM *out, double v, + jl_datatype_t *vt) JL_NOTSAFEPOINT +{ + size_t n = 0; + // TODO: non-canonical NaNs do not round-trip + ...
src/rtutils.c
26
C
0.786
suggestion
216
51
51
false
Make more types jl_static_show readably
58,512
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/rtutils.c PR Title: Make more types jl_static_show readably BEFORE CODE: return 0; } else if (_iter_count > 10000) { // We are very likely stuck in a cyclic datastructure, so we assume this is // _not_ a Function. ...
These seem unlikely correct, since the standard given results are one higher for these: https://github.com/JuliaLang/julia/pull/57977/files#r2028868985 ```suggestion // Float16 5 // Float32 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.
} static size_t jl_static_show_float(JL_STREAM *out, double v, jl_datatype_t *vt) JL_NOTSAFEPOINT { size_t n = 0; // TODO: non-canonical NaNs do not round-trip // TOOD: BFloat16 const char *size_suffix = vt == jl_float16_type ? "16" : vt ...
This seems likely prone to mistakes with double-rounding errors and implementation-defined choices of representations. I recommend changing this to `snprintf` to a small stack buffer and then outputting that with '%s' and then checking explicitly if it already contains `.`, rather than trying to guess
return 0; } else if (vt == jl_function_type) { return 1; } vt = vt->super; _iter_count += 1; } return 0; } static size_t jl_static_show_float(JL_STREAM *out, double v, jl_datatype_t *vt) JL_NOTSAFEPOINT { size_t n = ...
@@ -777,6 +804,42 @@ static int jl_static_is_function_(jl_datatype_t *vt) JL_NOTSAFEPOINT { return 0; } +static size_t jl_static_show_float(JL_STREAM *out, double v, + jl_datatype_t *vt) JL_NOTSAFEPOINT +{ + size_t n = 0; + // TODO: non-canonical NaNs do not round-trip + ...
src/rtutils.c
26
C
0.714
suggestion
302
51
51
false
Make more types jl_static_show readably
58,512
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/rtutils.c PR Title: Make more types jl_static_show readably BEFORE CODE: } static size_t jl_static_show_float(JL_STREAM *out, double v, jl_datatype_t *vt) JL_NOTSAFEPOINT { size_t n = 0; // TODO: non-canonical NaNs do...
This seems likely prone to mistakes with double-rounding errors and implementation-defined choices of representations. I recommend changing this to `snprintf` to a small stack buffer and then outputting that with '%s' and then checking explicitly if it already contains `.`, rather than trying to guess
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.
{ size_t n = 0; // TODO: non-canonical NaNs do not round-trip // TOOD: BFloat16 const char *size_suffix = vt == jl_float16_type ? "16" : vt == jl_float32_type ? "32" : ""; // Digits required to print p significand bi...
This can be implemented compactly similar to f64 case, with style '%e' and `e` replaced with `f` in the buffer
vt = vt->super; _iter_count += 1; } return 0; } static size_t jl_static_show_float(JL_STREAM *out, double v, jl_datatype_t *vt) JL_NOTSAFEPOINT { size_t n = 0; // TODO: non-canonical NaNs do not round-trip // TOOD: BFloat16 const char *size_suf...
@@ -777,6 +804,42 @@ static int jl_static_is_function_(jl_datatype_t *vt) JL_NOTSAFEPOINT { return 0; } +static size_t jl_static_show_float(JL_STREAM *out, double v, + jl_datatype_t *vt) JL_NOTSAFEPOINT +{ + size_t n = 0; + // TODO: non-canonical NaNs do not round-trip + ...
src/rtutils.c
26
C
0.571
style
111
51
51
false
Make more types jl_static_show readably
58,512
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/rtutils.c PR Title: Make more types jl_static_show readably BEFORE CODE: { size_t n = 0; // TODO: non-canonical NaNs do not round-trip // TOOD: BFloat16 const char *size_suffix = vt == jl_float16_type ? "16" : vt ==...
This can be implemented compactly similar to f64 case, with style '%e' and `e` replaced with `f` in the buffer
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 size_t jl_static_show_float(JL_STREAM *out, double v, jl_datatype_t *vt) JL_NOTSAFEPOINT { size_t n = 0; // TODO: non-canonical NaNs do not round-trip // TOOD: BFloat16 const char *size_suffix = vt == jl_float16_type ? "16" : vt ==...
```suggestion n += jl_printf(out, "%#.17g", v); ```
} else if (vt == jl_function_type) { return 1; } vt = vt->super; _iter_count += 1; } return 0; } static size_t jl_static_show_float(JL_STREAM *out, double v, jl_datatype_t *vt) JL_NOTSAFEPOINT { size_t n = 0; // TODO: non-ca...
@@ -777,6 +804,42 @@ static int jl_static_is_function_(jl_datatype_t *vt) JL_NOTSAFEPOINT { return 0; } +static size_t jl_static_show_float(JL_STREAM *out, double v, + jl_datatype_t *vt) JL_NOTSAFEPOINT +{ + size_t n = 0; + // TODO: non-canonical NaNs do not round-trip + ...
src/rtutils.c
26
C
0.571
suggestion
61
51
51
false
Make more types jl_static_show readably
58,512
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/rtutils.c PR Title: Make more types jl_static_show readably BEFORE CODE: static size_t jl_static_show_float(JL_STREAM *out, double v, jl_datatype_t *vt) JL_NOTSAFEPOINT { size_t n = 0; // TODO: non-canonical NaNs do n...
```suggestion n += jl_printf(out, "%#.17g", 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.
// TODO: non-canonical NaNs do not round-trip // TOOD: BFloat16 const char *size_suffix = vt == jl_float16_type ? "16" : vt == jl_float32_type ? "32" : ""; // Requires minimum 1 (sign) + 17 (sig) + 1 (dot) + 5 ("e-123") ...
While clever, would it be better to use the standard flag `#` for this to preserve all trailing zeros, which will end with simply `.` (rather than to imply the trailing digit is `.0` which may not be entirely true given final digit rounding, though I think it would have to round-trip the same since 17 digits is full ac...
// TODO: non-canonical NaNs do not round-trip // TOOD: BFloat16 const char *size_suffix = vt == jl_float16_type ? "16" : vt == jl_float32_type ? "32" : ""; // Requires minimum 1 (sign) + 17 (sig) + 1 (dot) + 5 ("e-123") ...
@@ -777,6 +812,55 @@ static int jl_static_is_function_(jl_datatype_t *vt) JL_NOTSAFEPOINT { return 0; } +static size_t jl_static_show_float(JL_STREAM *out, double v, + jl_datatype_t *vt) JL_NOTSAFEPOINT +{ + size_t n = 0; + // TODO: non-canonical NaNs do not round-trip + ...
src/rtutils.c
26
C
0.857
suggestion
402
51
51
false
Make more types jl_static_show readably
58,512
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/rtutils.c PR Title: Make more types jl_static_show readably BEFORE CODE: // TODO: non-canonical NaNs do not round-trip // TOOD: BFloat16 const char *size_suffix = vt == jl_float16_type ? "16" : vt == jl_float32_type ? "...
While clever, would it be better to use the standard flag `#` for this to preserve all trailing zeros, which will end with simply `.` (rather than to imply the trailing digit is `.0` which may not be entirely true given final digit rounding, though I think it would have to round-trip the same since 17 digits is full ac...
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.
special = 1; break; } } if (!special) { jl_uv_puts(out, str, len); n += len; } else if (raw) { // REF: Base.escape_raw_string int escapes = 0; for (size_t i = 0; i < len; i++) { ...
```suggestion n += jl_uv_puts(out, "\\", 1); escapes = 0; } n += jl_uv_puts(out, str + i, 1); } for (; escapes > 0; escapes--) n += jl_uv_puts(out, "\\", 1); ```
special = 1; break; } } if (!special) { jl_uv_puts(out, str, len); n += len; } else if (raw) { // REF: Base.escape_raw_string int escapes = 0; for (size_t i = 0; i < len; i++) { ...
@@ -722,6 +728,25 @@ static size_t jl_static_show_string(JL_STREAM *out, const char *str, size_t len, jl_uv_puts(out, str, len); n += len; } + else if (raw) { + // REF: Base.escape_raw_string + int escapes = 0; + for (size_t i = 0; i < len; i++)...
src/rtutils.c
26
C
0.786
security
291
51
51
false
Make more types jl_static_show readably
58,512
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/rtutils.c PR Title: Make more types jl_static_show readably BEFORE CODE: special = 1; break; } } if (!special) { jl_uv_puts(out, str, len); n += len; } else if (...
```suggestion n += jl_uv_puts(out, "\\", 1); escapes = 0; } n += jl_uv_puts(out, str + i, 1); } for (; escapes > 0; escapes--) n += jl_uv_puts(out, "\\", 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.
n += jl_printf(out, "("); n += jl_static_show_x(out, lb, depth, ctx); if (ua) n += jl_printf(out, ")"); n += jl_printf(out, "<:"); } n += jl_static_show_symbol(out, var->name); if (showbounds && (ub != (jl_value_t*)jl_any_type |...
Can you fix-up Pointer types as well? ```julia julia> ccall(:jl_, Cvoid, (Any,), Val(Ptr{Cvoid}(1))) Base.Val{0x0000000000000001}() ``` It's a little awkward, because their `repr` doesn't round-trip either: ```julia julia> Val(Ptr{Cvoid}(1)) Val{Ptr{Nothing} @0x0000000000000001}() julia> Val{Ptr{Nothing} @0x...
else if (vt == jl_int32_type) { n += jl_printf(out, "Int32(%" PRId32 ")", *(int32_t*)v); } else if (vt == jl_int16_type) { n += jl_printf(out, "Int16(%" PRId16 ")", *(int16_t*)v); } else if (vt == jl_int8_type) { n += jl_printf(out, "Int8(%" PRId8 ")", *(int8_t*)v); } ...
@@ -985,11 +1069,14 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt n += jl_printf(out, "0x%08" PRIx32, *(uint32_t*)v);
src/rtutils.c
26
C
1
suggestion
592
51
51
false
Make more types jl_static_show readably
58,512
JuliaLang/julia
35,573
Julia
topolarity
xal-0
Review this pull request change. Language: C File: src/rtutils.c PR Title: Make more types jl_static_show readably BEFORE CODE: n += jl_printf(out, "("); n += jl_static_show_x(out, lb, depth, ctx); if (ua) n += jl_printf(out, ")"); n += jl_printf(o...
Can you fix-up Pointer types as well? ```julia julia> ccall(:jl_, Cvoid, (Any,), Val(Ptr{Cvoid}(1))) Base.Val{0x0000000000000001}() ``` It's a little awkward, because their `repr` doesn't round-trip either: ```julia julia> Val(Ptr{Cvoid}(1)) Val{Ptr{Nothing} @0x0000000000000001}() julia> Val{Ptr{Nothing} @0x...
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 if (vt == jl_unionall_type) { jl_unionall_t *ua = (jl_unionall_t*)v; n += jl_static_show_x(out, ua->body, depth, ctx); n += jl_printf(out, " where "); n += jl_static_show_x(out, (jl_value_t*)ua->var, depth->prev, ctx); } else if (vt == jl_typename_type) { n...
Looks like negative `Int128` values are still problematic: ```julia julia> ccall(:jl_, Cvoid, (Any,), typemin(Int128)) Int128(0x80000000000000000000000000000000) julia> ccall(:jl_, Cvoid, (Any,), Int128(-1)) Int128(0xffffffffffffffffffffffffffffffff) ``` And `UInt128` prints with an explicit conversion it does...
n += jl_printf(out, ")"); } } if (dv->parameters && (jl_value_t*)dv != dv->name->wrapper) { size_t j, tlen = jl_nparams(dv); if (tlen > 0) { n += jl_printf(out, "{"); for (j = 0; j < tlen; j++) { jl_v...
@@ -954,17 +1034,21 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt int f = *(uint32_t*)jl_data_ptr(v); n += jl_printf(out, "#<intrinsic #%d %s>", f, jl_intrinsic_name(f)); } + else if (vt == jl_long_type) { + // Avoid unnecessary Int64(x)/Int32(x) + ...
src/rtutils.c
26
C
0.929
suggestion
533
51
51
false
Make more types jl_static_show readably
58,512
JuliaLang/julia
35,573
Julia
topolarity
xal-0
Review this pull request change. Language: C File: src/rtutils.c PR Title: Make more types jl_static_show readably BEFORE CODE: } else if (vt == jl_unionall_type) { jl_unionall_t *ua = (jl_unionall_t*)v; n += jl_static_show_x(out, ua->body, depth, ctx); n += jl_printf(out, " where ")...
Looks like negative `Int128` values are still problematic: ```julia julia> ccall(:jl_, Cvoid, (Any,), typemin(Int128)) Int128(0x80000000000000000000000000000000) julia> ccall(:jl_, Cvoid, (Any,), Int128(-1)) Int128(0xffffffffffffffffffffffffffffffff) ``` And `UInt128` prints with an explicit conversion it does...
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_throws ArgumentError resize!(Float64[], -2) b = rand(32) a = reshape(b, (2, 2, 2, 2, 2)) @test ndims(a) == 5 @test a[2,1,2,2,1] == b[14] @test a[2,2,2,2,2] == b[end] @test_throws DimensionMismatch reshape(1:3, 4) # issue #23107 a = [1,2,3] @test typeof(a)(a) !== a @t...
can this just be `Base.Compiler.is_removable_if_unused`?
@test_throws ArgumentError resize!(Float64[], -2) b = rand(32) a = reshape(b, (2, 2, 2, 2, 2)) @test ndims(a) == 5 @test a[2,1,2,2,1] == b[14] @test a[2,2,2,2,2] == b[end] @test_throws DimensionMismatch reshape(1:3, 4) # issue #23107 a = [1,2,3] @test typeof(a)(a) !== a @t...
@@ -100,6 +100,17 @@ using Dates @test Array{eltype(a)}(a) !== a @test Vector(a) !== a end +@testset "effect inference for `reshape` for `Array`" begin + for Arr ∈ (Array{<:Any, 0}, Vector, Matrix, Array{<:Any, 3}) + for Shape ∈ (Tuple{Int}, Tuple{Int, Int}) + effects = Base.infer_effect...
test/arrayops.jl
26
Julia
0.429
question
56
51
51
false
improve inferred effects for `reshape` for `Array`
58,672
JuliaLang/julia
35,573
Julia
oscardssmith
nsajko
Review this pull request change. Language: Julia File: test/arrayops.jl PR Title: improve inferred effects for `reshape` for `Array` BEFORE CODE: @test_throws ArgumentError resize!(Float64[], -2) b = rand(32) a = reshape(b, (2, 2, 2, 2, 2)) @test ndims(a) == 5 @test a[2,1,2,2,1] == b[14] @t...
can this just be `Base.Compiler.is_removable_if_unused`?
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.
push!(state.new_cfg_blocks[end].succs, length(state.new_cfg_blocks)+1) append!(state.new_cfg_blocks, inlinee_cfg.blocks) else # Merge the last block that was already there with the first block we're adding l = length(state.new_cfg_blocks) bb_rename_range = (l:length(inlinee_c...
```suggestion # the meaning of predecessor 0 depends on the block we encounter it: # - in the first block, it represents the function entry and so needs to be re-mapped # - elsewhere, it represents external control-flow from a caught exception which is ...
push!(state.new_cfg_blocks[end].succs, length(state.new_cfg_blocks)+1) append!(state.new_cfg_blocks, inlinee_cfg.blocks) else # Merge the last block that was already there with the first block we're adding l = length(state.new_cfg_blocks) bb_rename_range = (l:length(inlinee_c...
@@ -166,12 +167,15 @@ function cfg_inline_item!(ir::IRCode, idx::Int, todo::InliningTodo, state::CFGIn end new_block_range = (length(state.new_cfg_blocks)-length(inlinee_cfg.blocks)+1):length(state.new_cfg_blocks) - # Fixup the edges of the newely added blocks + # Fixup the edges of the newly added bl...
Compiler/src/ssair/inlining.jl
26
Julia
1
suggestion
567
51
51
false
Add 0 predecessor to entry basic block and handle it in inlining
58,683
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: Julia File: Compiler/src/ssair/inlining.jl PR Title: Add 0 predecessor to entry basic block and handle it in inlining BEFORE CODE: push!(state.new_cfg_blocks[end].succs, length(state.new_cfg_blocks)+1) append!(state.new_cfg_blocks, inlinee_cfg.blocks) e...
```suggestion # the meaning of predecessor 0 depends on the block we encounter it: # - in the first block, it represents the function entry and so needs to be re-mapped # - elsewhere, it represents external control-flow from a caught exception which is ...
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.
buffer[3] = 8; // length memcpy(&buffer[4], &message, 8); // Copy the pointer into the buffer _os_signpost_emit_with_name_impl(&__dso_handle, block->event->os_log_event.log, OS_SIGNPOST_EVENT, block->signpost_id, (block)->event->os_log_event.name, "%s", buffer, sizeof(buffer) ); } void _jl_os_signp...
Is it not possible to use `os/log.h` and the public `os_signpost_emit_with_type`?
block->signpost_id = os_signpost_id_make_with_pointer((block)->event->os_log_event.log, (void *)(block)); _os_signpost_emit_with_name_impl(&__dso_handle, block->event->os_log_event.log, OS_SIGNPOST_INTERVAL_BEGIN, block->signpost_id, (block)->event->os_log_event.name, "", buffer, sizeof(buffer)); } voi...
@@ -255,6 +255,45 @@ static __itt_event _jl_timing_ittapi_event_create(const char *event) { #endif // USE_ITTAPI +#ifdef USE_APPLE_OSLOG + +void _jl_os_log_signpost_print(jl_timing_block_t* block, const char *message) { + if (!os_signpost_enabled(block->event->os_log_event.log)) { + return; + } + u...
src/timing.c
26
C
0.571
question
81
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
maleadt
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: buffer[3] = 8; // length memcpy(&buffer[4], &message, 8); // Copy the pointer into the buffer _os_signpost_emit_with_name_impl(&__dso_handle, block->event->os_lo...
Is it not possible to use `os/log.h` and the public `os_signpost_emit_with_type`?
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 __itt_event _jl_timing_ittapi_event_create(const char *event) { JL_LOCK_NOGC(&jl_timing_ittapi_events_lock); const size_t n = jl_timing_ittapi_events.len; for (size_t i = 0; i < n; i++) { cached_ittapi_event_t *other_event = (cached_ittapi_event_t *)jl_timing_ittapi_events.items[i]; i...
This should probably be in `jl_timing_puts` instead?
static __itt_event _jl_timing_ittapi_event_create(const char *event) { JL_LOCK_NOGC(&jl_timing_ittapi_events_lock); const size_t n = jl_timing_ittapi_events.len; for (size_t i = 0; i < n; i++) { cached_ittapi_event_t *other_event = (cached_ittapi_event_t *)jl_timing_ittapi_events.items[i]; i...
@@ -253,6 +253,60 @@ static __itt_event _jl_timing_ittapi_event_create(const char *event) { #endif // USE_ITTAPI +#ifdef USE_APPLE_OSLOG + +void _jl_os_log_signpost_print(jl_timing_block_t* block, const char *message) {
src/timing.c
26
C
0.429
question
52
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: static __itt_event _jl_timing_ittapi_event_create(const char *event) { JL_LOCK_NOGC(&jl_timing_ittapi_events_lock); const size_t n = jl_timing_ittapi_events.len; ...
This should probably be in `jl_timing_puts` instead?
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 void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) { #ifdef USE_TRACY ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buffer to avoid allocation jl_static_show((JL_STREAM*)&buf, v); if (buf.size == buf.maxsize) memset(&buf.buf[IOS...
Probably better to: ```suggestion #ifdef USE_APPLE_OSLOG _jl_os_log_signpost_print(cur_block, buf.buf); #endif ``` and then re-use the `jl_static_show` and buf handling for both Tracy + OSLog
jl_timing_puts(cur_block, buf->buf); } JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) { #if defined(USE_TRACY) || defined(USE_APPLE_OSLOG) ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buffer to avoid allocation jl_static_show((JL_STR...
@@ -479,6 +539,17 @@ JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) TracyCZoneText(cur_block->tracy_ctx, buf.buf, buf.size); #endif +#ifdef USE_APPLE_OSLOG + ios_t buf; + ios_mem(&buf, IOS_INLSIZE); + buf.growable = 0; // Restrict to inline buffer to avoid allocation + + ...
src/timing.c
26
C
0.857
suggestion
201
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: } JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) { #ifdef USE_TRACY ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // R...
Probably better to: ```suggestion #ifdef USE_APPLE_OSLOG _jl_os_log_signpost_print(cur_block, buf.buf); #endif ``` and then re-use the `jl_static_show` and buf handling for both Tracy + OSLog
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 blk; } JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) { #ifdef USE_TRACY ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buffer to avoid allocation jl_static_show((JL_STREAM*)&buf, v); if (buf.size == buf.maxsize) ...
this looks potentially out-of-bounds
buf->buf[buf->size] = '\0'; // Ensure null-termination } jl_timing_puts(cur_block, buf->buf); } JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) { #if defined(USE_TRACY) || defined(USE_APPLE_OSLOG) ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Rest...
@@ -479,6 +539,17 @@ JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) TracyCZoneText(cur_block->tracy_ctx, buf.buf, buf.size); #endif +#ifdef USE_APPLE_OSLOG + ios_t buf; + ios_mem(&buf, IOS_INLSIZE); + buf.growable = 0; // Restrict to inline buffer to avoid allocation + + ...
src/timing.c
26
C
0.071
suggestion
36
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: } return blk; } JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) { #ifdef USE_TRACY ios_t buf; ios_mem(&buf, IOS_INLSIZE); ...
this looks potentially out-of-bounds
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_static_show((JL_STREAM*)&buf, v); if (buf.size == buf.maxsize) memset(&buf.buf[IOS_INLSIZE - 3], '.', 3); buf.buf[buf.size] = '\0'; // Ensure null-termination _jl_os_log_signpost_print(cur_block, buf.buf); #endif } JL_DLLEXPORT void jl_timing_show_module(jl_module_t *m, jl_timing_block_t *cu...
Perhaps better to share the logic with Tracy above? (and support `jl_timing_printf` for OSLog)
const char *module_name = jl_symbol_name(m->name); jl_timing_puts(cur_block, module_name); } else { jl_timing_printf(cur_block, "%s.%s", jl_symbol_name(root->name), jl_symbol_name(m->name)); } #endif } JL_DLLEXPORT void jl_timing_show_filename(const char *path, jl_timing_block_t *cur_bl...
@@ -492,6 +563,13 @@ JL_DLLEXPORT void jl_timing_show_module(jl_module_t *m, jl_timing_block_t *cur_b jl_timing_printf(cur_block, "%s.%s", jl_symbol_name(root->name), jl_symbol_name(m->name)); } #endif +#ifdef USE_APPLE_OSLOG + jl_module_t *root = jl_module_root(m); + if (root == m || root == jl_ma...
src/timing.c
26
C
0.429
suggestion
94
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: jl_static_show((JL_STREAM*)&buf, v); if (buf.size == buf.maxsize) memset(&buf.buf[IOS_INLSIZE - 3], '.', 3); buf.buf[buf.size] = '\0'; // Ensure null-ter...
Perhaps better to share the logic with Tracy above? (and support `jl_timing_printf` for OSLog)
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.
cached_ittapi_event_t *new_event = (cached_ittapi_event_t *)malloc(sizeof(cached_ittapi_event_t)); arraylist_push(&jl_timing_ittapi_events, (void *)new_event); new_event->name = event; new_event->event = __itt_event_create(event, strlen(event)); JL_UNLOCK_NOGC(&jl_timing_ittapi_events_lock); re...
this (and all the other functions) should follow the naming convention of other functions `_jl_timing_os_log_signpost_start`
cached_ittapi_event_t *new_event = (cached_ittapi_event_t *)malloc(sizeof(cached_ittapi_event_t)); arraylist_push(&jl_timing_ittapi_events, (void *)new_event); new_event->name = event; new_event->event = __itt_event_create(event, strlen(event)); JL_UNLOCK_NOGC(&jl_timing_ittapi_events_lock); re...
@@ -253,6 +253,60 @@ static __itt_event _jl_timing_ittapi_event_create(const char *event) { #endif // USE_ITTAPI +#ifdef USE_APPLE_OSLOG + +void _jl_os_log_signpost_print(jl_timing_block_t* block, const char *message) { + // Buffer the metadata to be emitted with the interval end + size_t len = strlen(messag...
src/timing.c
26
C
0.571
style
124
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: cached_ittapi_event_t *new_event = (cached_ittapi_event_t *)malloc(sizeof(cached_ittapi_event_t)); arraylist_push(&jl_timing_ittapi_events, (void *)new_event); n...
this (and all the other functions) should follow the naming convention of other functions `_jl_timing_os_log_signpost_start`
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.
// No matching event found - create a new one cached_ittapi_event_t *new_event = (cached_ittapi_event_t *)malloc(sizeof(cached_ittapi_event_t)); arraylist_push(&jl_timing_ittapi_events, (void *)new_event); new_event->name = event; new_event->event = __itt_event_create(event, strlen(event)); JL_...
This `block` is stack-allocated, so this seems wrong according to the documentation: > Creates a signpost identifier that’s unique among signposts logging to the specified log, using a pointer value to generate the unique value. Should this be part of the `event` instead?
// No matching event found - create a new one cached_ittapi_event_t *new_event = (cached_ittapi_event_t *)malloc(sizeof(cached_ittapi_event_t)); arraylist_push(&jl_timing_ittapi_events, (void *)new_event); new_event->name = event; new_event->event = __itt_event_create(event, strlen(event)); JL_...
@@ -253,6 +253,60 @@ static __itt_event _jl_timing_ittapi_event_create(const char *event) { #endif // USE_ITTAPI +#ifdef USE_APPLE_OSLOG + +void _jl_os_log_signpost_print(jl_timing_block_t* block, const char *message) { + // Buffer the metadata to be emitted with the interval end + size_t len = strlen(messag...
src/timing.c
26
C
0.643
bug
276
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: // No matching event found - create a new one cached_ittapi_event_t *new_event = (cached_ittapi_event_t *)malloc(sizeof(cached_ittapi_event_t)); arraylist_push(...
This `block` is stack-allocated, so this seems wrong according to the documentation: > Creates a signpost identifier that’s unique among signposts logging to the specified log, using a pointer value to generate the unique value. Should this be part of the `event` instead?
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_method_t *def = mi->def.method; jl_timing_show_location(jl_symbol_name(def->file), def->line, def->module, cur_block); } else { jl_timing_printf(cur_block, "<top-level thunk> in %s", jl_symbol_name(mi->def.module->name)); } } JL_DLLEXPORT void jl_timing_show_...
this now overwrites part of the ellipsis that may have been added
jl_symbol_name(root->name), jl_symbol_name(mod->name)); } #endif } JL_DLLEXPORT void jl_timing_show_method_instance(jl_method_instance_t *mi, jl_timing_block_t *cur_block) { jl_timing_show_func_sig(mi->specTypes, cur_block); if (jl_is_method(mi->def.value))...
@@ -551,8 +599,8 @@ JL_DLLEXPORT void jl_timing_show_func_sig(jl_value_t *v, jl_timing_block_t *cur_ jl_static_show_func_sig_((JL_STREAM*)&buf, v, config); if (buf.size == buf.maxsize) memset(&buf.buf[IOS_INLSIZE - 3], '.', 3); - - TracyCZoneText(cur_block->tracy_ctx, buf.buf, buf.size); + buf....
src/timing.c
26
C
0.214
suggestion
65
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: jl_method_t *def = mi->def.method; jl_timing_show_location(jl_symbol_name(def->file), def->line, def->module, cur_block); } else { jl_timing_prin...
this now overwrites part of the ellipsis that may have been added
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.
ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buffer to avoid allocation jl_vprintf((JL_STREAM*)&buf, format, args); if (buf.size == buf.maxsize) memset(&buf.buf[IOS_INLSIZE - 3], '.', 3); buf.buf[buf.size] = '\0'; // Ensure null-termination jl_timing...
```suggestion assert(cur_block->oslog_metadata_len < sizeof(cur_block->oslog_metadata)); size_t remaining = sizeof(cur_block->oslog_metadata) - cur_block->oslog_metadata_len - 1; ``` this is correct as-is, but easy to violate so worth the assert
JL_DLLEXPORT void jl_timing_printf(jl_timing_block_t *cur_block, const char *format, ...) { va_list args; va_start(args, format); #if defined(USE_APPLE_OSLOG) || defined(USE_TRACY) ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buffer to avoid allocation jl_vpri...
@@ -589,6 +636,17 @@ JL_DLLEXPORT void jl_timing_puts(jl_timing_block_t *cur_block, const char *str) #ifdef USE_TRACY TracyCZoneText(cur_block->tracy_ctx, str, strlen(str)); #endif +#ifdef USE_APPLE_OSLOG + // Buffer the metadata to be emitted with the interval end + size_t len = strlen(str); + size...
src/timing.c
26
C
0.786
suggestion
257
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buffer to avoid allocation jl_vprintf((JL_STREAM*)&buf, format, args); if ...
```suggestion assert(cur_block->oslog_metadata_len < sizeof(cur_block->oslog_metadata)); size_t remaining = sizeof(cur_block->oslog_metadata) - cur_block->oslog_metadata_len - 1; ``` this is correct as-is, but easy to violate so worth the assert
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.
//TracyCFiberLeave; #endif (void)ct; jl_timing_block_t *blk = ptls->timing_stack; ptls->timing_stack = NULL; if (blk != NULL) { _COUNTS_PAUSE(&blk->counts_ctx, cycleclock()); } return blk; } JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) { #if defin...
Is this missing a null terminator?
//TracyCFiberLeave; #endif (void)ct; jl_timing_block_t *blk = ptls->timing_stack; ptls->timing_stack = NULL; if (blk != NULL) { _COUNTS_PAUSE(&blk->counts_ctx, cycleclock()); } return blk; } static void _jl_timing_show_buf(jl_timing_block_t *cur_block, ios_t *buf) { if (buf->...
@@ -477,17 +525,17 @@ JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block) if (buf.size == buf.maxsize) memset(&buf.buf[IOS_INLSIZE - 3], '.', 3); - TracyCZoneText(cur_block->tracy_ctx, buf.buf, buf.size); + jl_timing_puts(cur_block, buf.buf);
src/timing.c
26
C
0.214
question
34
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: //TracyCFiberLeave; #endif (void)ct; jl_timing_block_t *blk = ptls->timing_stack; ptls->timing_stack = NULL; if (blk != NULL) { _COUNTS_PAUSE(...
Is this missing a null terminator?
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_timing_puts(cur_block, buf.buf); #endif } JL_DLLEXPORT void jl_timing_show_macro(jl_method_instance_t *macro, jl_value_t* lno, jl_module_t* mod, jl_timing_block_t *cur_block) { jl_timing_printf(cur_block, "%s", jl_symbol_name(macro->def.method->name)); assert(jl_typetagis(lno, jl_linenumbernode_type)); ...
this also overwrites the ellipsis
jl_static_show_config_t config = { /* quiet */ 1 }; jl_static_show_func_sig_((JL_STREAM*)&buf, v, config); _jl_timing_show_buf(cur_block, &buf); #endif } JL_DLLEXPORT void jl_timing_show_macro(jl_method_instance_t *macro, jl_value_t* lno, jl_module_t* mod, jl_timing_block_t *cur_block) { jl_timing_pri...
@@ -570,16 +622,15 @@ JL_DLLEXPORT void jl_timing_printf(jl_timing_block_t *cur_block, const char *for va_list args; va_start(args, format); -#ifdef USE_TRACY +#if defined(USE_APPLE_OSLOG) || defined(USE_TRACY) ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buf...
src/timing.c
26
C
0.071
suggestion
33
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: jl_timing_puts(cur_block, buf.buf); #endif } JL_DLLEXPORT void jl_timing_show_macro(jl_method_instance_t *macro, jl_value_t* lno, jl_module_t* mod, jl_timing_block_t *c...
this also overwrites the ellipsis
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.
ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buffer to avoid allocation jl_static_show((JL_STREAM*)&buf, v); _jl_timing_show_buf(cur_block, &buf); #endif } JL_DLLEXPORT void jl_timing_show_module(jl_module_t *m, jl_timing_block_t *cur_block) { #if defined(USE_TRAC...
Might be worth moving this to a `JL_TIMING_HAS_PUTS` or `JL_TIMING_HAS_PRINTF` define, but not required
#if defined(USE_TRACY) || defined(USE_APPLE_OSLOG) ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buffer to avoid allocation jl_static_show((JL_STREAM*)&buf, v); _jl_timing_show_buf(cur_block, &buf); #endif } JL_DLLEXPORT void jl_timing_show_module(jl_module_t *m, j...
@@ -496,15 +553,15 @@ JL_DLLEXPORT void jl_timing_show_module(jl_module_t *m, jl_timing_block_t *cur_b JL_DLLEXPORT void jl_timing_show_filename(const char *path, jl_timing_block_t *cur_block) { -#ifdef USE_TRACY +#if defined(USE_TRACY) || defined(USE_APPLE_OSLOG)
src/timing.c
26
C
0.5
suggestion
103
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: ios_t buf; ios_mem(&buf, IOS_INLSIZE); buf.growable = 0; // Restrict to inline buffer to avoid allocation jl_static_show((JL_STREAM*)&buf, v); _jl_timin...
Might be worth moving this to a `JL_TIMING_HAS_PUTS` or `JL_TIMING_HAS_PRINTF` define, but not required
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.
// // Eventually, Tracy will support telling the server which fibers // are active upon connection, but until then we work around the // problem by not explicitly leaving the fiber at all. // // Later when we enter the new fiber directly, that will cause the // the active fiber to be left im...
```suggestion buf->size -= 1; buf->buf[buf->size] = '\0'; // Ensure null-termination ``` just to be consistent about whether the null terminator is included in the buffer or not
// // Eventually, Tracy will support telling the server which fibers // are active upon connection, but until then we work around the // problem by not explicitly leaving the fiber at all. // // Later when we enter the new fiber directly, that will cause the // the active fiber to be left im...
@@ -466,28 +514,37 @@ jl_timing_block_t *jl_timing_block_task_exit(jl_task_t *ct, jl_ptls_t ptls) return blk; } +static void _jl_timing_show_buf(jl_timing_block_t *cur_block, ios_t *buf) +{ + if (buf->size == buf->maxsize) { + memset(&buf->buf[IOS_INLSIZE - 4], '.', 3); + buf->buf[buf->size-1] ...
src/timing.c
26
C
0.857
suggestion
199
51
51
false
Add option to use Apple os_signpost for instrumentation
58,702
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C File: src/timing.c PR Title: Add option to use Apple os_signpost for instrumentation BEFORE CODE: // // Eventually, Tracy will support telling the server which fibers // are active upon connection, but until then we work around the // problem by not expli...
```suggestion buf->size -= 1; buf->buf[buf->size] = '\0'; // Ensure null-termination ``` just to be consistent about whether the null terminator is included in the buffer or not
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.
continue end for prop_name in names(m) prop = getproperty(m, prop_name) if isa(prop, Libdl.LazyLibrary) lib_path = dlpath(prop) lazy_lib_deps = strip_soversion.(basename.(dlpath.(prop.dependencies))) ...
I'm not sure Windows has concept of soversion at all, libraries tend to append numbers to the basename to mimic soversions like in other platforms, but that's custom, not very standard. Instead of special-casing `libpcre2` here, wouldn't it be possible to list multiple values of library name when `libpcre2` is used? ...
continue end for prop_name in names(m) prop = getproperty(m, prop_name) if isa(prop, Libdl.LazyLibrary) lib_path = dlpath(prop) lazy_lib_deps = strip_soversion.(basename.(dlpath.(prop.dependencies))) ...
@@ -220,6 +220,19 @@ try missing_deps = setdiff(real_lib_deps, lazy_lib_deps) extraneous_deps = setdiff(lazy_lib_deps, real_lib_deps) + # The library name is `libpcre2-8`, with a dash in + # its name. That works fine on Unix. On Windows, ...
test/stdlib_dependencies.jl
26
Julia
0.643
suggestion
457
51
51
false
LibGit2: Update to 1.9.1
58,731
JuliaLang/julia
35,573
Julia
giordano
eschnett
Review this pull request change. Language: Julia File: test/stdlib_dependencies.jl PR Title: LibGit2: Update to 1.9.1 BEFORE CODE: continue end for prop_name in names(m) prop = getproperty(m, prop_name) if isa(prop, Libdl.LazyLibrary) ...
I'm not sure Windows has concept of soversion at all, libraries tend to append numbers to the basename to mimic soversions like in other platforms, but that's custom, not very standard. Instead of special-casing `libpcre2` here, wouldn't it be possible to list multiple values of library name when `libpcre2` is used? ...
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 # Check if we are building a PDF const render_pdf = "pdf" in ARGS # Generate a suitable markdown file from NEWS.md and put it in src function generate_markdown(basename) str = read(joinpath(@__DIR__, "..", "$basename.md"), String) splitted = split(str, "<!--- generated by $basename-update.jl: -->") ...
This makes the new section section 4 of 64 of the Manual. IMO this is a way too early/prominent of a position for the GC section.
) end # Check if we are building a PDF const render_pdf = "pdf" in ARGS # Generate a suitable markdown file from NEWS.md and put it in src function generate_markdown(basename) str = read(joinpath(@__DIR__, "..", "$basename.md"), String) splitted = split(str, "<!--- generated by $basename-update.jl: -->") ...
@@ -161,6 +161,7 @@ generate_markdown("NEWS") Manual = [ "manual/getting-started.md", "manual/installation.md", + "manual/memory-management.md",
doc/make.jl
26
Julia
0.357
suggestion
129
51
51
false
Docs: add GC user docs
58,733
JuliaLang/julia
35,573
Julia
nsajko
IanButterworth
Review this pull request change. Language: Julia File: doc/make.jl PR Title: Docs: add GC user docs BEFORE CODE: ) end # Check if we are building a PDF const render_pdf = "pdf" in ARGS # Generate a suitable markdown file from NEWS.md and put it in src function generate_markdown(basename) str = read(joinpa...
This makes the new section section 4 of 64 of the Manual. IMO this is a way too early/prominent of a position for the GC section.
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 = @_gc_preserve_begin a p = unsafe_convert(Ptr{Cvoid}, a) T = eltype(a) memset(p, x isa T ? x : convert(T, x), length(a) % UInt) @_gc_preserve_end t return a end ## Conversions ## convert(::Type{T}, a::AbstractArray) where {T<:Memory} = a isa T ? a : T(a)::T promote_rule(a::Type{Memory{T}},...
Should this be ```suggestion _checkbounds_array(Bool, A, i) ? (@inbounds A[i], i + 1) : nothing ``` like the `iterate(s::CodeUnits, i=1)` method (which would then be basically identical)?
t = @_gc_preserve_begin a p = unsafe_convert(Ptr{Cvoid}, a) T = eltype(a) memset(p, x isa T ? x : convert(T, x), length(a) % UInt) @_gc_preserve_end t return a end ## Conversions ## convert(::Type{T}, a::AbstractArray) where {T<:Memory} = a isa T ? a : T(a)::T promote_rule(a::Type{Memory{T}},...
@@ -227,7 +227,7 @@ Memory{T}(x::AbstractArray{S,1}) where {T,S} = copyto_axcheck!(Memory{T}(undef, function _iterate_array(A::Union{Memory, Array}, i::Int) @inline - (i - 1)%UInt < length(A)%UInt ? (A[i], i + 1) : nothing + _checkbounds_array(Bool, A, i) ? (A[i], i + 1) : nothing
base/genericmemory.jl
26
Julia
0.786
question
195
51
51
false
Unify `_checkbounds_array` into `checkbounds` and use it in more places
58,785
JuliaLang/julia
35,573
Julia
giordano
giordano
Review this pull request change. Language: Julia File: base/genericmemory.jl PR Title: Unify `_checkbounds_array` into `checkbounds` and use it in more places BEFORE CODE: t = @_gc_preserve_begin a p = unsafe_convert(Ptr{Cvoid}, a) T = eltype(a) memset(p, x isa T ? x : convert(T, x), length(a) % UIn...
Should this be ```suggestion _checkbounds_array(Bool, A, i) ? (@inbounds A[i], i + 1) : nothing ``` like the `iterate(s::CodeUnits, i=1)` method (which would then be basically identical)?
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::Union{AbstractString,AbstractChar}, r::Integer) = repeat(s, r) # reverse-order iteration for strings and indices thereof iterate(r::Iterators.Reverse{<:AbstractString}, i=lastindex(r.itr)) = i < firstindex(r.itr) ? nothing : (r.itr[i], prevind(r.itr, i)) iterate(r::Iterators.Reverse{<:EachStringIndex}, i=lastin...
Ah, I guess we would need to extend the signature of `_checkbounds_array` to accept `CodeUnits`, too.
(^)(s::Union{AbstractString,AbstractChar}, r::Integer) = repeat(s, r) # reverse-order iteration for strings and indices thereof iterate(r::Iterators.Reverse{<:AbstractString}, i=lastindex(r.itr)) = i < firstindex(r.itr) ? nothing : (r.itr[i], prevind(r.itr, i)) iterate(r::Iterators.Reverse{<:EachStringIndex}, i=lastin...
@@ -797,7 +797,7 @@ size(s::CodeUnits) = (length(s),) elsize(s::Type{<:CodeUnits{T}}) where {T} = sizeof(T) @propagate_inbounds getindex(s::CodeUnits, i::Int) = codeunit(s.s, i) IndexStyle(::Type{<:CodeUnits}) = IndexLinear() -@inline iterate(s::CodeUnits, i=1) = (i % UInt) - 1 < length(s) ? (@inbounds s[i], i + 1) ...
base/strings/basic.jl
26
Julia
0.5
suggestion
101
51
51
false
Unify `_checkbounds_array` into `checkbounds` and use it in more places
58,785
JuliaLang/julia
35,573
Julia
giordano
giordano
Review this pull request change. Language: Julia File: base/strings/basic.jl PR Title: Unify `_checkbounds_array` into `checkbounds` and use it in more places BEFORE CODE: (^)(s::Union{AbstractString,AbstractChar}, r::Integer) = repeat(s, r) # reverse-order iteration for strings and indices thereof iterate(r::Iter...
Ah, I guess we would need to extend the signature of `_checkbounds_array` to accept `CodeUnits`, 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.
(rows, cols) = axes(mat) (length(rows) == length(cols)) || throw(DimensionMismatch("multiplicative identity defined only for square matrices")) zer = zero(unit)::T require_one_based_indexing(mat) I = similar(mat, T) fill!(I, zer) for i ∈ rows I[i, i] = unit end I end o...
I'm not entirely sure about adding this `@inline`, but it was used in `Array` and `Memory` methods already.
(length(rows) == length(cols)) || throw(DimensionMismatch("multiplicative identity defined only for square matrices")) zer = zero(unit)::T require_one_based_indexing(mat) I = similar(mat, T) fill!(I, zer) for i ∈ rows I[i, i] = unit end I end one(x::AbstractMatrix{T}) wher...
@@ -1237,15 +1238,15 @@ oneunit(x::AbstractMatrix{T}) where {T} = _one(oneunit(T), x) iterate_starting_state(A) = iterate_starting_state(A, IndexStyle(A)) iterate_starting_state(A, ::IndexLinear) = firstindex(A) iterate_starting_state(A, ::IndexStyle) = (eachindex(A),) -iterate(A::AbstractArray, state = iterate_star...
base/abstractarray.jl
26
Julia
0.714
suggestion
107
51
51
false
Unify `_checkbounds_array` into `checkbounds` and use it in more places
58,785
JuliaLang/julia
35,573
Julia
giordano
giordano
Review this pull request change. Language: Julia File: base/abstractarray.jl PR Title: Unify `_checkbounds_array` into `checkbounds` and use it in more places BEFORE CODE: (rows, cols) = axes(mat) (length(rows) == length(cols)) || throw(DimensionMismatch("multiplicative identity defined only for squar...
I'm not entirely sure about adding this `@inline`, but it was used in `Array` and `Memory` methods already.
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.
I[i, i] = unit end I end one(x::AbstractMatrix{T}) where {T} = _one(one(T), x) oneunit(x::AbstractMatrix{T}) where {T} = _one(oneunit(T), x) ## iteration support for arrays by iterating over `eachindex` in the array ## # Allows fast iteration by default for both IndexLinear and IndexCartesian arrays ...
Does removing the `@inbounds` impact performance here? I had added it originally because iterating over a view of an `Array` with a non-unit stride was slow without it
end I end one(x::AbstractMatrix{T}) where {T} = _one(one(T), x) oneunit(x::AbstractMatrix{T}) where {T} = _one(oneunit(T), x) ## iteration support for arrays by iterating over `eachindex` in the array ## # Allows fast iteration by default for both IndexLinear and IndexCartesian arrays # While the definitions...
@@ -1237,15 +1238,15 @@ oneunit(x::AbstractMatrix{T}) where {T} = _one(oneunit(T), x) iterate_starting_state(A) = iterate_starting_state(A, IndexStyle(A)) iterate_starting_state(A, ::IndexLinear) = firstindex(A) iterate_starting_state(A, ::IndexStyle) = (eachindex(A),) -iterate(A::AbstractArray, state = iterate_star...
base/abstractarray.jl
26
Julia
0.714
performance
167
51
51
false
Unify `_checkbounds_array` into `checkbounds` and use it in more places
58,785
JuliaLang/julia
35,573
Julia
jishnub
giordano
Review this pull request change. Language: Julia File: base/abstractarray.jl PR Title: Unify `_checkbounds_array` into `checkbounds` and use it in more places BEFORE CODE: I[i, i] = unit end I end one(x::AbstractMatrix{T}) where {T} = _one(one(T), x) oneunit(x::AbstractMatrix{T}) where {T} = _one(o...
Does removing the `@inbounds` impact performance here? I had added it originally because iterating over a view of an `Array` with a non-unit stride was slow without 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.
checkbounds_indices(::Type{Bool}, inds::Tuple, ::Tuple{}) = (@inline; all(x->length(x)==1, inds)) # check along a single dimension """ checkindex(Bool, inds::AbstractUnitRange, index) Return `true` if the given `index` is within the bounds of `inds`. Custom types that would like to behave as indices for all array...
I fear this whole endeavor is a bit of a wild goose chase, driven by my own misunderstanding of `_checkbounds_array`. I think its use of intrinsics is either unnecessary or driven entirely by bootstrap orderings. Because these two definitions generate exactly the same LLVM for `Int`. Way better to use the generic th...
# check along a single dimension """ checkindex(Bool, inds::AbstractUnitRange, index) Return `true` if the given `index` is within the bounds of `inds`. Custom types that would like to behave as indices for all arrays can extend this method in order to provide a specialized bounds checking implementation. See al...
@@ -749,7 +750,7 @@ false checkindex(::Type{Bool}, inds, i) = throw(ArgumentError(LazyString("unable to check bounds for indices of type ", typeof(i)))) checkindex(::Type{Bool}, inds::AbstractUnitRange, i::Real) = (first(inds) <= i) & (i <= last(inds)) checkindex(::Type{Bool}, inds::IdentityUnitRange, i::Real) = che...
base/abstractarray.jl
26
Julia
0.786
suggestion
427
51
51
false
Unify `_checkbounds_array` into `checkbounds` and use it in more places
58,785
JuliaLang/julia
35,573
Julia
mbauman
giordano
Review this pull request change. Language: Julia File: base/abstractarray.jl PR Title: Unify `_checkbounds_array` into `checkbounds` and use it in more places BEFORE CODE: checkbounds_indices(::Type{Bool}, inds::Tuple, ::Tuple{}) = (@inline; all(x->length(x)==1, inds)) # check along a single dimension """ chec...
I fear this whole endeavor is a bit of a wild goose chase, driven by my own misunderstanding of `_checkbounds_array`. I think its use of intrinsics is either unnecessary or driven entirely by bootstrap orderings. Because these two definitions generate exactly the same LLVM for `Int`. Way better to use the generic th...
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 _OS_WINDOWS_ err = GetLastError(); break; // LoadLibrary already tested the rest #else // bail out and show the error if file actually exists if (jl_stat(path, (char*)&stbuf) == 0) break; #endif } notfound: if (throw_err) { #ifdef _OS_WINDOWS_ char rea...
It could be nice from a readability perspective to not have the argument represent a negation, as the double negative in `!no_deps` is (subjectively) less intuitive. That would also make it consistent with the `throw_err` argument, which isn't e.g. `dont_throw_err`. Anyway, just my drive-by $0.02, now back into the sha...
ios_putc(0, &path); handle = jl_dlopen(path.buf, flags); if (handle && !(flags & JL_RTLD_NOLOAD)) jl_timing_puts(JL_TIMING_DEFAULT_BLOCK, jl_pathname_for_handle(handle)); if (handle) goto success; #ifdef _OS_WINDOWS_ err = GetLastError(); break; //...
@@ -403,7 +404,7 @@ JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags, return handle; } -JL_DLLEXPORT int jl_dlsym(void *handle, const char *symbol, void ** value, int throw_err) JL_NOTSAFEPOINT +JL_DLLEXPORT int jl_dlsym(void *handle, const char *symbol, void ** value, int throw_er...
src/dlload.c
26
C
0.643
suggestion
332
51
51
false
jl_dlfind: do not find symbols in library dependencies
58,815
JuliaLang/julia
35,573
Julia
ararslan
xal-0
Review this pull request change. Language: C File: src/dlload.c PR Title: jl_dlfind: do not find symbols in library dependencies BEFORE CODE: #ifdef _OS_WINDOWS_ err = GetLastError(); break; // LoadLibrary already tested the rest #else // bail out and show the error if file actually exists ...
It could be nice from a readability perspective to not have the argument represent a negation, as the double negative in `!no_deps` is (subjectively) less intuitive. That would also make it consistent with the `throw_err` argument, which isn't e.g. `dont_throw_err`. Anyway, just my drive-by $0.02, now back into the sha...
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 -1; } return dlclose(handle); #endif } void *jl_find_dynamic_library_by_addr(void *symbol, int throw_err, int close) JL_NOTSAFEPOINT { void *handle; #ifdef _OS_WINDOWS_ if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, ...
```suggestion dlerror(); handle = dlopen(info.dli_fname, RTLD_NOW | RTLD_NOLOAD | RTLD_LOCAL); ```
return -1; } return dlclose(handle); #endif } void *jl_find_dynamic_library_by_addr(void *symbol, int throw_err, int close) JL_NOTSAFEPOINT { void *handle; #ifdef _OS_WINDOWS_ if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, ...
@@ -256,13 +257,19 @@ void *jl_find_dynamic_library_by_addr(void *symbol, int throw_err) { return NULL; } handle = dlopen(info.dli_fname, RTLD_NOW | RTLD_NOLOAD | RTLD_LOCAL);
src/dlload.c
26
C
0.857
suggestion
109
51
51
false
jl_dlfind: do not find symbols in library dependencies
58,815
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/dlload.c PR Title: jl_dlfind: do not find symbols in library dependencies BEFORE CODE: return -1; } return dlclose(handle); #endif } void *jl_find_dynamic_library_by_addr(void *symbol, int throw_err, int close) JL_NOTSAFEPOINT { void *handl...
```suggestion dlerror(); handle = dlopen(info.dli_fname, RTLD_NOW | RTLD_NOLOAD | RTLD_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.
// we can't use a normal safepoint because we don't have signal handlers yet. jl_atomic_fetch_add(&jl_gc_disable_counter, 1); // pass NULL as a special token to indicate we are running on an unmanaged task jl_safepoint_wait_gc(NULL); // this check is coupled with the one in `jl_safepoint_wait_gc`, w...
```suggestion void *handle = jl_find_dynamic_library_by_addr(retaddr, 0, 0); ```
// we can't use a normal safepoint because we don't have signal handlers yet. jl_atomic_fetch_add(&jl_gc_disable_counter, 1); // pass NULL as a special token to indicate we are running on an unmanaged task jl_safepoint_wait_gc(NULL); // this check is coupled with the one in `jl_safepoint_wait_gc`, w...
@@ -461,7 +461,7 @@ JL_DLLEXPORT jl_gcframe_t **jl_autoinit_and_adopt_thread(void) { if (!jl_is_initialized()) { void *retaddr = __builtin_extract_return_addr(__builtin_return_address(0)); - void *handle = jl_find_dynamic_library_by_addr(retaddr, 0); + void *handle = jl_find_dynamic_library...
src/threading.c
26
C
0.714
suggestion
90
51
51
false
jl_dlfind: do not find symbols in library dependencies
58,815
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/threading.c PR Title: jl_dlfind: do not find symbols in library dependencies BEFORE CODE: // we can't use a normal safepoint because we don't have signal handlers yet. jl_atomic_fetch_add(&jl_gc_disable_counter, 1); // pass NULL as a special token t...
```suggestion void *handle = jl_find_dynamic_library_by_addr(retaddr, 0, 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.
} #endif if (handle != NULL && close) dlclose(handle); // Undo ref count increment from `dlopen` #endif return handle; } JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags, int throw_err) { ios_t path, relocated; int i; #ifdef _OS_WINDOWS_ int err; #endif ...
```suggestion return jl_libjulia_internal_handle; ``` (remove close parameter)
handle = dlopen("", RTLD_NOW | RTLD_NOLOAD | RTLD_LOCAL); } #endif if (handle != NULL && close) dlclose(handle); // Undo ref count increment from `dlopen` #endif return handle; } JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags, int throw_err) { ios_t path,...
@@ -285,7 +292,7 @@ JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags, // modname == NULL is a sentinel value requesting the handle of libjulia-internal if (modname == NULL) - return jl_find_dynamic_library_by_addr(&jl_load_dynamic_library, throw_err); + return jl_...
src/dlload.c
26
C
0.786
suggestion
89
51
51
false
jl_dlfind: do not find symbols in library dependencies
58,815
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/dlload.c PR Title: jl_dlfind: do not find symbols in library dependencies BEFORE CODE: } #endif if (handle != NULL && close) dlclose(handle); // Undo ref count increment from `dlopen` #endif return handle; } JL_DLLEXPORT void *jl_load_dynam...
```suggestion return jl_libjulia_internal_handle; ``` (remove close parameter)
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.
*value = dlsym(handle, symbol); #endif /* Next, check for errors. On Windows, a NULL pointer means the symbol was * not found. On everything else, we can have NULL symbols, so we check for * non-NULL returns from dlerror(). Since POSIX doesn't require `dlerror` * to be implemented safely, FreeBS...
I'd recommend just tagging the pointer with `| 1` before `dlsym` instead of using jl_find_dynamic_library_by_addr, since handle comparison is potentially annoying (you have to mask with &-4 to remove mode bits) https://github.com/apple-oss-distributions/dyld/blob/9307719dd8dc9b385daa412b03cfceb897b2b398/dyld/DyldAPI...
/* When !search_deps and the handle isn't special, force RTLD_FIRST. */ if (!search_deps && handle != RTLD_NEXT && handle != RTLD_DEFAULT && handle != RTLD_SELF && handle != RTLD_MAIN_ONLY) handle = (void *)((uintptr_t)handle | 1); *value = dlsym(handle, symbol); #else *value = dlsym(han...
@@ -437,14 +452,35 @@ JL_DLLEXPORT int jl_dlsym(void *handle, const char *symbol, void ** value, int t } #endif - if (!symbol_found && throw_err) { + int rtld_first_handle = 0; +#ifdef _OS_DARWIN_ + rtld_first_handle = (uintptr_t)handle & 1; +#endif
src/dlload.c
26
C
0.786
suggestion
448
51
51
false
jl_dlfind: do not find symbols in library dependencies
58,815
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: C File: src/dlload.c PR Title: jl_dlfind: do not find symbols in library dependencies BEFORE CODE: *value = dlsym(handle, symbol); #endif /* Next, check for errors. On Windows, a NULL pointer means the symbol was * not found. On everything else, we can have N...
I'd recommend just tagging the pointer with `| 1` before `dlsym` instead of using jl_find_dynamic_library_by_addr, since handle comparison is potentially annoying (you have to mask with &-4 to remove mode bits) https://github.com/apple-oss-distributions/dyld/blob/9307719dd8dc9b385daa412b03cfceb897b2b398/dyld/DyldAPI...
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 Integer(a) end length(r::OneTo) = Integer(r.stop - zero(r.stop)) length(r::StepRangeLen) = r.len length(r::LinRange) = r.len let bigints = Union{Int, UInt, Int64, UInt64, Int128, UInt128}, smallints = (Int === Int64 ? Union{Int8, UInt8, Int16, UInt16, Int32, UInt32} : ...
```suggestion return a + oneunit(a) ``` Oops, this was leftover from me trying to remove the isempty branch, but that doesn't work.
end return Integer(a) end length(r::OneTo) = Integer(r.stop - zero(r.stop)) length(r::StepRangeLen) = r.len length(r::LinRange) = r.len let bigints = Union{Int, UInt, Int64, UInt64, Int128, UInt128}, smallints = (Int === Int64 ? Union{Int8, UInt8, Int16, UInt16, Int32, UInt32} : ...
@@ -805,17 +805,10 @@ let bigints = Union{Int, UInt, Int64, UInt64, Int128, UInt128}, s = step(r) diff = last(r) - first(r) isempty(r) && return zero(diff) - # if |s| > 1, diff might have overflowed, but unsigned(diff)÷s should - # therefore still be valid (if the result is repr...
base/range.jl
26
Julia
0.786
suggestion
144
51
51
false
optimize `length(::OrdinalRange)` for large bit-ints
58,864
JuliaLang/julia
35,573
Julia
mbauman
mbauman
Review this pull request change. Language: Julia File: base/range.jl PR Title: optimize `length(::OrdinalRange)` for large bit-ints BEFORE CODE: end return Integer(a) end length(r::OneTo) = Integer(r.stop - zero(r.stop)) length(r::StepRangeLen) = r.len length(r::LinRange) = r.len let bigints = Union{Int, ...
```suggestion return a + oneunit(a) ``` Oops, this was leftover from me trying to remove the isempty branch, but that doesn't work.
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 Integer(a) end length(r::OneTo) = Integer(r.stop - zero(r.stop)) length(r::StepRangeLen) = r.len length(r::LinRange) = r.len let bigints = Union{Int, UInt, Int64, UInt64, Int128, UInt128}, smallints = (Int === Int64 ? Union{Int8, UInt8, Int16, UInt16, Int32, UInt32} : ...
Just notice this comment, `unsigned` might not be defined for `s`, e.g. `StepRange{Int,BigInt}(1,1,1)` ```julia a = div(unsigned(flipsign(diff, s)), s) % typeof(diff) return flipsign(a, s) + oneunit(a) ``` seems better?
end return Integer(a) end length(r::OneTo) = Integer(r.stop - zero(r.stop)) length(r::StepRangeLen) = r.len length(r::LinRange) = r.len let bigints = Union{Int, UInt, Int64, UInt64, Int128, UInt128}, smallints = (Int === Int64 ? Union{Int8, UInt8, Int16, UInt16, Int32, UInt32} : ...
@@ -805,16 +805,9 @@ let bigints = Union{Int, UInt, Int64, UInt64, Int128, UInt128}, s = step(r) diff = last(r) - first(r) isempty(r) && return zero(diff) - # if |s| > 1, diff might have overflowed, but unsigned(diff)÷s should - # therefore still be valid (if the result is repre...
base/range.jl
26
Julia
1
question
240
51
51
false
optimize `length(::OrdinalRange)` for large bit-ints
58,864
JuliaLang/julia
35,573
Julia
N5N3
mbauman
Review this pull request change. Language: Julia File: base/range.jl PR Title: optimize `length(::OrdinalRange)` for large bit-ints BEFORE CODE: end return Integer(a) end length(r::OneTo) = Integer(r.stop - zero(r.stop)) length(r::StepRangeLen) = r.len length(r::LinRange) = r.len let bigints = Union{Int, ...
Just notice this comment, `unsigned` might not be defined for `s`, e.g. `StepRange{Int,BigInt}(1,1,1)` ```julia a = div(unsigned(flipsign(diff, s)), s) % typeof(diff) return flipsign(a, s) + oneunit(a) ``` seems better?
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 refine_partial_type(@nospecialize t) t′ = unwrap_unionall(t) if isa(t′, DataType) && t′.name === _NAMEDTUPLE_NAME && length(t′.parameters) == 2 && (t′.parameters[1] === () || t′.parameters[2] === Tuple{}) # if the first/second parameter of `NamedTuple` is known to be empty, # th...
I think things can break if we hit this case, so possibly we should bail out if this happens. Need some advice on this.
function refine_partial_type(@nospecialize t) t′ = unwrap_unionall(t) if isa(t′, DataType) && t′.name === _NAMEDTUPLE_NAME && length(t′.parameters) == 2 && (t′.parameters[1] === () || t′.parameters[2] === Tuple{}) # if the first/second parameter of `NamedTuple` is known to be empty, # th...
@@ -3485,7 +3485,39 @@ function refine_partial_type(@nospecialize t) return t end +function abstract_eval_nonlinearized_foreigncall_name(interp::AbstractInterpreter, e, sstate::StatementState, sv::AbsIntState) + if isexpr(e, :call) + n = length(e.args) + argtypes = Vector{Any}(undef, n) + ...
Compiler/src/abstractinterpretation.jl
26
Julia
0.429
suggestion
119
51
51
false
fix #57749, model ccall binding access in inference
58,872
JuliaLang/julia
35,573
Julia
JeffBezanson
JeffBezanson
Review this pull request change. Language: Julia File: Compiler/src/abstractinterpretation.jl PR Title: fix #57749, model ccall binding access in inference BEFORE CODE: function refine_partial_type(@nospecialize t) t′ = unwrap_unionall(t) if isa(t′, DataType) && t′.name === _NAMEDTUPLE_NAME && length(t′.par...
I think things can break if we hit this case, so possibly we should bail out if this happens. Need some advice on this.
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 isexpr(e, :call) n = length(e.args) argtypes = Vector{Any}(undef, n) callresult = Future{CallMeta}() i::Int = 1 nextstate::UInt8 = 0x0 local ai, res function evalargs(interp, sv) if nextstate === 0x1 @goto state1 else...
IIRC, this call will occasionally corrupt the InferenceState structure for the current statement, since this is not actually the current statement (there might be some support code in return_type_tfunc for working around it though)
function abstract_eval_nonlinearized_foreigncall_name(interp::AbstractInterpreter, e, sstate::StatementState, sv::AbsIntState) if isexpr(e, :call) n = length(e.args) argtypes = Vector{Any}(undef, n) callresult = Future{CallMeta}() i::Int = 1 nextstate::UInt8 = 0x0 lo...
@@ -3485,7 +3485,57 @@ function refine_partial_type(@nospecialize t) return t end +function abstract_eval_nonlinearized_foreigncall_name(interp::AbstractInterpreter, e, sstate::StatementState, sv::AbsIntState) + if isexpr(e, :call) + n = length(e.args) + argtypes = Vector{Any}(undef, n) + ...
Compiler/src/abstractinterpretation.jl
26
Julia
0.571
suggestion
231
51
51
false
fix #57749, model ccall binding access in inference
58,872
JuliaLang/julia
35,573
Julia
vtjnash
JeffBezanson
Review this pull request change. Language: Julia File: Compiler/src/abstractinterpretation.jl PR Title: fix #57749, model ccall binding access in inference BEFORE CODE: if isexpr(e, :call) n = length(e.args) argtypes = Vector{Any}(undef, n) callresult = Future{CallMeta}() i::Int ...
IIRC, this call will occasionally corrupt the InferenceState structure for the current statement, since this is not actually the current statement (there might be some support code in return_type_tfunc for working around it 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.
sz = 2 * sizeof(Int) else sz = Core.sizeof(obj) end if sz == 0 # 0-field mutable structs are not unique return gc_alignment(0) end return count ? 1 : sz end (::SummarySize)(obj::Symbol) = 0 (::SummarySize)(obj::SummarySize) = 0 function (ss::SummarySize)(obj::String...
I don't know where these magic numbers were pulled from, so I'm not sure if this is 1 object or 2 (or 3?) I'll need to reverse engineer before merging.
# black-list of items that don't have a Core.sizeof sz = 2 * sizeof(Int) else sz = Core.sizeof(obj) end if sz == 0 # 0-field mutable structs are not unique return gc_alignment(0) end return count ? 1 : sz end (::SummarySize)(obj::Symbol) = 0 (::SummarySize)(o...
@@ -121,14 +128,14 @@ end function (ss::SummarySize)(obj::String) key = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), obj) haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) - return Core.sizeof(Int) + Core.sizeof(obj) + return (ss.count ? 1 : (Core.sizeof(Int) + Core.sizeof(obj))) end function (...
base/summarysize.jl
26
Julia
0.357
suggestion
154
51
51
false
Base: Add `count` argument to `Base.summarysize`
58,874
JuliaLang/julia
35,573
Julia
topolarity
topolarity
Review this pull request change. Language: Julia File: base/summarysize.jl PR Title: Base: Add `count` argument to `Base.summarysize` BEFORE CODE: sz = 2 * sizeof(Int) else sz = Core.sizeof(obj) end if sz == 0 # 0-field mutable structs are not unique return gc_alignment(0...
I don't know where these magic numbers were pulled from, so I'm not sure if this is 1 object or 2 (or 3?) I'll need to reverse engineer before merging.
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.
haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) return (ss.count ? 1 : (Core.sizeof(Int) + Core.sizeof(obj))) end function (ss::SummarySize)(obj::DataType) key = pointer_from_objref(obj) haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) size::Int = (ss.count ? 1 : (7 * Core.sizeof...
@oscardssmith Is the header here separate from the `obj` itself that we count below? I don't quite grok the accounting
key = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), obj) haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) return (ss.count ? 1 : (Core.sizeof(Int) + Core.sizeof(obj))) end function (ss::SummarySize)(obj::DataType) key = pointer_from_objref(obj) haskey(ss.seen, key) ? (return 0) : (ss.seen[key] ...
@@ -139,17 +146,17 @@ end function (ss::SummarySize)(obj::Core.TypeName) key = pointer_from_objref(obj) haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) - return Core.sizeof(obj) + return (ss.count ? 1 : Core.sizeof(obj)) end function (ss::SummarySize)(obj::GenericMemory) haskey(ss.se...
base/summarysize.jl
26
Julia
0.5
suggestion
118
51
51
false
Base: Add `count` argument to `Base.summarysize`
58,874
JuliaLang/julia
35,573
Julia
topolarity
topolarity
Review this pull request change. Language: Julia File: base/summarysize.jl PR Title: Base: Add `count` argument to `Base.summarysize` BEFORE CODE: haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) return (ss.count ? 1 : (Core.sizeof(Int) + Core.sizeof(obj))) end function (ss::SummarySize)(obj::Data...
@oscardssmith Is the header here separate from the `obj` itself that we count below? I don't quite grok the accounting
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.
haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) size::Int = (ss.count ? 1 : (7 * Core.sizeof(Int) + 6 * Core.sizeof(Int32))) size += (ss.count ? 1 : (4 * nfields(obj) + ifelse(Sys.WORD_SIZE == 64, 4, 0))) size += ss(obj.parameters)::Int if isdefined(obj, :types) size += ss(obj.type...
```suggestion elseif pointer_from_objref(obj) + 16 != datakey ```
haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) size::Int = ss.count ? 1 : sizeof(DataType) size += ss(obj.parameters)::Int if isdefined(obj, :types) size += ss(obj.types)::Int end return size end function (ss::SummarySize)(obj::Core.TypeName) key = pointer_from_objref(obj...
@@ -139,17 +147,21 @@ end function (ss::SummarySize)(obj::Core.TypeName) key = pointer_from_objref(obj) haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) - return Core.sizeof(obj) + return (ss.count ? 1 : Core.sizeof(obj)) end function (ss::SummarySize)(obj::GenericMemory) haskey(ss.se...
base/summarysize.jl
26
Julia
0.571
suggestion
75
51
51
false
Base: Add `count` argument to `Base.summarysize`
58,874
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: Julia File: base/summarysize.jl PR Title: Base: Add `count` argument to `Base.summarysize` BEFORE CODE: haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true) size::Int = (ss.count ? 1 : (7 * Core.sizeof(Int) + 6 * Core.sizeof(Int32))) size += (ss.count ? 1 ...
```suggestion elseif pointer_from_objref(obj) + 16 != datakey ```
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.
value = unwrap_unionall(value) end if isa(value, DataType) && parentmodule(value) === obj && nameof(value) === binding # charge a TypeName to its module (but not to the type) size += ss(value.name)::Int end ...
```suggestion (ss::SummarySize)(obj::BigInt) = _summarysize(ss, obj, ss.count) + (ss.count ? 1 : obj.alloc * sizeof(Base.GMP.Limb)) ```
end if isa(value, DataType) && parentmodule(value) === obj && nameof(value) === binding # charge a TypeName to its module (but not to the type) size += ss(value.name)::Int end end end end return size end ...
@@ -204,4 +216,4 @@ function (ss::SummarySize)(obj::Task) return size end -(ss::SummarySize)(obj::BigInt) = _summarysize(ss, obj) + obj.alloc*sizeof(Base.GMP.Limb) +(ss::SummarySize)(obj::BigInt) = _summarysize(ss, obj, ss.count) + obj.alloc * (ss.count ? 1 : sizeof(Base.GMP.Limb))
base/summarysize.jl
26
Julia
0.714
suggestion
137
27
26
false
Base: Add `count` argument to `Base.summarysize`
58,874
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: Julia File: base/summarysize.jl PR Title: Base: Add `count` argument to `Base.summarysize` BEFORE CODE: value = unwrap_unionall(value) end if isa(value, DataType) && parentmodule(value) === obj && nameof(value) === bindin...
```suggestion (ss::SummarySize)(obj::BigInt) = _summarysize(ss, obj, ss.count) + (ss.count ? 1 : obj.alloc * sizeof(Base.GMP.Limb)) ```
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.
value = unwrap_unionall(value) end if isa(value, DataType) && parentmodule(value) === obj && nameof(value) === binding # charge a TypeName to its module (but not to the type) size += ss(value.name)::Int end ...
```suggestion (ss::SummarySize)(obj::BigInt) = _summarysize(ss, obj, ss.count) + (ss.count ? 1 : obj.alloc * sizeof(GMP.Limb)) ```
end if isa(value, DataType) && parentmodule(value) === obj && nameof(value) === binding # charge a TypeName to its module (but not to the type) size += ss(value.name)::Int end end end end return size end ...
@@ -204,4 +216,4 @@ function (ss::SummarySize)(obj::Task) return size end -(ss::SummarySize)(obj::BigInt) = _summarysize(ss, obj) + obj.alloc*sizeof(Base.GMP.Limb) +(ss::SummarySize)(obj::BigInt) = _summarysize(ss, obj, ss.count) + obj.alloc * (ss.count ? 1 : sizeof(GMP.Limb))
base/summarysize.jl
26
Julia
0.714
suggestion
132
27
26
false
Base: Add `count` argument to `Base.summarysize`
58,874
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: Julia File: base/summarysize.jl PR Title: Base: Add `count` argument to `Base.summarysize` BEFORE CODE: value = unwrap_unionall(value) end if isa(value, DataType) && parentmodule(value) === obj && nameof(value) === bindin...
```suggestion (ss::SummarySize)(obj::BigInt) = _summarysize(ss, obj, ss.count) + (ss.count ? 1 : obj.alloc * sizeof(GMP.Limb)) ```
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.
wrapper(t::Tuple) = map(wrapper, t) fcviews(t::Tuple) = map(fcviews, t) offset(t::Tuple) = map(offset, t) test_many_wrappers(testf, A, wrappers) = foreach(w -> testf(w(A)), wrappers) test_many_wrappers(testf, A) = test_many_wrappers(testf, A, (identity, tslow, wrapper, fcviews, offset)) A = Int64[1, 2, 3, 4] Ars = In...
just folding this into the same at L163
tslow(t::Tuple) = map(tslow, t) wrapper(t::Tuple) = map(wrapper, t) fcviews(t::Tuple) = map(fcviews, t) offset_nominal(t::Tuple) = map(offset_nominal, t) offset_maybe(t::Tuple) = map(offset_maybe, t) test_many_wrappers(testf, A, wrappers) = foreach(w -> testf(w(A)), wrappers) test_many_wrappers(testf, A) = test_many_w...
@@ -37,10 +39,6 @@ test_many_wrappers(B, (identity, tslow)) do _B @test @inferred(size(reinterpret(reshape, Int128, _B))) == (3,) end -test_many_wrappers(C) do Cr
test/reinterpretarray.jl
26
Julia
0.071
suggestion
39
51
51
false
make ReinterpretArray more Offset-safe
58,898
JuliaLang/julia
35,573
Julia
adienes
adienes
Review this pull request change. Language: Julia File: test/reinterpretarray.jl PR Title: make ReinterpretArray more Offset-safe BEFORE CODE: wrapper(t::Tuple) = map(wrapper, t) fcviews(t::Tuple) = map(fcviews, t) offset(t::Tuple) = map(offset, t) test_many_wrappers(testf, A, wrappers) = foreach(w -> testf(w(A)), ...
just folding this into the same at L163
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.
A macro to execute an expression and produce a report of any time spent importing packages and their dependencies. Any compilation time will be reported as a percentage, and how much of which was recompilation, if any. One line is printed per package or package extension. The duration shown is the time to import that ...
Looks like another set of functions to add functor support to! P.S. Do we want to enable this for `@which`, `@less`, etc. above?
return Expr(:call, :error, "@$fcn expects only one non-keyword argument") end end return gen_call_with_extracted_types(__module__, fcn, arg, kws; is_source_reflection, supports_binding_reflection, use_signature_tuple) end for fname in [:which, :less, :edit, :functionloc] @eval begin ...
@@ -398,13 +401,13 @@ end for fname in [:code_warntype, :code_llvm, :code_native, :infer_return_type, :infer_effects, :infer_exception_type] @eval macro ($fname)(ex0...) - gen_call_with_extracted_types_and_kwargs(__module__, $(QuoteNode(fname)), ex0; is_source_reflection = false) + ge...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
0.5
question
131
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
topolarity
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: A macro to execute an expression and produce a report of any time spent importing packages and their dependencies. Any c...
Looks like another set of functions to add functor support to! P.S. Do we want to enable this for `@which`, `@less`, etc. above?
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 isexpr(ex, :...) newarg = Expr(:..., newarg) push!(args, only(ex.args)) elseif isexpr(ex, :kw) newarg = Expr(:kw, ex.args[1], newarg) push!(args, ex.args[end]) else push!(args, ex) end return newarg, i+1 end function extract_farg(@nospecialize arg) !is...
```suggestion To remove this restriction, the reflection macro may set `use_signature_tuple = true` if the reflection function accepts "functor" arguments, specified as a `Tuple{...}` type.")) ```
elseif isexpr(ex, :.) (start, branches) = (1, ex.args[2].args) else (start, branches) = (2, ex.args) end for j in start:length(branches)::Int branch, i = recursive_dotcalls!(branches[j], args, i) branches[j] = branch end ret...
@@ -105,7 +106,8 @@ function construct_callable(@nospecialize(func::Type)) # Don't support type annotations otherwise, we don't want to give wrong answers # for callables such as `(::Returns{Int})(args...)` where using `Returns{Int}` # would give us code for the constructor, not for the callable object. ...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
1
refactor
223
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
topolarity
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: if isexpr(ex, :...) newarg = Expr(:..., newarg) push!(args, only(ex.args)) elseif isexpr(ex, :kw...
```suggestion To remove this restriction, the reflection macro may set `use_signature_tuple = true` if the reflection function accepts "functor" arguments, specified as a `Tuple{...}` type.")) ```
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.
args = [#=__source__::=#LineNumberNode, #=__module__::=#Module, Core.Typeof.(ex0.args[3:end])...] return gen_call(fcn, Any[ex0.args[1], Ref.(args)...], where_params, kws; use_signature_tuple) end ex = Meta.lower(__module__, ex0) if !isa(ex, Expr) return Expr(:call, :error, "expressi...
This should probably document how `use_signature_tuple` affects the generated code / called function, but the edit to the error above will also help folks understand that this places interface requirements on `fcn`
then carry on using this function. For example, for the input expression `a .+ b`, we emit the anonymous function `(a, b) -> a .+ b` then call `fcn` just as if the user had issued a call to this anonymous function. That should be the desired behavior for most macros that want to map an expression to the corresponding g...
@@ -190,12 +192,30 @@ function merge_namedtuple_types(nt::Type{<:NamedTuple}, nts::Type{<:NamedTuple}. end end end - NamedTuple{Tuple(names), Tuple{types...}} + return NamedTuple{Tuple(names), Tuple{types...}} +end + +function gen_call(fcn, args, where_params, kws; use_signature_tuple::...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
0.786
suggestion
214
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
topolarity
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: args = [#=__source__::=#LineNumberNode, #=__module__::=#Module, Core.Typeof.(ex0.args[3:end])...] return...
This should probably document how `use_signature_tuple` affects the generated code / called function, but the edit to the error above will also help folks understand that this places interface requirements on `fcn`
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.
using Base: insert!, replace_ref_begin_end_!, infer_return_type, infer_exception_type, infer_effects, code_ircode, isexpr # defined in Base so it's possible to time all imports, including InteractiveUtils and its deps # via. `Base.@time_imports` etc. import Base: @time_imports, @trace_compile, @trace_dispatch typ...
Why are you vendoring a buggy copy of Meta.reescape now?
using Base: insert!, replace_ref_begin_end!, infer_return_type, infer_exception_type, infer_effects, code_ircode, isexpr # defined in Base so it's possible to time all imports, including InteractiveUtils and its deps # via. `Base.@time_imports` etc. import Base: @time_imports, @trace_compile, @trace_dispatch type...
@@ -21,25 +22,33 @@ function rewrap_where(ex::Expr, where_params::Union{Nothing, Vector{Any}}) Expr(:where, ex, esc.(where_params)...) end -function get_typeof(@nospecialize ex) - # Always unescape to get the core expression, then reescape and esc - original_ex = ex - ex = Meta.unescape(ex) +function r...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
0.357
bug
56
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
vtjnash
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: using Base: insert!, replace_ref_begin_end_!, infer_return_type, infer_exception_type, infer_effects, code_ircode, i...
Why are you vendoring a buggy copy of Meta.reescape now?
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 ex in exs if isexpr(ex, :kw) push!(kwargs, ex) elseif isexpr(ex, :parameters) for kw in ex.args push!(kwargs, kw) end else push!(args, ex) end end args, kwargs end function are_kwargs_valid(kwargs::Vector{An...
These are invalid kwargs, unless unescaping them contains a valid kwarg
function separate_kwargs(exs::Vector{Any}) args = [] kwargs = [] for ex in exs if isexpr(ex, :kw) push!(kwargs, ex) elseif isexpr(ex, :parameters) for kw in ex.args push!(kwargs, kw) end else push!(args, ex) end...
@@ -147,6 +151,8 @@ function are_kwargs_valid(kwargs::Vector{Any}) isexpr(kwarg, :kw, 2) && isa(kwarg.args[1], Symbol) && continue isexpr(kwarg, :(::), 2) && continue isa(kwarg, Symbol) && continue + isexpr(kwarg, :escape) && continue + isexpr(kwarg, :var"hygienic-scope") && con...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
0.214
suggestion
71
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
vtjnash
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: for ex in exs if isexpr(ex, :kw) push!(kwargs, ex) elseif isexpr(ex, :parameters) ...
These are invalid kwargs, unless unescaping them contains a valid kwarg
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.
elseif isexpr(ex0, :.) && is_source_reflection # If `ex0` has the form A.B (or some chain A.B.C.D) and `fcn` reflects into the source, # `A` (or `A.B.C`) may be a module, in which case `fcn` is probably more interested in # the binding rather than the `getproperty` call. ...
This seems like a bad idea to find some random variable by name and then apply random mutation to it (mainly it seems it would result in incorrect code being executed if someone has a statement with multiple `begin` or `end` like `a[end][end]`)
new = replace_ref_begin_end!(__module__, ex) modified = ex.args .≠ args if any(modified) && (isexpr(arr, :(::), 1) || isexpr(arr, :(::), 2) || isexpr(arr, :..., 1)) return Expr(:call, :error, "`begin` or `end` cannot be used with a type-annotated left-hand side argument for an indexing syntax") ...
@@ -206,15 +211,167 @@ function merge_namedtuple_types(nt::Type{<:NamedTuple}, nts::Type{<:NamedTuple}. end end end - NamedTuple{Tuple(names), Tuple{types...}} + return NamedTuple{Tuple(names), Tuple{types...}} +end + +function gen_call(fcn, args, where_params, kws; use_signature_tuple:...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
0.571
bug
244
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
vtjnash
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: elseif isexpr(ex0, :.) && is_source_reflection # If `ex0` has the form A.B (or some chain A.B.C.D) a...
This seems like a bad idea to find some random variable by name and then apply random mutation to it (mainly it seems it would result in incorrect code being executed if someone has a statement with multiple `begin` or `end` like `a[end][end]`)
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 if ex.head === :thunk || exret.head === :none exret = Expr(:call, :error, "expression is not a function call, \ or is too complex for @$fcn to analyze; \ break it down to simpler parts if possible. \ ...
Style (and performance) nit: we tend to use `...` instead of `;` for explicit concat, and an explicit `Any` type: ``` call_reflection = gen_call(fcn, Any[getproperty, ex0.args...], where_params, kws; use_signature_tuple) ``` This seems to have been detected as a issue elsewhere already, but then i...
dotfuncname = gensym("dotfunction") call = gen_call(fcn, Any[dotfuncname, args...], where_params, kws; use_signature_tuple) return quote let $(esc(:($dotfuncname($(xargs...)) = $ex))) $call end end elseif isexpr(...
@@ -262,10 +420,10 @@ function gen_call_with_extracted_types(__module__, fcn, ex0, kws = Expr[]; is_so end fully_qualified_symbol &= ex1 isa Symbol if fully_qualified_symbol || isexpr(ex1, :(::), 1) - call_reflection = :($(fcn)(Base.getproperty, $(typesof_expr(ex0.a...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
1
bug
570
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
vtjnash
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: end if ex.head === :thunk || exret.head === :none exret = Expr(:call, :error, "expression is not a funct...
Style (and performance) nit: we tend to use `...` instead of `;` for explicit concat, and an explicit `Any` type: ``` call_reflection = gen_call(fcn, Any[getproperty, ex0.args...], where_params, kws; use_signature_tuple) ``` This seems to have been detected as a issue elsewhere already, but then i...
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 for fname in [:which, :less, :edit, :functionloc] @eval begin macro ($fname)(ex0) gen_call_with_extracted_types(__module__, $(Expr(:quote, fname)), ex0, Expr[]; is_source_reflection = true, supports_binding_...
This seems very sketchy, since `Ref(nt)` is a perfectly fine, and somewhat common, thing to normally encounter in an AST already (after this function called macroexpand). There should not be any unique behavior of calling `typeof` based on the value of a object found in the code.
binding_reflection = :(error("expression is not a function call")) end return quote local arg1 = $(esc(ex0.args[1])) if isa(arg1, Module) $binding_reflection else ...
@@ -292,41 +450,24 @@ function gen_call_with_extracted_types(__module__, fcn, ex0, kws = Expr[]; is_so $(esc(ex0)) # trigger syntax errors if any end nt = generate_merged_namedtuple_type(kwargs) - tt = rewrap_where(:(Tuple{$nt, $(get_typeof.(args)...)}), where_param...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
0.786
suggestion
280
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
vtjnash
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: end for fname in [:which, :less, :edit, :functionloc] @eval begin macro ($fname)(ex0) gen_call_...
This seems very sketchy, since `Ref(nt)` is a perfectly fine, and somewhat common, thing to normally encounter in an AST already (after this function called macroexpand). There should not be any unique behavior of calling `typeof` based on the value of a object found in the code.
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.
rows = Any[ (isa(x,Expr) && x.head === :row ? x.args : Any[x]) for x in args ] lens = map(length, rows) args = Any[Expr(:tuple, lens...); vcat(rows...)] ex0.head === :typed_vcat && pushfirst!(args, ex0.args[1]) return Expr(:call, fcn, hf, t...
Please reapply this change to add PairSymAny, so that this part of the code can be type-stable
to a source location, or `@which` to get the method matching the input). In this case, we don't have a clear semantic source to give (shall it be `broadcasted`, or `materialize`, or something else?), so we return a throwing expression. However, if provenance is not of interest, we define an intermediate function on th...
@@ -342,75 +483,46 @@ function gen_call_with_extracted_types(__module__, fcn, ex0, kws = Expr[]; is_so lens = map(length, rows) args = Any[Expr(:tuple, lens...); vcat(rows...)] ex0.head === :typed_vcat && pushfirst!(args, ex0.args[1]) - return Expr(:call...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
0.429
suggestion
94
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
vtjnash
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: rows = Any[ (isa(x,Expr) && x.head === :row ? x.args : Any[x]) for x in args ] lens = ma...
Please reapply this change to add PairSymAny, so that this part of the code can be type-stable
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.
""" @less Evaluates the arguments to the function or macro call, determines their types, and calls the [`less`](@ref) function on the resulting expression. See also: [`@edit`](@ref), [`@which`](@ref), [`@code_lowered`](@ref). """ :@less """ @edit Evaluates the arguments to the function or macro call, determ...
same comment about `Ref.()` being problematic here (because it shouldn't affect behavior and because is is the wrong way to map to an Any array)
lens = map(length, rows) args = Any[Expr(:tuple, lens...); vcat(rows...)] ex0.head === :typed_vcat && pushfirst!(args, ex0.args[1]) return gen_call(fcn, Any[hf, args...], where_params, kws; use_signature_tuple) else return gen_c...
@@ -342,75 +483,46 @@ function gen_call_with_extracted_types(__module__, fcn, ex0, kws = Expr[]; is_so lens = map(length, rows) args = Any[Expr(:tuple, lens...); vcat(rows...)] ex0.head === :typed_vcat && pushfirst!(args, ex0.args[1]) - return Expr(:call...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
0.571
bug
144
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
vtjnash
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: """ @less Evaluates the arguments to the function or macro call, determines their types, and calls the [`less`](@re...
same comment about `Ref.()` being problematic here (because it shouldn't affect behavior and because is is the wrong way to map to an Any array)
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.
PairSymAny(:(.), Base.getproperty), PairSymAny(:vect, Base.vect), PairSymAny(Symbol("'"), Base.adjoint), PairSymAny(:typed_hcat, Base.typed_hcat), PairSymAny(:string, str...
Did this get deleted by accident? I don't see why you are still calling `Meta.lower` if you unconditionally ignore the result now (and I'm also not entirely certain what this part of the code did before either).
to the type constructor. To remove the ambiguity, `code_typed` must support an implementation that directly accepts a function type. This implementation is assumed to be the method for `fcn(sigt::Type{<:Tuple})`. """ function gen_call_with_extracted_types(__module__, fcn, ex0, kws = Expr[]; is_source_reflection = !is_c...
@@ -342,75 +483,46 @@ function gen_call_with_extracted_types(__module__, fcn, ex0, kws = Expr[]; is_so lens = map(length, rows) args = Any[Expr(:tuple, lens...); vcat(rows...)] ex0.head === :typed_vcat && pushfirst!(args, ex0.args[1]) - return Expr(:call...
stdlib/InteractiveUtils/src/macros.jl
26
Julia
0.571
suggestion
211
51
51
false
InteractiveUtils: Support callable objects as functions in introspection macros
58,905
JuliaLang/julia
35,573
Julia
vtjnash
serenity4
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/macros.jl PR Title: InteractiveUtils: Support callable objects as functions in introspection macros BEFORE CODE: PairSymAny(:(.), Base.getproperty), PairSymAny(:vect, Base.v...
Did this get deleted by accident? I don't see why you are still calling `Meta.lower` if you unconditionally ignore the result now (and I'm also not entirely certain what this part of the code did before either).
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.
$(Expr(:thisfunction)) end inner_func end let cs = CallableStruct2() @test cs()() === cs() @test cs()() !== cs end # Keywords let @eval f2(; n=1) = n <= 1 ? n : n * $(Expr(:thisfunction))(; n=n-1) result = f2(n=5) @test result == ...
```suggestion @test occursin("Cols", result) ```
@testset "Closures and nested functions" begin # Prevents boxed closures function make_closure() fib(n) = n <= 1 ? 1 : (@__FUNCTION__)(n - 1) + (@__FUNCTION__)(n - 2) return fib end Test.@inferred make_closure() closure = make_closure() @test ...
@@ -4351,3 +4351,59 @@ let f = NoSpecClosure.K(1) @test f(2) == 1 @test typeof(f).parameters == Core.svec() end + +@testset "Expr(:thisfunction)" begin + # regular functions can use Expr(:thisfunction) to refer to the function itself + @eval regular_func() = $(Expr(:thisfunction)) + @test regular_fu...
test/syntax.jl
26
Julia
0.571
suggestion
58
29
51
false
Create `@__FUNCTION__` and `Expr(:thisfunction)` as generic function self-reference
58,940
JuliaLang/julia
35,573
Julia
MilesCranmer
MilesCranmer
Review this pull request change. Language: Julia File: test/syntax.jl PR Title: Create `@__FUNCTION__` and `Expr(:thisfunction)` as generic function self-reference BEFORE CODE: $(Expr(:thisfunction)) end inner_func end let cs = CallableStruct2() @test cs()() === cs() ...
```suggestion @test occursin("Cols", result) ```
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 f in Base.project_names if isfile(joinpath(path, f)) return nothing end end # Move up a directory path = dirname(path) end # We never found anything, just return `nothing` return nothing end # We do this to avoid doing the `joinp...
Should we re-use `Base._require_world_age`?
for f in Base.project_names if isfile(joinpath(path, f)) return nothing end end # Move up a directory path = dirname(path) end # We never found anything, just return `nothing` return nothing end # We do this to avoid doing the `joinp...
@@ -542,7 +542,21 @@ function jointail(dir, tail) end end +const _artifact_str_world_age = Ref{UInt}(typemax(UInt))
stdlib/Artifacts/src/Artifacts.jl
26
Julia
0.286
question
43
51
51
false
shield `_artifact_str` function behind a world age barrier
58,957
JuliaLang/julia
35,573
Julia
topolarity
KristofferC
Review this pull request change. Language: Julia File: stdlib/Artifacts/src/Artifacts.jl PR Title: shield `_artifact_str` function behind a world age barrier BEFORE CODE: for f in Base.project_names if isfile(joinpath(path, f)) return nothing end end ...
Should we re-use `Base._require_world_age`?
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.
# Move up a directory path = dirname(path) end # We never found anything, just return `nothing` return nothing end # We do this to avoid doing the `joinpath()` work if we don't have to, and also to # avoid a trailing slash due to `joinpath()`'s habit of including one when the last # argum...
```suggestion return Base.invoke_in_world(world, __artifact_str, __module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, Val(LazyArtifacts))::String ```
# Move up a directory path = dirname(path) end # We never found anything, just return `nothing` return nothing end # We do this to avoid doing the `joinpath()` work if we don't have to, and also to # avoid a trailing slash due to `joinpath()`'s habit of including one when the last # argum...
@@ -543,6 +543,14 @@ function jointail(dir, tail) end function _artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifacts + world = Base._require_world_age[] + if world == typemax(UInt) + world = Base.get_world_counter() + end ...
stdlib/Artifacts/src/Artifacts.jl
26
Julia
0.714
suggestion
178
51
51
false
shield `_artifact_str` function behind a world age barrier
58,957
JuliaLang/julia
35,573
Julia
topolarity
KristofferC
Review this pull request change. Language: Julia File: stdlib/Artifacts/src/Artifacts.jl PR Title: shield `_artifact_str` function behind a world age barrier BEFORE CODE: # Move up a directory path = dirname(path) end # We never found anything, just return `nothing` return nothing end ...
```suggestion return Base.invoke_in_world(world, __artifact_str, __module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, Val(LazyArtifacts))::String ```
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 function __artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifacts pkg = Base.PkgId(__module__) if pkg.uuid !== nothing # Process overrides for this UUID, if we know what it is process_overrides(artifact_dict, pkg.uu...
```suggestion path_base = (@invokelatest LazyArtifacts.ensure_artifact_installed(string(name), meta, artifacts_toml; platform))::String ```
end function __artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifacts pkg = Base.PkgId(__module__) if pkg.uuid !== nothing # Process overrides for this UUID, if we know what it is process_overrides(artifact_dict, pkg.uu...
@@ -565,7 +573,8 @@ function _artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dic if nameof(LazyArtifacts) in (:Pkg, :Artifacts, :PkgArtifacts) Base.depwarn("using Pkg instead of using LazyArtifacts is deprecated", :var"@artifact_str", force=true) end - ...
stdlib/Artifacts/src/Artifacts.jl
26
Julia
0.714
suggestion
153
51
51
false
shield `_artifact_str` function behind a world age barrier
58,957
JuliaLang/julia
35,573
Julia
topolarity
KristofferC
Review this pull request change. Language: Julia File: stdlib/Artifacts/src/Artifacts.jl PR Title: shield `_artifact_str` function behind a world age barrier BEFORE CODE: end function __artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifact...
```suggestion path_base = (@invokelatest LazyArtifacts.ensure_artifact_installed(string(name), meta, artifacts_toml; platform))::String ```
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.
UVcpus = Ref{Ptr{UV_cpu_info_t}}() count = Ref{Int32}() err = ccall(:uv_cpu_info, Int32, (Ptr{Ptr{UV_cpu_info_t}}, Ptr{Int32}), UVcpus, count) Base.uv_error("uv_cpu_info", err) cpus = Vector{CPUinfo}(undef, count[]) for i = 1:length(cpus) cpus[i] = CPUinfo(unsafe_load(UVcpus[], i)) e...
Can we just call this `sysimage_target`?
UVcpus = Ref{Ptr{UV_cpu_info_t}}() count = Ref{Int32}() err = ccall(:uv_cpu_info, Int32, (Ptr{Ptr{UV_cpu_info_t}}, Ptr{Int32}), UVcpus, count) Base.uv_error("uv_cpu_info", err) cpus = Vector{CPUinfo}(undef, count[]) for i = 1:length(cpus) cpus[i] = CPUinfo(unsafe_load(UVcpus[], i)) e...
@@ -312,6 +313,23 @@ function cpu_info() return cpus end +""" + Sys.sysimage_cpu_target_str() + +Return the CPU target string that was used to build the current system image. + +This function returns the original CPU target specification that was passed to Julia +when the system image was compiled. This can ...
base/sysinfo.jl
26
Julia
0.214
question
40
51
51
false
Add 'sysimage' keyword for `JULIA_CPU_TARGET` to match (or extend) the sysimage target
58,970
JuliaLang/julia
35,573
Julia
vchuravy
IanButterworth
Review this pull request change. Language: Julia File: base/sysinfo.jl PR Title: Add 'sysimage' keyword for `JULIA_CPU_TARGET` to match (or extend) the sysimage target BEFORE CODE: UVcpus = Ref{Ptr{UV_cpu_info_t}}() count = Ref{Int32}() err = ccall(:uv_cpu_info, Int32, (Ptr{Ptr{UV_cpu_info_t}}, Ptr{Int3...
Can we just call this `sysimage_target`?
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_value_t *p = *ptr; if (p != NULL && (uintptr_t)p >= 4096U) { jl_value_t *p_ty = jl_typeof(p); if ((uintptr_t)p_ty >= 4096U) { if (!jl_isbits(p_ty)) { nlsep = 1; brea...
Wait a second, boxed elements should never be locked, right?
jl_value_t *p = *ptr; if (p != NULL && (uintptr_t)p >= 4096U) { jl_value_t *p_ty = jl_typeof(p); if ((uintptr_t)p_ty >= 4096U) { if (!jl_isbits(p_ty)) { nlsep = 1; brea...
@@ -1290,10 +1290,20 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt for (size_t j = 0; j < tlen; j++) { if (layout->flags.arrayelem_isboxed) { jl_value_t **ptr = ((jl_value_t**)m->ptr) + j; + if (layout->flags.arr...
src/rtutils.c
26
C
0.286
question
60
51
51
false
add array element mutex offset in print and gc
58,997
JuliaLang/julia
35,573
Julia
bbrehm
vtjnash
Review this pull request change. Language: C File: src/rtutils.c PR Title: add array element mutex offset in print and gc BEFORE CODE: jl_value_t *p = *ptr; if (p != NULL && (uintptr_t)p >= 4096U) { jl_value_t *p_ty = jl_typeof(p); if ((uintptr...
Wait a second, boxed elements should never be locked, right?
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.
A = mmap(file, Vector{Float64}, 20) @test Mmap.madvise!(A, Mmap.MADV_WILLNEED) === nothing # checking for no error finalize(A); A = nothing; GC.gc() write(file, BitArray(rand(Bool, 20))) b = mmap(file, BitArray, 20) @test Mmap.madvise!(b, Mmap.MADV_WILLNEED) === nothing finalize(b); b = not...
Should this be put into a `@testset` to make failures here more localized?
A = mmap(file, Vector{Float64}, 20) @test Mmap.madvise!(A, Mmap.MADV_WILLNEED) === nothing # checking for no error finalize(A); A = nothing; GC.gc() write(file, BitArray(rand(Bool, 20))) b = mmap(file, BitArray, 20) @test Mmap.madvise!(b, Mmap.MADV_WILLNEED) === nothing finalize(b); b = not...
@@ -343,6 +343,18 @@ end GC.gc() rm(file) +# test for #58982
stdlib/Mmap/test/runtests.jl
26
Julia
0.429
bug
74
41
42
false
Bugfix: Use Base.aligned_sizeof instead of sizeof in Mmap.mmap
58,998
JuliaLang/julia
35,573
Julia
Seelengrab
JonasIsensee
Review this pull request change. Language: Julia File: stdlib/Mmap/test/runtests.jl PR Title: Bugfix: Use Base.aligned_sizeof instead of sizeof in Mmap.mmap BEFORE CODE: A = mmap(file, Vector{Float64}, 20) @test Mmap.madvise!(A, Mmap.MADV_WILLNEED) === nothing # checking for no error finalize(A); A = no...
Should this be put into a `@testset` to make failures here more localized?
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_fptr_args(jl_value_t *f, jl_value_t **args, uint32_t nargs, jl_code_instance_t *m) { jl_fptr_args_t invoke = jl_atomic_load_relaxed(&m->specptr.fptr1); assert(invoke && "Forgot to set specptr for jl_fptr_args!"); return invoke(f, args, nargs); } JL_DLLEXPORT jl_value_t *jl_fptr...
I'm not sure what this is about, but without this, i was seeing several lines like this: ``` precompile(Tuple) precompile(Tuple) precompile(Tuple) ```
jl_atomic_fetch_add(&jl_force_trace_dispatch_enabled, -1); } static void record_dispatch_statement(jl_method_instance_t *mi) { static ios_t f_dispatch; static JL_STREAM* s_dispatch = NULL; jl_method_t *def = mi->def.method; if (!jl_is_method(def)) return; uint8_t force_trace_dispatch =...
@@ -2795,7 +2795,8 @@ static void record_dispatch_statement(jl_method_instance_t *mi) s_dispatch = (JL_STREAM*) &f_dispatch; } } - if (!jl_has_free_typevars(mi->specTypes)) { + // NOTE: Sometimes the specType is just `Tuple`, which is not useful to print. + if (!jl_has_free_typevars(...
src/gf.c
26
C
0.714
suggestion
155
51
51
false
Improve --trace-dispatch coverage: emit in "full-cache" fast path as well.
59,012
JuliaLang/julia
35,573
Julia
NHDaly
NHDaly
Review this pull request change. Language: C File: src/gf.c PR Title: Improve --trace-dispatch coverage: emit in "full-cache" fast path as well. BEFORE CODE: JL_DLLEXPORT jl_value_t *jl_fptr_args(jl_value_t *f, jl_value_t **args, uint32_t nargs, jl_code_instance_t *m) { jl_fptr_args_t invoke = jl_atomic_load_r...
I'm not sure what this is about, but without this, i was seeing several lines like this: ``` precompile(Tuple) precompile(Tuple) precompile(Tuple) ```
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.
// Increment the flag to allow reentrant callers to `@trace_dispatch`. jl_atomic_fetch_add(&jl_force_trace_dispatch_enabled, -1); } static void record_dispatch_statement(jl_method_instance_t *mi) { static ios_t f_dispatch; static JL_STREAM* s_dispatch = NULL; jl_method_t *def = mi->def.method; ...
```suggestion // NOTE: For builtin functions, the specType is just `Tuple`, which is not useful to print. ```
// Increment the flag to allow reentrant callers to `@trace_dispatch`. jl_atomic_fetch_add(&jl_force_trace_dispatch_enabled, -1); } static void record_dispatch_statement(jl_method_instance_t *mi) { static ios_t f_dispatch; static JL_STREAM* s_dispatch = NULL; jl_method_t *def = mi->def.method; ...
@@ -3096,7 +3096,8 @@ static void record_dispatch_statement(jl_method_instance_t *mi) s_dispatch = (JL_STREAM*) &f_dispatch; } } - if (!jl_has_free_typevars(mi->specTypes)) { + // NOTE: Sometimes the specType is just `Tuple`, which is not useful to print.
src/gf.c
26
C
0.929
suggestion
115
51
51
false
Improve --trace-dispatch coverage: emit in "full-cache" fast path as well.
59,012
JuliaLang/julia
35,573
Julia
NHDaly
NHDaly
Review this pull request change. Language: C File: src/gf.c PR Title: Improve --trace-dispatch coverage: emit in "full-cache" fast path as well. BEFORE CODE: // Increment the flag to allow reentrant callers to `@trace_dispatch`. jl_atomic_fetch_add(&jl_force_trace_dispatch_enabled, -1); } static void recor...
```suggestion // NOTE: For builtin functions, the specType is just `Tuple`, which is not useful to print. ```
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 handle_invoke_expr!(todo::Vector{Pair{Int,Any}}, ir::IRCode, idx::Int, stmt::Expr, @nospecialize(info::CallInfo), flag::UInt32, sig::Signature, state::InliningState) edge = stmt.args[1] mi = isa(edge, MethodInstance) ? edge : get_ci_mi(edge::CodeInstance) case = resolve_todo(mi, info, flag, sta...
looks like `process_simple!` can call `inline_apply!` which contains `ir.stmts[idx][:info] = new_info`, so maybe the variable assignment `info = inst[:info]` needs to still happen on L1634 ?
function handle_invoke_expr!(todo::Vector{Pair{Int,Any}}, ir::IRCode, idx::Int, stmt::Expr, @nospecialize(info::CallInfo), flag::UInt32, sig::Signature, state::InliningState) edge = stmt.args[1] mi = isa(edge, MethodInstance) ? edge : get_ci_mi(edge::CodeInstance) case = resolve_todo(mi, info, flag, sta...
@@ -1625,14 +1623,14 @@ function assemble_inline_todo!(ir::IRCode, state::InliningState) todo = Pair{Int, Any}[] for idx in 1:length(ir.stmts) - flag = ir.stmts[idx][:flag] + inst = ir.stmts[idx] + flag = inst[:flag] + info = inst[:info]
Compiler/src/ssair/inlining.jl
26
Julia
0.5
question
190
51
51
false
Don't inline generated functions if we can't invoke their generator
59,018
JuliaLang/julia
35,573
Julia
adienes
serenity4
Review this pull request change. Language: Julia File: Compiler/src/ssair/inlining.jl PR Title: Don't inline generated functions if we can't invoke their generator BEFORE CODE: function handle_invoke_expr!(todo::Vector{Pair{Int,Any}}, ir::IRCode, idx::Int, stmt::Expr, @nospecialize(info::CallInfo), flag::UInt32...
looks like `process_simple!` can call `inline_apply!` which contains `ir.stmts[idx][:info] = new_info`, so maybe the variable assignment `info = inst[:info]` needs to still happen on L1634 ?
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 evalpoly(x*x, (1.0f0, -4.934802f0, 4.058712f0, -1.3352624f0, 0.23531426f0, -0.0255071f0)) end struct CosPiEvaluationScheme{T <: AbstractFloat, Rest <: Tuple{T, Vararg{T}}} """ Coefficient 0 of the polynomial. """ c₀::T """ Coefficient 2 of the polynomial, in double-word format (uneva...
I don't love these structs/I'm not sure they pull their weight as an abstraction (compared to just a function to evaluate the kernel like this replaces).
return evalpoly(x*x, (1.0f0, -4.934802f0, 4.058712f0, -1.3352624f0, 0.23531426f0, -0.0255071f0)) end function _cospi_kernel(x::AbstractFloat, sch) x² = x * x c₀ = sch.c₀ (c₂, c₂_lo) = sch.c₂ rest = sch.rest c₂ = -c₂ c₂_lo = -c₂_lo r = evalpoly(x², rest) * x² a_x² = c₂ * x² a_x²_...
@@ -784,6 +772,194 @@ end return evalpoly(x*x, (1.0f0, -4.934802f0, 4.058712f0, -1.3352624f0, 0.23531426f0, -0.0255071f0)) end +struct CosPiEvaluationScheme{T <: AbstractFloat, Rest <: Tuple{T, Vararg{T}}} + """ + Coefficient 0 of the polynomial. + """ + c₀::T + """ + Coefficient 2 of the poly...
base/special/trig.jl
26
Julia
0.429
refactor
153
51
51
false
redo `sinpi` and `cospi` kernel polynomial approximation
59,031
JuliaLang/julia
35,573
Julia
oscardssmith
nsajko
Review this pull request change. Language: Julia File: base/special/trig.jl PR Title: redo `sinpi` and `cospi` kernel polynomial approximation BEFORE CODE: return evalpoly(x*x, (1.0f0, -4.934802f0, 4.058712f0, -1.3352624f0, 0.23531426f0, -0.0255071f0)) end struct CosPiEvaluationScheme{T <: AbstractFloat, Rest ...
I don't love these structs/I'm not sure they pull their weight as an abstraction (compared to just a function to evaluate the kernel like this replaces).
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.
elseif opts.malloc_log == 3 push!(addflags, "--track-allocation=@$(unsafe_string(opts.tracked_path))") end if opts.color == 1 push!(addflags, "--color=yes") elseif opts.color == 2 push!(addflags, "--color=no") end if opts.startupfile == 2 push!(addflags, "--startu...
I don't believe we propagate any flags related to `--output` (why would we?) ```suggestion ```
elseif opts.malloc_log == 3 push!(addflags, "--track-allocation=@$(unsafe_string(opts.tracked_path))") end if opts.color == 1 push!(addflags, "--color=yes") elseif opts.color == 2 push!(addflags, "--color=no") end if opts.startupfile == 2 push!(addflags, "--startu...
@@ -248,6 +248,15 @@ function julia_cmd(julia=joinpath(Sys.BINDIR, julia_exename()); cpu_target::Unio if opts.compress_sysimage == 1 push!(addflags, "--compress-sysimage=yes") end + if opts.target_sanitize_memory == 1 + push!(addflags, "--target-sanitize=memory") + end + if opts.targe...
base/util.jl
26
Julia
0.571
suggestion
94
51
51
false
Add --target-sanitize=(memory|thread|address)
59,035
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: Julia File: base/util.jl PR Title: Add --target-sanitize=(memory|thread|address) BEFORE CODE: elseif opts.malloc_log == 3 push!(addflags, "--track-allocation=@$(unsafe_string(opts.tracked_path))") end if opts.color == 1 push!(addflags, "--color=...
I don't believe we propagate any flags related to `--output` (why would we?) ```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.
empty!(EXT_DORMITORY_FAILED) filter!(failed) do extid return !run_extension_callbacks(extid) end prepend!(EXT_DORMITORY_FAILED, failed) end return end """ get_extension(parent::Module, extension::Symbol) Return the module for `extension` of `parent` or return `nothing` if the exten...
Revert remaining changes to this file also? ```suggestion # OOICCDDP - see jl_cache_flags ```
end false finally global loading_extension = false end return succeeded end function run_extension_callbacks(pkgid::PkgId) assert_havelock(require_lock) # take ownership of extids that depend on this pkgid extids = pop!(EXT_DORMITORY, pkgid, nothing) extids === nothi...
@@ -1656,7 +1656,7 @@ end struct CacheFlags - # OOICCDDP - see jl_cache_flags + # OOICCDDP ?????ATM - see jl_cache_flags
base/loading.jl
26
Julia
0.643
performance
97
51
51
false
Add --target-sanitize=(memory|thread|address)
59,035
JuliaLang/julia
35,573
Julia
vtjnash
xal-0
Review this pull request change. Language: Julia File: base/loading.jl PR Title: Add --target-sanitize=(memory|thread|address) BEFORE CODE: empty!(EXT_DORMITORY_FAILED) filter!(failed) do extid return !run_extension_callbacks(extid) end prepend!(EXT_DORMITORY_FAILED, failed) end retu...
Revert remaining changes to this file also? ```suggestion # OOICCDDP - see jl_cache_flags ```
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.
@inbounds setindex!(zd, val % UInt32, nlimbs-1) @inbounds setindex!(zd, (val >> 32) % UInt32, nlimbs) end z end function BigFloat(x::BigInt, r::MPFRRoundingMode=rounding_raw(BigFloat); precision::Integer=_precision_with_base_2(BigFloat)) z = BigFloat(;precision=precision) ccall((:mpfr_s...
why does the default rounding mode change?
@inbounds setindex!(zd, val % UInt32, nlimbs-1) @inbounds setindex!(zd, (val >> 32) % UInt32, nlimbs) end z end function BigFloat(x::BigInt, r::MPFRRoundingMode=rounding_raw(BigFloat); precision::Integer=_precision_with_base_2(BigFloat)) z = BigFloat(;precision=precision) ccall((:mpfr_s...
@@ -391,13 +391,19 @@ BigFloat(x::Union{UInt8,UInt16,UInt32}, r::MPFRRoundingMode=rounding_raw(BigFloa BigFloat(x::Union{Float16,Float32}, r::MPFRRoundingMode=rounding_raw(BigFloat); precision::Integer=_precision_with_base_2(BigFloat)) = BigFloat(Float64(x), r; precision=precision) -function BigFloat(x::Rationa...
base/mpfr.jl
26
Julia
0.143
question
42
51
51
false
Fix rounding when converting Rational to BigFloat
59,063
JuliaLang/julia
35,573
Julia
adienes
OlivierHnt
Review this pull request change. Language: Julia File: base/mpfr.jl PR Title: Fix rounding when converting Rational to BigFloat BEFORE CODE: @inbounds setindex!(zd, val % UInt32, nlimbs-1) @inbounds setindex!(zd, (val >> 32) % UInt32, nlimbs) end z end function BigFloat(x::BigInt, r::MPFRRo...
why does the default rounding mode change?
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 module ULPError export ulp_error, ulp_error_maximum @noinline function throw_invalid() throw(ArgumentError("invalid")) end function ulp_error(accurate::AbstractFloat, approximate::AbstractFloat) if isnan(accur...
this should return `Inf` if one is NaN and the other isn't, or 0 if both are NaN.
# This file is a part of Julia. License is MIT: https://julialang.org/license module ULPError export ulp_error, ulp_error_maximum function ulp_error(accurate::AbstractFloat, approximate::AbstractFloat) # the ULP error is usually not required to great accuracy, so `Float32` should be precise enough ...
@@ -0,0 +1,57 @@ +# This file is a part of Julia. License is MIT: https://julialang.org/license + +module ULPError + export ulp_error, ulp_error_maximum + @noinline function throw_invalid() + throw(ArgumentError("invalid")) + end + function ulp_error(accurate::AbstractFloat, approximate::AbstractFloa...
test/testhelpers/ULPError.jl
14
Julia
0.429
suggestion
81
39
39
false
improve `cosc(::Float32)` and `cosc(::Float64)` accuracy
59,087
JuliaLang/julia
35,573
Julia
oscardssmith
nsajko
Review this pull request change. Language: Julia File: test/testhelpers/ULPError.jl PR Title: improve `cosc(::Float32)` and `cosc(::Float64)` accuracy BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license module ULPError export ulp_error, ulp_error_maximum @noinline fun...
this should return `Inf` if one is NaN and the other isn't, or 0 if both are NaN.
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.
module ULPError export ulp_error, ulp_error_maximum @noinline function throw_invalid() throw(ArgumentError("invalid")) end function ulp_error(accurate::AbstractFloat, approximate::AbstractFloat) # the ULP error is usually not required to great accuracy, so `Float32` should be precise en...
maybe put all of this inside `!(isfinite(approx) && isfinite(accurate))`? Also, I don't think these variables are used enough to be worthwhile.
module ULPError export ulp_error, ulp_error_maximum function ulp_error(accurate::AbstractFloat, approximate::AbstractFloat) # the ULP error is usually not required to great accuracy, so `Float32` should be precise enough zero_return = 0f0 inf_return = Inf32 # handle floating-poi...
@@ -0,0 +1,59 @@ +# This file is a part of Julia. License is MIT: https://julialang.org/license + +module ULPError + export ulp_error, ulp_error_maximum + @noinline function throw_invalid() + throw(ArgumentError("invalid")) + end + function ulp_error(accurate::AbstractFloat, approximate::AbstractFloa...
test/testhelpers/ULPError.jl
26
Julia
0.571
suggestion
143
51
47
false
improve `cosc(::Float32)` and `cosc(::Float64)` accuracy
59,087
JuliaLang/julia
35,573
Julia
oscardssmith
nsajko
Review this pull request change. Language: Julia File: test/testhelpers/ULPError.jl PR Title: improve `cosc(::Float32)` and `cosc(::Float64)` accuracy BEFORE CODE: module ULPError export ulp_error, ulp_error_maximum @noinline function throw_invalid() throw(ArgumentError("invalid")) end func...
maybe put all of this inside `!(isfinite(approx) && isfinite(accurate))`? Also, I don't think these variables are used enough to be worthwhile.
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.
accur_is_zero = iszero(accurate) accur_is_nan = isnan(accurate) accur_is_inf = isinf(accurate) approx_is_inf = isinf(approximate) approx_is_nan = isnan(approximate) approx_is_zero = iszero(approximate) if accur_is_nan || approx_is_nan return if accur_i...
why is this necessary? I would trust the precision of `accurate` It's often nice to be able to use lower precision than BigFloat to avoid the allocation and speed penalty.
if accur_is_nan || approx_is_nan return if accur_is_nan === approx_is_nan zero_return else inf_return end end if isinf(approximate) return if isinf(accurate) && (signbit(accurate) ...
@@ -0,0 +1,59 @@ +# This file is a part of Julia. License is MIT: https://julialang.org/license + +module ULPError + export ulp_error, ulp_error_maximum + @noinline function throw_invalid() + throw(ArgumentError("invalid")) + end + function ulp_error(accurate::AbstractFloat, approximate::AbstractFloa...
test/testhelpers/ULPError.jl
26
Julia
0.571
question
172
48
36
false
improve `cosc(::Float32)` and `cosc(::Float64)` accuracy
59,087
JuliaLang/julia
35,573
Julia
oscardssmith
nsajko
Review this pull request change. Language: Julia File: test/testhelpers/ULPError.jl PR Title: improve `cosc(::Float32)` and `cosc(::Float64)` accuracy BEFORE CODE: accur_is_zero = iszero(accurate) accur_is_nan = isnan(accurate) accur_is_inf = isinf(accurate) approx_is_inf = isinf(app...
why is this necessary? I would trust the precision of `accurate` It's often nice to be able to use lower precision than BigFloat to avoid the allocation and speed penalty.
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.
i == 2 || i == 1 || error("unexpected index") pi = p[i] prod, err = two_mul(hi,x) hi = pi+prod lo = fma(lo, x, prod - (hi - pi) + err) return hi, lo end # generic, but involves double rounding function _180_over_pi(z::AbstractFloat) 180 / oftype(z, pi) end function _pi_over_180(z::AbstractF...
Should just be `z::Float16` (and no if branch below), or is missing a `Float32`?
i == 2 || i == 1 || error("unexpected index") pi = p[i] prod, err = two_mul(hi,x) hi = pi+prod lo = fma(lo, x, prod - (hi - pi) + err) return hi, lo end # generic, but involves double rounding function _180_over_pi(z::AbstractFloat) 180 / oftype(z, pi) end function _pi_over_180(z::AbstractF...
@@ -228,6 +228,30 @@ end return hi, lo end +# generic, but involves double rounding +function _180_over_pi(z::AbstractFloat) + 180 / oftype(z, pi) +end +function _pi_over_180(z::AbstractFloat) + oftype(z, pi) / 180 +end + +# rounded to closest representable number where necessary +function _180_over_pi(z:...
base/math.jl
26
Julia
0.429
question
80
51
51
false
more accurate `rad2deg` and `deg2rad` for `Float16` and `Float32`
59,097
JuliaLang/julia
35,573
Julia
thchr
nsajko
Review this pull request change. Language: Julia File: base/math.jl PR Title: more accurate `rad2deg` and `deg2rad` for `Float16` and `Float32` BEFORE CODE: i == 2 || i == 1 || error("unexpected index") pi = p[i] prod, err = two_mul(hi,x) hi = pi+prod lo = fma(lo, x, prod - (hi - pi) + err) ...
Should just be `z::Float16` (and no if branch below), or is missing a `Float32`?
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.
side::Float64 end struct Circle <: Shape radius::Float64 end area(s::Square) = s.side^2 area(c::Circle) = pi*c.radius^2 sum_areas(v::Vector{Shape}) = sum(area, v) function @main(args::Vector{String})::Cint println(Core.stdout, str()) foreach(x->println(Core.stdout, x), args) # test map/mapreduce;...
This one now works for me locally! ```suggestion d = mapreduce(x -> x^2, +, sorted_arr) ```
side::Float64 end struct Circle <: Shape radius::Float64 end area(s::Square) = s.side^2 area(c::Circle) = pi*c.radius^2 sum_areas(v::Vector{Shape}) = sum(area, v) function @main(args::Vector{String})::Cint println(Core.stdout, str()) foreach(x->println(Core.stdout, x), args) # test map/mapreduce;...
@@ -3,8 +3,34 @@ const str = OncePerProcess{String}() do return "Hello, " * world end +abstract type Shape end +struct Square <: Shape + side::Float64 +end +struct Circle <: Shape + radius::Float64 +end +area(s::Square) = s.side^2 +area(c::Circle) = pi*c.radius^2 + +sum_areas(v::Vector{Shape}) = sum(area,...
test/trimming/hello.jl
26
Julia
0.714
suggestion
100
30
30
false
make more cases of mapreduce trimmable
59,104
JuliaLang/julia
35,573
Julia
mbauman
JeffBezanson
Review this pull request change. Language: Julia File: test/trimming/hello.jl PR Title: make more cases of mapreduce trimmable BEFORE CODE: side::Float64 end struct Circle <: Shape radius::Float64 end area(s::Square) = s.side^2 area(c::Circle) = pi*c.radius^2 sum_areas(v::Vector{Shape}) = sum(area, v) fun...
This one now works for me locally! ```suggestion d = mapreduce(x -> x^2, +, sorted_arr) ```
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 struct Circle <: Shape radius::Float64 end area(s::Square) = s.side^2 area(c::Circle) = pi*c.radius^2 sum_areas(v::Vector{Shape}) = sum(area, v) function @main(args::Vector{String})::Cint println(Core.stdout, str()) foreach(x->println(Core.stdout, x), args) # test map/mapreduce; should work but r...
And this one works if we pass an init. I don't understand why it's not working without it, though. The verifier is still routing through all the reduce empty methods: ```julia Verifier error #1: unresolved call from statement Base.reduce_empty(op::Function, T::Type)::Any Stacktrace: [1] mapreduce_empty(::type...
end struct Circle <: Shape radius::Float64 end area(s::Square) = s.side^2 area(c::Circle) = pi*c.radius^2 sum_areas(v::Vector{Shape}) = sum(area, v) function @main(args::Vector{String})::Cint println(Core.stdout, str()) foreach(x->println(Core.stdout, x), args) # test map/mapreduce; should work but r...
@@ -3,8 +3,34 @@ const str = OncePerProcess{String}() do return "Hello, " * world end +abstract type Shape end +struct Square <: Shape + side::Float64 +end +struct Circle <: Shape + radius::Float64 +end +area(s::Square) = s.side^2 +area(c::Circle) = pi*c.radius^2 + +sum_areas(v::Vector{Shape}) = sum(area,...
test/trimming/hello.jl
26
Julia
1
nitpick
3,959
29
29
false
make more cases of mapreduce trimmable
59,104
JuliaLang/julia
35,573
Julia
mbauman
JeffBezanson
Review this pull request change. Language: Julia File: test/trimming/hello.jl PR Title: make more cases of mapreduce trimmable BEFORE CODE: end struct Circle <: Shape radius::Float64 end area(s::Square) = s.side^2 area(c::Circle) = pi*c.radius^2 sum_areas(v::Vector{Shape}) = sum(area, v) function @main(args::...
And this one works if we pass an init. I don't understand why it's not working without it, though. The verifier is still routing through all the reduce empty methods: ```julia Verifier error #1: unresolved call from statement Base.reduce_empty(op::Function, T::Type)::Any Stacktrace: [1] mapreduce_empty(::type...
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.
others...) end _alloftype(ofdesiredtype, accumulated) = ofdesiredtype, Base.front(accumulated) let d = MixedKeyDict((Dict(1 => 3), Dict(4. => 2))) e = MixedKeyDict((Dict(1 => 7), Dict(5. => 9))) @test merge(+, d, e).dicts == (Dict(1 => 10), Dict(4.0 => 2, 5.0 => 9)) f = MixedKeyDic...
This looks like it has a decent chance to be inferred as `WrapperWithUnionall33472{Int}`.
others...) end _alloftype(ofdesiredtype, accumulated) = ofdesiredtype, Base.front(accumulated) let d = MixedKeyDict((Dict(1 => 3), Dict(4. => 2))) e = MixedKeyDict((Dict(1 => 7), Dict(5. => 9))) @test merge(+, d, e).dicts == (Dict(1 => 10), Dict(4.0 => 2, 5.0 => 9)) f = MixedKeyDic...
@@ -3549,8 +3549,14 @@ f31974(n::Int) = f31974(1:n) # call cycles. @test code_typed(f31974, Tuple{Int}) !== nothing -f_overly_abstract_complex() = Complex(Ref{Number}(1)[]) -@test Base.return_types(f_overly_abstract_complex, Tuple{}) == [Complex] +# Issue #33472 +struct WrapperWithUnionall33472{T<:Real} + x::T +...
Compiler/test/inference.jl
26
Julia
0.357
suggestion
89
51
51
false
inference: Make test indepdent of the `Complex` method table
59,105
JuliaLang/julia
35,573
Julia
JeffBezanson
Keno
Review this pull request change. Language: Julia File: Compiler/test/inference.jl PR Title: inference: Make test indepdent of the `Complex` method table BEFORE CODE: others...) end _alloftype(ofdesiredtype, accumulated) = ofdesiredtype, Base.front(accumulated) let d = MixedKeyDict((Dict(1 ...
This looks like it has a decent chance to be inferred as `WrapperWithUnionall33472{Int}`.
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.