On Wed, 13 May 2026 10:12:50 GMT, Axel Boldt-Christmas <[email protected]> 
wrote:

> This changes our runtime clone barriers to unconditionally handle tenured 
> destination objects. 
> 
> We already had a solution for object arrays as they were something ZGCs own 
> allocator could tenure, however we assumed no safepoints for normal object 
> clones. However  because of `JVMTI_EVENT_SAMPLED_OBJECT_ALLOC` arbitrary java 
> code may be ran between the allocation and the clone barrier. 
> 
> This patch creates a lock-step iterator, which iterates over the object, 
> copies everything between the oops incrementally and does the proper load, 
> and store barriers. 
> 
> _The only thing the implementation currently rely on is that our 
> `oop_oop_iterate` iterator visits the fields or elements in address order, 
> which I do not see changing, but is currently not an explicit contract but an 
> implementation detail._
> 
> The initial implementation used this new construction for tenured object 
> clone. By the fact is that the new cloner can handle cloning any object with 
> the same or better overhead than the three different implementations. So 
> added a commit which generalised and uses this cloner for all objects: 
> https://github.com/openjdk/jdk/commit/e7e4de633204d50d2a8b153a590dc82d02bdf6f7
> 
> Also added a `JVMTI_EVENT_SAMPLED_OBJECT_ALLOC` reproducer, which verifies 
> that we can handle tenured object and object array clones. 
> 
> Currently running testing.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: f2bc36d8
Author:    Axel Boldt-Christmas <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/f2bc36d8ddfd7fd011162bdd796a6988dd82db9e
Stats:     457 lines in 7 files changed: 426 ins; 18 del; 13 mod

8383421: ZGC: Problematic interactions between 
`JVMTI_EVENT_SAMPLED_OBJECT_ALLOC` and `clone`

Reviewed-by: stefank, jsikstro

-------------

PR: https://git.openjdk.org/jdk/pull/31149

Reply via email to