Skip to content

Commit c363d3f

Browse files
committed
8350106: [PPC] Avoid ticks_unknown_not_Java AsyncGetCallTrace() if JavaFrameAnchor::_last_Java_pc not set
Reviewed-by: mdoerr Backport-of: d5908231ebc16f443b3fc9b2ebf03cc4deb67373
1 parent 1d96b82 commit c363d3f

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

src/hotspot/os_cpu/aix_ppc/thread_aix_ppc.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2012, 2014 SAP SE. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2012, 2025 SAP SE. All rights reserved.
44
* Copyright (c) 2022, IBM Corp.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
*
@@ -27,6 +27,7 @@
2727
#include "precompiled.hpp"
2828
#include "memory/metaspace.hpp"
2929
#include "runtime/frame.inline.hpp"
30+
#include "runtime/os.inline.hpp"
3031
#include "runtime/thread.hpp"
3132

3233
frame JavaThread::pd_last_frame() {
@@ -54,9 +55,19 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext,
5455
if (has_last_Java_frame() && frame_anchor()->walkable()) {
5556
intptr_t* sp = last_Java_sp();
5657
address pc = _anchor.last_Java_pc();
57-
// pc can be seen as null because not all writers use store pc + release store sp.
58-
// Simply discard the sample in this very rare case.
59-
if (pc == nullptr) return false;
58+
if (pc == nullptr) {
59+
// This is not uncommon. Many c1/c2 runtime stubs do not set the pc in the anchor.
60+
intptr_t* top_sp = os::Aix::ucontext_get_sp((const ucontext_t*)ucontext);
61+
if ((uint64_t)sp <= ((frame::abi_minframe*)top_sp)->callers_sp) {
62+
// The interrupt occurred either in the last java frame or in its direct callee.
63+
// We cannot be sure that the link register LR was already saved to the
64+
// java frame. Therefore we discard this sample.
65+
return false;
66+
}
67+
// The last java pc will be found in the abi part of the last java frame.
68+
*fr_addr = frame(sp);
69+
return true;
70+
}
6071
*fr_addr = frame(sp, pc);
6172
return true;
6273
}

src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2012, 2022 SAP SE. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2012, 2025 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -54,9 +54,19 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext,
5454
if (has_last_Java_frame() && frame_anchor()->walkable()) {
5555
intptr_t* sp = last_Java_sp();
5656
address pc = _anchor.last_Java_pc();
57-
// pc can be seen as null because not all writers use store pc + release store sp.
58-
// Simply discard the sample in this very rare case.
59-
if (pc == nullptr) return false;
57+
if (pc == nullptr) {
58+
// This is not uncommon. Many c1/c2 runtime stubs do not set the pc in the anchor.
59+
intptr_t* top_sp = os::Linux::ucontext_get_sp((const ucontext_t*)ucontext);
60+
if ((uint64_t)sp <= ((frame::abi_minframe*)top_sp)->callers_sp) {
61+
// The interrupt occurred either in the last java frame or in its direct callee.
62+
// We cannot be sure that the link register LR was already saved to the
63+
// java frame. Therefore we discard this sample.
64+
return false;
65+
}
66+
// The last java pc will be found in the abi part of the last java frame.
67+
*fr_addr = frame(sp);
68+
return true;
69+
}
6070
*fr_addr = frame(sp, pc);
6171
return true;
6272
}

0 commit comments

Comments
 (0)