On Tue, 28 Apr 2026 23:04:08 GMT, Serguei Spitsyn <[email protected]> wrote:
>> Thanks for the questions. >> >>> When you combine the semantics of klass->allocate_instance() and copying >>> with BufferedValuePayload, are you guaranteed to have a fully initialized >>> object? >> >> What do you mean by this? The purpose is to create a snapshot even though >> the object has not been fully initialized yet. In fact, it can be >> non-initialized at all. Is it a concern about a need for a memory order >> action like: >> >> // Must ensure the content of the buffered value is visible >> // before publishing the buffered value oop >> OrderAccess::storestore(); >> >> Please, see `FlatValuePayload::read(TRAPS)`. >> I guess, we can check with @dean-long if it is really needed. > > Update: I've added a call to the `OrderAccess::storestore();`. > Also, does BufferedValuePayload do deep cloning, and if yes, is that > necessary? I don't think it is necessary. I'm not sure there is a reason for that. We create a value object snapshot during initialization. It is needed because the value object can mutate during its construction, and so, the `ObjectReference` we create can cause some trouble. It is not clear if it is allowed for value objects to have mutable references to other objects in their fields. But if it is, then it has to be okay and right thing to do to avoid their snashotting. ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/2363#discussion_r3157768688
