RFR: Implement JEP 509: JFR CPU-Time Profiling [v45]

Johannes Bechberger jbechberger at openjdk.org
Mon May 5 13:29:57 UTC 2025


On Mon, 5 May 2025 13:20:17 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> The `LockFreeStack` doesn't say how its elements are allocated, so you can allocate your elements into an array.
>
> ```c++
> struct Node { volatile Node* next; int x; static volatile Node* get_next(Node& n)  { return n->next; } }
> static Node nodes[16];
> static i = 0;
> Node* alloc() {
>   return nodes[i++]:
> }
> 
> void foo() {
>   LockFreeStack<Node, Node::get_next> lfs;
>   Node* n = alloc();
>   n->x = 0;
>   lfs.push(n*);
>   Node* n2 = lfs.top();
>   tty->print_cr("%d\n", n2->x);
>   lfs.pop();
> }

Wouldn't this defeat its purpose? I would need to get the next free element from an array whenever I want to enqueue.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20752#discussion_r2073437538


More information about the hotspot-dev mailing list