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
i -= 1 break end end pathpart = join(path_arr[i+1:something(findlast(x -> !isempty(x), path_arr), 0)], path_separator) prefix_num = something(findlast(x -> !isempty(x), start_arr), 0) - i - 1 if prefix_num >= 0 prefix = pardir * path_separator relpath_ = i...
codeunits are not utf8. but we can easily do something about that: ```suggestion for cu in utf8units(s) ```
end return isempty(relpath_) ? curdir : relpath_ end relpath(path::AbstractString, startpath::AbstractString) = relpath(String(path)::String, String(startpath)::String) for f in (:isdirpath, :splitdir, :splitdrive, :splitext, :normpath, :abspath, :isabspath) @eval $f(path::AbstractString) = $f(String(...
@@ -610,14 +777,28 @@ end relpath(path::AbstractString, startpath::AbstractString) = relpath(String(path)::String, String(startpath)::String) -for f in (:isdirpath, :splitdir, :splitdrive, :splitext, :normpath, :abspath) +for f in (:isdirpath, :splitdir, :splitdrive, :splitext, :normpath, :abspath, :isabspath) ...
base/path.jl
26
Julia
0.714
suggestion
114
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
vtjnash
johroj
Review this pull request change. Language: Julia File: base/path.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: i -= 1 break end end pathpart = join(path_arr[i+1:something(findlast(x -> !isempty(x), path_arr), 0)], path_separator...
codeunits are not utf8. but we can easily do something about that: ```suggestion for cu in utf8units(s) ```
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 path_arr[i] != start_arr[i] i -= 1 break end end pathpart = join(path_arr[i+1:something(findlast(x -> !isempty(x), path_arr), 0)], path_separator) prefix_num = something(findlast(x -> !isempty(x), start_arr), 0) - i - 1 if prefix_num >= 0 prefix = pardi...
```suggestion out = empty!(StringVector(sizeof(s))) ```
relpath_ = pathpart end return isempty(relpath_) ? curdir : relpath_ end relpath(path::AbstractString, startpath::AbstractString) = relpath(String(path)::String, String(startpath)::String) for f in (:isdirpath, :splitdir, :splitdrive, :splitext, :normpath, :abspath, :isabspath) @eval $f(path::...
@@ -610,14 +777,28 @@ end relpath(path::AbstractString, startpath::AbstractString) = relpath(String(path)::String, String(startpath)::String) -for f in (:isdirpath, :splitdir, :splitdrive, :splitext, :normpath, :abspath) +for f in (:isdirpath, :splitdir, :splitdrive, :splitext, :normpath, :abspath, :isabspath) ...
base/path.jl
26
Julia
0.571
suggestion
61
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
vtjnash
johroj
Review this pull request change. Language: Julia File: base/path.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: if path_arr[i] != start_arr[i] i -= 1 break end end pathpart = join(path_arr[i+1:something(findlast(x -> !ise...
```suggestion out = empty!(StringVector(sizeof(s))) ```
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.
(on Windows) has a drive specification that doesn't match the drive computed for the join of the preceding paths, then prior components are dropped. Note on Windows since there is a current directory for each drive, `joinpath("c:", "foo")` represents a path relative to the current directory on drive "c:" so this is eq...
While this is slow path operations, I don't think we can suddenly decide to make it this inefficient
``` ```jldoctest julia> joinpath(["/home/myuser", "example.jl"]) "/home/myuser/example.jl" ``` """ joinpath function _split_at_separators(path::AbstractString; keepempty = true) # Equivalent to Base.split(path, r"/+"sa; keepempty) (r"[\\/]+"sa on windows) # Since there is no split between consecutive separato...
@@ -372,6 +514,31 @@ julia> joinpath(["/home/myuser", "example.jl"]) """ joinpath +function _split_at_separators(path::AbstractString; keepempty = true) + # Essentially Base.split(path, isseparator; keepempty) + # with the extra condition that consecutive separators are + # treated as one separator. + chars::Vector...
base/path.jl
26
Julia
0.357
performance
100
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
vtjnash
johroj
Review this pull request change. Language: Julia File: base/path.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: (on Windows) has a drive specification that doesn't match the drive computed for the join of the preceding paths, then prior components are dropped. Note on...
While this is slow path operations, I don't think we can suddenly decide to make it this inefficient
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.
Join path components into a full path. If some argument is an absolute path or (on Windows) has a drive specification that doesn't match the drive computed for the join of the preceding paths, then prior components are dropped. Note on Windows since there is a current directory for each drive, `joinpath("c:", "foo")` ...
This appears to be the definition of keepempty=false, so I'm not sure you can say it is "essentially the same as a flag" that it re-implements without that flag
"/home/myuser/example.jl" ``` ```jldoctest julia> joinpath(["/home/myuser", "example.jl"]) "/home/myuser/example.jl" ``` """ joinpath function _split_at_separators(path::AbstractString; keepempty = true) # Equivalent to Base.split(path, r"/+"sa; keepempty) (r"[\\/]+"sa on windows) # Since there is no split be...
@@ -372,6 +514,31 @@ julia> joinpath(["/home/myuser", "example.jl"]) """ joinpath +function _split_at_separators(path::AbstractString; keepempty = true) + # Essentially Base.split(path, isseparator; keepempty) + # with the extra condition that consecutive separators are + # treated as one separator.
base/path.jl
26
Julia
0.357
suggestion
160
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
vtjnash
johroj
Review this pull request change. Language: Julia File: base/path.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: Join path components into a full path. If some argument is an absolute path or (on Windows) has a drive specification that doesn't match the drive computed f...
This appears to be the definition of keepempty=false, so I'm not sure you can say it is "essentially the same as a flag" that it re-implements without that flag
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
julia> isabspath("home") false ``` """ isabspath(path::AbstractString) """ isdirpath(path::AbstractString)::Bool Determine whether a path refers to a directory (for example, ends with a path separator). # Examples ```jldoctest julia> isdirpath("/home") false julia> isdirpath("/home/") true ``` """ function isd...
These newlines are a bit surprising. They don't directly appear in the regex above, can you explain where they come from?
# Examples ```jldoctest julia> isabspath("/home") true julia> isabspath("home") false ``` """ isabspath(path::AbstractString) """ isdirpath(path::AbstractString)::Bool Determine whether a path refers to a directory (for example, ends with a path separator). # Examples ```jldoctest julia> isdirpath("/home") fals...
@@ -133,7 +237,12 @@ julia> isdirpath("/home/") true ``` """ -isdirpath(path::String) = occursin(path_directory_re, splitdrive(path)[2]) +function isdirpath(path::String)::Bool + # Reimplements occursin(r"(?:^|/)\.{0,2}$"sa, splitdrive(path)[2]) + + _, after_last_separator = _splitdir_nodrive("", splitdrive(pa...
base/path.jl
26
Julia
0.357
question
122
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: base/path.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: julia> isabspath("home") false ``` """ isabspath(path::AbstractString) """ isdirpath(path::AbstractString)::Bool Determine whether a path refers to a ...
These newlines are a bit surprising. They don't directly appear in the regex above, can you explain where they come from?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@inline isdriveletter(c::Char) = isascii(c) && isdriveletter(UInt8(c)) @inline function isdriveletter(c::UInt8) UInt8('A') <= c <= UInt8('Z') || UInt8('a') <= c <= UInt8('z') end function _split_longunc(s::String)::Tuple{String, String} # Long UNC path, e.g. `\\?\UNC\server\shar...
Can you comment to note where this `10` comes from?
@inline isseparator(c::UInt8) = c === UInt8('/') || c === UInt8('\\') @inline isdriveletter(c::Char) = isascii(c) && isdriveletter(UInt8(c)) @inline function isdriveletter(c::UInt8) UInt8('A') <= c <= UInt8('Z') || UInt8('a') <= c <= UInt8('z') end function _split_longunc(s::String...
@@ -20,40 +22,124 @@ export if Sys.isunix() const path_separator = "/" - const path_separator_re = r"/+"sa - const path_directory_re = r"(?:^|/)\.{0,2}$"sa - const path_dir_splitter = r"^(.*?)(/+)([^/]*)$"sa - const path_ext_splitter = r"^((?:.*/)?(?:\.|[^/\.])[^/]*?)(\.[^/\.]*|)$"sa + @inline...
base/path.jl
26
Julia
0.357
question
51
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: base/path.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: @inline isdriveletter(c::Char) = isascii(c) && isdriveletter(UInt8(c)) @inline function isdriveletter(c::UInt8) UInt8('A') <= c <= UInt8('Z')...
Can you comment to note where this `10` comes from?
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.
start_arr = _split_at_separators(abspath(path_drive * startpath_without_drive)) else path_arr = _split_at_separators(abspath(path)) start_arr = _split_at_separators(abspath(startpath)) end i = 0 while i < min(length(path_arr), length(start_arr)) i += 1 if path_ar...
This is much better than `percent_escape` implicitly assuming it's called on a UTF-8 string, thanks
i -= 1 break end end pathpart = join(path_arr[i+1:something(findlast(x -> !isempty(x), path_arr), 0)], path_separator) prefix_num = something(findlast(x -> !isempty(x), start_arr), 0) - i - 1 if prefix_num >= 0 prefix = pardir * path_separator relpath_ = i...
@@ -610,14 +773,28 @@ end relpath(path::AbstractString, startpath::AbstractString) = relpath(String(path)::String, String(startpath)::String) -for f in (:isdirpath, :splitdir, :splitdrive, :splitext, :normpath, :abspath) +for f in (:isdirpath, :splitdir, :splitdrive, :splitext, :normpath, :abspath, :isabspath) ...
base/path.jl
26
Julia
0.429
security
99
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: base/path.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: start_arr = _split_at_separators(abspath(path_drive * startpath_without_drive)) else path_arr = _split_at_separators(abspath(path)) ...
This is much better than `percent_escape` implicitly assuming it's called on a UTF-8 string, thanks
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 splitdir(S("C:\\")) == ("C:\\", "") @test splitdir(S("C:\\foo")) == ("C:\\", "foo") @test splitdir(S("C:\\foo\\bar")) == ("C:\\foo", "bar") @test splitdir(S("\\\\?\\C:\\foo\\bar")) == ("\\\\?\\C:\\foo", "bar") @test splitdir(S("\\\\?\\C:\\foo\\bar\\")) =...
Now that we have our parity check complete (thanks for achieving that first), I think we can also fix-up this newline handling as well similar to @JeffBezanson 's suggestion above
@test splitdir(S("C:\\")) == ("C:\\", "") @test splitdir(S("C:\\foo")) == ("C:\\", "foo") @test splitdir(S("C:\\foo\\bar")) == ("C:\\foo", "bar") @test splitdir(S("\\\\?\\C:\\foo\\bar")) == ("\\\\?\\C:\\foo", "bar") @test splitdir(S("\\\\?\\C:\\foo\\bar\\")) =...
@@ -200,6 +255,20 @@ @test_broken splitext(S(".foo..")) == (".foo", "..") @test_broken splitext(S(".foo...")) == (".foo", "...") @test splitext(S(".foo.bar")) == (".foo", ".bar") + @test splitext(S("bar/.foo/baz")) == ("bar/.foo/baz", "") + @test splitext(S("bar/foo/.baz")) == (...
test/path.jl
26
Julia
0.357
suggestion
181
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: test/path.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: @test splitdir(S("C:\\")) == ("C:\\", "") @test splitdir(S("C:\\foo")) == ("C:\\", "foo") @test splitdir(S("C:\\foo\\bar"...
Now that we have our parity check complete (thanks for achieving that first), I think we can also fix-up this newline handling as well similar to @JeffBezanson 's suggestion 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.
isdirpath, joinpath, normpath, realpath, relpath, splitdir, splitdrive, splitext, splitpath if Sys.isunix() const path_separator = "/" const path_separator_re = r"/+"sa const path_directory_re = r"(?:^|/)\.{0,2}$"sa const path_dir_splitter = r"^(.*?)(/+)([^/]*)$"s...
Random trivia: drive letters aren't ascii, but are truncated utf16 (https://www.ryanliptak.com/blog/windows-drive-letters-are-not-limited-to-a-z/)
homedir, isabspath, isdirpath, joinpath, normpath, realpath, relpath, splitdir, splitdrive, splitext, splitpath if Sys.isunix() const path_separator = "/" const path_separator_re = r"/+"sa # May be used by some external packages @inline isseparator(c::Char) = ...
@@ -20,40 +22,128 @@ export if Sys.isunix() const path_separator = "/" - const path_separator_re = r"/+"sa - const path_directory_re = r"(?:^|/)\.{0,2}$"sa - const path_dir_splitter = r"^(.*?)(/+)([^/]*)$"sa - const path_ext_splitter = r"^((?:.*/)?(?:\.|[^/\.])[^/]*?)(\.[^/\.]*|)$"sa + const p...
base/path.jl
26
Julia
0.357
suggestion
146
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
vtjnash
johroj
Review this pull request change. Language: Julia File: base/path.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: isdirpath, joinpath, normpath, realpath, relpath, splitdir, splitdrive, splitext, splitpath if Sys.isunix() const pa...
Random trivia: drive letters aren't ascii, but are truncated utf16 (https://www.ryanliptak.com/blog/windows-drive-letters-are-not-limited-to-a-z/)
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.
ctx->ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; if (!GetThreadContext(hThread, ctx)) { if ((DWORD)-1 == ResumeThread(hThread)) abort(); return 0; } return 1; } void jl_thread_resume(int tid) { jl_ptls_t ptls2 = jl_atomic_load_relaxed(&jl_all_tls_states)[tid]; ...
```suggestion int success = jl_thread_suspend_and_get_state(tid, 0, ctx); if (jl_atomic_load_relaxed(&dll_notify_queue)) { // if the dll_notify_queue is set, we lost the race against new code being added and cannot safely examine ctx // resume the thread and let the outer loop retry (better ...
ctx->ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; if (!GetThreadContext(hThread, ctx)) { if ((DWORD)-1 == ResumeThread(hThread)) abort(); return 0; } return 1; } void jl_thread_resume(int tid) { jl_ptls_t ptls2 = jl_atomic_load_relaxed(&jl_all_tls_states)[tid]; ...
@@ -475,6 +468,7 @@ int jl_thread_suspend(int16_t tid, bt_context_t *ctx) { jl_lock_profile(); // prevent concurrent mutation uv_mutex_lock(&jl_in_stackwalk); // prevent multi-threaded dbghelp calls + jl_profile_process_dll_events(); // process any deferred dll events delayed due to lock contention i...
src/signals-win.c
26
C
1
suggestion
430
51
51
false
[Windows] Add DLL notification queue to avoid deadlock
60,690
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C File: src/signals-win.c PR Title: [Windows] Add DLL notification queue to avoid deadlock BEFORE CODE: ctx->ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; if (!GetThreadContext(hThread, ctx)) { if ((DWORD)-1 == ResumeThread(hThread)) abort()...
```suggestion int success = jl_thread_suspend_and_get_state(tid, 0, ctx); if (jl_atomic_load_relaxed(&dll_notify_queue)) { // if the dll_notify_queue is set, we lost the race against new code being added and cannot safely examine ctx // resume the thread and let the outer loop retry (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.
event->DllBase = (uintptr_t)NotificationData->Unloaded.DllBase; } event->NotificationReason = NotificationReason; event->next = jl_atomic_exchange_release(&dll_notify_queue, event); if (uv_mutex_trylock(&jl_in_stackwalk) != 0) return; // lock unavailable, process later jl_profile_...
This is technically now a data race, since we requested that the profile thread concurrently read this object while we just got notified that it is about to be unmapped. Is there a way we can safely stall here (inside the close library lock) to cause profiling to stop looking at the earlier entry?
dll_notification_event_t *next = event->next; free(event); event = next; } dll_notify_queue = NULL; } // Callback for LdrRegisterDllNotification static VOID CALLBACK dll_notification_callback( ULONG NotificationReason, PCLDR_DLL_NOTIFICATION_DATA NotificationData, PVOID Con...
@@ -503,29 +513,59 @@ typedef VOID CALLBACK (*PLDR_DLL_NOTIFICATION_FUNCTION)( NTSTATUS NTAPI LdrRegisterDllNotification(ULONG Flags, PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction, PVOID Context, PVOID *Cookie); NTSTATUS NTAPI LdrUnregisterDllNotification(PVOID Cookie); +// caller should hold jl_in_stackwalk ...
src/stackwalk.c
26
C
0.643
bug
298
51
51
false
[Windows] Add DLL notification queue to avoid deadlock
60,690
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C File: src/stackwalk.c PR Title: [Windows] Add DLL notification queue to avoid deadlock BEFORE CODE: event->DllBase = (uintptr_t)NotificationData->Unloaded.DllBase; } event->NotificationReason = NotificationReason; event->next = jl_atomic_exchange_rel...
This is technically now a data race, since we requested that the profile thread concurrently read this object while we just got notified that it is about to be unmapped. Is there a way we can safely stall here (inside the close library lock) to cause profiling to stop looking at the earlier entry?
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.
event = next; } } // Callback for LdrRegisterDllNotification static VOID CALLBACK dll_notification_callback( ULONG NotificationReason, PCLDR_DLL_NOTIFICATION_DATA NotificationData, PVOID Context) { (void)Context; dll_notification_event_t *event = (dll_notification_event_t*)malloc(sizeo...
this releases event before storing to next, which makes any access (read/write) of next in the future UB
int prior_enqueued_load_of_same_module = 0; dll_notification_event_t *prior_event = event; while (prior_event->next) { if (prior_event->next->DllBase == event->DllBase) { assert(prior_event->next->NotificationReason == LDR_DLL_NOTIFICATION_REASON_L...
@@ -503,29 +513,59 @@ typedef VOID CALLBACK (*PLDR_DLL_NOTIFICATION_FUNCTION)( NTSTATUS NTAPI LdrRegisterDllNotification(ULONG Flags, PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction, PVOID Context, PVOID *Cookie); NTSTATUS NTAPI LdrUnregisterDllNotification(PVOID Cookie); +// caller should hold jl_in_stackwalk ...
src/stackwalk.c
26
C
0.357
suggestion
104
51
51
false
[Windows] Add DLL notification queue to avoid deadlock
60,690
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C File: src/stackwalk.c PR Title: [Windows] Add DLL notification queue to avoid deadlock BEFORE CODE: event = next; } } // Callback for LdrRegisterDllNotification static VOID CALLBACK dll_notification_callback( ULONG NotificationReason, PCLDR_DLL_NOTIF...
this releases event before storing to next, which makes any access (read/write) of next in the future UB
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 (NotificationReason == LDR_DLL_NOTIFICATION_REASON_LOADED) { const LDR_DLL_LOADED_NOTIFICATION_DATA *data = &NotificationData->Loaded; event->FullDllName = _wcsdup(data->FullDllName->Buffer); event->BaseDllName = _wcsdup(data->BaseDllName->Buffer); event->DllBase = (uintptr_t)data...
It feels overly complicated to me for these events to get processed in two completely different places. And notably this one seems like wasted work since it is unreliable ```suggestion ```
if (NotificationReason == LDR_DLL_NOTIFICATION_REASON_LOADED) { const LDR_DLL_LOADED_NOTIFICATION_DATA *data = &NotificationData->Loaded; event->FullDllName = _wcsdup(data->FullDllName->Buffer); event->BaseDllName = _wcsdup(data->BaseDllName->Buffer); event->DllBase = (uintptr_t)data...
@@ -503,36 +514,101 @@ typedef VOID CALLBACK (*PLDR_DLL_NOTIFICATION_FUNCTION)( NTSTATUS NTAPI LdrRegisterDllNotification(ULONG Flags, PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction, PVOID Context, PVOID *Cookie); NTSTATUS NTAPI LdrUnregisterDllNotification(PVOID Cookie); +// caller should hold jl_in_stackwalk...
src/stackwalk.c
26
C
0.714
suggestion
190
51
51
false
[Windows] Add DLL notification queue to avoid deadlock
60,690
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C File: src/stackwalk.c PR Title: [Windows] Add DLL notification queue to avoid deadlock BEFORE CODE: if (NotificationReason == LDR_DLL_NOTIFICATION_REASON_LOADED) { const LDR_DLL_LOADED_NOTIFICATION_DATA *data = &NotificationData->Loaded; event->FullDl...
It feels overly complicated to me for these events to get processed in two completely different places. And notably this one seems like wasted work since it is unreliable ```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.
memset(ctx, 0, sizeof(CONTEXT)); ctx->ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; if (!GetThreadContext(hThread, ctx)) { if ((DWORD)-1 == ResumeThread(hThread)) abort(); return 0; } return 1; } void jl_thread_resume(int tid) { jl_ptls_t ptls2 = jl_atomic_load_r...
You're missing a call to this function before any same-thread unwind (since it is now unreliable whether the trylock happens before you started running that code). Anywhere we took the jl_in_stackwalk lock (except when the victim thread is stopped) we need to now run this again (just like the old need_syminit flag appr...
memset(ctx, 0, sizeof(CONTEXT)); ctx->ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; if (!GetThreadContext(hThread, ctx)) { if ((DWORD)-1 == ResumeThread(hThread)) abort(); return 0; } return 1; } void jl_thread_resume(int tid) { jl_ptls_t ptls2 = jl_atomic_load_r...
@@ -475,7 +468,10 @@ int jl_thread_suspend(int16_t tid, bt_context_t *ctx) { jl_lock_profile(); // prevent concurrent mutation uv_mutex_lock(&jl_in_stackwalk); // prevent multi-threaded dbghelp calls + uv_mutex_lock(&jl_dll_notify_lock); + jl_profile_process_dll_events(); // process any deferred dll ev...
src/signals-win.c
26
C
0.571
nitpick
414
51
51
false
[Windows] Add DLL notification queue to avoid deadlock
60,690
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C File: src/signals-win.c PR Title: [Windows] Add DLL notification queue to avoid deadlock BEFORE CODE: memset(ctx, 0, sizeof(CONTEXT)); ctx->ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; if (!GetThreadContext(hThread, ctx)) { if ((DWORD)-1 == Resum...
You're missing a call to this function before any same-thread unwind (since it is now unreliable whether the trylock happens before you started running that code). Anywhere we took the jl_in_stackwalk lock (except when the victim thread is stopped) we need to now run this again (just like the old need_syminit flag appr...
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.
AA.registerFunctionAnalysis<ScopedNoAliasAA>(); AA.registerFunctionAnalysis<TypeBasedAA>(); } TM.registerDefaultAliasAnalyses(AA); return AA; }); // Register our TargetLibraryInfoImpl. FAM.registerPass([&] JL_NOTSAFEPOINT { retu...
Please use a real parser (even if it is just getopt) and not this claude garbage. If we want to act like LLVM, it should use the function structure here: https://llvm.org/doxygen/CommandLine_8cpp_source.html#l01462 e.g. tokenization by [TokenizeGNUCommandLine](https://llvm.org/doxygen/namespacellvm_1_1cl.html#aff28c...
AA.registerFunctionAnalysis<BasicAA>(); AA.registerFunctionAnalysis<ScopedNoAliasAA>(); AA.registerFunctionAnalysis<TypeBasedAA>(); } TM.registerDefaultAliasAnalyses(AA); return AA; }); // Register our TargetLibraryInfoI...
@@ -738,8 +740,55 @@ PIC.addClassToPassName(decltype(CREATE_PASS)::name(), NAME); } } -NewPM::NewPM(std::unique_ptr<TargetMachine> TM, OptimizationLevel O, OptimizationOptions options) : - TM(std::move(TM)), O(O), options(options), TimePasses() {} +// Parse LLVM-style option string into PrintOptions +void pa...
src/pipeline.cpp
26
C++
0.5
suggestion
676
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C++ File: src/pipeline.cpp PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: AA.registerFunctionAnalysis<ScopedNoAliasAA>(); AA.registerFunctionAnalysis<TypeBasedAA>(); } ...
Please use a real parser (even if it is just getopt) and not this claude garbage. If we want to act like LLVM, it should use the function structure here: https://llvm.org/doxygen/CommandLine_8cpp_source.html#l01462 e.g. tokenization by [TokenizeGNUCommandLine](https://llvm.org/doxygen/namespacellvm_1_1cl.html#aff28c...
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.
llvmf_dump = Ref{LLVMFDump}() @ccall jl_get_llvmf_defn(llvmf_dump::Ptr{LLVMFDump}, mi::Any, src::Any, wrapper::Bool, true::Bool, ""::Cstring, params::CodegenParams)::Cvoid llvmf_dump[].f == C_NULL && error("could not compile the specified method") str = @ccall jl_dump_functi...
This should be freed by the same shared library that allocated it. Freeing objects from a different place than you allocated it leads to awkwardness (aka crashes) when you try to use alternatively allocators like mimalloc, and is an anti-pattern that should be always avoided
strip_ir_metadata::Bool, dump_module::Bool, optimize::Bool, debuginfo::Symbol, llvm_options::String, params::CodegenParams) llvmf_dump = Ref{LLVMFDump}() @ccall jl_get_llvmf_defn(llvmf_dump::Ptr{LLVMFDump}, mi::Any, src::Any, wrapper::Bool, optimize::...
@@ -312,18 +314,30 @@ function _dump_function_llvm( mi::Core.MethodInstance, src::Core.CodeInfo, wrapper::Bool, strip_ir_metadata::Bool, dump_module::Bool, optimize::Bool, debuginfo::Symbol, + llvm_options::String, params::CodegenParams) llvmf_dump = Ref{LLVMFDump}() ...
stdlib/InteractiveUtils/src/codeview.jl
26
Julia
0.5
bug
275
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/codeview.jl PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: llvmf_dump = Ref{LLVMFDump}() @ccall jl_get_llvmf_defn(llvmf_dump::Ptr{LLVMFDump}, mi::Any, src::Any, wrapper::Bool,...
This should be freed by the same shared library that allocated it. Freeing objects from a different place than you allocated it leads to awkwardness (aka crashes) when you try to use alternatively allocators like mimalloc, and is an anti-pattern that should be always avoided
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 _dump_function_llvm( mi::Core.MethodInstance, src::Core.CodeInfo, wrapper::Bool, strip_ir_metadata::Bool, dump_module::Bool, optimize::Bool, debuginfo::Symbol, llvm_options::String, params::CodegenParams) llvmf_dump = Ref{LLVMFDump}() @ccall jl_get_llvmf_def...
I makes me wonder if we want to support more (all) of the opt pipeline? In particular remarks? But perhaps custom opt pipeline would also make sense
llvmf_dump[].f == C_NULL && error("could not compile the specified method") # jl_dump_function_ir handles pass_output internally (prepends it and frees it) str = @ccall jl_dump_function_ir(llvmf_dump::Ptr{LLVMFDump}, strip_ir_metadata::Bool, dump_module::Bool, debuginfo:...
@@ -333,12 +347,23 @@ All metadata and dbg.* calls are removed from the printed bitcode. For the full To dump the entire module that encapsulates the function (with declarations), set the `dump_module` keyword to true. Keyword argument `debuginfo` may be one of source (default) or none, to specify the verbosity of co...
stdlib/InteractiveUtils/src/codeview.jl
26
Julia
0.357
suggestion
149
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vchuravy
gbaraldi
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/codeview.jl PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: end function _dump_function_llvm( mi::Core.MethodInstance, src::Core.CodeInfo, wrapper::Bool, strip_ir_meta...
I makes me wonder if we want to support more (all) of the opt pipeline? In particular remarks? But perhaps custom opt pipeline would also make sense
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.
// Parse LLVM-style option string into PrintOptions using LLVM's tokenizer void parseLLVMOptions(const char *options, PrintOptions &out) JL_NOTSAFEPOINT { if (!options || options[0] == '\0') return; // Tokenize the options string using LLVM's GNU command line tokenizer BumpPtrAllocator Alloc; ...
```suggestion } else if (Arg.starts_with("-print-after=")) { out.print_after = Arg.substr(13).str(); } else if (Arg == "-print-after") { out.print_after = std::string(Argv[++i]); ``` and so on, with bounds checking of course
// Parse LLVM-style option string into PrintOptions using LLVM's tokenizer void parseLLVMOptions(const char *options, PrintOptions &out) JL_NOTSAFEPOINT { if (!options || options[0] == '\0') return; // Tokenize the options string using LLVM's GNU command line tokenizer BumpPtrAllocator Alloc; ...
@@ -738,8 +741,43 @@ PIC.addClassToPassName(decltype(CREATE_PASS)::name(), NAME); } } -NewPM::NewPM(std::unique_ptr<TargetMachine> TM, OptimizationLevel O, OptimizationOptions options) : - TM(std::move(TM)), O(O), options(options), TimePasses() {} +// Parse LLVM-style option string into PrintOptions using LL...
src/pipeline.cpp
26
C++
0.786
suggestion
270
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C++ File: src/pipeline.cpp PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: // Parse LLVM-style option string into PrintOptions using LLVM's tokenizer void parseLLVMOptions(const char *options, PrintOptions &out) JL_NOTSAFEP...
```suggestion } else if (Arg.starts_with("-print-after=")) { out.print_after = Arg.substr(13).str(); } else if (Arg == "-print-after") { out.print_after = std::string(Argv[++i]); ``` and so on, with bounds checking of course
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 str end function _dump_function_llvm( mi::Core.MethodInstance, src::Core.CodeInfo, wrapper::Bool, strip_ir_metadata::Bool, dump_module::Bool, optimize::Bool, debuginfo::Symbol, llvm_options::String, params::CodegenParams) llvmf_dump = Ref{LLVMFDump}() @ccall j...
Should we prepend `;` to each newline in the annotations stream? I think normally in LLVM it might go to stderr while the final output goes to stdout, so they are normally separated that way instead? ```julia str = replace(str, '\n' => "\n;") ```
params::CodegenParams)::Cvoid llvmf_dump[].f == C_NULL && error("could not compile the specified method") # jl_dump_function_ir handles pass_output internally (prepends it and frees it) str = @ccall jl_dump_function_ir(llvmf_dump::Ptr{LLVMFDump}, strip_ir_metadata::Bool, ...
@@ -312,18 +314,30 @@ function _dump_function_llvm( mi::Core.MethodInstance, src::Core.CodeInfo, wrapper::Bool, strip_ir_metadata::Bool, dump_module::Bool, optimize::Bool, debuginfo::Symbol, + llvm_options::String, params::CodegenParams) llvmf_dump = Ref{LLVMFDump}() ...
stdlib/InteractiveUtils/src/codeview.jl
26
Julia
0.857
question
249
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: Julia File: stdlib/InteractiveUtils/src/codeview.jl PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: return str end function _dump_function_llvm( mi::Core.MethodInstance, src::Core.CodeInfo, wrapper::Bool, ...
Should we prepend `;` to each newline in the annotations stream? I think normally in LLVM it might go to stderr while the final output goes to stdout, so they are normally separated that way instead? ```julia str = replace(str, '\n' => "\n;") ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
metadataM.setOverrideStackAlignment(OverrideStackAlignment); // reflect the address of the jl_RTLD_DEFAULT_handle variable // back to the caller, so that we can check for consistency issues GlobalValue *jlRTLD_DEFAULT_var = jl_emit_RTLD_DEFAULT_var(&metadataM); Type *T_size = D...
Looks like jl_dump_function_asm isn't freeing the newly added memory?
jl_printf(stream, "\n---- optimized IR ----\n"); jl_get_llvmf_defn(&llvmf_dump, mi, src, 0, true, nullptr, jl_default_cgparams); if (llvmf_dump.F) { jl_value_t *ir = jl_dump_function_ir(&llvmf_dump, 0, 1, "source"); if (ir != NULL && jl_is_string(ir)) jl_printf(stream, "%s", jl_s...
@@ -2552,11 +2552,12 @@ extern "C" JL_DLLEXPORT_CODEGEN jl_code_info_t *jl_gdbdumpcode(jl_method_instanc // for use in reflection from Julia. // This is paired with jl_dump_function_ir and jl_dump_function_asm, either of which will free all memory allocated here
src/aotcompile.cpp
26
C++
0.357
question
69
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C++ File: src/aotcompile.cpp PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: metadataM.setOverrideStackAlignment(OverrideStackAlignment); // reflect the address of the jl_RTLD_DEFAULT_handle variable ...
Looks like jl_dump_function_asm isn't freeing the newly added memory?
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.
// Check for "=" syntax first if (Arg.size() > prefix.size() && Arg[prefix.size()] == '=') { return Arg.substr(prefix.size() + 1); } // Otherwise, consume the next argument if (idx + 1 < Argv.size()) { return StringRef(Argv[++idx]); } errs(...
Can you ask Claude to rewrite this so that is isn't doing just a prefix check, but can have `getNextValue` implement the exact checks: ```suggestion } else if (StringRef val = getNextValue(i, Arg, "-print-after=")) { ``` If you were going to do a prefix comparison scan only, the getopt standard requires ...
// Supports both "-option=value" and "-option value" syntax auto getNextValue = [&](size_t &idx, StringRef Arg, StringRef option) JL_NOTSAFEPOINT -> StringRef { StringRef optionName = option.drop_back(); // remove trailing "=" // Check for "-option=value" syntax if (Arg.starts_with(optio...
@@ -738,8 +741,64 @@ PIC.addClassToPassName(decltype(CREATE_PASS)::name(), NAME); } } -NewPM::NewPM(std::unique_ptr<TargetMachine> TM, OptimizationLevel O, OptimizationOptions options) : - TM(std::move(TM)), O(O), options(options), TimePasses() {} +// Parse LLVM-style option string into PrintOptions using LL...
src/pipeline.cpp
26
C++
0.786
suggestion
568
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C++ File: src/pipeline.cpp PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: // Check for "=" syntax first if (Arg.size() > prefix.size() && Arg[prefix.size()] == '=') { return Arg.substr(prefix.siz...
Can you ask Claude to rewrite this so that is isn't doing just a prefix check, but can have `getNextValue` implement the exact checks: ```suggestion } else if (StringRef val = getNextValue(i, Arg, "-print-after=")) { ``` If you were going to do a prefix comparison scan only, the getopt standard requires ...
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.
global.second->setLinkage(GlobalValue::PrivateLinkage); global.second->setUnnamedAddr(GlobalValue::UnnamedAddr::Global); global.second->setVisibility(GlobalValue::DefaultVisibility); } } if (!jl_o...
jl_free_llvmf_pass_output doesn't exist
// This file is a part of Julia. License is MIT: https://julialang.org/license #include "llvm-version.h" #include "platform.h" // target support #include <llvm/TargetParser/Triple.h> #include "llvm/Support/CodeGen.h" #include <llvm/ADT/Statistic.h> #include <llvm/Analysis/TargetLibraryInfo.h> #include <llvm/Analysis/...
@@ -2645,10 +2646,21 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t *dump, jl_method_instance_t *mi, jl_ opts.sanitize_memory = params.sanitize_memory; opts.sanitize_thread = params.sanitize_thread; opts.sanitize_address = params.sanitize_address; - ...
src/aotcompile.cpp
26
C++
0.071
suggestion
39
51
2,499
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C++ File: src/aotcompile.cpp PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: global.second->setLinkage(GlobalValue::PrivateLinkage); global.second->setUnnamedAddr(GlobalValue::...
jl_free_llvmf_pass_output doesn't exist
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.
bool sanitize_thread=true, #else bool sanitize_thread=false, #endif #ifdef _COMPILER_ASAN_ENABLED_ bool sanitize_address=true #else bool sanitize_address=false #endif ) JL_NOTSAFEPOINT { return {lower_intrinsics, dump_native, external_use, llvm_only, always_inline...
That isn't a very useful link. The link for the ChangeReporter is here: https://llvm.org/doxygen/classllvm_1_1ChangeReporter.html#a7a57fcd8f955992d5167dae6978748f2 (and is simply a text diff, nothing fancy, no "integration" is required)
bool sanitize_thread=true, #else bool sanitize_thread=false, #endif #ifdef _COMPILER_ASAN_ENABLED_ bool sanitize_address=true #else bool sanitize_address=false #endif ) JL_NOTSAFEPOINT { return {lower_intrinsics, dump_native, external_use, llvm_only, always_inline...
@@ -132,12 +132,42 @@ struct OptimizationOptions { } }; +struct PrintOptions { + bool print_before_all = false; + bool print_after_all = false; + bool print_module_scope = false; + // TODO: Add print_changed support. This would require integrating with LLVM's + // ChangedIRPrinter infrastructure ...
src/jitlayers.h
26
C/C++
0.5
suggestion
237
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C/C++ File: src/jitlayers.h PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: bool sanitize_thread=true, #else bool sanitize_thread=false, #endif #ifdef _COMPILER_ASAN_ENABLED_ bool sanitize_address=tru...
That isn't a very useful link. The link for the ChangeReporter is here: https://llvm.org/doxygen/classllvm_1_1ChangeReporter.html#a7a57fcd8f955992d5167dae6978748f2 (and is simply a text diff, nothing fancy, no "integration" is 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.
void parseLLVMOptions(const char *options, PrintOptions &out) JL_NOTSAFEPOINT { if (!options || options[0] == '\0') return; // Tokenize the options string using LLVM's GNU command line tokenizer BumpPtrAllocator Alloc; StringSaver Saver(Alloc); SmallVector<const char *, 16> Argv; cl::To...
Can you add the error string to PrintOptions, to print in the output, rather than relying on the `errs()` stream working correctly here
void parseLLVMOptions(const char *options, PrintOptions &out) JL_NOTSAFEPOINT { if (!options || options[0] == '\0') return; // Tokenize the options string using LLVM's GNU command line tokenizer BumpPtrAllocator Alloc; StringSaver Saver(Alloc); SmallVector<const char *, 16> Argv; cl::To...
@@ -738,8 +741,61 @@ PIC.addClassToPassName(decltype(CREATE_PASS)::name(), NAME); } } -NewPM::NewPM(std::unique_ptr<TargetMachine> TM, OptimizationLevel O, OptimizationOptions options) : - TM(std::move(TM)), O(O), options(options), TimePasses() {} +// Parse LLVM-style option string into PrintOptions using LL...
src/pipeline.cpp
26
C++
0.643
suggestion
135
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C++ File: src/pipeline.cpp PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: void parseLLVMOptions(const char *options, PrintOptions &out) JL_NOTSAFEPOINT { if (!options || options[0] == '\0') return; // Token...
Can you add the error string to PrintOptions, to print in the output, rather than relying on the `errs()` stream working correctly here
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
//We must recreate the analysis managers every time //so that analyses from previous runs of the pass manager //do not hang around for the next run StandardInstrumentations SI(M.getContext(), /*DebugLogging=*/false); PassInstrumentationCallbacks PIC; adjustPIC(PIC); TimePasses.registerCallba...
This should be a comma-separated list (e.g. use split in a loop when parsing, since the user also can pass this flag multiple times). See https://llvm.org/doxygen/CommandLine_8cpp.html#a030478956c379ec2bb71550cb0526fb6 (CommaSeparateAndAddOccurrence)
} else if (const auto *SCC = unwrapIR<LazyCallGraph::SCC>(IR)) { for (auto &CGN : *SCC) { Function &F = CGN.getFunction(); F.print(OS); } } else { OS << "Unknown IR type\n"; } } void NewPM::run(Module &M) { //We must recreate the analysis managers every t...
@@ -762,14 +818,97 @@ AnalysisManagers::AnalysisManagers(PassBuilder &PB) : LAM(), FAM(), CGAM(), MAM( AnalysisManagers::~AnalysisManagers() = default; +// Helper to unwrap IR from Any to a specific type +template <typename IRType> +static const IRType *unwrapIR(Any IR) JL_NOTSAFEPOINT { + const IRType *const *...
src/pipeline.cpp
26
C++
0.5
suggestion
250
51
51
false
codegen: Add llvm_options parameter to code_llvm for pass instrumentation
60,698
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C++ File: src/pipeline.cpp PR Title: codegen: Add llvm_options parameter to code_llvm for pass instrumentation BEFORE CODE: //We must recreate the analysis managers every time //so that analyses from previous runs of the pass manager //do not hang around for th...
This should be a comma-separated list (e.g. use split in a loop when parsing, since the user also can pass this flag multiple times). See https://llvm.org/doxygen/CommandLine_8cpp.html#a030478956c379ec2bb71550cb0526fb6 (CommaSeparateAndAddOccurrence)
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 Optimizer::initializeAlloca(IRBuilder<> &prolog_builder, AllocaInst *buff, AllocFnKind allockind) { if ((allockind & AllocFnKind::Uninitialized) != AllocFnKind::Unknown) return; assert(!buff->isArrayAllocation()); Type *T = buff->getAllocatedType(); const DataLayout &DL = F.getParent()->...
This feels loosely unsound, since this is the minimum known alignment, and not the required alignment. The JL_SMALL_BYTE_ALIGNMENT value is the largest value that julia.gc_alloc_obj is permitted to return, so it is sometimes reasonable that we can use this as a hint, but we should be sure to clarify that this overalign...
} void Optimizer::initializeAlloca(IRBuilder<> &prolog_builder, AllocaInst *buff, AllocFnKind allockind) { if ((allockind & AllocFnKind::Uninitialized) != AllocFnKind::Unknown) return; assert(!buff->isArrayAllocation()); Type *T = buff->getAllocatedType(); const DataLayout &DL = F.getParent()->...
@@ -678,11 +678,8 @@ void Optimizer::moveToStack(CallInst *orig_inst, size_t sz, bool has_ref, AllocF // The allocation does not escape or get used in a phi node so none of the derived // SSA from it are live when we run the allocation again. // It is now safe to promote the allocation to an entry block ...
src/llvm-alloc-opt.cpp
26
C++
1
performance
543
51
51
false
llvm: Fix alloca alignment and type selection in AllocOpt
60,699
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C++ File: src/llvm-alloc-opt.cpp PR Title: llvm: Fix alloca alignment and type selection in AllocOpt BEFORE CODE: } void Optimizer::initializeAlloca(IRBuilder<> &prolog_builder, AllocaInst *buff, AllocFnKind allockind) { if ((allockind & AllocFnKind::Uninitialized) !=...
This feels loosely unsound, since this is the minimum known alignment, and not the required alignment. The JL_SMALL_BYTE_ALIGNMENT value is the largest value that julia.gc_alloc_obj is permitted to return, so it is sometimes reasonable that we can use this as a hint, but we should be sure to clarify that this overalign...
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.
kind(rhs) in KSet"new splatnew cfunction isdefined call foreigncall gc_preserve_begin foreigncall new_opaque_closure") end function check_no_local_bindings(ctx, ex, msg) contains_nonglobal_binding = contains_unquoted(ex) do e kind(e) == K"BindingId" && get_binding(ctx, e).kind !== :global e...
```suggestion elseif ((all_simple || is_const_read_arg(ctx, arg_val)) && is_valid_body_ir_argument(ctx, arg_val)) ``` Aligning to the inner block is confusing IMO. Although I actually don't think we have a great style for breaking conditions on multiple lines like this.
kind(rhs) in KSet"new splatnew cfunction isdefined call foreigncall gc_preserve_begin foreigncall new_opaque_closure") end function check_no_local_bindings(ctx, ex, msg) contains_nonglobal_binding = contains_unquoted(ex) do e kind(e) == K"BindingId" && get_binding(ctx, e).kind !== :global e...
@@ -161,7 +161,11 @@ function compile_args(ctx, args) args_out = SyntaxList(ctx) for arg in args arg_val = compile(ctx, arg, true, false) - if (all_simple || is_const_read_arg(ctx, arg_val)) && is_valid_body_ir_argument(ctx, arg_val) + if isnothing(arg_val) + # arguments that...
JuliaLowering/src/linear_ir.jl
26
Julia
0.786
suggestion
303
51
51
false
[JuliaLowering] Fix linearize step when arguments have no value
60,704
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/linear_ir.jl PR Title: [JuliaLowering] Fix linearize step when arguments have no value BEFORE CODE: kind(rhs) in KSet"new splatnew cfunction isdefined call foreigncall gc_preserve_begin foreigncall new_opaque_closure") end functio...
```suggestion elseif ((all_simple || is_const_read_arg(ctx, arg_val)) && is_valid_body_ir_argument(ctx, arg_val)) ``` Aligning to the inner block is confusing IMO. Although I actually don't think we have a great style for breaking conditions on multiple lines like 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.
# TODO: Should every form get layerid systematically? Or only the ones # which expand_forms_2 needs? layerid = get(ex, :scope_layer, current_layer_id(ctx)) setattr(mapchildren(e->expand_forms_1(ctx,e), ctx, ex), :scope_layer, layerid) else mapchildren(e->expan...
What prevents this from accidentally transforming a quoted `if @generated ...`? Is it just that macro-expansion hasn't happened yet, so it's impossible to "type" `if $(Expr(:generated)) ...` ? (side note) this pattern matching turned out quite nice, I can see why you wanted the utility 👍
# TODO: Should every form get layerid systematically? Or only the ones # which expand_forms_2 needs? layerid = get(ex, :scope_layer, current_layer_id(ctx)) setattr(mapchildren(e->expand_forms_1(ctx,e), ctx, ex), :scope_layer, layerid) else mapchildren(e->expan...
@@ -564,6 +572,20 @@ function expand_forms_1(ctx::MacroExpansionContext, ex::SyntaxTree) end end +has_if_generated(st::SyntaxTree) = JuliaSyntax.@stm st begin + (_, when=is_leaf(st)||is_quoted(st)) -> false + [K"function" _...] -> false + ([K"=" call _], when=is_eventually_call(call)) -> false + [K"...
JuliaLowering/src/macro_expansion.jl
26
Julia
0.714
refactor
292
50
51
false
[JuliaLowering] Quote generated function body before desugaring
60,710
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/macro_expansion.jl PR Title: [JuliaLowering] Quote generated function body before desugaring BEFORE CODE: # TODO: Should every form get layerid systematically? Or only the ones # which expand_forms_2 needs? layerid = ge...
What prevents this from accidentally transforming a quoted `if @generated ...`? Is it just that macro-expansion hasn't happened yet, so it's impossible to "type" `if $(Expr(:generated)) ...` ? (side note) this pattern matching turned out quite nice, I can see why you wanted the utility 👍
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.
gen = expand_forms_1(ctx, expand_quote( ctx, @ast ctx e2 [K"block" split_generated(e2, true)])) nongen = split_generated(e2, false) @ast ctx ex [K"generated_function" e1 gen nongen] elseif k == K"<:" || k == K">:" || k == K"-->" # TODO: Should every form get layerid syste...
nitpick, but this ternary is a bit hard to read ```suggestion [K"if" [K"generated"] gen nongen] -> if gen_part @ast st._graph st [K"$" gen] else nongen end ```
gen = expand_forms_1(ctx, expand_quote( ctx, @ast ctx e2 [K"block" split_generated(e2, true)])) nongen = split_generated(e2, false) @ast ctx ex [K"generated_function" e1 gen nongen] elseif k == K"<:" || k == K">:" || k == K"-->" # TODO: Should every form get layerid syste...
@@ -564,6 +572,20 @@ function expand_forms_1(ctx::MacroExpansionContext, ex::SyntaxTree) end end +has_if_generated(st::SyntaxTree) = JuliaSyntax.@stm st begin + (_, when=is_leaf(st)||is_quoted(st)) -> false + [K"function" _...] -> false + ([K"=" call _], when=is_eventually_call(call)) -> false + [K"...
JuliaLowering/src/macro_expansion.jl
26
Julia
0.714
suggestion
194
51
51
false
[JuliaLowering] Quote generated function body before desugaring
60,710
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/macro_expansion.jl PR Title: [JuliaLowering] Quote generated function body before desugaring BEFORE CODE: gen = expand_forms_1(ctx, expand_quote( ctx, @ast ctx e2 [K"block" split_generated(e2, true)])) nongen = spli...
nitpick, but this ternary is a bit hard to read ```suggestion [K"if" [K"generated"] gen nongen] -> if gen_part @ast st._graph st [K"$" gen] else nongen 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.
# This file is a part of Julia. License is MIT: https://julialang.org/license include("tempdepot.jl") function precompile_test_harness(@nospecialize(f), testset::String) @testset "$testset" precompile_test_harness(f, true) end function precompile_test_harness(@nospecialize(f), separate::Bool=true) load_path =...
Something probably went horribly wrong if `ci.max_world != WORLD_AGE_REVALIDATION_SENTINEL`, since that means the Compiler made a mistake and forgot to validate it
try pushfirst!(LOAD_PATH, load_path) pushfirst!(DEPOT_PATH, load_cache_path) f(load_path) finally filter!((≠)(load_path), LOAD_PATH) separate && filter!((≠)(load_cache_path), DEPOT_PATH) end return nothing end let original_depot_path = copy(Base.DEPOT_PATH) o...
@@ -29,3 +29,14 @@ let original_depot_path = copy(Base.DEPOT_PATH) append!(Base.LOAD_PATH, original_load_path) end end + +function check_presence(mi, token) + ci = isdefined(mi, :cache) ? mi.cache : nothing + while ci !== nothing + if ci.owner === token && ci.max_world == typemax(UInt)
test/precompile_utils.jl
26
Julia
0.5
bug
163
32
33
false
[1.12] Don't skip CIs from external absints
60,741
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: Julia File: test/precompile_utils.jl PR Title: [1.12] Don't skip CIs from external absints BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license include("tempdepot.jl") function precompile_test_harness(@nospecialize(f), testset::Strin...
Something probably went horribly wrong if `ci.max_world != WORLD_AGE_REVALIDATION_SENTINEL`, since that means the Compiler made a mistake and forgot to validate 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.
@test !success(cmd) end end ## `Main.main` entrypoint # Basic usage @test readchomp(`$(Base.julia_cmd()) -e '(@main)(args) = println("hello")'`) == "hello" # Test ARGS with -e @test readchomp(`$(Base.julia_cmd()) -e '(@main)(args) = println(args)' a b`) == repr(["a", "b"]) # Test import from module @test readch...
This is kind of what `@testset let` is for, but that's a nit.
MAX32HEAP = 1536 * 1024 * 1024 if Int === Int32 && hint > MAX32HEAP hint = MAX32HEAP end @test abs(Float64(maxmem) - hint)/maxmem < 0.05 @test readchomp(`$(Base.julia_cmd()) --startup-file=no --heap-size-hint=10M -e "println(@ccall jl_gc_get_max_memory()::UInt64)"`) == "$(1*1024*1024)" end ...
@@ -1364,9 +1364,20 @@ end # test --bug-report=rr if Sys.islinux() && Sys.ARCH in (:i686, :x86_64) # rr is only available on these platforms mktempdir() do temp_trace_dir - test_read_success(setenv(`$(Base.julia_cmd()) --bug-report=rr-local -e 'exit()'`, - "JULIA_RR_RECORD_...
test/cmdlineargs.jl
26
Julia
0.357
suggestion
61
51
51
false
Treat 'unable to open perf counter' as success in rr-related tests
60,780
JuliaLang/julia
35,573
Julia
Keno
qinsoon
Review this pull request change. Language: Julia File: test/cmdlineargs.jl PR Title: Treat 'unable to open perf counter' as success in rr-related tests BEFORE CODE: @test !success(cmd) end end ## `Main.main` entrypoint # Basic usage @test readchomp(`$(Base.julia_cmd()) -e '(@main)(args) = println("hello")'`) ...
This is kind of what `@testset let` is for, but that's a nit.
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.
record_reason(reasons, "different Julia build configuration") return true # incompatible cache file end modules, (includes, _, requires), required_modules, srctextpos, prefs, prefs_hash, clone_targets, actual_flags, syntax_version = parse_cache_header(io, cachefile) if is...
Is `stalecheck` really right here? This is more like the cache flag above. Isn't the issue that require_stdlib is trying to load with the wrong syntax version?
catch ex ex isa IOError || ex isa SystemError || rethrow() @debug "Rejecting cache file $cachefile for $modkey because it could not be opened" isfile(cachefile) return true end try checksum = isvalid_cache_header(io) if iszero(checksum) @debug "Rejecting c...
@@ -4286,7 +4286,7 @@ end record_reason(reasons, "different compilation options") return true end - if syntax_version != cache_syntax_version(modspec.julia_syntax_version) + if stalecheck && syntax_version != cache_syntax_version(modspec.julia_syntax_version)
base/loading.jl
26
Julia
0.5
bug
159
51
51
false
Skip syntax check in require_stdlib. Add test. Update stdlib manifest
60,791
JuliaLang/julia
35,573
Julia
Keno
IanButterworth
Review this pull request change. Language: Julia File: base/loading.jl PR Title: Skip syntax check in require_stdlib. Add test. Update stdlib manifest BEFORE CODE: record_reason(reasons, "different Julia build configuration") return true # incompatible cache file end modules,...
Is `stalecheck` really right here? This is more like the cache flag above. Isn't the issue that require_stdlib is trying to load with the wrong syntax version?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@test invokelatest(getglobal, (@eval (using VersionedDep1; VersionedDep1)), :ver) == v"1.13" # syntax.julia_version from Manifest = "1.14" @test invokelatest(getglobal, (@eval (using VersionedDep2; VersionedDep2)), :ver) == v"1.14" # syntax.julia_version from Manifest = "1.0" should be c...
Just realized this test needs to monitor stderr. This doesn't currently work.
@test invokelatest(getglobal, (@eval (using VersionedDep1; VersionedDep1)), :ver) == v"1.13" # syntax.julia_version from Manifest = "1.14" @test invokelatest(getglobal, (@eval (using VersionedDep2; VersionedDep2)), :ver) == v"1.14" # syntax.julia_version from Manifest = "1.0" should be c...
@@ -1925,3 +1925,18 @@ module M58272_to end @test parse(VersionNumber, read(`$(Base.julia_cmd()) --project=$(joinpath(explicit_env, "VersionedDep1")) $syntax_version_script`, String)) == v"1.13" @test parse(VersionNumber, read(`$(Base.julia_cmd()) --project=$(joinpath(explicit_env, "VersionedDep2")) $syntax_v...
test/loading.jl
26
Julia
0.214
suggestion
77
34
37
false
Skip syntax check in require_stdlib. Add test. Update stdlib manifest
60,791
JuliaLang/julia
35,573
Julia
IanButterworth
IanButterworth
Review this pull request change. Language: Julia File: test/loading.jl PR Title: Skip syntax check in require_stdlib. Add test. Update stdlib manifest BEFORE CODE: @test invokelatest(getglobal, (@eval (using VersionedDep1; VersionedDep1)), :ver) == v"1.13" # syntax.julia_version from Manifest = "1.1...
Just realized this test needs to monitor stderr. This doesn't currently 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.
typevar_names, field_names, field_types) if inner_rewritten === doc_func return ex end result = _emit_decls_with_rewritten(ctx, ex, decl_kind, func_ex, inner_rewritten) return result !== nothing ? result : in...
```suggestion function rewrite_new_calls(ctx, ex, struct_name, global_struct_name, typevar_names, field_names, field_types) if kind(ex) == K"doc" docs = ex[1] ex = ex[2] else docs = nothing end if kind(ex) in KSet"global local" stmts = SyntaxL...
# or in the case of splatnew this is enforced by the runtime. typemax(Int) else numchildren(ex) - 1 end elseif !is_leaf(ex) minimum((_constructor_min_initialized(e) for e in children(ex)), init=typemax(Int)) else typemax(Int) end end # Let...
JuliaLowering/src/desugaring.jl
26
Julia
1
refactor
1,369
51
51
false
[JuliaLowering] Fix `new()` in global/local functions inside struct
60,793
JuliaLang/julia
35,573
Julia
mlechu
aviatesk
Review this pull request change. Language: Julia File: JuliaLowering/src/desugaring.jl PR Title: [JuliaLowering] Fix `new()` in global/local functions inside struct BEFORE CODE: typevar_names, field_names, field_types) if inner_rewritten === doc_func ...
```suggestion function rewrite_new_calls(ctx, ex, struct_name, global_struct_name, typevar_names, field_names, field_types) if kind(ex) == K"doc" docs = ex[1] ex = ex[2] else docs = nothing end if kind(ex) in KSet"global local" stmts = SyntaxL...
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.
- `bail_out_apply(::AbstractInterpreter, rt, ::InferenceState)`: bail out from `_apply_iterate` inference when return type `rt` grows up to `Any` It also bails out from local statement/frame inference when any lattice element gets down to `Bottom`, but `AbstractInterpreter` doesn't provide a specific interface for c...
style nit: Don't make code unnecessarily slow and complicated for no reason ```suggestion localcache::InferenceCache ```
`_apply_iterate` inference when return type `rt` grows up to `Any` It also bails out from local statement/frame inference when any lattice element gets down to `Bottom`, but `AbstractInterpreter` doesn't provide a specific interface for configuring it. """ function bail_out_toplevel_call end, function bail_out_call ...
@@ -509,16 +549,34 @@ typeinf_lattice(::AbstractInterpreter) = InferenceLattice(BaseInferenceLattice.i ipo_lattice(::AbstractInterpreter) = InferenceLattice(IPOResultLattice.instance) optimizer_lattice(::AbstractInterpreter) = SimpleInferenceLattice.instance -struct OverlayCodeCache{Cache} +struct OverlayCodeCache{...
Compiler/src/types.jl
26
Julia
0.714
performance
127
51
51
false
Use dictionary instead of linear search for the local cache.
60,795
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: Julia File: Compiler/src/types.jl PR Title: Use dictionary instead of linear search for the local cache. BEFORE CODE: - `bail_out_apply(::AbstractInterpreter, rt, ::InferenceState)`: bail out from `_apply_iterate` inference when return type `rt` grows up to `Any` It als...
style nit: Don't make code unnecessarily slow and complicated for no reason ```suggestion localcache::InferenceCache ```
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.
while (value == -1 && m->parent != m && m != jl_base_module) { m = m->parent; value = m->max_methods; } return value; } JL_DLLEXPORT void jl_set_istopmod(jl_module_t *self, uint8_t isprimary) { self->istopmod = 1; if (isprimary) { jl_top_module = self; } } JL_DLLEXPORT ...
nit: slightly more canonical form? ```suggestion jl_set_typetagof(g, jl_globalref_tag, 0); ```
while (value == -1 && m->parent != m && m != jl_base_module) { m = m->parent; value = m->max_methods; } return value; } JL_DLLEXPORT void jl_set_istopmod(jl_module_t *self, uint8_t isprimary) { self->istopmod = 1; if (isprimary) { jl_top_module = self; } } JL_DLLEXPORT ...
@@ -776,6 +776,8 @@ static jl_globalref_t *jl_new_globalref(jl_module_t *mod, jl_sym_t *name, jl_bin { jl_task_t *ct = jl_current_task; jl_globalref_t *g = (jl_globalref_t*)jl_gc_alloc(ct->ptls, sizeof(jl_globalref_t), jl_globalref_type); + if (jl_globalref_type->smalltag) + jl_set_typetagof(g, jl_...
src/module.c
26
C
0.714
suggestion
98
51
51
false
Compiler: add smalltags for IR node types and optimize _useref_getindex
60,831
JuliaLang/julia
35,573
Julia
vtjnash
gbaraldi
Review this pull request change. Language: C File: src/module.c PR Title: Compiler: add smalltags for IR node types and optimize _useref_getindex BEFORE CODE: while (value == -1 && m->parent != m && m != jl_base_module) { m = m->parent; value = m->max_methods; } return value; } JL_DLLEX...
nit: slightly more canonical form? ```suggestion jl_set_typetagof(g, jl_globalref_tag, 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.
1:3 ``` See also [`reshape`](@ref), [`dropdims`](@ref). """ vec(a::AbstractArray) = reshape(a,length(a)) vec(a::AbstractVector) = a _sub(::Tuple{}, ::Tuple{}) = () _sub(t::Tuple, ::Tuple{}) = t _sub(t::Tuple, s::Tuple) = _sub(tail(t), tail(s)) """ dropdims(A; dims) Return an array with the same data as `A`, but...
```suggestion Inverse of [`insertdims`](@ref). ```
1:3 ``` See also [`reshape`](@ref), [`dropdims`](@ref). """ vec(a::AbstractArray) = reshape(a,length(a)) vec(a::AbstractVector) = a _sub(::Tuple{}, ::Tuple{}) = () _sub(t::Tuple, ::Tuple{}) = t _sub(t::Tuple, s::Tuple) = _sub(tail(t), tail(s)) """ dropdims(A; dims) Return an array with the same data as `A`, but...
@@ -49,13 +49,16 @@ _sub(t::Tuple, s::Tuple) = _sub(tail(t), tail(s)) dropdims(A; dims) Return an array with the same data as `A`, but with the dimensions specified by -`dims` removed. `size(A,d)` must equal 1 for every `d` in `dims`, -and repeated dimensions or numbers outside `1:ndims(A)` are forbidden. +`dim...
base/abstractarraymath.jl
26
Julia
0.571
suggestion
52
51
51
false
Improve `insertdims` & `dropdims` docstrings
60,833
JuliaLang/julia
35,573
Julia
fingolfin
fingolfin
Review this pull request change. Language: Julia File: base/abstractarraymath.jl PR Title: Improve `insertdims` & `dropdims` docstrings BEFORE CODE: 1:3 ``` See also [`reshape`](@ref), [`dropdims`](@ref). """ vec(a::AbstractArray) = reshape(a,length(a)) vec(a::AbstractVector) = a _sub(::Tuple{}, ::Tuple{}) = () _...
```suggestion Inverse of [`insertdims`](@ref). ```
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 TestDownload using Test mktempdir() do temp_dir try download("https://httpbin.julialang.org") global url = "https://httpbin.julialang.org" catch global url = "https://httpbin.org" end # Downlo...
```suggestion url = try download("https://httpbin.julialang.org") "https://httpbin.julialang.org" catch "https://httpbin.org" end ``` Is `global` necessary?
# This file is a part of Julia. License is MIT: https://julialang.org/license module TestDownload using Test mktempdir() do temp_dir url = try download("https://httpbingo.julialang.org") "https://httpbingo.julialang.org" catch ex bt = catch_backtrace() @info "Looks like there ...
@@ -5,22 +5,28 @@ module TestDownload using Test mktempdir() do temp_dir + try + download("https://httpbin.julialang.org") + global url = "https://httpbin.julialang.org" + catch + global url = "https://httpbin.org" + end
test/download_exec.jl
13
Julia
0.714
question
192
38
38
false
Test suite: switch to `httpbingo.julialang`, fall back to `httpbin.julialang` on failure
60,834
JuliaLang/julia
35,573
Julia
giordano
rokke-git
Review this pull request change. Language: Julia File: test/download_exec.jl PR Title: Test suite: switch to `httpbingo.julialang`, fall back to `httpbin.julialang` on failure BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license module TestDownload using Test mktempdir() do ...
```suggestion url = try download("https://httpbin.julialang.org") "https://httpbin.julialang.org" catch "https://httpbin.org" end ``` Is `global` necessary?
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 TestDownload using Test mktempdir() do temp_dir url = try download("https://httpbin.julialang.org") "https://httpbin.julialang.org" catch "https://httpbin.org" end # Download a file file =...
```suggestion "https://httpbingo.org" ```
# This file is a part of Julia. License is MIT: https://julialang.org/license module TestDownload using Test mktempdir() do temp_dir url = try download("https://httpbingo.julialang.org") "https://httpbingo.julialang.org" catch ex bt = catch_backtrace() @info "Looks like there ...
@@ -5,22 +5,28 @@ module TestDownload using Test mktempdir() do temp_dir + url = try + download("https://httpbin.julialang.org") + "https://httpbin.julialang.org" + catch + "https://httpbin.org"
test/download_exec.jl
12
Julia
0.429
suggestion
49
37
37
false
Test suite: switch to `httpbingo.julialang`, fall back to `httpbin.julialang` on failure
60,834
JuliaLang/julia
35,573
Julia
inkydragon
rokke-git
Review this pull request change. Language: Julia File: test/download_exec.jl PR Title: Test suite: switch to `httpbingo.julialang`, fall back to `httpbin.julialang` on failure BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license module TestDownload using Test mktempdir() do ...
```suggestion "https://httpbingo.org" ```
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 TestDownload using Test mktempdir() do temp_dir url = try download("https://httpbin.julialang.org") "https://httpbin.julialang.org" catch "https://httpbingo.julialang.org/" end # Download a fi...
```suggestion catch ex bt = catch_backtrace() @info "Looks like there is a problem with a JuliaLang mirror of httpbin(go)" exception=(ex,bt) "https://httpbingo.julialang.org/" ```
# This file is a part of Julia. License is MIT: https://julialang.org/license module TestDownload using Test mktempdir() do temp_dir url = try download("https://httpbingo.julialang.org") "https://httpbingo.julialang.org" catch ex bt = catch_backtrace() @info "Looks like there ...
@@ -5,22 +5,28 @@ module TestDownload using Test mktempdir() do temp_dir + url = try + download("https://httpbin.julialang.org") + "https://httpbin.julialang.org" + catch + "https://httpbingo.julialang.org/"
test/download_exec.jl
12
Julia
0.929
suggestion
212
37
37
false
Test suite: switch to `httpbingo.julialang`, fall back to `httpbin.julialang` on failure
60,834
JuliaLang/julia
35,573
Julia
DilumAluthge
rokke-git
Review this pull request change. Language: Julia File: test/download_exec.jl PR Title: Test suite: switch to `httpbingo.julialang`, fall back to `httpbin.julialang` on failure BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license module TestDownload using Test mktempdir() do ...
```suggestion catch ex bt = catch_backtrace() @info "Looks like there is a problem with a JuliaLang mirror of httpbin(go)" exception=(ex,bt) "https://httpbingo.julialang.org/" ```
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 TestDownload using Test mktempdir() do temp_dir url = try download("https://httpbin.julialang.org") "https://httpbin.julialang.org" catch ex bt = catch_backtrace() @info "Looks like there is a...
Let's start with `httpbingo`, and then fall back to `httpbin`. ```suggestion url = try download("https://httpbingo.julialang.org") "https://httpbingo.julialang.org" catch ex bt = catch_backtrace() @info "Looks like there is a problem with a JuliaLang mirror of httpbingo"...
# This file is a part of Julia. License is MIT: https://julialang.org/license module TestDownload using Test mktempdir() do temp_dir url = try download("https://httpbingo.julialang.org") "https://httpbingo.julialang.org" catch ex bt = catch_backtrace() @info "Looks like there ...
@@ -5,22 +5,31 @@ module TestDownload using Test mktempdir() do temp_dir + url = try + download("https://httpbin.julialang.org") + "https://httpbin.julialang.org" + catch ex + bt = catch_backtrace() + @info "Looks like there is a problem with a JuliaLang mirror of httpbin." + ...
test/download_exec.jl
16
Julia
0.929
suggestion
426
41
41
false
Test suite: switch to `httpbingo.julialang`, fall back to `httpbin.julialang` on failure
60,834
JuliaLang/julia
35,573
Julia
DilumAluthge
rokke-git
Review this pull request change. Language: Julia File: test/download_exec.jl PR Title: Test suite: switch to `httpbingo.julialang`, fall back to `httpbin.julialang` on failure BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license module TestDownload using Test mktempdir() do ...
Let's start with `httpbingo`, and then fall back to `httpbin`. ```suggestion url = try download("https://httpbingo.julialang.org") "https://httpbingo.julialang.org" catch ex bt = catch_backtrace() @info "Looks like there is a problem with a JuliaLang mirror of httpbingo"...
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.
exit_on_error::Bool=false, revise::Bool=false, propagate_project::Bool=false, seed::Union{BitInteger,Nothing}=nothing, julia_args::Cmd=``) if isa(tests,AbstractString) tests = split(tests) end exit_on_error && ...
```suggestion vinfo = read(setenv(`$(julia_cmd()) -e 'let InteractiveUtils = Base.require_stdlib(Base.PkgId(Base.UUID(0xb77e0a4c_d291_57a0_90e8_8db25a27a240), "InteractiveUtils")); @invokelatest(InteractiveUtils.versioninfo()); end'`, ENV2), String) ```
exit_on_error::Bool=false, revise::Bool=false, propagate_project::Bool=false, seed::Union{BitInteger,Nothing}=nothing, julia_args::Cmd=``) if isa(tests,AbstractString) tests = split(tests) end exit_on_error && ...
@@ -719,12 +719,16 @@ function runtests(tests = ["all"]; ncores::Int = ceil(Int, Sys.EFFECTIVE_CPU_THR Base.DATAROOTDIR, "julia", "test", "runtests.jl")) $tests`, ENV2)) nothing catch - buf = PipeBuffer() - let InteractiveUtils = Base.require_stdlib(PkgId(UUID(0xb77e0a4c_d291_57...
base/util.jl
26
Julia
0.786
suggestion
262
46
46
false
Clean up Base.runtests failure print
60,837
JuliaLang/julia
35,573
Julia
IanButterworth
IanButterworth
Review this pull request change. Language: Julia File: base/util.jl PR Title: Clean up Base.runtests failure print BEFORE CODE: exit_on_error::Bool=false, revise::Bool=false, propagate_project::Bool=false, seed::Union{BitInteger,Nothing}=nothin...
```suggestion vinfo = read(setenv(`$(julia_cmd()) -e 'let InteractiveUtils = Base.require_stdlib(Base.PkgId(Base.UUID(0xb77e0a4c_d291_57a0_90e8_8db25a27a240), "InteractiveUtils")); @invokelatest(InteractiveUtils.versioninfo()); end'`, ENV2), 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.
function provenance(ex::SyntaxTree) s = ex.source if s isa NodeId return (SyntaxTree(ex._graph, s),) elseif s isa Tuple return SyntaxTree.((ex._graph,), s) else return (s,) end end function _sourceref(sources, id) i = 1 while true i += 1 s = sources[i...
Should we try using `Dict{NodeId}` in more places? Right now I believe we're using `Dict{Any, Any}` (inside the `Dict{Symbol, X}`) everywhere. Not sure it would change much.
function provenance(ex::SyntaxTree) s = ex.source if s isa NodeId return (SyntaxTree(ex._graph, s),) elseif s isa Tuple return SyntaxTree.((ex._graph,), s) else return (s,) end end function _sourceref(sources, id) i = 1 while true i += 1 s = sources[i...
@@ -371,8 +370,8 @@ function _sourceref(sources, id) end function sourceref(ex::SyntaxTree) - sources = ex._graph.source - id::NodeId = ex._id + sources = ex._graph.source::Dict{NodeId}
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.571
question
174
51
51
false
[JuliaSyntax] improve type stability of `SyntaxTree` query APIs
60,851
JuliaLang/julia
35,573
Julia
mlechu
aviatesk
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: [JuliaSyntax] improve type stability of `SyntaxTree` query APIs BEFORE CODE: function provenance(ex::SyntaxTree) s = ex.source if s isa NodeId return (SyntaxTree(ex._graph, s),) elseif s is...
Should we try using `Dict{NodeId}` in more places? Right now I believe we're using `Dict{Any, Any}` (inside the `Dict{Symbol, X}`) everywhere. Not sure it would change much.
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.
"|(&\nfunction" => "(call | (& (function (error (error)) (block (error)) (error-t))) (error-t))" "@(" => "(macrocall (macro_name (parens (error-t))))" "x = @(" => "(= x (macrocall (macro_name (parens (error-t)))))" "function(where" => "(function (tuple-p where (error-t)) (block (error)) (error-t))" ...
I think we should disallow this one in 1.14 syntax - needs to work in 1.13 syntax of course, but i think it's too confusing otherwise and we may want it for more complicated labels in the future.
((v=v"1.14",), "break f()") => "(break f (error-t) (tuple-p))" ((v=v"1.14",), "continue _") => "(continue _)" ((v=v"1.14",), "continue label") => "(continue label)" ((v=v"1.14",), "break +") => "(break (error-t +))" ((v=v"1.14",), "a[break label end]") => "(ref a (break label end))" ...
@@ -1127,6 +1133,13 @@ parsestmt_test_specs = [ # unit tests there. "''" => "(char (error))" + # break / continue with trailing tokens are legal in some cases + "a ? break : c" => "(? a (break) c)" + "begin break end" => "(block (break))" + "a ? continue : c" => "(? a (continue) c)" + "...
JuliaSyntax/test/parser.jl
26
Julia
0.429
suggestion
195
51
51
false
Fixes for `break label` and `continue label` parsing
60,910
JuliaLang/julia
35,573
Julia
Keno
c42f
Review this pull request change. Language: Julia File: JuliaSyntax/test/parser.jl PR Title: Fixes for `break label` and `continue label` parsing BEFORE CODE: "|(&\nfunction" => "(call | (& (function (error (error)) (block (error)) (error-t))) (error-t))" "@(" => "(macrocall (macro_name (parens (error-t))))"...
I think we should disallow this one in 1.14 syntax - needs to work in 1.13 syntax of course, but i think it's too confusing otherwise and we may want it for more complicated labels in the future.
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 !global_assigned end @testset "soft scope isn't top level" begin ex = quote begin for i in 1:1; global soft_assigned_explicit_global = 1; end for i in 1:1; soft_assigned_explicit_global = 2; end end end expr_eval(test...
Might be nice to encode these skip / error cases into `results`, but pretty orthogonal to this PR
(true, decls_neutral, wrap_none, wrap_neutral) => (true,true), (true, decls_none, wrap_hard, wrap_func ) => (true,false), (true, decls_none, wrap_hard, wrap_hard ) => (true,false), (true, decls_none, wrap_hard, wrap_neutral) => (true,false), (true, d...
@@ -147,85 +147,136 @@ end # Switch to Core.eval for sanity-checking expr_eval(mod, ex) = JuliaLowering.eval(mod, ex) -enable_softscope(e) = Expr(:block, Expr(:softscope, true), e) -inner_neutral(e) = :(for _ in 1:1; $e; end) -inner_func(e) = :((function (); $e end)(#=called=#)) -inner_hard(e) = :(let; $e end) - -o...
JuliaLowering/test/scopes.jl
26
Julia
0.5
suggestion
97
51
51
false
[JuliaLowering] Fix soft scope semantics leaking through hard scope
60,917
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/test/scopes.jl PR Title: [JuliaLowering] Fix soft scope semantics leaking through hard scope BEFORE CODE: @test !global_assigned end @testset "soft scope isn't top level" begin ex = quote begin ...
Might be nice to encode these skip / error cases into `results`, but pretty orthogonal to this PR
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->prefer_specsig == b->prefer_specsig) && (a->gnu_pubnames == b->gnu_pubnames) && (a->debug_info_kind == b->debug_info_kind) && (a->safepoint_on_entry == b->safepoint_on_entry) && (a->gcstack_arg == b->gcstack_arg) && (a->use_jlplt == b->use_jlplt) && ...
fixme: this probably shouldn't be hard coded
(a->prefer_specsig == b->prefer_specsig) && (a->gnu_pubnames == b->gnu_pubnames) && (a->debug_info_kind == b->debug_info_kind) && (a->safepoint_on_entry == b->safepoint_on_entry) && (a->gcstack_arg == b->gcstack_arg) && (a->use_jlplt == b->use_jlplt) && ...
@@ -4681,18 +4725,37 @@ static int compare_cgparams(const jl_cgparams_t *a, const jl_cgparams_t *b) } #endif -static auto *emit_genericmemory_unchecked(jl_codectx_t &ctx, Value *cg_nbytes, Value *cg_typ) +// Emit allocation for variable-length GenericMemory +// If zeroinit_nbytes is non-null, adds a zeroinit_indire...
src/cgutils.cpp
26
C++
0.143
suggestion
44
51
51
false
codegen: Move GC pointer zeroing to late-gc-lowering
60,924
JuliaLang/julia
35,573
Julia
gbaraldi
gbaraldi
Review this pull request change. Language: C++ File: src/cgutils.cpp PR Title: codegen: Move GC pointer zeroing to late-gc-lowering BEFORE CODE: (a->prefer_specsig == b->prefer_specsig) && (a->gnu_pubnames == b->gnu_pubnames) && (a->debug_info_kind == b->debug_info_kind) && ...
fixme: this probably shouldn't be hard coded
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: metas is_literal(k) || is_identifier_like(ex) || k == K"Symbol" || k == K"inert" || k == K"inert_syntaxtree" || k == K"top" || k == K"core" || k == K"Value" # flisp also includes `a.b` with simple `a`, but this seems like a bug # because this calls the user-defined getproperty? e...
Looks reasonable. Hopefully it's not a problem to have a *lot* of scope layers... they are lighter than `BindingInfo` though so I guess it's fine! It would be nice to ensure these never end up global "by mistake" in the same way that macro expanded identifiers skip accidentally becoming global by the use of the is_mac...
# TODO: metas is_literal(k) || is_identifier_like(ex) || k == K"Symbol" || k == K"inert" || k == K"inert_syntaxtree" || k == K"top" || k == K"core" || k == K"Value" # flisp also includes `a.b` with simple `a`, but this seems like a bug # because this calls the user-defined getproperty? e...
@@ -93,6 +93,13 @@ function check_no_assignment(exs, msg="misplaced assignment statement in `[ ... end end +# Generating a new_local_binding or ssaval should only be done if we can +# guarantee there's some scope it's declared in, and that it's not declared or +# used outside of that scope (binding capture is O...
JuliaLowering/src/desugaring.jl
26
Julia
0.643
suggestion
562
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/desugaring.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: # TODO: metas is_literal(k) || is_identifier_like(ex) || k == K"Symbol" || k == K"inert" || k == K"inert_syntaxtree" || k...
Looks reasonable. Hopefully it's not a problem to have a *lot* of scope layers... they are lighter than `BindingInfo` though so I guess it's fine! It would be nice to ensure these never end up global "by mistake" in the same way that macro expanded identifiers skip accidentally becoming global by the use of the is_mac...
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.
kwcall_arg_names, kwcall_arg_types, first_default, arg_defaults) end positional_forwarding_args = if has_slurp a = copy(arg_names) a[end] = @ast ctx a[end] [K"..." a[end]] a else arg_names end #--------------------------------------...
Why the mutating variant? In general I feel we should avoid expression mutation in lowering if possible outside of utilities in ast.jl. Yes, even in trivial/local cases because using mutation just makes everything harder to reason about. I see there's quite a lot now... Can we do less of it, not more? If it's just a...
optional_positional_defs!(ctx, kwcall_method_defs, srcref, callex_srcref, kwcall_mtable, typevar_names, typevar_stmts, kwcall_arg_names, kwcall_arg_types, first_default, arg_defaults) end positional_forwarding_args = if has_slurp ...
@@ -2758,7 +2757,8 @@ function keyword_function_defs(ctx, srcref, callex_srcref, name_str, typevar_nam for n in kw_names # If not using slots for the keyword argument values, still declare # them for reflection purposes. - push!(kw_val_stmts, @ast ctx n [K"local"(meta=Compi...
JuliaLowering/src/desugaring.jl
26
Julia
0.643
refactor
446
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/desugaring.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: kwcall_arg_names, kwcall_arg_types, first_default, arg_defaults) end positional_forwarding_arg...
Why the mutating variant? In general I feel we should avoid expression mutation in lowering if possible outside of utilities in ast.jl. Yes, even in trivial/local cases because using mutation just makes everything harder to reason about. I see there's quite a lot now... Can we do less of it, not more? If it's just 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.
end top_scope(ctx) = ctx.scopes[1] is_top_scope(scope::ScopeInfo) = scope.parent_id === 0 enclosing_lambda(ctx, scope::ScopeInfo) = ctx.scopes[scope.lambda_id] parent(ctx, scope::ScopeInfo) = is_top_scope(scope) ? nothing : ctx.scopes[scope.parent_id] _var_str(v) = v === :local ? "local variable" : v === :glo...
I assume this would be an internal error in lowering?
top_scope(ctx) = ctx.scopes[1] is_top_scope(scope::ScopeInfo) = scope.parent_id === 0 enclosing_lambda(ctx, scope::ScopeInfo) = ctx.scopes[scope.lambda_id] parent(ctx, scope::ScopeInfo) = is_top_scope(scope) ? nothing : ctx.scopes[scope.parent_id] _var_str(v) = v === :local ? "local variable" : v === :global ...
@@ -113,8 +126,12 @@ _var_str(v) = v === :local ? "local variable" : function maybe_declare_in_scope!(ctx, scope::ScopeInfo, ex, new_k::Symbol) if kind(ex) === K"BindingId" bid = ex.var_id - @assert get_binding(ctx, bid).kind === new_k - record_lambda_var!(ctx, scope, get_binding(ctx, bid),...
JuliaLowering/src/scope_analysis.jl
26
Julia
0.357
question
53
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/scope_analysis.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: end top_scope(ctx) = ctx.scopes[1] is_top_scope(scope::ScopeInfo) = scope.parent_id === 0 enclosing_lambda(ctx, scope::ScopeInfo) = ...
I assume this would be an internal error in lowering?
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 elseif old_k === new_k (new_k === :global || new_k === :local) && return bid throw(LoweringError(ex, "function $(_var_str(new_k)) name not unique")) # See note in test/scopes.jl: "globals may overlap args or sparams" # elseif new_k === :global && old_k in (:argument, :static_para...
Looks reasonable. It could also be ok or maybe good to have an extra flag on `ScopeLayer` for `is_internal`. A bit like a "light" version of `BindingInfo`.
elseif old_k === new_k (new_k === :global || new_k === :local) && return bid throw(LoweringError(ex, "function $(_var_str(new_k)) name not unique")) # See note in test/scopes.jl: "globals may overlap args or sparams" # elseif new_k === :global && old_k in (:argument, :static_parameter) #...
@@ -152,29 +169,38 @@ function declare_in_scope!(ctx, scope::ScopeInfo, ex, bk::Symbol; kws...) declaration_scope = scope mod = nothing end - b = _new_binding(ctx, ex, nk.name, bk; mod, kws...) + b = _new_binding(ctx, ex, nk.name, bk; + mod, is_internal=getmeta(ex, :is_i...
JuliaLowering/src/scope_analysis.jl
26
Julia
0.571
suggestion
155
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/scope_analysis.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: end elseif old_k === new_k (new_k === :global || new_k === :local) && return bid throw(LoweringError(ex, ...
Looks reasonable. It could also be ok or maybe good to have an extra flag on `ScopeLayer` for `is_internal`. A bit like a "light" version of `BindingInfo`.
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.
lam.locals_capt[b.id] = false b.lambda_id = lam.id nothing end function ensure_captured!(ctx, scope::ScopeInfo, b) if b.kind === :global || b.is_ssa return end lam = enclosing_lambda(ctx, scope) if !haskey(lam.locals_capt, b.id) b.is_captured = true lam.locals_capt[b...
Sure, could easily have a lazily filled cache on the scope if we find it helps performance.
b.lambda_id = lam.id nothing end function ensure_captured!(ctx, scope::ScopeInfo, b) if b.kind === :global || b.is_ssa return end lam = enclosing_lambda(ctx, scope) if !haskey(lam.locals_capt, b.id) b.is_captured = true lam.locals_capt[b.id] = true s2 = parent(ct...
@@ -183,6 +209,7 @@ function needs_resolution(ex) end function resolve_name(ctx, ex; exclude_toplevel_globals=false) + # TODO: probably want to cache these lookups
JuliaLowering/src/scope_analysis.jl
26
Julia
0.429
performance
91
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/scope_analysis.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: lam.locals_capt[b.id] = false b.lambda_id = lam.id nothing end function ensure_captured!(ctx, scope::ScopeInfo, b) i...
Sure, could easily have a lazily filled cache on the scope if we find it helps performance.
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.
6 (isdefined slot₁/y) 7 (gotoifnot %₆ label₁₀) 8 slot₁/y 9 (call top.setindex! %₅ %₈ :y) 10 (return %₅) ######################################## # @locals with function args (TODO: static parameters) function f(z) @locals end #--------------------- 1 (method TestMod.f) 2 latestworld 3 TestMod.f 4 ...
`@locals` should not (or currently does not, in flisp) include internal names so I think this is a bug.
6 (isdefined slot₁/y) 7 (gotoifnot %₆ label₁₀) 8 slot₁/y 9 (call top.setindex! %₅ %₈ :y) 10 (return %₅) ######################################## # @locals with function args (TODO: static parameters) function f(z) @locals end #--------------------- 1 (method TestMod.f) 2 latestworld 3 TestMod.f 4 ...
@@ -199,12 +199,14 @@ end 7 SourceLocation::1:10 8 (call core.svec %₅ %₆ %₇) 9 --- method core.nothing %₈ - slots: [slot₁/#self#(!read) slot₂/z] + slots: [slot₁/#self# slot₂/z] 1 (call core.apply_type top.Dict core.Symbol core.Any) 2 (call %₁) 3 (gotoifnot true label₅) - 4 (call...
JuliaLowering/test/scopes_ir.jl
26
Julia
0.714
bug
103
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/test/scopes_ir.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: 6 (isdefined slot₁/y) 7 (gotoifnot %₆ label₁₀) 8 slot₁/y 9 (call top.setindex! %₅ %₈ :y) 10 (return %₅) #######################...
`@locals` should not (or currently does not, in flisp) include internal names so I think this is a bug.
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 inner(x::T)::Tuple{T, Vector{T}} where T (x,T[x]) end inner(a) end f_inner_rt_sp(1), f_inner_rt_sp("foo") end """) == ((1, [1]), ("foo", ["foo"])) @test JuliaLowering.include_string(test_mod, """ begin function f_many_closure_sp() function (); function (...
I don't expect this test to work: the `T` is not a typevar which is in scope for the inner closure, it's just a part of the `UnionAll` definition? Did you mean to use `f_many_closure_sp_capt(x::T) where T` ?
function inner(x::T)::Tuple{T, Vector{T}} where T (x,T[x]) end inner(a) end f_inner_rt_sp(1), f_inner_rt_sp("foo") end """) == ((1, [1]), ("foo", ["foo"])) @test JuliaLowering.include_string(test_mod, """ begin function f_many_closure_sp() function (); function (...
@@ -472,6 +472,81 @@ end @test_throws UndefVarError test_mod.f_undef_static_param(nothing)() @test test_mod.f_undef_static_param(42)() == Int +@test JuliaLowering.include_string(test_mod, """ +begin + function f_inner_sp(x::T) where T + function inner(y::U) where U + (T, U) + end + ...
JuliaLowering/test/closures.jl
26
Julia
0.786
question
208
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/test/closures.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: function inner(x::T)::Tuple{T, Vector{T}} where T (x,T[x]) end inner(a) end f_inner_rt_sp(1), ...
I don't expect this test to work: the `T` is not a typevar which is in scope for the inner closure, it's just a part of the `UnionAll` definition? Did you mean to use `f_many_closure_sp_capt(x::T) where T` ?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@test JuliaLowering.include_string(test_mod, """ begin function f_many_closure_sp() function (); function (); function (x::T) where T; (x, T) end; end; end end f_many_closure_sp()()()(1) end """) == (1, Int) @test_broken JuliaLowering.include_string(test_mod, """ begin function f_many_closure_s...
This one seems to be a bug, yes. I thought I tried to make this work. But maybe I'm just remembering reading the flisp code which goes to extra lengths to get selected cases working when inner method declarations depend on static parameters from the outer function. If I remember flisp makes this work by making the ty...
@test JuliaLowering.include_string(test_mod, """ begin function f_many_closure_sp() function (); function (); function (x::T) where T; (x, T) end; end; end end f_many_closure_sp()()()(1) end """) == (1, Int) @test JuliaLowering.include_string(test_mod, """ begin function f_many_closure_sp_capt(...
@@ -472,6 +472,81 @@ end @test_throws UndefVarError test_mod.f_undef_static_param(nothing)() @test test_mod.f_undef_static_param(42)() == Int +@test JuliaLowering.include_string(test_mod, """ +begin + function f_inner_sp(x::T) where T + function inner(y::U) where U + (T, U) + end + ...
JuliaLowering/test/closures.jl
26
Julia
0.714
bug
351
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/test/closures.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: @test JuliaLowering.include_string(test_mod, """ begin function f_many_closure_sp() function (); function (); function (x::T) ...
This one seems to be a bug, yes. I thought I tried to make this work. But maybe I'm just remembering reading the flisp code which goes to extra lengths to get selected cases working when inner method declarations depend on static parameters from the outer function. If I remember flisp makes this work by making the ty...
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 f_many_closure_sp() function (); function (); function (x::T) where T; (x, T) end; end; end end f_many_closure_sp()()()(1) end """) == (1, Int) @test_broken JuliaLowering.include_string(test_mod, """ begin function f_many_closure_sp_capt(x::T where T) function (); function (); ...
```suggestion # Inner method typevar `U` depending on a static parameter `T` so hoisting the method def # for `inner` out to top level would require detecting this and making `inner` parametric on `T`. # Note this doesn't work in flisp either ```
function f_many_closure_sp() function (); function (); function (x::T) where T; (x, T) end; end; end end f_many_closure_sp()()()(1) end """) == (1, Int) @test JuliaLowering.include_string(test_mod, """ begin function f_many_closure_sp_capt(x::T) where T function (); function (); functio...
@@ -472,6 +472,81 @@ end @test_throws UndefVarError test_mod.f_undef_static_param(nothing)() @test test_mod.f_undef_static_param(42)() == Int +@test JuliaLowering.include_string(test_mod, """ +begin + function f_inner_sp(x::T) where T + function inner(y::U) where U + (T, U) + end + ...
JuliaLowering/test/closures.jl
26
Julia
0.929
suggestion
246
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/test/closures.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: function f_many_closure_sp() function (); function (); function (x::T) where T; (x, T) end; end; end end f_many_closur...
```suggestion # Inner method typevar `U` depending on a static parameter `T` so hoisting the method def # for `inner` out to top level would require detecting this and making `inner` parametric on `T`. # Note this doesn't work in flisp 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.
######################################## # Error: ccall with too many arguments ccall(:strlen, Csize_t, (Cstring,), "asdfg", "blah") #--------------------- LoweringError: ccall(:strlen, Csize_t, (Cstring,), "asdfg", "blah") └──────────────────────────────────────────────────┘ ── More arguments than types in ccall ####...
```suggestion # cglobal special support for (sym, lib) tuple # unlike flisp we outline the tuple and allow constant propgation to put it back # before codegen generates code for `cglobal` ```
######################################## # Error: ccall with too many arguments ccall(:strlen, Csize_t, (Cstring,), "asdfg", "blah") #--------------------- LoweringError: ccall(:strlen, Csize_t, (Cstring,), "asdfg", "blah") └──────────────────────────────────────────────────┘ ── More arguments than types in ccall ####...
@@ -502,9 +502,11 @@ ccall(:foo, Csize_t, (Cstring..., Cstring...), "asdfg", "blah") # cglobal special support for (sym, lib) tuple
JuliaLowering/test/function_calls_ir.jl
26
Julia
0.714
suggestion
191
51
51
false
[JuliaLowering] Make locals introduced in `K"method_defs"` top-level
60,942
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/test/function_calls_ir.jl PR Title: [JuliaLowering] Make locals introduced in `K"method_defs"` top-level BEFORE CODE: ######################################## # Error: ccall with too many arguments ccall(:strlen, Csize_t, (Cstring,), "asdfg", "bla...
```suggestion # cglobal special support for (sym, lib) tuple # unlike flisp we outline the tuple and allow constant propgation to put it back # before codegen generates code for `cglobal` ```
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 *bp = julia_binding_gv(ctx, bnd); Value *v = ctx.builder.CreateCall(prepare_call(jlgetbindingvalue_func), { bp }); undef_var_error_ifnot(ctx, ctx.builder.CreateIsNotNull(v), name, (jl_value_t*)mod); return mark_julia_type(ctx, v, true, jl_any_type); } static jl_cgval_t emit_globalref(jl_codectx...
```suggestion if (jl_generating_output()) jl_temporary_root(ctx, constval); ```
{ Value *bp = julia_binding_gv(ctx, bnd); Value *v = ctx.builder.CreateCall(prepare_call(jlgetbindingvalue_func), { bp }); undef_var_error_ifnot(ctx, ctx.builder.CreateIsNotNull(v), name, (jl_value_t*)mod); return mark_julia_type(ctx, v, true, jl_any_type); } static jl_cgval_t emit_globalref(jl_codectx...
@@ -3505,6 +3505,8 @@ static jl_cgval_t emit_globalref(jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t * undef_var_error_ifnot(ctx, ConstantInt::get(getInt1Ty(ctx.builder.getContext()), 0), name, (jl_value_t*)mod); return jl_cgval_t(); } + // root is required to allow bindings to...
src/codegen.cpp
26
C++
0.571
suggestion
99
51
51
false
codegen: Mark resolved `const` `GlobalRef` as method root
60,945
JuliaLang/julia
35,573
Julia
vtjnash
topolarity
Review this pull request change. Language: C++ File: src/codegen.cpp PR Title: codegen: Mark resolved `const` `GlobalRef` as method root BEFORE CODE: { Value *bp = julia_binding_gv(ctx, bnd); Value *v = ctx.builder.CreateCall(prepare_call(jlgetbindingvalue_func), { bp }); undef_var_error_ifnot(ctx, ctx....
```suggestion if (jl_generating_output()) jl_temporary_root(ctx, constval); ```
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 setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0, CI0) == fill(1.0) ...
fix the test ```suggestion @test Base.infer_return_type(checkbounds, Tuple{typ, Any}) <: Nothing ```
@test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0, CI0) == fill(1.0) ...
@@ -3256,6 +3256,12 @@ end @test setindex!(zeros(2,2), fill(1.0), CI0, 1, 1) == [1.0 0.0; 0.0 0.0] end +@testset "conditionally-throwing version of `checkbounds` should return `nothing` if it returns" begin + for typ in (AbstractString, DenseArray, Base.AbstractBroadcasted) + @test Base.infer_return_t...
test/arrayops.jl
26
Julia
0.857
suggestion
109
51
51
false
make `checkbounds(collection, indices...)` return `nothing` when returning
60,956
JuliaLang/julia
35,573
Julia
nsajko
nsajko
Review this pull request change. Language: Julia File: test/arrayops.jl PR Title: make `checkbounds(collection, indices...)` return `nothing` when returning BEFORE CODE: @test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(f...
fix the test ```suggestion @test Base.infer_return_type(checkbounds, Tuple{typ, Any}) <: Nothing ```
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> checkbounds(Bool, A, 1:3) true julia> checkbounds(Bool, A, 1:3, 2:4) false ``` """ function checkbounds(::Type{Bool}, A::AbstractArray, I...) @inline checkbounds_indices(Bool, axes(A), I) end # Linear indexing is explicitly allowed when there is only one (non-cartesian) index; # indices that do not all...
Revert doc change. ```suggestion ```
julia> checkbounds(Bool, A, 1:3) true julia> checkbounds(Bool, A, 1:3, 2:4) false ``` """ function checkbounds(::Type{Bool}, A::AbstractArray, I...) @inline checkbounds_indices(Bool, axes(A), I) end # Linear indexing is explicitly allowed when there is only one (non-cartesian) index; # indices that do not all...
@@ -696,6 +696,8 @@ end checkbounds(A, I...) Throw an error if the specified indices `I` are not in bounds for the given array `A`. + +In case there is no throw, it is recommended to return [`nothing`](@ref).
base/abstractarray.jl
26
Julia
0.5
suggestion
37
51
51
false
make `checkbounds(collection, indices...)` return `nothing` when returning
60,956
JuliaLang/julia
35,573
Julia
nsajko
nsajko
Review this pull request change. Language: Julia File: base/abstractarray.jl PR Title: make `checkbounds(collection, indices...)` return `nothing` when returning BEFORE CODE: julia> checkbounds(Bool, A, 1:3) true julia> checkbounds(Bool, A, 1:3, 2:4) false ``` """ function checkbounds(::Type{Bool}, A::AbstractArra...
Revert doc change. ```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.
@test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0, CI0) == fill(1.0) ...
Out of curiosity, why not test something like ``` all(==(...), Base.return_types(checkbounds, Tuple{Any, Any}) ``` ?
@test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0, CI0) == fill(1.0) ...
@@ -3256,6 +3256,12 @@ end @test setindex!(zeros(2,2), fill(1.0), CI0, 1, 1) == [1.0 0.0; 0.0 0.0] end +@testset "conditionally-throwing version of `checkbounds` should return `nothing` if it returns" begin + for typ in (AbstractString, DenseArray, Base.AbstractBroadcasted) + @test Base.infer_return_t...
test/arrayops.jl
26
Julia
0.857
question
118
51
51
false
make `checkbounds(collection, indices...)` return `nothing` when returning
60,956
JuliaLang/julia
35,573
Julia
KristofferC
nsajko
Review this pull request change. Language: Julia File: test/arrayops.jl PR Title: make `checkbounds(collection, indices...)` return `nothing` when returning BEFORE CODE: @test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(f...
Out of curiosity, why not test something like ``` all(==(...), Base.return_types(checkbounds, Tuple{Any, Any}) ``` ?
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 setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0, CI0) == fill(1.0) ...
fix: make the test more strict: ```suggestion @test Base.infer_return_type(checkbounds, Tuple{typ, Vararg}) <: Nothing ```
@test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0, CI0) == fill(1.0) ...
@@ -3256,6 +3256,12 @@ end @test setindex!(zeros(2,2), fill(1.0), CI0, 1, 1) == [1.0 0.0; 0.0 0.0] end +@testset "conditionally-throwing version of `checkbounds` should return `nothing` if it returns" begin + for typ in (AbstractString, DenseArray, Base.AbstractBroadcasted) + @test Base.infer_return_t...
test/arrayops.jl
26
Julia
0.857
suggestion
131
51
51
false
make `checkbounds(collection, indices...)` return `nothing` when returning
60,956
JuliaLang/julia
35,573
Julia
nsajko
nsajko
Review this pull request change. Language: Julia File: test/arrayops.jl PR Title: make `checkbounds(collection, indices...)` return `nothing` when returning BEFORE CODE: @test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(f...
fix: make the test more strict: ```suggestion @test Base.infer_return_type(checkbounds, Tuple{typ, Vararg}) <: Nothing ```
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.
# 0-dimensional @test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0,...
make the test even more strict: ```suggestion for typ in (AbstractString, AbstractArray, Base.AbstractBroadcasted) ```
# 0-dimensional @test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0,...
@@ -3256,6 +3256,12 @@ end @test setindex!(zeros(2,2), fill(1.0), CI0, 1, 1) == [1.0 0.0; 0.0 0.0] end +@testset "conditionally-throwing version of `checkbounds` should return `nothing` if it returns" begin + for typ in (AbstractString, DenseArray, Base.AbstractBroadcasted)
test/arrayops.jl
26
Julia
0.857
refactor
123
51
51
false
make `checkbounds(collection, indices...)` return `nothing` when returning
60,956
JuliaLang/julia
35,573
Julia
nsajko
nsajko
Review this pull request change. Language: Julia File: test/arrayops.jl PR Title: make `checkbounds(collection, indices...)` return `nothing` when returning BEFORE CODE: # 0-dimensional @test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) ...
make the test even more strict: ```suggestion for typ in (AbstractString, AbstractArray, Base.AbstractBroadcasted) ```
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 setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0, CI0) == fill(1.0) ...
```suggestion # can not just set `typ = Any` because that would include the predicate (non-throwing) methods of `checkbounds`, because `Type{Bool} <: Any` for typ in (AbstractString, AbstractArray, Base.AbstractBroadcasted) ```
@test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, :) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), :, CI0, CI0) == fill(1.0) ...
@@ -3256,6 +3256,12 @@ end @test setindex!(zeros(2,2), fill(1.0), CI0, 1, 1) == [1.0 0.0; 0.0 0.0] end +@testset "conditionally-throwing version of `checkbounds` should return `nothing` if it returns" begin + for typ in (AbstractString, AbstractArray, Base.AbstractBroadcasted)
test/arrayops.jl
26
Julia
1
refactor
235
51
51
false
make `checkbounds(collection, indices...)` return `nothing` when returning
60,956
JuliaLang/julia
35,573
Julia
nsajko
nsajko
Review this pull request change. Language: Julia File: test/arrayops.jl PR Title: make `checkbounds(collection, indices...)` return `nothing` when returning BEFORE CODE: @test setindex!(fill(0.0), fill(1.0), CI0) == fill(1.0) @test setindex!(fill(0.0), fill(1.0), CI0, CI0) == fill(1.0) @test setindex!(f...
```suggestion # can not just set `typ = Any` because that would include the predicate (non-throwing) methods of `checkbounds`, because `Type{Bool} <: Any` for typ in (AbstractString, AbstractArray, Base.AbstractBroadcasted) ```
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 ## File Operations (Libuv-based) ## """ JL_O_APPEND JL_O_ASYNC JL_O_CLOEXEC JL_O_CREAT JL_O_DIRECT JL_O_DIRECTORY JL_O_DSYNC JL_O_EXCL JL_O_FSYNC JL_O_LARGEFILE JL_O_NDELAY JL_O_NOATIME JL...
```suggestion # n.b. this file is `Core.eval`-uated into (pre-existing) Base.Filesystem # module Filesystem ```
# This file is a part of Julia. License is MIT: https://julialang.org/license # NB: This file is `Core.eval`-uated into the (pre-existing) module Filesystem ## File Operations (Libuv-based) ## """ JL_O_APPEND JL_O_ASYNC JL_O_CLOEXEC JL_O_CREAT JL_O_DIRECT JL_O_DIRECTORY JL_O_DSYNC JL_...
@@ -2,8 +2,6 @@ ## File Operations (Libuv-based) ##
base/filesystem.jl
6
Julia
0.714
suggestion
111
31
31
false
Feature/change bootstrap to use libdl in pcre
60,967
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: base/filesystem.jl PR Title: Feature/change bootstrap to use libdl in pcre BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license ## File Operations (Libuv-based) ## """ JL_O_APPEND JL_O_ASYNC JL_O_CLOEXEC J...
```suggestion # n.b. this file is `Core.eval`-uated into (pre-existing) Base.Filesystem # module Filesystem ```
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.
include("iobuffer.jl") # Concurrency (part 1) include("linked_list.jl") include("condition.jl") include("threads.jl") include("lock.jl") # strings & printing include("intfuncs.jl") include("strings/strings.jl") #= isdebugbuild is defined here as this is imported in libdl.jl (included in libc.jl) =# """ isdebugbu...
Can we define these "multi-stage" modules in `Base.jl` directly and then `Core.eval` into them anywhere they have definitions added? Makes it easier to see how these modules are built w/o relying on comments to stay up-to-date
include("iobuffer.jl") # Concurrency (part 1) include("linked_list.jl") include("condition.jl") include("threads.jl") include("lock.jl") # strings & printing include("intfuncs.jl") include("strings/strings.jl") #= isdebugbuild is defined here as this is imported in libdl.jl (included in libc.jl) =# """ isdebugbu...
@@ -106,6 +106,27 @@ include("lock.jl") # strings & printing include("intfuncs.jl") include("strings/strings.jl") + +#= +isdebugbuild is defined here as this is imported in libdl.jl (included in libc.jl) +=# +""" + isdebugbuild() + +Return `true` if julia is a debug version. +""" +function isdebugbuild() + ret...
base/Base.jl
26
Julia
0.571
question
227
51
51
false
Feature/change bootstrap to use libdl in pcre
60,967
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: base/Base.jl PR Title: Feature/change bootstrap to use libdl in pcre BEFORE CODE: include("iobuffer.jl") # Concurrency (part 1) include("linked_list.jl") include("condition.jl") include("threads.jl") include("lock.jl") # strings & printing include("intfuncs.j...
Can we define these "multi-stage" modules in `Base.jl` directly and then `Core.eval` into them anywhere they have definitions added? Makes it easier to see how these modules are built w/o relying on comments to stay up-to-date
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.
# tm.isdst = -1 if r == C_NULL # TODO: better error message throw(ArgumentError("invalid arguments")) end @static if Sys.isapple() function shouldcallmktime(s::AbstractString) # Equivalent to !occursin(r"([^%]|^)%(a|A|j|w|Ow)"a, s), but # without regex sin...
```suggestion i = findnext(==(UInt8('%')), c, i+1) ```
# tm.isdst = -1 if r == C_NULL # TODO: better error message throw(ArgumentError("invalid arguments")) end @static if Sys.isapple() function shouldcallmktime(s::AbstractString) # Equivalent to !occursin(r"([^%]|^)%(a|A|j|w|Ow)"a, s), but # without regex sin...
@@ -266,9 +266,32 @@ function strptime(fmt::AbstractString, timestr::AbstractString) throw(ArgumentError("invalid arguments")) end @static if Sys.isapple() + function shouldcallmktime(s::AbstractString) + # Equivalent to !occursin(r"([^%]|^)%(a|A|j|w|Ow)"a, s), but + # wi...
base/libc.jl
26
Julia
0.571
suggestion
70
51
51
false
Feature/change bootstrap to use libdl in pcre
60,967
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: base/libc.jl PR Title: Feature/change bootstrap to use libdl in pcre BEFORE CODE: # tm.isdst = -1 if r == C_NULL # TODO: better error message throw(ArgumentError("invalid arguments")) end @static if Sys.isapple() function...
```suggestion i = findnext(==(UInt8('%')), c, i+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.
r = ccall(:strptime, Cstring, (Cstring, Cstring, Ref{TmStruct}), timestr, fmt, tm) # the following would tell mktime() that this is a local time, and that # it should try to guess the timezone. not sure if/how this should be # exposed in the API. # tm.isdst = -1 if r == C_NULL # TODO: be...
```suggestion if c[i+1] in b"aAjw" return false elseif c[i+1] == UInt8('O') (i <= N-2) && (c[i+2] == UInt8('w')) && return false ``` or similar (to avoid the `Vector{UInt8}` allocation from the slice)
r = ccall(:strptime, Cstring, (Cstring, Cstring, Ref{TmStruct}), timestr, fmt, tm) # the following would tell mktime() that this is a local time, and that # it should try to guess the timezone. not sure if/how this should be # exposed in the API. # tm.isdst = -1 if r == C_NULL # TODO: be...
@@ -266,9 +266,32 @@ function strptime(fmt::AbstractString, timestr::AbstractString) throw(ArgumentError("invalid arguments")) end @static if Sys.isapple() + function shouldcallmktime(s::AbstractString) + # Equivalent to !occursin(r"([^%]|^)%(a|A|j|w|Ow)"a, s), but + # wi...
base/libc.jl
26
Julia
0.857
suggestion
289
51
51
false
Feature/change bootstrap to use libdl in pcre
60,967
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: base/libc.jl PR Title: Feature/change bootstrap to use libdl in pcre BEFORE CODE: r = ccall(:strptime, Cstring, (Cstring, Cstring, Ref{TmStruct}), timestr, fmt, tm) # the following would tell mktime() that this is a local time, and that # it should ...
```suggestion if c[i+1] in b"aAjw" return false elseif c[i+1] == UInt8('O') (i <= N-2) && (c[i+2] == UInt8('w')) && return false ``` or similar (to avoid the `Vector{UInt8}` allocation from the slice)
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.
strptime(timestr::AbstractString) = strptime("%c", timestr) function strptime(fmt::AbstractString, timestr::AbstractString) tm = TmStruct() r = ccall(:strptime, Cstring, (Cstring, Cstring, Ref{TmStruct}), timestr, fmt, tm) # the following would tell mktime() that this is a local time, and that # it shou...
```suggestion if !(i > firstindex(c) && c[i-1] == UInt8('%')) ```
strptime(timestr::AbstractString) = strptime("%c", timestr) function strptime(fmt::AbstractString, timestr::AbstractString) tm = TmStruct() r = ccall(:strptime, Cstring, (Cstring, Cstring, Ref{TmStruct}), timestr, fmt, tm) # the following would tell mktime() that this is a local time, and that # it shou...
@@ -266,9 +266,32 @@ function strptime(fmt::AbstractString, timestr::AbstractString) throw(ArgumentError("invalid arguments")) end @static if Sys.isapple() + function shouldcallmktime(s::AbstractString) + # Equivalent to !occursin(r"([^%]|^)%(a|A|j|w|Ow)"a, s), but + # wi...
base/libc.jl
26
Julia
0.571
suggestion
81
51
51
false
Feature/change bootstrap to use libdl in pcre
60,967
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: base/libc.jl PR Title: Feature/change bootstrap to use libdl in pcre BEFORE CODE: strptime(timestr::AbstractString) = strptime("%c", timestr) function strptime(fmt::AbstractString, timestr::AbstractString) tm = TmStruct() r = ccall(:strptime, Cstring, (...
```suggestion if !(i > firstindex(c) && c[i-1] == UInt8('%')) ```
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.
vb.constraintkind = vb.concrete ? 1 : 2; else if (u->var->lb != jl_bottom_type) vb.constraintkind = 2; else if (vb.occurs_cov && noinv) vb.constraintkind = 1; int reintersection = constraint1 != vb.constraintkind || vb.concrete; if (reintersection) { ...
I'm suspicious of a call to `jl_subtype` happening from this deep inside the subtyping algorithm, ignoring all the current status of the algorithm
else if (jl_is_uniontype(v)) { return always_occurs_cov(((jl_uniontype_t*)v)->a, var, param) && always_occurs_cov(((jl_uniontype_t*)v)->b, var, param); } else if (jl_is_unionall(v)) { jl_unionall_t *ua = (jl_unionall_t*)v; return ua->var != var && ( always_...
@@ -3497,6 +3521,34 @@ static jl_value_t *intersect_unionall(jl_value_t *t, jl_unionall_t *u, jl_stenv_ res = intersect_unionall_(t, u, e, R, param, &vb); } } + else if (res == jl_bottom_type && vb.constraintkind == 1 && + vb.occurs_cov > 1) { + // vb.constraintkind == 1...
src/subtype.c
26
C
0.643
suggestion
146
51
51
false
fix intersection returning Union{} for diagonal vars with different Type{X} arguments
60,989
JuliaLang/julia
35,573
Julia
vtjnash
adienes
Review this pull request change. Language: C File: src/subtype.c PR Title: fix intersection returning Union{} for diagonal vars with different Type{X} arguments BEFORE CODE: vb.constraintkind = vb.concrete ? 1 : 2; else if (u->var->lb != jl_bottom_type) vb.constraintkind = 2; ...
I'm suspicious of a call to `jl_subtype` happening from this deep inside the subtyping algorithm, ignoring all the current status of the algorithm
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 is_leaf_bound(v->lb); } static jl_value_t *widen_Type(jl_value_t *t JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT { if (jl_is_type_type(t) && !jl_is_typevar(jl_tparam0(t))) return jl_typeof(jl_tparam0(t)); if (jl_is_uniontype(t)) { jl_value_t *a = widen_Type(((jl_uniontype_t*)t)->a); ...
Perhaps we can fuse this with the `widen_Type` by adding a `concrete_only` like flag? ```c static jl_value_t *widen_Type(jl_value_t *t JL_PROPAGATES_ROOT, int concrete_only) JL_NOTSAFEPOINT { if (jl_is_type_type(t) && !jl_is_typevar(jl_tparam0(t))) return jl_typeof(jl_tparam0(t)); if (jl_is_uniontype(t...
{ return is_leaf_bound(v->lb); } static jl_value_t *widen_Type_if_concrete(jl_value_t *t JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT { if (jl_is_type_type(t) && !jl_is_typevar(jl_tparam0(t))) return jl_typeof(jl_tparam0(t)); if (jl_is_uniontype(t)) { jl_value_t *a = widen_Type_if_concrete(((jl_unio...
@@ -886,6 +887,27 @@ static jl_value_t *widen_Type(jl_value_t *t JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT return t; } +// Map Type{X} to kind type (DataType, UnionAll, Union, TypeofBottom) over union
src/subtype.c
26
C
1
suggestion
1,496
51
51
false
fix intersection returning Union{} for diagonal vars with different Type{X} arguments
60,989
JuliaLang/julia
35,573
Julia
N5N3
adienes
Review this pull request change. Language: C File: src/subtype.c PR Title: fix intersection returning Union{} for diagonal vars with different Type{X} arguments BEFORE CODE: { return is_leaf_bound(v->lb); } static jl_value_t *widen_Type(jl_value_t *t JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT { if (jl_is_type_typ...
Perhaps we can fuse this with the `widen_Type` by adding a `concrete_only` like flag? ```c static jl_value_t *widen_Type(jl_value_t *t JL_PROPAGATES_ROOT, int concrete_only) JL_NOTSAFEPOINT { if (jl_is_type_type(t) && !jl_is_typevar(jl_tparam0(t))) return jl_typeof(jl_tparam0(t)); if (jl_is_uniontype(t...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
vb.intersected = 1; if (vb.limited) { // if the environment got too big, avoid tree recursion and propagate the flag if (e->vars) e->vars->limited = 1; } else if (res != jl_bottom_type) { int constraint1 = vb.constraintkind; if (vb.concrete || vb.occurs_inv>1 ...
With the change below (always try Type widening for constraintkind == 1), we can trust the intersection result (no false `Union{}`), and only trigger the final re-intersection if `widen_to_kind == 1` && `occurs_cov > 1` && `vb.ub is a kind` ```c if (res != jl_bottom_type && vb.constraintkind == 1 && vb.widen_to_k...
static int always_occurs_cov(jl_value_t *v, jl_tvar_t *var, int param) JL_NOTSAFEPOINT { if (param > 1) { return 0; } else if (v == (jl_value_t*)var) { return param == 1; } else if (jl_is_uniontype(v)) { return always_occurs_cov(((jl_uniontype_t*)v)->a, var, param) && ...
@@ -3497,6 +3521,37 @@ static jl_value_t *intersect_unionall(jl_value_t *t, jl_unionall_t *u, jl_stenv_ res = intersect_unionall_(t, u, e, R, param, &vb); } } + else if (res == jl_bottom_type && vb.constraintkind == 1 &&
src/subtype.c
26
C
1
suggestion
549
51
51
false
fix intersection returning Union{} for diagonal vars with different Type{X} arguments
60,989
JuliaLang/julia
35,573
Julia
N5N3
adienes
Review this pull request change. Language: C File: src/subtype.c PR Title: fix intersection returning Union{} for diagonal vars with different Type{X} arguments BEFORE CODE: vb.intersected = 1; if (vb.limited) { // if the environment got too big, avoid tree recursion and propagate the flag i...
With the change below (always try Type widening for constraintkind == 1), we can trust the intersection result (no false `Union{}`), and only trigger the final re-intersection if `widen_to_kind == 1` && `occurs_cov > 1` && `vb.ub is a kind` ```c if (res != jl_bottom_type && vb.constraintkind == 1 && vb.widen_to_k...
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 (ub != (jl_value_t*)b) { if (jl_has_free_typevars(ub)) { if (check_unsat_bound(ub, b, e)) { JL_GC_POP(); return jl_bottom_type; } } bb->ub = ub; if ((jl_is_uniontype(ub) && !jl_is_uniontype...
Perhaps we can always try to widening `bb->ub` if `bb->constraintkind == 1` and let the flag to record if `ub` really got widened, i.e. ```c if (e->triangular && param == 1) { if (check_unsat_bound(ub, b, e)) return jl_bottom_type; set_bound(&bb->ub, ub, b, e); return (jl_value_t...
if (R) flip_offset(e); int ccheck = intersect_var_ccheck_in_env(bb->lb, bb->ub, a, a, e, !R); if (R) flip_offset(e); if (!ccheck) { JL_GC_POP(); return jl_bottom_type; } ub = a; } else { e...
@@ -2841,6 +2863,8 @@ static jl_value_t *intersect_var(jl_tvar_t *b, jl_value_t *a, jl_stenv_t *e, int if (e->triangular && check_unsat_bound(ub, b, e)) return jl_bottom_type; set_bound(&bb->ub, ub, b, e); + if (bb->constraintkind == 1 && bb->widen_to_kind) + set_bound(&...
src/subtype.c
26
C
1
suggestion
1,251
51
51
false
fix intersection returning Union{} for diagonal vars with different Type{X} arguments
60,989
JuliaLang/julia
35,573
Julia
N5N3
adienes
Review this pull request change. Language: C File: src/subtype.c PR Title: fix intersection returning Union{} for diagonal vars with different Type{X} arguments BEFORE CODE: if (ub != (jl_value_t*)b) { if (jl_has_free_typevars(ub)) { if (check_unsat_bound(ub, b, e)) { ...
Perhaps we can always try to widening `bb->ub` if `bb->constraintkind == 1` and let the flag to record if `ub` really got widened, i.e. ```c if (e->triangular && param == 1) { if (check_unsat_bound(ub, b, e)) return jl_bottom_type; set_bound(&bb->ub, ub, b, e); return (jl_value_t...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
e->invdepth, NULL, e->vars }; JL_GC_PUSH4(&res, &vb.lb, &vb.ub, &vb.innervars); save_env(e, &se, 1); int noinv = !var_occurs_invariant(u->body, u->var); if (is_leaf_typevar(u->var) && noinv && always_occurs_cov(u->body, u->var, param)) vb.constraintkind = 1; res = ...
In fact, non-leaf `lb` (rather than `ub`) violates the diagonal rule. Looks like the remaining `@test_broken` stems from this.
} else if (res != jl_bottom_type) { int constraint1 = vb.constraintkind; if (vb.concrete || vb.occurs_inv>1 || (vb.occurs_inv && vb.occurs_cov)) vb.constraintkind = vb.concrete ? 1 : 2; else if (u->var->lb != jl_bottom_type) vb.constraintkind = 2; else if ...
@@ -3533,35 +3578,30 @@ static jl_value_t *intersect_unionall(jl_value_t *t, jl_unionall_t *u, jl_stenv_ res = intersect_unionall_(t, u, e, R, param, &vb); } } - else if (res == jl_bottom_type && vb.constraintkind == 1 && - vb.occurs_cov > 1) { - // vb.constraintkind == ...
src/subtype.c
26
C
0.5
bug
126
51
51
false
fix intersection returning Union{} for diagonal vars with different Type{X} arguments
60,989
JuliaLang/julia
35,573
Julia
N5N3
adienes
Review this pull request change. Language: C File: src/subtype.c PR Title: fix intersection returning Union{} for diagonal vars with different Type{X} arguments BEFORE CODE: e->invdepth, NULL, e->vars }; JL_GC_PUSH4(&res, &vb.lb, &vb.ub, &vb.innervars); save_env(e, &se, 1); in...
In fact, non-leaf `lb` (rather than `ub`) violates the diagonal rule. Looks like the remaining `@test_broken` stems from 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.
jl_value_t *a = widen_Type_if_concrete(((jl_uniontype_t*)t)->a); jl_value_t *b = widen_Type_if_concrete(((jl_uniontype_t*)t)->b); if (a == b) return a; } if (jl_is_unionall(t)) { jl_unionall_t *u = (jl_unionall_t*)t; jl_value_t *body = widen_Type_if_concrete(u...
I'm not sure return a `Union{}` is a good idea here, this might remove part of `ub` and make the result too narrow, e.g. ```julia typeintersect(Tuple{Union{Type{Val},Type{Int8}},Union{Type{Val},Type{Int}}}, NTuple{2,<:Union{Type{<:Val},DataType}}) ``` why not just return `t`? BTW, there seems no need to maintain `filt...
jl_value_t *a = widen_Type_if_concrete(((jl_uniontype_t*)t)->a); jl_value_t *b = widen_Type_if_concrete(((jl_uniontype_t*)t)->b); if (a == b) return a; } if (jl_is_unionall(t)) { jl_unionall_t *u = (jl_unionall_t*)t; jl_value_t *body = widen_Type_if_concrete(u...
@@ -874,49 +874,70 @@ static int is_leaf_typevar(jl_tvar_t *v) JL_NOTSAFEPOINT return is_leaf_bound(v->lb); } -static jl_value_t *widen_Type(jl_value_t *t JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT +static jl_value_t *widen_Type_if_concrete(jl_value_t *t JL_PROPAGATES_ROOT) JL_NOTSAFEPOINT { if (jl_is_type_type(...
src/subtype.c
26
C
1
suggestion
492
51
51
false
fix intersection returning Union{} for diagonal vars with different Type{X} arguments
60,989
JuliaLang/julia
35,573
Julia
N5N3
adienes
Review this pull request change. Language: C File: src/subtype.c PR Title: fix intersection returning Union{} for diagonal vars with different Type{X} arguments BEFORE CODE: jl_value_t *a = widen_Type_if_concrete(((jl_uniontype_t*)t)->a); jl_value_t *b = widen_Type_if_concrete(((jl_uniontype_t*)t)->...
I'm not sure return a `Union{}` is a good idea here, this might remove part of `ub` and make the result too narrow, e.g. ```julia typeintersect(Tuple{Union{Type{Val},Type{Int8}},Union{Type{Val},Type{Int}}}, NTuple{2,<:Union{Type{<:Val},DataType}}) ``` why not just return `t`? BTW, there seems no need to maintain `filt...
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!(method_stmts, method_def_expr(ctx, srcref, callex, method_table, trimmed_typevar_names, trimmed_arg_names, trimmed_arg_types, body)) end end function scope_nest(ctx, names, values, body) for (name, value) in Iterators.rever...
Does this comment still apply?
push!(method_stmts, method_def_expr(ctx, srcref, callex, method_table, trimmed_typevar_names, trimmed_arg_names, trimmed_arg_types, body)) end end function scope_nest(ctx, names, values, body) for (name, value) in Iterators.rever...
@@ -2614,13 +2614,15 @@ function keyword_function_defs(ctx, srcref, callex_srcref, name_str, typevar_nam end # TODO: Is the layer correct here? Which module should be the parent module # of this body function?
JuliaLowering/src/desugaring.jl
26
Julia
0.071
question
30
51
51
false
[JuliaLowering] Fix closure-conversion of keyword functions
61,001
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/desugaring.jl PR Title: [JuliaLowering] Fix closure-conversion of keyword functions BEFORE CODE: push!(method_stmts, method_def_expr(ctx, srcref, callex, method_table, trimmed_typevar_names, ...
Does this comment still apply?
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!(kwcall_method_defs, method_def_expr(ctx, srcref, callex_srcref, kwcall_mtable, main_kwcall_typevars, kwcall_arg_names, kwcall_arg_types, kwcall_body)) # Check kws of body method check_all_typevars_used(body_arg_types, typevar_names, typevar_stmts) kw_func_meth...
```suggestion # This should inherit the local / global status of the body func, # so provide that here for closure conversion, even though this is # really a method on Core.kwcall body_func_name ``` I assume this is done for closure conversion, but the comment seems to ...
main_kwcall_typevars, kwcall_arg_names, kwcall_arg_types, kwcall_body)) # Check kws of body method check_all_typevars_used(body_arg_types, typevar_names, typevar_stmts) kw_func_method_defs = @ast ctx srcref [K"block" [K"function_decl" body_func_name] [K"method_def...
@@ -2860,7 +2862,9 @@ function keyword_function_defs(ctx, srcref, callex_srcref, name_str, typevar_nam ] ] [K"method_defs" - "nothing"::K"core" + # We want this method to be local or global at the same time as the + # body func, but it's really a method on...
JuliaLowering/src/desugaring.jl
26
Julia
0.857
suggestion
556
51
51
false
[JuliaLowering] Fix closure-conversion of keyword functions
61,001
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/desugaring.jl PR Title: [JuliaLowering] Fix closure-conversion of keyword functions BEFORE CODE: push!(kwcall_method_defs, method_def_expr(ctx, srcref, callex_srcref, kwcall_mtable, main_kwcall_typevars,...
```suggestion # This should inherit the local / global status of the body func, # so provide that here for closure conversion, even though this is # really a method on Core.kwcall body_func_name ``` I assume this is done for closure conversion, but the comment seems to ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
function _match_kind(srcref, ex) kws = [] if Meta.isexpr(ex, :call) kind = esc(ex.args[1]) args = ex.args[2:end] if Meta.isexpr(args[1], :parameters) kws = map(_kw_to_pair, args[1].args) popfirst!(args) end while length(args) >= 1 && Meta.isexpr(a...
`line` makes me think this has semantic (not debug) meaning
function _match_kind(srcref, ex) kws = [] if Meta.isexpr(ex, :call) kind = esc(ex.args[1]) args = ex.args[2:end] if Meta.isexpr(args[1], :parameters) kws = map(_kw_to_pair, args[1].args) popfirst!(args) end while length(args) >= 1 && Meta.isexpr(a...
@@ -233,7 +233,7 @@ function _match_kind(srcref, ex) return (kind, srcref, kws) end -function _expand_ast_tree(ctx, srcref, tree) +function _expand_ast_tree(ctx, srcref, tree, line::QuoteNode)
JuliaLowering/src/ast.jl
26
Julia
0.5
bug
59
51
51
false
SyntaxTree: Add `jl_source` attribute for debugging JuliaLowering
61,006
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/ast.jl PR Title: SyntaxTree: Add `jl_source` attribute for debugging JuliaLowering BEFORE CODE: function _match_kind(srcref, ex) kws = [] if Meta.isexpr(ex, :call) kind = esc(ex.args[1]) args = ex.args[2:end] i...
`line` makes me think this has semantic (not debug) meaning
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 #else # ifdef JL_NDEBUG # define NDEBUG # include <assert.h> # undef NDEBUG # else # include <assert.h> # endif #endif #if defined __has_builtin # define jl_has_builtin(x) __has_builtin(x) #else # define jl_has_builtin(x) 0 #endif #ifdef JL_NDEBUG # if jl_has_builtin(__builtin_assume) #defin...
the space-indenting for these directives seems inconsistent
// This file is a part of Julia. License is MIT: https://julialang.org/license // Include this file instead of `assert.h` directly. // This is necessary because LLVM sometimes has bugs that cause runtime assertion if // the `NDEBUG` setting is different from the one used to compile LLVM. // For C++ files, we set `NDEB...
@@ -29,4 +35,100 @@ # include <assert.h> # endif #endif + +#if defined __has_builtin +# define jl_has_builtin(x) __has_builtin(x) +#else +# define jl_has_builtin(x) 0 +#endif + +#ifdef JL_NDEBUG +# if jl_has_builtin(__builtin_assume) +#define jl_assume(cond) \ + (__extension__({ ...
src/julia_assert.h
26
C/C++
0.214
style
59
51
33
false
Make jl_assume, jl_assume_aligned, jl_unreachable asserts in debug
61,015
JuliaLang/julia
35,573
Julia
topolarity
xal-0
Review this pull request change. Language: C/C++ File: src/julia_assert.h PR Title: Make jl_assume, jl_assume_aligned, jl_unreachable asserts in debug BEFORE CODE: # endif #else # ifdef JL_NDEBUG # define NDEBUG # include <assert.h> # undef NDEBUG # else # include <assert.h> # endif #endif #if defi...
the space-indenting for these directives seems inconsistent
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.
#define FORCE_INLINE static inline __attribute__((always_inline)) #define EXTERN_INLINE_DECLARE inline __attribute__ ((visibility("default"))) #define EXTERN_INLINE_DEFINE extern inline JL_DLLEXPORT #if defined(_OS_WINDOWS_) && !defined(_COMPILER_GCC_) # define NOINLINE __declspec(noinline) # define NOINLINE_DECL(f...
```suggestion #if defined(__has_builtin) ``` just a tiny style nit, since we (mostly) use this form
#define FORCE_INLINE static inline __attribute__((always_inline)) #define EXTERN_INLINE_DECLARE inline __attribute__ ((visibility("default"))) #define EXTERN_INLINE_DEFINE extern inline JL_DLLEXPORT #if defined(_OS_WINDOWS_) && !defined(_COMPILER_GCC_) # define NOINLINE __declspec(noinline) # define NOINLINE_DECL(f...
@@ -142,52 +143,87 @@ typedef intptr_t ssize_t; # define JL_ATTRIBUTE_ALIGN_PTRSIZE(x) #endif -#ifdef __has_builtin +#if defined __has_builtin
src/support/dtypes.h
26
C/C++
0.786
suggestion
100
51
51
false
Make jl_assume, jl_assume_aligned, jl_unreachable asserts in debug
61,015
JuliaLang/julia
35,573
Julia
topolarity
xal-0
Review this pull request change. Language: C/C++ File: src/support/dtypes.h PR Title: Make jl_assume, jl_assume_aligned, jl_unreachable asserts in debug BEFORE CODE: #define FORCE_INLINE static inline __attribute__((always_inline)) #define EXTERN_INLINE_DECLARE inline __attribute__ ((visibility("default"))) #defin...
```suggestion #if defined(__has_builtin) ``` just a tiny style nit, since we (mostly) use this form
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.
# Desugaring uses this helper internally, so we may see K"kw" too. if k == K"=" && numchildren(ex) === 2 ex = @ast ctx ex [K"kw" ex[1] ex[2]] end mapchildren(c->_apply_nospecialize(ctx, c), ctx, ex, 1:1) else throw(LoweringError(ex, "Invalid function argument")) ...
```suggestion function Base.var"@nospecialize"(__context__::MacroContext, exs::SyntaxTree...) if length(exs) == 0 @ast __context__ __context__.macrocall [K"meta" "nospecialize"::K"Symbol"] elseif length(exs) == 1 _apply_nospecialize(__context__, only(exs)) else @ast __context__ __con...
# Desugaring uses this helper internally, so we may see K"kw" too. if k == K"=" && numchildren(ex) === 2 ex = @ast ctx ex [K"kw" ex[1] ex[2]] end mapchildren(c->_apply_nospecialize(ctx, c), ctx, ex, 1:1) else throw(LoweringError(ex, "Invalid function argument")) ...
@@ -32,11 +32,23 @@ function _apply_nospecialize(ctx, ex) end end -function Base.var"@nospecialize"(__context__::MacroContext, ex, exs...) - # TODO support multi-arg version properly +function Base.var"@nospecialize"(__context__::MacroContext) + @ast __context__ __context__.macrocall [K"meta" "nospecializ...
JuliaLowering/src/syntax_macros.jl
26
Julia
0.786
suggestion
516
51
51
false
[JuliaLowering] Fix `@nospecialize` multi-arg and add 0-arg
61,021
JuliaLang/julia
35,573
Julia
topolarity
aviatesk
Review this pull request change. Language: Julia File: JuliaLowering/src/syntax_macros.jl PR Title: [JuliaLowering] Fix `@nospecialize` multi-arg and add 0-arg BEFORE CODE: # Desugaring uses this helper internally, so we may see K"kw" too. if k == K"=" && numchildren(ex) === 2 ex = @ast ...
```suggestion function Base.var"@nospecialize"(__context__::MacroContext, exs::SyntaxTree...) if length(exs) == 0 @ast __context__ __context__.macrocall [K"meta" "nospecialize"::K"Symbol"] elseif length(exs) == 1 _apply_nospecialize(__context__, only(exs)) else @ast __context__ __con...
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 declare_in_scope!(ctx, scope, ex, :local) end elseif b.kind === :static_parameter throw(LoweringError(ex, "cannot overwrite a static parameter")) elseif b.kind === :local || b.kind === :argument # unambiguous assignment to existing var...
Writing tests for this PR, I found body-level `@nospecialize` effects haven't been working properly, so I made this change to propagate the effects to `BindingInfo` during scope analysis. (N.B. argument-level `@nospecialize` effects are processed during desugaring i.e. `_resolve_function_arg`)
# Add local decls to start of block so that closure conversion can # initialize if necessary. for id in sort!(collect(values(scope.vars))) binfo = get_binding(ctx, id) if binfo.kind == :local push!(stmts, @ast ctx srcref [K"local" binding_ex(ctx, id)]) end end end fu...
@@ -364,6 +364,11 @@ function _resolve_scopes(ctx, ex::SyntaxTree, gid = declare_in_scope!(ctx, top_scope(ctx), ex, :global) b = get_binding(ctx, gid) end + # Body-level @nospecialize sets :nospecialize metadata on identifiers. + # Propagate this to the binding so the sl...
JuliaLowering/src/scope_analysis.jl
26
Julia
0.643
suggestion
294
51
51
false
[JuliaLowering] Fix `@nospecialize` multi-arg and add 0-arg
61,021
JuliaLang/julia
35,573
Julia
aviatesk
aviatesk
Review this pull request change. Language: Julia File: JuliaLowering/src/scope_analysis.jl PR Title: [JuliaLowering] Fix `@nospecialize` multi-arg and add 0-arg BEFORE CODE: else declare_in_scope!(ctx, scope, ex, :local) end elseif b.kind === :static_parameter ...
Writing tests for this PR, I found body-level `@nospecialize` effects haven't been working properly, so I made this change to propagate the effects to `BindingInfo` during scope analysis. (N.B. argument-level `@nospecialize` effects are processed during desugaring i.e. `_resolve_function_arg`)
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, b) end f_nospecialize_single_body(1, 2) end """) == (1, 2) @test only(methods(test_mod.f_nospecialize_single_body)).nospecialize == 0b10 # @nospecialize with zero args in function body (blanket nospecialize) @test JuliaLowering.include_string(test_mod, """ begin...
Would be good to add a broken test for the body form (which doesn't work, as noted in https://github.com/JuliaLang/julia/blob/3a3289a17f5a36feddf0898b67788b894a5c7440/JuliaLowering/src/desugaring.jl#L2582). A `kwargs` example would also be good (and is similarly broken for the body form). Sorry to make you add so many...
(a, b) end f_nospecialize_single_body(1, 2) end """) == (1, 2) @test only(methods(test_mod.f_nospecialize_single_body)).nospecialize == 0b10 # @nospecialize with zero args in function body (blanket nospecialize) @test JuliaLowering.include_string(test_mod, """ begin...
@@ -378,6 +378,61 @@ end (f_branch_meta(10, false), f_branch_meta(20, true)) end """) == (12, 21) + + # @nospecialize with multiple args in function body + @test JuliaLowering.include_string(test_mod, """ + begin + function f_nospecialize_multi_body(a, b, c, d) + @nospecial...
JuliaLowering/test/functions.jl
26
Julia
0.571
bug
388
51
51
false
[JuliaLowering] Fix `@nospecialize` multi-arg and add 0-arg
61,021
JuliaLang/julia
35,573
Julia
topolarity
aviatesk
Review this pull request change. Language: Julia File: JuliaLowering/test/functions.jl PR Title: [JuliaLowering] Fix `@nospecialize` multi-arg and add 0-arg BEFORE CODE: (a, b) end f_nospecialize_single_body(1, 2) end """) == (1, 2) @test only(methods(test_mod.f_nospecialize...
Would be good to add a broken test for the body form (which doesn't work, as noted in https://github.com/JuliaLang/julia/blob/3a3289a17f5a36feddf0898b67788b894a5c7440/JuliaLowering/src/desugaring.jl#L2582). A `kwargs` example would also be good (and is similarly broken for the body form). Sorry to make you add so many...
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 JuliaLowering.include_string(test_mod, """ begin function f_body_nospecialize_default(x, y=1) @nospecialize (x, y) end (f_body_nospecialize_default(10, 20), f_body_nospecialize_default(30)) end """) == ((10, 20), (30, 1)) # The 2-arg method has n...
```suggestion @test_broken only(methods(Core.kwcall, (NamedTuple,typeof(test_mod.f_body_nospecialize_with_kwargs),Any))).nospecialize == 1 << 2 ```
@test JuliaLowering.include_string(test_mod, """ begin function f_body_nospecialize_default(x, y=1) @nospecialize (x, y) end (f_body_nospecialize_default(10, 20), f_body_nospecialize_default(30)) end """) == ((10, 20), (30, 1)) # The 2-arg method has n...
@@ -378,6 +378,90 @@ end (f_branch_meta(10, false), f_branch_meta(20, true)) end """) == (12, 21) + + # @nospecialize with multiple args in function body + @test JuliaLowering.include_string(test_mod, """ + begin + function f_nospecialize_multi_body(a, b, c, d) + @nospecial...
JuliaLowering/test/functions.jl
26
Julia
0.857
bug
151
51
51
false
[JuliaLowering] Fix `@nospecialize` multi-arg and add 0-arg
61,021
JuliaLang/julia
35,573
Julia
topolarity
aviatesk
Review this pull request change. Language: Julia File: JuliaLowering/test/functions.jl PR Title: [JuliaLowering] Fix `@nospecialize` multi-arg and add 0-arg BEFORE CODE: @test JuliaLowering.include_string(test_mod, """ begin function f_body_nospecialize_default(x, y=1) @nospecialize ...
```suggestion @test_broken only(methods(Core.kwcall, (NamedTuple,typeof(test_mod.f_body_nospecialize_with_kwargs),Any))).nospecialize == 1 << 2 ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
struct ValidationDiagnostic sts::SyntaxList msg::String loc::LineNumberNode # for noting where failures come from in this file end ValidationDiagnostic(st::SyntaxTree, msg, loc) = ValidationDiagnostic( SyntaxList(syntax_graph(st), NodeId[st._id]), msg, loc) """ The type returned by all `vst` fu...
It may be nice to also check for `allowed_attrs`, not just required ? Assuming that we don't have a good path to make those the same
function assert_syntaxtree(st::SyntaxTree) vr = _assert_syntaxtree(st, NodeId[], pass()) @assert is_known(vr) if !vr.ok msg = string("assert_syntaxtree failed: ", node_string(st), "\n") for err in vr.errors msg *= "node: " * node_string(only(err.sts)) * "\nreason: " * err.msg ...
@@ -1027,3 +1028,75 @@ vst0_quoted(vcx, st; quote_level) = @stm st begin vst0_quoted(vcx, x; quote_level=quote_level+1) _ -> all(vst0_quoted, vcx, children(st); quote_level) end + +#------------------------------------------------------------------------------- +# Tree invariants assumed everywhere, incl...
JuliaLowering/src/validation.jl
26
Julia
0.5
suggestion
133
1,030
51
false
[JuliaLowering] Printing improvements: malformed trees, leaf kinds
61,028
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/validation.jl PR Title: [JuliaLowering] Printing improvements: malformed trees, leaf kinds BEFORE CODE: struct ValidationDiagnostic sts::SyntaxList msg::String loc::LineNumberNode # for noting where failures come from in this file ...
It may be nice to also check for `allowed_attrs`, not just required ? Assuming that we don't have a good path to make those the same
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 = length(groups) for i = 1:n argᵢ = fargs[i] if argᵢ isa SlotNumber || argᵢ isa SSAValue for j in 1:i-1 if fargs[j] === argᵢ groups[i] = groups[j] break end end end end return groups...
When you guys get older and have as bad eyes as I do now, you'll seriously regret using identifiers like tᵢ and tⱼ for being virtually indistinguishable unless you zoom in a lot. (I also don't get what these offer over `ti` or `t_i` -- but you do you, I am just a grumpy old man on the sidelines ;-) )
for i = 1:length(groups) arg_i = fargs[i] if arg_i isa SlotNumber || arg_i isa SSAValue for j in 1:i-1 if fargs[j] === arg_i groups[i] = groups[j] break end end end end return groups end ...
@@ -192,16 +192,90 @@ function tuple_tail_elem(𝕃::AbstractLattice, @nospecialize(init), ct::Vector{ return Vararg{widenconst(t)} end +# Given `fargs` from `ArgInfo` and optionally `argtypes`, compute alias groups +# for argument positions. Returns `nothing` if `fargs === nothing`, otherwise a +# `Vector{Int}` ...
Compiler/src/typeutils.jl
26
Julia
0.571
suggestion
301
51
51
false
inference: Alias-aware union splitting for identical arguments
61,041
JuliaLang/julia
35,573
Julia
fingolfin
aviatesk
Review this pull request change. Language: Julia File: Compiler/src/typeutils.jl PR Title: inference: Alias-aware union splitting for identical arguments BEFORE CODE: n = length(groups) for i = 1:n argᵢ = fargs[i] if argᵢ isa SlotNumber || argᵢ isa SSAValue for j in 1:i-1 ...
When you guys get older and have as bad eyes as I do now, you'll seriously regret using identifiers like tᵢ and tⱼ for being virtually indistinguishable unless you zoom in a lot. (I also don't get what these offer over `ti` or `t_i` -- but you do you, I am just a grumpy old man on the sidelines ;-) )
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.
na = length(argtypes) groups = compute_alias_groups(na, fargs, argtypes) return _switchtupleunion(𝕃, argtypes, na, [], nothing, groups) end function _switchtupleunion(𝕃::AbstractLattice, t::Vector{Any}, i::Int, tunion::Vector{Any}, @nospecialize(origt), groups::Union{Nothing,Ve...
nit: The implementation right now constrains that `i > j`, but nothing really says that it must be true> ```suggestion for j in 1:length(t) ``` Additionally, when we have alias groups, it might be cool to similarly refine dependent types during `smerge!` also
na = length(argtypes) groups = compute_alias_groups(na, fargs, argtypes) return _switchtupleunion(𝕃, argtypes, na, [], nothing, groups) end function _switchtupleunion(𝕃::AbstractLattice, t::Vector{Any}, i::Int, tunion::Vector{Any}, @nospecialize(origt), groups::Union{Nothing,Ve...
@@ -225,34 +297,69 @@ function switchtupleunion(@nospecialize(ty)) return _switchtupleunion(JLTypeLattice(), Any[tparams...], length(tparams), [], ty) end -switchtupleunion(𝕃::AbstractLattice, argtypes::Vector{Any}) = _switchtupleunion(𝕃, argtypes, length(argtypes), [], nothing) +function switchtupleunion(𝕃:...
Compiler/src/typeutils.jl
26
Julia
0.929
suggestion
272
51
51
false
inference: Alias-aware union splitting for identical arguments
61,041
JuliaLang/julia
35,573
Julia
vtjnash
aviatesk
Review this pull request change. Language: Julia File: Compiler/src/typeutils.jl PR Title: inference: Alias-aware union splitting for identical arguments BEFORE CODE: na = length(argtypes) groups = compute_alias_groups(na, fargs, argtypes) return _switchtupleunion(𝕃, argtypes, na, [], nothing, groups) ...
nit: The implementation right now constrains that `i > j`, but nothing really says that it must be true> ```suggestion for j in 1:length(t) ``` Additionally, when we have alias groups, it might be cool to similarly refine dependent types during `smerge!` also
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end end function _hasmethod(@nospecialize(tt)) # this function has a special tfunc world = ccall(:jl_get_tls_world_age, UInt, ()) # tls_world_age() return Intrinsics.not_int(ccall(:jl_gf_invoke_lookup, Any, (Any, Any, UInt), tt, nothing, world) === nothing) end # for backward compat arrayref(inbounds::Boo...
This is pretty easy to lead to mistakes in the future: ```julia julia> Core.shl_int(0x1, 8) 0x00 ```
end end function _hasmethod(@nospecialize(tt)) # this function has a special tfunc world = ccall(:jl_get_tls_world_age, UInt, ()) # tls_world_age() return Intrinsics.not_int(ccall(:jl_gf_invoke_lookup, Any, (Any, Any, UInt), tt, nothing, world) === nothing) end # for backward compat arrayref(inbounds::Boo...
@@ -1138,10 +1138,11 @@ EnterNode(old::EnterNode, new_dest::Int) = isdefined(old, :scope) ? EnterNode(new_dest, old.scope) : EnterNode(new_dest) # typename(_).constprop_heuristic -const FORCE_CONST_PROP = 0x1 -const ARRAY_INDEX_HEURISTIC = 0x2 -const ITERATE_HEURISTIC = 0x3 -const SAMETYPE_HEURISTIC ...
base/boot.jl
26
Julia
0.714
suggestion
100
51
51
false
inference: make `constprop_heuristic` a bitfield
61,045
JuliaLang/julia
35,573
Julia
topolarity
aviatesk
Review this pull request change. Language: Julia File: base/boot.jl PR Title: inference: make `constprop_heuristic` a bitfield BEFORE CODE: end end function _hasmethod(@nospecialize(tt)) # this function has a special tfunc world = ccall(:jl_get_tls_world_age, UInt, ()) # tls_world_age() return Intrinsi...
This is pretty easy to lead to mistakes in the future: ```julia julia> Core.shl_int(0x1, 8) 0x00 ```
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 force_const_prop(interp::AbstractInterpreter, @nospecialize(f), method::Method) return is_aggressive_constprop(method) || InferenceParams(interp).aggressive_constant_propagation || !iszero(typename(typeof(f)).constprop_heuristic & Core.FORCE_CONST_PROP) end function const_prop_functi...
Doesn't the `elseif` here leave this as effectively exclusive with the above heuristic?
function force_const_prop(interp::AbstractInterpreter, @nospecialize(f), method::Method) return is_aggressive_constprop(method) || InferenceParams(interp).aggressive_constant_propagation || !iszero(typename(typeof(f)).constprop_heuristic & Core.FORCE_CONST_PROP) end function const_prop_functi...
@@ -1179,14 +1185,14 @@ function const_prop_function_heuristic(interp::AbstractInterpreter, @nospecializ elseif ⊑(𝕃ᵢ, arrty, Array) || ⊑(𝕃ᵢ, arrty, GenericMemory) return false end - elseif heuristic === Core.ITERATE_HEURISTIC + elseif !iszero(heuristic & Core.I...
Compiler/src/abstractinterpretation.jl
26
Julia
0.357
question
87
51
51
false
inference: make `constprop_heuristic` a bitfield
61,045
JuliaLang/julia
35,573
Julia
topolarity
aviatesk
Review this pull request change. Language: Julia File: Compiler/src/abstractinterpretation.jl PR Title: inference: make `constprop_heuristic` a bitfield BEFORE CODE: function force_const_prop(interp::AbstractInterpreter, @nospecialize(f), method::Method) return is_aggressive_constprop(method) || Infe...
Doesn't the `elseif` here leave this as effectively exclusive with the above heuristic?
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 lift_keyvalue_get!(compact::IncrementalCompact, idx::Int, stmt::Expr, 𝕃ₒ::AbstractLattice) collection = stmt.args[end-1] key = stmt.args[end] leaves, visited_philikes = collect_leaves(compact, collection, Any, 𝕃ₒ, keyvalue_predecessors(key, 𝕃ₒ)) isempty(leaves) && return lifted_le...
Is all of this extra checking useful? Seems like the lifting is valid to do by the OptimizedGenerics contract regardless
end function lift_keyvalue_get!(compact::IncrementalCompact, idx::Int, stmt::Expr, 𝕃ₒ::AbstractLattice) collection = stmt.args[end-1] key = stmt.args[end] leaves, visited_philikes = collect_leaves(compact, collection, Any, 𝕃ₒ, keyvalue_predecessors(key, 𝕃ₒ)) isempty(leaves) && return lifted_le...
@@ -1044,17 +1044,27 @@ function lift_keyvalue_get!(compact::IncrementalCompact, idx::Int, stmt::Expr, result_t = tmerge(𝕃ₒ, result_t, argextype(v.val, compact)) end + # Extract the wrapper type (e.g. Some{V}) from the inferred return type + # Union{Nothing, Some{V}} by subtracting Nothing. Bail...
Compiler/src/ssair/passes.jl
26
Julia
0.429
performance
121
51
51
false
optimizer: Switch to `Some{}` in PersistentDict optimized generics
61,053
JuliaLang/julia
35,573
Julia
topolarity
Keno
Review this pull request change. Language: Julia File: Compiler/src/ssair/passes.jl PR Title: optimizer: Switch to `Some{}` in PersistentDict optimized generics BEFORE CODE: end function lift_keyvalue_get!(compact::IncrementalCompact, idx::Int, stmt::Expr, 𝕃ₒ::AbstractLattice) collection = stmt.args[end-1] ...
Is all of this extra checking useful? Seems like the lifting is valid to do by the OptimizedGenerics contract regardless
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.
source::LineNumberNode end struct Threw <: ExecutionResult exception current_exceptions::Base.ExceptionStack source::LineNumberNode end function eval_test_comparison(comparison::Expr, quoted::Expr, source::LineNumberNode, negate::Bool=false) comparison.head === :comparison || throw(ArgumentError("...
I think https://github.com/JuliaLang/julia/pull/61149 was right that `quoted` is the wrong predicate here in that it may have insufficiently many levels of quoting for correct printing.
source::LineNumberNode end struct Threw <: ExecutionResult exception current_exceptions::Base.ExceptionStack source::LineNumberNode end function eval_test_comparison(comparison::Expr, ops::Vector{Any}, source::LineNumberNode, negate::Bool=false) comparison.head === :comparison || throw(ArgumentErr...
@@ -368,33 +368,35 @@ struct Threw <: ExecutionResult source::LineNumberNode end -function eval_test_comparison(comparison::Expr, quoted::Expr, source::LineNumberNode, negate::Bool=false) +function eval_test_comparison(comparison::Expr, ops::Vector{Any}, source::LineNumberNode, negate::Bool=false) comparis...
stdlib/Test/src/Test.jl
26
Julia
0.5
bug
185
51
51
false
Test: quote Symbol values in @test failure pretty printing
61,054
JuliaLang/julia
35,573
Julia
Keno
apoorvdarshan
Review this pull request change. Language: Julia File: stdlib/Test/src/Test.jl PR Title: Test: quote Symbol values in @test failure pretty printing BEFORE CODE: source::LineNumberNode end struct Threw <: ExecutionResult exception current_exceptions::Base.ExceptionStack source::LineNumberNode end f...
I think https://github.com/JuliaLang/julia/pull/61149 was right that `quoted` is the wrong predicate here in that it may have insufficiently many levels of quoting for correct printing.
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 isnothing(st_k) setattr!(newnode(graph, old_src, K"unknown_head", cs), :name_val, head_s) else newnode(graph, old_src, st_k, cs) end # elseif e isa GlobalRef # TODO: Better-behaved as K"globalref", but lowering doesn't know this else # We may wa...
```suggestion function est_to_expr(st::SyntaxTree; suppress_linenodes=false) ``` just a suggestion, for clarity
if isnothing(st_k) setattr!(newnode(graph, old_src, K"unknown_head", cs), :name_val, head_s) else newnode(graph, old_src, st_k, cs) end # elseif e isa GlobalRef # TODO: Better-behaved as K"globalref", but lowering doesn't know this else # We may wa...
@@ -97,7 +97,7 @@ function _expr_to_est(graph::SyntaxGraph, @nospecialize(e), src::LineNumberNode) return st._id, src end -function est_to_expr(st::SyntaxTree) +function est_to_expr(st::SyntaxTree, suppress_linenodes=false)
JuliaLowering/src/compat.jl
26
Julia
0.714
suggestion
111
51
51
false
[JuliaLowering] Several small bugfixes found in stdlib testing
61,070
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/compat.jl PR Title: [JuliaLowering] Several small bugfixes found in stdlib testing BEFORE CODE: if isnothing(st_k) setattr!(newnode(graph, old_src, K"unknown_head", cs), :name_val, head_s) else newnode(g...
```suggestion function est_to_expr(st::SyntaxTree; suppress_linenodes=false) ``` just a suggestion, for clarity
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.
QuoteNode(est_to_expr(st[1])) else # TODO: should handle post-lowering forms as well @assert !is_leaf(st) "est_to_expr should only be used pre-desugaring" # In a partially-expanded or quoted AST, there may be heads with no # corresponding kind head = Symbol(k === K"un...
```suggestion let suppress_linenodes = i == 1 && (k == K"for" || k == K"let") push!(out.args, est_to_expr(c; suppress_linenodes)) end ```
# Expr(st.value). isa_lowering_ast_node(v) ? QuoteNode(v) : v elseif k === K"inert" QuoteNode(est_to_expr(st[1])) else # TODO: should handle post-lowering forms as well @assert !is_leaf(st) "est_to_expr should only be used pre-desugaring" # In a partially-expanded...
@@ -116,22 +116,45 @@ function est_to_expr(st::SyntaxTree) elseif k === K"inert" QuoteNode(est_to_expr(st[1])) else - # TODO: should handle post-desugaring forms as well + # TODO: should handle post-lowering forms as well @assert !is_leaf(st) "est_to_expr should only be used pr...
JuliaLowering/src/compat.jl
26
Julia
0.714
suggestion
177
51
51
false
[JuliaLowering] Several small bugfixes found in stdlib testing
61,070
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/compat.jl PR Title: [JuliaLowering] Several small bugfixes found in stdlib testing BEFORE CODE: QuoteNode(est_to_expr(st[1])) else # TODO: should handle post-lowering forms as well @assert !is_leaf(st) "est_to_expr ...
```suggestion let suppress_linenodes = i == 1 && (k == K"for" || k == K"let") push!(out.args, est_to_expr(c; suppress_linenodes)) 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.
# Macro authors are responsible for handling any linenodes that follow # the rules above (but the presence of optional linenodes can't be # counted upon). need_lnns = head in (:block, :toplevel) && !suppress_linenodes for (i, c) in enumerate(children(st)) need_lnns &&...
Is it possible for this to add the `LineNumberNode` we're trying to suppress?
# Other than that, optional linenodes may show up anywhere within: # - `block`, unless the block is the first child of `for` or `let` # - `toplevel` # Macro authors are responsible for handling any linenodes that follow # the rules above (but the presence of optional linenodes ca...
@@ -116,22 +116,45 @@ function est_to_expr(st::SyntaxTree) elseif k === K"inert" QuoteNode(est_to_expr(st[1])) else - # TODO: should handle post-desugaring forms as well + # TODO: should handle post-lowering forms as well @assert !is_leaf(st) "est_to_expr should only be used pr...
JuliaLowering/src/compat.jl
26
Julia
0.357
question
77
51
51
false
[JuliaLowering] Several small bugfixes found in stdlib testing
61,070
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/compat.jl PR Title: [JuliaLowering] Several small bugfixes found in stdlib testing BEFORE CODE: # Macro authors are responsible for handling any linenodes that follow # the rules above (but the presence of optional linenodes ca...
Is it possible for this to add the `LineNumberNode` we're trying to suppress?
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.
head = Symbol(k === K"unknown_head" ? st.name_val : untokenize(k)) out = Expr(head) # (Move the following assumptions to the docs if they turn out accurate) # The only mandatory LineNumberNode is the second macrocall argument. # Other than that, optional linenodes may show up an...
```suggestion # all following cases ignore `suppress_linenodes` # (it only applies to the immediate expression, not transitively to children) [K"module" _... [K"block" _...]] -> ```
@assert !is_leaf(st) "est_to_expr should only be used pre-desugaring" # In a partially-expanded or quoted AST, there may be heads with no # corresponding kind head = Symbol(k === K"unknown_head" ? st.name_val : untokenize(k)) out = Expr(head) # (Move the following assump...
@@ -116,22 +116,45 @@ function est_to_expr(st::SyntaxTree) elseif k === K"inert" QuoteNode(est_to_expr(st[1])) else - # TODO: should handle post-desugaring forms as well + # TODO: should handle post-lowering forms as well @assert !is_leaf(st) "est_to_expr should only be used pr...
JuliaLowering/src/compat.jl
26
Julia
0.786
suggestion
217
51
51
false
[JuliaLowering] Several small bugfixes found in stdlib testing
61,070
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/compat.jl PR Title: [JuliaLowering] Several small bugfixes found in stdlib testing BEFORE CODE: head = Symbol(k === K"unknown_head" ? st.name_val : untokenize(k)) out = Expr(head) # (Move the following assumptions to t...
```suggestion # all following cases ignore `suppress_linenodes` # (it only applies to the immediate expression, not transitively to children) [K"module" _... [K"block" _...]] -> ```
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.
int sweep_full = next_sweep_full; int recollect = 0; assert(gc_n_threads != 0); for (int i = 0; i < gc_n_threads; i++) { jl_ptls_t ptls2 = gc_all_tls_states[i]; if (ptls2 != NULL) remset_nptr += ptls2->gc_tls.heap.remset_nptr; } (void)remset_nptr; //Use this informati...
please take a note - we are monitoring content of `gc_record_full_sweep_reason` and gc_num during pre/post gc hooks to understand what runtime decided to do. please make sure that we would be able to reconstruct that FULL GC scheduled but cancelled
int remset_nptr = 0; int sweep_full = next_sweep_full; int recollect = 0; assert(gc_n_threads != 0); for (int i = 0; i < gc_n_threads; i++) { jl_ptls_t ptls2 = gc_all_tls_states[i]; if (ptls2 != NULL) remset_nptr += ptls2->gc_tls.heap.remset_nptr; } (void)remset_n...
@@ -3177,6 +3178,9 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection) JL_NOTS recollect = 1; gc_record_full_sweep_reason(FULL_SWEEP_REASON_FORCED_FULL_SWEEP); } + if (gc_disable_auto_full_sweep && collection != JL_GC_FULL) { + sweep_full = 0;
src/gc-stock.c
26
C
0.571
suggestion
248
51
51
false
Add API to disable full collections
61,087
JuliaLang/julia
35,573
Julia
tz-lom
gbaraldi
Review this pull request change. Language: C File: src/gc-stock.c PR Title: Add API to disable full collections BEFORE CODE: int sweep_full = next_sweep_full; int recollect = 0; assert(gc_n_threads != 0); for (int i = 0; i < gc_n_threads; i++) { jl_ptls_t ptls2 = gc_all_tls_states[i]; ...
please take a note - we are monitoring content of `gc_record_full_sweep_reason` and gc_num during pre/post gc hooks to understand what runtime decided to do. please make sure that we would be able to reconstruct that FULL GC scheduled but cancelled
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.
x == 2 && return Int(0) x == 3 && return C_NULL return nothing end function _bitcast_trigger(x::Int) val = _bitcast_returns_union(x) return Core.Intrinsics.bitcast(Ptr{Nothing}, val) end @test _bitcast_trigger(1) === Ptr{Nothing}(0) @test _bitcast_trigger(3) =...
This triggers some UB and may make the GC segfault (since the unsafe_store isn't visible, so in rare cases the `val` might survive after the preserve block ends but not the contents). Can you use a `Libc.malloc` for buf to avoid any issues
x == 2 && return Int(0) x == 3 && return C_NULL return nothing end function _bitcast_trigger(x::Int) val = _bitcast_returns_union(x) return Core.Intrinsics.bitcast(Ptr{Nothing}, val) end @test _bitcast_trigger(1) === Ptr{Nothing}(0) @test _bitcast_trigger(3) =...
@@ -587,3 +587,29 @@ end @test _bitcast_trigger(1) === Ptr{Nothing}(0) @test _bitcast_trigger(3) === Ptr{Nothing}(0) end + +# Test unsafe_store! on union values with inline_roots (split representation) +@testset "pointerset union with inline_roots" begin + struct PointersetMixedGC + a::Vector{Int} ...
test/intrinsics.jl
26
Julia
0.643
bug
239
38
38
false
fix pointerset for values with inline_roots
61,105
JuliaLang/julia
35,573
Julia
vtjnash
adienes
Review this pull request change. Language: Julia File: test/intrinsics.jl PR Title: fix pointerset for values with inline_roots BEFORE CODE: x == 2 && return Int(0) x == 3 && return C_NULL return nothing end function _bitcast_trigger(x::Int) val = _bitcast_returns_union(x) ...
This triggers some UB and may make the GC segfault (since the unsafe_store isn't visible, so in rare cases the `val` might survive after the preserve block ends but not the contents). Can you use a `Libc.malloc` for buf to avoid any issues
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 (id, from_outer_lambda) in lambda_bindings.locals_capt b = get_binding(ctx, id) !b.is_captured && continue from_outer_lambda && continue if b.is_assigned_once && b.kind in (:local, :argument) push!(candidates, id) end end isempty(candidates) && return ...
```suggestion # safe-to-unbox implies is-always-defined (but not vice-versa) b.safe_to_unbox = true b.is_always_defined = true ``` this may be clearer than the separate `for` loop below, since the is_always_defined check is not actually sufficient on its own, which is why we cannot ...
for (id, from_outer_lambda) in lambda_bindings.locals_capt b = get_binding(ctx, id) !b.is_captured && continue from_outer_lambda && continue if b.is_assigned_once && b.kind in (:local, :argument) push!(candidates, id) end end isempty(candidates) && return ...
@@ -319,40 +308,38 @@ function _analyze_lambda_vars!(ctx, ex) # Collect candidate variables: captured and single-assigned candidates = Set{IdTag}() for (id, from_outer_lambda) in lambda_bindings.locals_capt - binfo = get_binding(ctx, id) - maybe_boxed = binfo.is_captured && binfo.kind in (:...
JuliaLowering/src/binding_analysis.jl
26
Julia
0.857
suggestion
340
37
26
false
[JuliaLowering] Don't clobber `is_always_defined` in unboxing
61,134
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/binding_analysis.jl PR Title: [JuliaLowering] Don't clobber `is_always_defined` in unboxing BEFORE CODE: for (id, from_outer_lambda) in lambda_bindings.locals_capt b = get_binding(ctx, id) !b.is_captured && continue ...
```suggestion # safe-to-unbox implies is-always-defined (but not vice-versa) b.safe_to_unbox = true b.is_always_defined = true ``` this may be clearer than the separate `for` loop below, since the is_always_defined check is not actually sufficient on its own, which is why we cannot ...
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.
symbolic_block_labels::Set{String} # labels that are symbolic blocks (not allowed as @goto targets) meta::Dict{Symbol, Any} mod::Module end function LinearIRContext(graph, ctx, is_toplevel_thunk, lambda_bindings, return_type) rett = isnothing(return_type) ? nothing : reparent(graph, return_type) A...
```suggestion binfo.is_always_defined ```
symbolic_block_labels::Set{String} # labels that are symbolic blocks (not allowed as @goto targets) meta::Dict{Symbol, Any} mod::Module end function LinearIRContext(graph, ctx, is_toplevel_thunk, lambda_bindings, return_type) rett = isnothing(return_type) ? nothing : reparent(graph, return_type) A...
@@ -106,9 +106,6 @@ function is_valid_body_ir_argument(ctx, ex) true elseif kind(ex) == K"BindingId" binfo = get_binding(ctx, ex) - # arguments are inherently always-defined, but the closure - # box analysis overrides this flag to mean "valid to leave - # unboxed" so we check...
JuliaLowering/src/linear_ir.jl
26
Julia
0.429
suggestion
49
51
51
false
[JuliaLowering] Don't clobber `is_always_defined` in unboxing
61,134
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/linear_ir.jl PR Title: [JuliaLowering] Don't clobber `is_always_defined` in unboxing BEFORE CODE: symbolic_block_labels::Set{String} # labels that are symbolic blocks (not allowed as @goto targets) meta::Dict{Symbol, Any} mod::Mod...
```suggestion binfo.is_always_defined ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# fields. The new type will be named `name_str` which must be an unassigned # name in the module. function type_for_closure(ctx::ClosureConversionCtx, srcref, name_str, field_syms, field_is_box) # New closure types always belong to the module we're expanding into - they # need to be serialized there during prec...
Arguably this should be set in the `.unboxed` analysis too
# fields. The new type will be named `name_str` which must be an unassigned # name in the module. function type_for_closure(ctx::ClosureConversionCtx, srcref, name_str, field_syms, field_is_box) # New closure types always belong to the module we're expanding into - they # need to be serialized there during prec...
@@ -292,20 +292,15 @@ function type_for_closure(ctx::ClosureConversionCtx, srcref, name_str, field_sym type_ex, type_binding end +# No box needed for: +# - non-captured vars +# - static params (can't be reassigned) +# - any local our optimizations have determined to be unboxed function is_boxed(binfo::BindingI...
JuliaLowering/src/closure_conversion.jl
26
Julia
0.429
suggestion
58
51
51
false
[JuliaLowering] Don't clobber `is_always_defined` in unboxing
61,134
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/closure_conversion.jl PR Title: [JuliaLowering] Don't clobber `is_always_defined` in unboxing BEFORE CODE: # fields. The new type will be named `name_str` which must be an unassigned # name in the module. function type_for_closure(ctx::Closure...
Arguably this should be set in the `.unboxed` analysis 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.
} jl_locked_stream &get_dump_compiles_stream() JL_NOTSAFEPOINT JL_NOTSAFEPOINT_ENTER { return dump_compiles_stream; } jl_locked_stream &get_dump_llvm_opt_stream() JL_NOTSAFEPOINT JL_NOTSAFEPOINT_ENTER { return dump_llvm_opt_stream; } std::string getMangledName(StringRef Name) JL_...
Would be good to document the meaning of the return value here.
} jl_locked_stream &get_dump_compiles_stream() JL_NOTSAFEPOINT JL_NOTSAFEPOINT_ENTER { return dump_compiles_stream; } jl_locked_stream &get_dump_llvm_opt_stream() JL_NOTSAFEPOINT JL_NOTSAFEPOINT_ENTER { return dump_llvm_opt_stream; } std::string getMangledName(StringRef Name) JL_...
@@ -785,7 +785,7 @@ class JuliaOJIT { // Rename LinkGraph symbols to match the previously chosen names and // register debug info for defined symbols. - void linkOutput(orc::MaterializationResponsibility &MR, MemoryBufferRef ObjBuf, + bool linkOutput(orc::MaterializationResponsibility &MR, MemoryBuffe...
src/jitlayers.h
26
C/C++
0.214
suggestion
63
51
51
false
Local names linking fixes
61,165
JuliaLang/julia
35,573
Julia
topolarity
xal-0
Review this pull request change. Language: C/C++ File: src/jitlayers.h PR Title: Local names linking fixes BEFORE CODE: } jl_locked_stream &get_dump_compiles_stream() JL_NOTSAFEPOINT JL_NOTSAFEPOINT_ENTER { return dump_compiles_stream; } jl_locked_stream &get_dump_llvm_opt_stream() JL_NOTSAF...
Would be good to document the meaning of the return value here.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.