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
type Buffer struct {
buf []byte
bootstrap [64]byte
}
var b *Buffer = ...
b.buf = b.bootstrap[:]
I don't think we need a write barrier when we write the slice pointer into b.buf, because the pointer always points from an object into (part of) itself.
But see the discussion in #14855 . Writing a pointer to the heap without a write barrier is tricky in the presence of races. Make sure the arguments in that issue don't apply here (I don't think they do, writing a self-pointer is like writing nil).
How much do you think this would actually win? Rick and I just spent half an hour debating whether it was actually safe to ignore write barriers for writes of nil in the presence of concurrent stack rescanning (which we don't do yet, but are considering). We eventually decided it was, but things like that make me weary of subtle write barrier optimizations.
Go code often does something like:
I don't think we need a write barrier when we write the slice pointer into b.buf, because the pointer always points from an object into (part of) itself.
But see the discussion in #14855 . Writing a pointer to the heap without a write barrier is tricky in the presence of races. Make sure the arguments in that issue don't apply here (I don't think they do, writing a self-pointer is like writing nil).
@aclements
The text was updated successfully, but these errors were encountered: