Skip to content

Commit d590823

Browse files
committed
8350106: [PPC] Avoid ticks_unknown_not_Java AsyncGetCallTrace() if JavaFrameAnchor::_last_Java_pc not set
Reviewed-by: phh Backport-of: 030c85de1376123615e804f98084cb3723205819
1 parent 6b6961d commit d590823

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

src/hotspot/os_cpu/aix_ppc/javaThread_aix_ppc.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 1997, 2023, 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
*
@@ -28,6 +28,7 @@
2828
#include "memory/metaspace.hpp"
2929
#include "runtime/frame.inline.hpp"
3030
#include "runtime/javaThread.hpp"
31+
#include "runtime/os.inline.hpp"
3132

3233
frame JavaThread::pd_last_frame() {
3334
assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
@@ -47,9 +48,17 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext,
4748
if (has_last_Java_frame() && frame_anchor()->walkable()) {
4849
intptr_t* sp = last_Java_sp();
4950
address pc = _anchor.last_Java_pc();
50-
// pc can be seen as null because not all writers use store pc + release store sp.
51-
// Simply discard the sample in this very rare case.
52-
if (pc == nullptr) return false;
51+
if (pc == nullptr) {
52+
// This is not uncommon. Many c1/c2 runtime stubs do not set the pc in the anchor.
53+
intptr_t* top_sp = os::Aix::ucontext_get_sp((const ucontext_t*)ucontext);
54+
if ((uint64_t)sp <= ((frame::common_abi*)top_sp)->callers_sp) {
55+
// The interrupt occurred either in the last java frame or in its direct callee.
56+
// We cannot be sure that the link register LR was already saved to the
57+
// java frame. Therefore we discard this sample.
58+
return false;
59+
}
60+
// The last java pc will be found in the abi part of the last java frame.
61+
}
5362
*fr_addr = frame(sp, pc);
5463
return true;
5564
}

src/hotspot/os_cpu/linux_ppc/javaThread_linux_ppc.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 1997, 2023, 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
@@ -47,9 +47,17 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext,
4747
if (has_last_Java_frame() && frame_anchor()->walkable()) {
4848
intptr_t* sp = last_Java_sp();
4949
address pc = _anchor.last_Java_pc();
50-
// pc can be seen as null because not all writers use store pc + release store sp.
51-
// Simply discard the sample in this very rare case.
52-
if (pc == nullptr) return false;
50+
if (pc == nullptr) {
51+
// This is not uncommon. Many c1/c2 runtime stubs do not set the pc in the anchor.
52+
intptr_t* top_sp = os::Linux::ucontext_get_sp((const ucontext_t*)ucontext);
53+
if ((uint64_t)sp <= ((frame::common_abi*)top_sp)->callers_sp) {
54+
// The interrupt occurred either in the last java frame or in its direct callee.
55+
// We cannot be sure that the link register LR was already saved to the
56+
// java frame. Therefore we discard this sample.
57+
return false;
58+
}
59+
// The last java pc will be found in the abi part of the last java frame.
60+
}
5361
*fr_addr = frame(sp, pc);
5462
return true;
5563
}

0 commit comments

Comments
 (0)