Skip to content
41 changes: 0 additions & 41 deletions src/hotspot/cpu/aarch64/frame_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,47 +453,6 @@ JavaThread** frame::saved_thread_address(const frame& f) {
return thread_addr;
}

//------------------------------------------------------------------------------
// frame::verify_deopt_original_pc
//
// Verifies the calculated original PC of a deoptimization PC for the
// given unextended SP.
#ifdef ASSERT
void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) {
frame fr;

// This is ugly but it's better than to change {get,set}_original_pc
// to take an SP value as argument. And it's only a debugging
// method anyway.
fr._unextended_sp = unextended_sp;

address original_pc = nm->get_original_pc(&fr);
assert(nm->insts_contains_inclusive(original_pc),
"original PC must be in the main code section of the compiled method (or must be immediately following it)");
}
#endif

//------------------------------------------------------------------------------
// frame::adjust_unextended_sp
#ifdef ASSERT
void frame::adjust_unextended_sp() {
// On aarch64, sites calling method handle intrinsics and lambda forms are treated
// as any other call site. Therefore, no special action is needed when we are
// returning to any of these call sites.

if (_cb != nullptr) {
nmethod* sender_nm = _cb->as_nmethod_or_null();
if (sender_nm != nullptr) {
// If the sender PC is a deoptimization point, get the original PC.
if (sender_nm->is_deopt_entry(_pc)) {
verify_deopt_original_pc(sender_nm, _unextended_sp);
}
}
}
}
#endif


//------------------------------------------------------------------------------
// frame::sender_for_interpreter_frame
frame frame::sender_for_interpreter_frame(RegisterMap* map) const {
Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/cpu/aarch64/frame_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@
int _offset_unextended_sp; // for use in stack-chunk frames
};

void adjust_unextended_sp() NOT_DEBUG_RETURN;

// true means _sp value is correct and we can use it to get the sender's sp
// of the compiled frame, otherwise, _sp value may be invalid and we can use
// _fp to get the sender's sp if PreserveFramePointer is enabled.
Expand All @@ -152,11 +150,6 @@
return (intptr_t*) addr_at(offset);
}

#ifdef ASSERT
// Used in frame::sender_for_{interpreter,compiled}_frame
static void verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp);
#endif

public:
// Constructors

Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {
}

inline void frame::setup(address pc) {
adjust_unextended_sp();

address original_pc = get_deopt_original_pc();
if (original_pc != nullptr) {
_pc = original_pc;
Expand Down Expand Up @@ -223,7 +221,6 @@ inline frame::frame(intptr_t* sp, intptr_t* fp) {
// assert(_pc != nullptr, "no pc?");

_cb = CodeCache::find_blob(_pc);
adjust_unextended_sp();

address original_pc = get_deopt_original_pc();
if (original_pc != nullptr) {
Expand Down
36 changes: 0 additions & 36 deletions src/hotspot/cpu/arm/frame_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,42 +329,6 @@ JavaThread** frame::saved_thread_address(const frame& f) {
return nullptr;
}

//------------------------------------------------------------------------------
// frame::verify_deopt_original_pc
//
// Verifies the calculated original PC of a deoptimization PC for the
// given unextended SP.
#ifdef ASSERT
void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) {
frame fr;

// This is ugly but it's better than to change {get,set}_original_pc
// to take an SP value as argument. And it's only a debugging
// method anyway.
fr._unextended_sp = unextended_sp;

address original_pc = nm->get_original_pc(&fr);
assert(nm->insts_contains_inclusive(original_pc),
"original PC must be in the main code section of the compiled method (or must be immediately following it)");
}
#endif

//------------------------------------------------------------------------------
// frame::adjust_unextended_sp
void frame::adjust_unextended_sp() {
// On arm, sites calling method handle intrinsics and lambda forms are treated
// as any other call site. Therefore, no special action is needed when we are
// returning to any of these call sites.

nmethod* sender_nm = (_cb == nullptr) ? nullptr : _cb->as_nmethod_or_null();
if (sender_nm != nullptr) {
// If the sender PC is a deoptimization point, get the original PC.
if (sender_nm->is_deopt_entry(_pc)) {
DEBUG_ONLY(verify_deopt_original_pc(sender_nm, _unextended_sp));
}
}
}

//------------------------------------------------------------------------------
// frame::update_map_with_saved_link
void frame::update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr) {
Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/cpu/arm/frame_arm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,11 @@
// original sp.

intptr_t* _unextended_sp;
void adjust_unextended_sp();

intptr_t* ptr_at_addr(int offset) const {
return (intptr_t*) addr_at(offset);
}

#ifdef ASSERT
// Used in frame::sender_for_{interpreter,compiled}_frame
static void verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp);
#endif

public:
// Constructors

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/cpu/arm/frame_arm.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ inline void frame::init(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, add
}

inline void frame::setup(address pc) {
adjust_unextended_sp();

address original_pc = get_deopt_original_pc();
if (original_pc != nullptr) {
_pc = original_pc;
Expand Down
42 changes: 0 additions & 42 deletions src/hotspot/cpu/riscv/frame_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,48 +426,6 @@ JavaThread** frame::saved_thread_address(const frame& f) {
return thread_addr;
}

//------------------------------------------------------------------------------
// frame::verify_deopt_original_pc
//
// Verifies the calculated original PC of a deoptimization PC for the
// given unextended SP.
#ifdef ASSERT
void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) {
frame fr;

// This is ugly but it's better than to change {get,set}_original_pc
// to take an SP value as argument. And it's only a debugging
// method anyway.
fr._unextended_sp = unextended_sp;

assert_cond(nm != nullptr);
address original_pc = nm->get_original_pc(&fr);
assert(nm->insts_contains_inclusive(original_pc),
"original PC must be in the main code section of the compiled method (or must be immediately following it)");
}
#endif

//------------------------------------------------------------------------------
// frame::adjust_unextended_sp
#ifdef ASSERT
void frame::adjust_unextended_sp() {
// On riscv, sites calling method handle intrinsics and lambda forms are treated
// as any other call site. Therefore, no special action is needed when we are
// returning to any of these call sites.

if (_cb != nullptr) {
nmethod* sender_nm = _cb->as_nmethod_or_null();
if (sender_nm != nullptr) {
// If the sender PC is a deoptimization point, get the original PC.
if (sender_nm->is_deopt_entry(_pc)) {
verify_deopt_original_pc(sender_nm, _unextended_sp);
}
}
}
}
#endif


//------------------------------------------------------------------------------
// frame::sender_for_interpreter_frame
frame frame::sender_for_interpreter_frame(RegisterMap* map) const {
Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/cpu/riscv/frame_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,10 @@
int _offset_unextended_sp; // for use in stack-chunk frames
};

void adjust_unextended_sp() NOT_DEBUG_RETURN;

intptr_t* ptr_at_addr(int offset) const {
return (intptr_t*) addr_at(offset);
}

#ifdef ASSERT
// Used in frame::sender_for_{interpreter,compiled}_frame
static void verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp);
#endif

public:
// Constructors

Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/cpu/riscv/frame_riscv.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ inline void frame::init(intptr_t* ptr_sp, intptr_t* ptr_fp, address pc) {
}

inline void frame::setup(address pc) {
adjust_unextended_sp();

address original_pc = get_deopt_original_pc();
if (original_pc != nullptr) {
_pc = original_pc;
Expand Down Expand Up @@ -215,7 +213,6 @@ inline frame::frame(intptr_t* ptr_sp, intptr_t* ptr_fp) {
// value.

_cb = CodeCache::find_blob(_pc);
adjust_unextended_sp();

address original_pc = get_deopt_original_pc();
if (original_pc != nullptr) {
Expand Down
40 changes: 0 additions & 40 deletions src/hotspot/cpu/x86/frame_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,46 +442,6 @@ JavaThread** frame::saved_thread_address(const frame& f) {
return thread_addr;
}

//------------------------------------------------------------------------------
// frame::verify_deopt_original_pc
//
// Verifies the calculated original PC of a deoptimization PC for the
// given unextended SP.
#ifdef ASSERT
void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) {
frame fr;

// This is ugly but it's better than to change {get,set}_original_pc
// to take an SP value as argument. And it's only a debugging
// method anyway.
fr._unextended_sp = unextended_sp;

address original_pc = nm->get_original_pc(&fr);
assert(nm->insts_contains_inclusive(original_pc),
"original PC must be in the main code section of the compiled method (or must be immediately following it) original_pc: " INTPTR_FORMAT " unextended_sp: " INTPTR_FORMAT " name: %s", p2i(original_pc), p2i(unextended_sp), nm->name());
}
#endif

//------------------------------------------------------------------------------
// frame::adjust_unextended_sp
#ifdef ASSERT
void frame::adjust_unextended_sp() {
// On x86, sites calling method handle intrinsics and lambda forms are treated
// as any other call site. Therefore, no special action is needed when we are
// returning to any of these call sites.

if (_cb != nullptr) {
nmethod* sender_nm = _cb->as_nmethod_or_null();
if (sender_nm != nullptr) {
// If the sender PC is a deoptimization point, get the original PC.
if (sender_nm->is_deopt_entry(_pc)) {
verify_deopt_original_pc(sender_nm, _unextended_sp);
}
}
}
}
#endif

//------------------------------------------------------------------------------
// frame::sender_for_interpreter_frame
frame frame::sender_for_interpreter_frame(RegisterMap* map) const {
Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/cpu/x86/frame_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,10 @@
int _offset_unextended_sp; // for use in stack-chunk frames
};

void adjust_unextended_sp() NOT_DEBUG_RETURN;

intptr_t* ptr_at_addr(int offset) const {
return (intptr_t*) addr_at(offset);
}

#ifdef ASSERT
// Used in frame::sender_for_{interpreter,compiled}_frame
static void verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp);
#endif

public:
// Constructors

Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/cpu/x86/frame_x86.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {
}

inline void frame::setup(address pc) {
adjust_unextended_sp();

address original_pc = get_deopt_original_pc();
if (original_pc != nullptr) {
_pc = original_pc;
Expand Down Expand Up @@ -209,7 +207,6 @@ inline frame::frame(intptr_t* sp, intptr_t* fp) {
// assert(_pc != nullptr, "no pc?");

_cb = CodeCache::find_blob(_pc);
adjust_unextended_sp();

address original_pc = get_deopt_original_pc();
if (original_pc != nullptr) {
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/runtime/frame.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ inline address frame::get_deopt_original_pc() const {

nmethod* nm = _cb->as_nmethod_or_null();
if (nm != nullptr && nm->is_deopt_pc(_pc)) {
return nm->get_original_pc(this);
address original_pc = nm->get_original_pc(this);
assert(nm->insts_contains_inclusive(original_pc),
"original PC must be in the main code section of the compiled method (or must be immediately following it)");
return original_pc;
}
return nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ public static int pcReturnOffset() {
return pcReturnOffset;
}

protected void adjustForDeopt() {
if ( pc != null) {
// Look for a deopt pc and if it is deopted convert to original pc
CodeBlob cb = VM.getVM().getCodeCache().findBlob(pc);
if (cb != null && cb.isJavaMethod()) {
NMethod nm = (NMethod) cb;
if (pc.equals(nm.deoptHandlerBegin())) {
if (Assert.ASSERTS_ENABLED) {
Assert.that(this.getUnextendedSP() != null, "null SP in Java frame");
}
// adjust pc if frame is deoptimized.
pc = this.getUnextendedSP().getAddressAt(nm.origPCOffset());
deoptimized = true;
}
}
}
}

private static synchronized void initialize(TypeDataBase db) {
Type ConstMethodType = db.lookupType("ConstMethod");
// FIXME: not sure whether alignment here is correct or how to
Expand Down
Loading