-
Notifications
You must be signed in to change notification settings - Fork 1
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
Accessing non-shared locals insides shared-barrier #47
Comments
Taking this a step further, you could say that there truly is no difference between shared-suspendable and shared-fixed functions, just shared functions that are all suspendable by default but are also allowed to have unshared parameters and locals. The unshared parameters can always be safely accessed; it is impossible for a function with unshared parameters to be called except inside a shared barrier or unshared function. Unshared locals can be accessed only in shared barriers as described above. We could optionally make shared functions with unshared parameters have implicit shared barriers around their bodies to save code size, but that’s probably too magical. Regardless, engines could optimize out explicit shared barriers in such functions and just have them reset any unshared locals since the engine would know that there must already be a shared barrier on the stack. |
Thinking about the following program...
I think the only way to make the above work is to make
EDIT: ah, I get the point about unshared parameters - if they were provided, there must already be an outer EDIT2: one further point - if the reason to avoid separate |
Right, the neat thing here is that unshared locals can never be live outside of or across shared-barriers by construction.
But this is totally fine because all shared functions with the same signatures can have the same type. If one function takes a shared argument and another had a similar signature but the argument is unshared, then of course they’re going to have different function types. |
This is an interesting idea. I sort of understand the local managment as One unfortunate piece here is that we'd have to pay the complexity cost of But then again, timelines for standards are hard to predict. Maybe we'll have stack-switching finished before this proposal? |
@eqrion I'm personally beginning to feel that starting out with EDIT: and starting with just This would likely mean that |
Why is that? My understanding is that we would want to differentiate the definitions to determine the validation mode for their bodies, but why would references to the two kinds of functions need to have different types? Apart from that point, starting with |
If we start with I would currently be in favour of the latter semantics for two reasons.
EDIT: thinking through things further, I think I could be ok with the "implicit |
Makes sense.
I've been assuming that |
At the meeting today we discussed how it would be useful for
shared-barrier
to work likelet
and introduce new non-shared locals that could be accessed only inside the barrier block. However,let
had a bunch of usability issues that caused us to discard it in favor of tracking the initialization state of non-nullable locals.I realized that we could use the same strategy for non-shared locals inside
shared-barrier
blocks. Non-shared locals could be declared alongside other locals in shared-suspendable functions, but would not be accessible except insideshared-barrier
blocks. They would start out as uninitialized at the beginning of eachshared-barrier
and would have to be explicitly initialized (potentially with null values) before they could be accessed. Alternatively, the beginning of theshared-barrier
could implicitly set defaultable non-shared locals to their default values.This seems to neatly solve the problem of accessing non-shared locals inside
shared-barriers
using only the existing mechanism of initialization tracking. It also eliminates one of the differences between shared-suspendable and shared-fixed functions by letting them declare the same kinds of locals, which seems nice.The text was updated successfully, but these errors were encountered: