RFR: Implement JEP 509: JFR CPU-Time Profiling [v45]
Johan Sjölen
jsjolen at openjdk.org
Mon May 5 13:29:56 UTC 2025
On Mon, 5 May 2025 13:17:31 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
>> I see. If it is only used in signal handlers, does it really need to be multi-threaded?
>
> 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();
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20752#discussion_r2073436807
More information about the hotspot-dev
mailing list