Skip to content

Commit ea5c4ce

Browse files
authored
Update (2023.03.07)
29715: LA port of 8301346: Remove dead emit_entry_barrier_stub definition 29714: LA port of 8299795: Relativize locals in interpreter frames 29713: LA port of 8298400: Virtual thread instability when stack overflows
1 parent 19bcbbd commit ea5c4ce

File tree

9 files changed

+39
-18
lines changed

9 files changed

+39
-18
lines changed

src/hotspot/cpu/loongarch/c2_MacroAssembler_loongarch.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2021, 2022, Loongson Technology. All rights reserved.
3+
* Copyright (c) 2021, 2023, Loongson Technology. 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
@@ -29,9 +29,6 @@
2929
// C2_MacroAssembler contains high-level macros for C2
3030

3131
public:
32-
void emit_entry_barrier_stub(C2EntryBarrierStub* stub);
33-
static int entry_barrier_stub_size();
34-
3532
void cmp_branch_short(int flag, Register op1, Register op2, Label& L, bool is_signed);
3633
void cmp_branch_long(int flag, Register op1, Register op2, Label* L, bool is_signed);
3734
void cmp_branchEqNe_off21(int flag, Register op1, Label& L);

src/hotspot/cpu/loongarch/continuationFreezeThaw_loongarch.inline.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ inline void FreezeBase::relativize_interpreted_frame_metadata(const frame& f, co
145145

146146
// at(frame::interpreter_frame_last_sp_offset) can be NULL at safepoint preempts
147147
*hf.addr_at(frame::interpreter_frame_last_sp_offset) = hf.unextended_sp() - hf.fp();
148+
// this line can be changed into an assert when we have fixed the "frame padding problem", see JDK-8300197
148149
*hf.addr_at(frame::interpreter_frame_locals_offset) = frame::sender_sp_offset + f.interpreter_frame_method()->max_locals() - 1;
149150

150151
relativize_one(vfp, hfp, frame::interpreter_frame_initial_sp_offset); // == block_top == block_bottom
@@ -219,12 +220,12 @@ template<typename FKind> frame ThawBase::new_stack_frame(const frame& hf, frame&
219220
assert(frame_sp == unextended_sp, "");
220221
caller.set_sp(fp + frame::sender_sp_offset);
221222
frame f(frame_sp, frame_sp, fp, hf.pc());
222-
// it's set again later in set_interpreter_frame_bottom, but we need to set the locals now so that
223-
// we could call ContinuationHelper::InterpretedFrame::frame_bottom
223+
// we need to set the locals so that the caller of new_stack_frame() can call
224+
// ContinuationHelper::InterpretedFrame::frame_bottom
224225
intptr_t offset = *hf.addr_at(frame::interpreter_frame_locals_offset);
225226
assert((int)offset == frame::sender_sp_offset + locals - 1, "");
226-
// derelativize locals
227-
*(intptr_t**)f.addr_at(frame::interpreter_frame_locals_offset) = fp + offset;
227+
// set relativized locals
228+
*f.addr_at(frame::interpreter_frame_locals_offset) = offset;
228229
return f;
229230
} else {
230231
int fsize = FKind::size(hf);
@@ -285,7 +286,9 @@ inline void ThawBase::derelativize_interpreted_frame_metadata(const frame& hf, c
285286
}
286287

287288
inline void ThawBase::set_interpreter_frame_bottom(const frame& f, intptr_t* bottom) {
288-
*(intptr_t**)f.addr_at(frame::interpreter_frame_locals_offset) = bottom - 1;
289+
// set relativized locals
290+
// This line can be changed into an assert when we have fixed the "frame padding problem", see JDK-8300197
291+
*f.addr_at(frame::interpreter_frame_locals_offset) = (bottom - 1) - f.fp();
289292
}
290293

291294
#endif // CPU_LOONGARCH_CONTINUATIONFREEZETHAW_LOONGARCH_INLINE_HPP

src/hotspot/cpu/loongarch/continuationHelper_loongarch.inline.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ inline intptr_t* ContinuationHelper::InterpretedFrame::frame_top(const frame& f,
131131
}
132132

133133
inline intptr_t* ContinuationHelper::InterpretedFrame::frame_bottom(const frame& f) { // exclusive; this will not be copied with the frame
134-
return (intptr_t*)f.at(frame::interpreter_frame_locals_offset) + 1; // exclusive, so we add 1 word
134+
return (intptr_t*)f.at_relative(frame::interpreter_frame_locals_offset) + 1; // exclusive, so we add 1 word
135135
}
136136

137137
inline intptr_t* ContinuationHelper::InterpretedFrame::frame_top(const frame& f, int callee_argsize, bool callee_interpreted) {

src/hotspot/cpu/loongarch/frame_loongarch.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2015, 2022, Loongson Technology. All rights reserved.
3+
* Copyright (c) 2015, 2023, Loongson Technology. 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
@@ -289,6 +289,13 @@ intptr_t* frame::entry_frame_argument_at(int offset) const {
289289
return &unextended_sp()[index];
290290
}
291291

292+
// locals
293+
void frame::interpreter_frame_set_locals(intptr_t* locs) {
294+
assert(is_interpreted_frame(), "interpreted frame expected");
295+
// set relativized locals
296+
ptr_at_put(interpreter_frame_locals_offset, (intptr_t) (locs - fp()));
297+
}
298+
292299
// sender_sp
293300
intptr_t* frame::interpreter_frame_sender_sp() const {
294301
assert(is_interpreted_frame(), "interpreted frame expected");
@@ -498,7 +505,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
498505
}
499506

500507
// validate locals
501-
address locals = (address) *interpreter_frame_locals_addr();
508+
address locals = (address)interpreter_frame_locals();
502509
if (locals > thread->stack_base() /*|| locals < (address) fp() */) {
503510
return false;
504511
}

src/hotspot/cpu/loongarch/frame_loongarch.inline.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2015, 2022, Loongson Technology. All rights reserved.
3+
* Copyright (c) 2015, 2023, Loongson Technology. 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
@@ -245,8 +245,9 @@ inline address* frame::sender_pc_addr() const { return (address*) addr_at(re
245245
inline address frame::sender_pc() const { return *sender_pc_addr(); }
246246
inline intptr_t* frame::sender_sp() const { return addr_at(sender_sp_offset); }
247247

248-
inline intptr_t** frame::interpreter_frame_locals_addr() const {
249-
return (intptr_t**)addr_at(interpreter_frame_locals_offset);
248+
inline intptr_t* frame::interpreter_frame_locals() const {
249+
intptr_t n = *addr_at(interpreter_frame_locals_offset);
250+
return &fp()[n]; // return relativized locals
250251
}
251252

252253
inline intptr_t* frame::interpreter_frame_last_sp() const {

src/hotspot/cpu/loongarch/interp_masm_loongarch.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class InterpreterMacroAssembler: public MacroAssembler {
8383

8484
void restore_locals() {
8585
ld_d(LVP, FP, frame::interpreter_frame_locals_offset * wordSize);
86+
alsl_d(LVP, LVP, FP, LogBytesPerWord-1);
8687
}
8788

8889
void get_dispatch();

src/hotspot/cpu/loongarch/sharedRuntime_loongarch_64.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,14 @@ static void gen_continuation_yield(MacroAssembler* masm,
13031303

13041304
__ bind(pinned); // pinned -- return to caller
13051305

1306+
// handle pending exception thrown by freeze
1307+
__ ld_d(AT, Address(TREG, in_bytes(Thread::pending_exception_offset())));
1308+
Label ok;
1309+
__ beqz(AT, ok);
1310+
__ leave();
1311+
__ jmp(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
1312+
__ bind(ok);
1313+
13061314
__ leave();
13071315
__ jr(RA);
13081316

src/hotspot/cpu/loongarch/templateInterpreterGenerator_loongarch.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,10 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
864864
__ addi_d(FP, SP, (frame_size) * wordSize);
865865
__ st_d(Rsender, FP, (-++i) * wordSize); // save sender's sp
866866
__ st_d(R0, FP,(-++i) * wordSize); //save last_sp as null
867-
__ st_d(LVP, FP, (-++i) * wordSize); // save locals offset
867+
__ sub_d(AT, LVP, FP);
868+
__ srli_d(AT, AT, Interpreter::logStackElementSize);
869+
// Store relativized LVP, see frame::interpreter_frame_locals().
870+
__ st_d(AT, FP, (-++i) * wordSize); // save locals offset
868871
__ ld_d(BCP, Rmethod, in_bytes(Method::const_offset())); // get constMethodOop
869872
__ addi_d(BCP, BCP, in_bytes(ConstMethod::codes_offset())); // get codebase
870873
__ st_d(Rmethod, FP, (-++i) * wordSize); // save Method*

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/loongarch64/LOONGARCH64Frame.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2018, 2022, Loongson Technology. All rights reserved.
3+
* Copyright (c) 2018, 2023, Loongson Technology. 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
@@ -411,7 +411,8 @@ public Address getSenderSP() {
411411
}
412412

413413
public Address addressOfInterpreterFrameLocals() {
414-
return addressOfStackSlot(INTERPRETER_FRAME_LOCALS_OFFSET);
414+
long n = addressOfStackSlot(INTERPRETER_FRAME_LOCALS_OFFSET).getCIntegerAt(0, VM.getVM().getAddressSize(), false);
415+
return getFP().addOffsetTo(n * VM.getVM().getAddressSize());
415416
}
416417

417418
private Address addressOfInterpreterFrameBCX() {

0 commit comments

Comments
 (0)