-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gc use intrinisic #23562
Add gc use intrinisic #23562
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good enough as a first version but should be extended to be compatible with dead code elimination.
base/boot.jl
Outdated
@@ -438,4 +438,6 @@ show(@nospecialize a) = show(STDOUT, a) | |||
print(@nospecialize a...) = print(STDOUT, a...) | |||
println(@nospecialize a...) = println(STDOUT, a...) | |||
|
|||
gcuse(a) = ccall(:jl_gc_use, Void, (Any,), a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nospecialize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if that doesn't prevent inlining.
Now that our gc root placement pass is significantly more aggressive about dropping roots, we need to be a bit more careful about our use of pointer, etc. This adds a low-level intrinsic for annotating gc uses to keep objects alive even if they would be otherwise unreferenced. As an initial use case, we get rid of a number of uses of `pointer` in string, but creating a new `unsafe_load` that keeps the string alive.
end | ||
cnum | ||
end | ||
|
||
@noinline function slow_utf8_next(p::Ptr{UInt8}, b::UInt8, i::Int, l::Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The noinline
can probably be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that was there for performance reasons to keep the slow path out of the icache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sure. (Not that the current heuristic inlines the big function anyway....)
@@ -59,6 +59,13 @@ String(s::Symbol) = unsafe_string(Cstring(s)) | |||
pointer(s::String) = unsafe_convert(Ptr{UInt8}, s) | |||
pointer(s::String, i::Integer) = pointer(s)+(i-1) | |||
|
|||
function unsafe_load(s::String, i::Integer=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem like the right name for this function, as we've been deprecating names of this form. It seems like it should be spelled @inbounds codeunit(...)
instead, following the example of the array code.
Addresses post-commit review in #23562.
Now that our gc root placement pass is significantly more aggressive about
dropping roots, we need to be a bit more careful about our use of pointer,
etc. This adds a low-level, zero-overhead intrinsic for annotating gc uses to keep objects
alive even if they would be otherwise unreferenced.
As an initial use case, we get rid of a number of uses of
pointer
in string,but creating a new
unsafe_load
that keeps the string alive.