You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-7248 Simultaneous access when using non-class-bound protocol
Issue Description:
Currently, SILGen emits a nonmutating setter call as a mutation of the underlying access path. Enough jargon. This is what happens to an innocent fruit basket:
publicprotocolFruit {
varseeds: Int { getnonmutatingset }
}
classApple: Fruit {
init() {}
varseeds: Int = 0
}
publicclassBasket {
varfruit: Fruit = Apple()
}
publicfuncfoo(basket: Basket) {
basket.fruit.seeds = 3
}
foo will begin an exclusive modify of `fruit`, call materializeForSet, execute the writeback, and end the exlusive access.
However, the fruit isn't actually being modified (according to this silly class-based model, the seeds aren't part of the value). So, we should not need exclusive access to fruit, and we shouldn't need to materializeForSet or writeback. Just getting a reference to its seeds and calling the setter should be fine.
In addition to performance, this actually affects semantics. Fixing this is backward source compatible though, so this is a good improvement to make any time.
Additional Detail from JIRA
md5: e48aca74fdd947f40063a338b94cec45
relates to:
Issue Description:
Currently, SILGen emits a nonmutating setter call as a mutation of the underlying access path. Enough jargon. This is what happens to an innocent fruit basket:
foo
will begin an exclusive modify of `fruit`, call materializeForSet, execute the writeback, and end the exlusive access.However, the fruit isn't actually being modified (according to this silly class-based model, the seeds aren't part of the value). So, we should not need exclusive access to fruit, and we shouldn't need to materializeForSet or writeback. Just getting a reference to its seeds and calling the setter should be fine.
In addition to performance, this actually affects semantics. Fixing this is backward source compatible though, so this is a good improvement to make any time.
The text was updated successfully, but these errors were encountered: