Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add gc use intrinisic #23562

Merged
merged 1 commit into from
Sep 3, 2017
Merged

Add gc use intrinisic #23562

merged 1 commit into from
Sep 3, 2017

Conversation

Keno
Copy link
Member

@Keno Keno commented Sep 2, 2017

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.

Copy link
Contributor

@yuyichao yuyichao left a 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.

@ararslan ararslan added the GC Garbage collector label Sep 2, 2017
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)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nospecialize?

Copy link
Member Author

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)
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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....)

@Keno Keno merged commit 7e2e6c9 into master Sep 3, 2017
@martinholters martinholters deleted the kf/gcuse branch September 3, 2017 17:29
@@ -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)
Copy link
Sponsor Member

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.

Keno added a commit that referenced this pull request Sep 4, 2017
Addresses post-commit review in #23562.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GC Garbage collector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants