-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
optimize the new setglobal! function #44753
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
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.
Not super familiar with all the codegen parts, but otherwise LGTM
| if (ty == (jl_value_t*)jl_nothing) { | ||
| jl_binding_t *b = jl_get_binding_wr(mod, sym, 0); | ||
| if (b) { | ||
| if (b && b->owner == mod) { |
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.
Ah, good catch!
The codegen declares this is callee rooted (since we do not usually alllocate), but we might call jl_isa now, which could. The annotations on this function previously were incorrect.
Main exports everything, so it is not useful to include in this test. Refs: #44740
Fixes some atomic ordering issues also where we were ignoring the argument. Uses the new builtin where we could. But also fixes some cases where we would allocate the global binding at the wrong time (which is a globally visible side-effect of compilation), or might throw from inside codegen accidentally there instead.
ccd83f2 to
bcbdfc3
Compare
|
This should probably not have been squashed, as the commit message now is somewhat gibberish |
* add missing gc root for typed global assignment The codegen declares this is callee rooted (since we do not usually alllocate), but we might call jl_isa now, which could. The annotations on this function previously were incorrect. * test: make exports of modules check ignore Main Main exports everything, so it is not useful to include in this test. Refs: #44740 * codegen: optimize setglobal like assignment Fixes some atomic ordering issues also where we were ignoring the argument. Uses the new builtin where we could. But also fixes some cases where we would allocate the global binding at the wrong time (which is a globally visible side-effect of compilation), or might throw from inside codegen accidentally there instead.
This optimizes
setglobal!in codegen, as well as fixes some issues encountered with itside note: our set of random things that might happen when you declare something global (e.g. assign to it, look up its type, using it, import it–possibly as something else–create a method, or write the
globalkeyword in some context—all conditional on whether it wasconstsomewhere at some point) is quite a bit intractable to deal with