Skip to content

Commit

Permalink
add patch of Kim Barrett
Browse files Browse the repository at this point in the history
  • Loading branch information
MBaesken committed Jul 25, 2024
1 parent 390a217 commit b6f5dcf
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 83 deletions.
20 changes: 8 additions & 12 deletions src/hotspot/cpu/aarch64/smallRegisterMap_aarch64.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@

// Java frames don't have callee saved registers (except for rfp), so we can use a smaller RegisterMap
class SmallRegisterMap {
constexpr SmallRegisterMap() = default;
~SmallRegisterMap() = default;
NONCOPYABLE(SmallRegisterMap);

public:
static constexpr SmallRegisterMap* instance = nullptr;
static const SmallRegisterMap* instance() {
static constexpr SmallRegisterMap the_instance{};
return &the_instance;
}
private:
static void assert_is_rfp(VMReg r) NOT_DEBUG_RETURN
DEBUG_ONLY({ assert (r == rfp->as_VMReg() || r == rfp->as_VMReg()->next(), "Reg: %s", r->name()); })
Expand All @@ -48,17 +55,6 @@ class SmallRegisterMap {
return map;
}

SmallRegisterMap() {}

SmallRegisterMap(const RegisterMap* map) {
#ifdef ASSERT
for(int i = 0; i < RegisterMap::reg_count; i++) {
VMReg r = VMRegImpl::as_VMReg(i);
if (map->location(r, (intptr_t*)nullptr) != nullptr) assert_is_rfp(r);
}
#endif
}

inline address location(VMReg reg, intptr_t* sp) const {
assert_is_rfp(reg);
return (address)(sp - frame::sender_sp_offset);
Expand Down
15 changes: 8 additions & 7 deletions src/hotspot/cpu/arm/smallRegisterMap_arm.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@

// Java frames don't have callee saved registers (except for rfp), so we can use a smaller RegisterMap
class SmallRegisterMap {
constexpr SmallRegisterMap() = default;
~SmallRegisterMap() = default;
NONCOPYABLE(SmallRegisterMap);

public:
static constexpr SmallRegisterMap* instance = nullptr;
static const SmallRegisterMap* instance() {
static constexpr SmallRegisterMap the_instance{};
return &the_instance;
}
private:
static void assert_is_rfp(VMReg r) NOT_DEBUG_RETURN
DEBUG_ONLY({ Unimplemented(); })
Expand All @@ -46,12 +53,6 @@ class SmallRegisterMap {
return map;
}

SmallRegisterMap() {}

SmallRegisterMap(const RegisterMap* map) {
Unimplemented();
}

inline address location(VMReg reg, intptr_t* sp) const {
Unimplemented();
return nullptr;
Expand Down
24 changes: 9 additions & 15 deletions src/hotspot/cpu/ppc/smallRegisterMap_ppc.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@

// Java frames don't have callee saved registers, so we can use a smaller RegisterMap
class SmallRegisterMap {
constexpr SmallRegisterMap() = default;
~SmallRegisterMap() = default;
NONCOPYABLE(SmallRegisterMap);

public:
static constexpr SmallRegisterMap* instance = nullptr;
public:
static const SmallRegisterMap* instance() {
static constexpr SmallRegisterMap the_instance{};
return &the_instance;
}

// as_RegisterMap is used when we didn't want to templatize and abstract over RegisterMap type to support SmallRegisterMap
// Consider enhancing SmallRegisterMap to support those cases
const RegisterMap* as_RegisterMap() const { return nullptr; }
Expand All @@ -44,19 +51,6 @@ class SmallRegisterMap {
return map;
}

SmallRegisterMap() {}

SmallRegisterMap(const RegisterMap* map) {
#ifdef ASSERT
for(int i = 0; i < RegisterMap::reg_count; i++) {
VMReg r = VMRegImpl::as_VMReg(i);
if (map->location(r, (intptr_t*)nullptr) != nullptr) {
assert(false, "Reg: %s", r->name()); // Should not reach here
}
}
#endif
}

inline address location(VMReg reg, intptr_t* sp) const {
assert(false, "Reg: %s", reg->name());
return nullptr;
Expand Down
20 changes: 8 additions & 12 deletions src/hotspot/cpu/riscv/smallRegisterMap_riscv.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@

// Java frames don't have callee saved registers (except for fp), so we can use a smaller RegisterMap
class SmallRegisterMap {
constexpr SmallRegisterMap() = default;
~SmallRegisterMap() = default;
NONCOPYABLE(SmallRegisterMap);

public:
static constexpr SmallRegisterMap* instance = nullptr;
static const SmallRegisterMap* instance() {
static constexpr SmallRegisterMap the_instance{};
return &the_instance;
}
private:
static void assert_is_fp(VMReg r) NOT_DEBUG_RETURN
DEBUG_ONLY({ assert (r == fp->as_VMReg() || r == fp->as_VMReg()->next(), "Reg: %s", r->name()); })
Expand All @@ -48,17 +55,6 @@ class SmallRegisterMap {
return map;
}

SmallRegisterMap() {}

SmallRegisterMap(const RegisterMap* map) {
#ifdef ASSERT
for(int i = 0; i < RegisterMap::reg_count; i++) {
VMReg r = VMRegImpl::as_VMReg(i);
if (map->location(r, (intptr_t*)nullptr) != nullptr) assert_is_fp(r);
}
#endif
}

inline address location(VMReg reg, intptr_t* sp) const {
assert_is_fp(reg);
return (address)(sp - 2);
Expand Down
15 changes: 8 additions & 7 deletions src/hotspot/cpu/s390/smallRegisterMap_s390.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@

// Java frames don't have callee saved registers (except for rfp), so we can use a smaller RegisterMap
class SmallRegisterMap {
constexpr SmallRegisterMap() = default;
~SmallRegisterMap() = default;
NONCOPYABLE(SmallRegisterMap);

public:
static constexpr SmallRegisterMap* instance = nullptr;
static const SmallRegisterMap* instance() {
static constexpr SmallRegisterMap the_instance{};
return &the_instance;
}
private:
static void assert_is_rfp(VMReg r) NOT_DEBUG_RETURN
DEBUG_ONLY({ Unimplemented(); })
Expand All @@ -46,12 +53,6 @@ class SmallRegisterMap {
return map;
}

SmallRegisterMap() {}

SmallRegisterMap(const RegisterMap* map) {
Unimplemented();
}

inline address location(VMReg reg, intptr_t* sp) const {
Unimplemented();
return nullptr;
Expand Down
21 changes: 9 additions & 12 deletions src/hotspot/cpu/x86/smallRegisterMap_x86.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@

// Java frames don't have callee saved registers (except for rbp), so we can use a smaller RegisterMap
class SmallRegisterMap {
constexpr SmallRegisterMap() = default;
~SmallRegisterMap() = default;
NONCOPYABLE(SmallRegisterMap);

public:
static constexpr SmallRegisterMap* instance = nullptr;
static const SmallRegisterMap* instance() {
static constexpr SmallRegisterMap the_instance{};
return &the_instance;
}

private:
static void assert_is_rbp(VMReg r) NOT_DEBUG_RETURN
DEBUG_ONLY({ assert(r == rbp->as_VMReg() || r == rbp->as_VMReg()->next(), "Reg: %s", r->name()); })
Expand All @@ -48,17 +56,6 @@ class SmallRegisterMap {
return map;
}

SmallRegisterMap() {}

SmallRegisterMap(const RegisterMap* map) {
#ifdef ASSERT
for(int i = 0; i < RegisterMap::reg_count; i++) {
VMReg r = VMRegImpl::as_VMReg(i);
if (map->location(r, (intptr_t*)nullptr) != nullptr) assert_is_rbp(r);
}
#endif
}

inline address location(VMReg reg, intptr_t* sp) const {
assert_is_rbp(reg);
return (address)(sp - frame::sender_sp_offset);
Expand Down
15 changes: 8 additions & 7 deletions src/hotspot/cpu/zero/smallRegisterMap_zero.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@

// Java frames don't have callee saved registers (except for rfp), so we can use a smaller RegisterMap
class SmallRegisterMap {
constexpr SmallRegisterMap() = default;
~SmallRegisterMap() = default;
NONCOPYABLE(SmallRegisterMap);

public:
static constexpr SmallRegisterMap* instance = nullptr;
static const SmallRegisterMap* instance() {
static constexpr SmallRegisterMap the_instance{};
return &the_instance;
}
private:
static void assert_is_rfp(VMReg r) NOT_DEBUG_RETURN
DEBUG_ONLY({ Unimplemented(); })
Expand All @@ -46,12 +53,6 @@ class SmallRegisterMap {
return map;
}

SmallRegisterMap() {}

SmallRegisterMap(const RegisterMap* map) {
Unimplemented();
}

inline address location(VMReg reg, intptr_t* sp) const {
Unimplemented();
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/stackChunkOop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static int num_java_frames(const StackChunkFrameStream<ChunkFrames::Mixed>& f) {
int stackChunkOopDesc::num_java_frames() const {
int n = 0;
for (StackChunkFrameStream<ChunkFrames::Mixed> f(const_cast<stackChunkOopDesc*>(this)); !f.is_done();
f.next(SmallRegisterMap::instance)) {
f.next(SmallRegisterMap::instance())) {
if (!f.is_stub()) {
n += ::num_java_frames(f);
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/stackChunkOop.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ inline void stackChunkOopDesc::iterate_stack(StackChunkFrameClosureType* closure

template <ChunkFrames frame_kind, class StackChunkFrameClosureType>
inline void stackChunkOopDesc::iterate_stack(StackChunkFrameClosureType* closure) {
const SmallRegisterMap* map = SmallRegisterMap::instance;
const SmallRegisterMap* map = SmallRegisterMap::instance();
assert(!map->in_cont(), "");

StackChunkFrameStream<frame_kind> f(this);
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/share/runtime/continuationFreezeThaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ int ThawBase::remove_top_compiled_frame_from_chunk(stackChunkOop chunk, int &arg
const int frame_size = f.cb()->frame_size();
argsize = f.stack_argsize();

f.next(SmallRegisterMap::instance, true /* stop */);
f.next(SmallRegisterMap::instance(), true /* stop */);
empty = f.is_done();
assert(!empty || argsize == chunk->argsize(), "");

Expand Down Expand Up @@ -2075,7 +2075,7 @@ bool ThawBase::recurse_thaw_java_frame(frame& caller, int num_frames) {

int argsize = _stream.stack_argsize();

_stream.next(SmallRegisterMap::instance);
_stream.next(SmallRegisterMap::instance());
assert(_stream.to_frame().is_empty() == _stream.is_done(), "");

// we never leave a compiled caller of an interpreted frame as the top frame in the chunk
Expand Down Expand Up @@ -2183,7 +2183,7 @@ NOINLINE void ThawBase::recurse_thaw_interpreted_frame(const frame& hf, frame& c
assert(hf.is_interpreted_frame(), "");

if (UNLIKELY(seen_by_gc())) {
_cont.tail()->do_barriers<stackChunkOopDesc::BarrierType::Store>(_stream, SmallRegisterMap::instance);
_cont.tail()->do_barriers<stackChunkOopDesc::BarrierType::Store>(_stream, SmallRegisterMap::instance());
}

const bool is_bottom_frame = recurse_thaw_java_frame<ContinuationHelper::InterpretedFrame>(caller, num_frames);
Expand Down Expand Up @@ -2226,7 +2226,7 @@ NOINLINE void ThawBase::recurse_thaw_interpreted_frame(const frame& hf, frame& c

if (!is_bottom_frame) {
// can only fix caller once this frame is thawed (due to callee saved regs)
_cont.tail()->fix_thawed_frame(caller, SmallRegisterMap::instance);
_cont.tail()->fix_thawed_frame(caller, SmallRegisterMap::instance());
} else if (_cont.tail()->has_bitmap() && locals > 0) {
assert(hf.is_heap_frame(), "should be");
address start = (address)(heap_frame_bottom - locals);
Expand All @@ -2243,7 +2243,7 @@ void ThawBase::recurse_thaw_compiled_frame(const frame& hf, frame& caller, int n
assert(_cont.is_preempted() || !stub_caller, "stub caller not at preemption");

if (!stub_caller && UNLIKELY(seen_by_gc())) { // recurse_thaw_stub_frame already invoked our barriers with a full regmap
_cont.tail()->do_barriers<stackChunkOopDesc::BarrierType::Store>(_stream, SmallRegisterMap::instance);
_cont.tail()->do_barriers<stackChunkOopDesc::BarrierType::Store>(_stream, SmallRegisterMap::instance());
}

const bool is_bottom_frame = recurse_thaw_java_frame<ContinuationHelper::CompiledFrame>(caller, num_frames);
Expand Down Expand Up @@ -2302,7 +2302,7 @@ void ThawBase::recurse_thaw_compiled_frame(const frame& hf, frame& caller, int n

if (!is_bottom_frame) {
// can only fix caller once this frame is thawed (due to callee saved regs); this happens on the stack
_cont.tail()->fix_thawed_frame(caller, SmallRegisterMap::instance);
_cont.tail()->fix_thawed_frame(caller, SmallRegisterMap::instance());
} else if (_cont.tail()->has_bitmap() && added_argsize > 0) {
address start = (address)(heap_frame_top + ContinuationHelper::CompiledFrame::size(hf) + frame::metadata_words_at_top);
int stack_args_slots = f.cb()->as_nmethod()->num_stack_arg_slots(false /* rounded */);
Expand Down Expand Up @@ -2384,7 +2384,7 @@ void ThawBase::finish_thaw(frame& f) {
f.set_sp(align_down(f.sp(), frame::frame_alignment));
}
push_return_frame(f);
chunk->fix_thawed_frame(f, SmallRegisterMap::instance); // can only fix caller after push_return_frame (due to callee saved regs)
chunk->fix_thawed_frame(f, SmallRegisterMap::instance()); // can only fix caller after push_return_frame (due to callee saved regs)

assert(_cont.is_empty() == _cont.last_frame().is_empty(), "");

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/runtime/frame.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "runtime/continuation.hpp"
#include "runtime/registerMap.hpp"
#include "runtime/stubRoutines.hpp"
#include "sanitizers/ub.hpp"
#include "utilities/macros.hpp"
#ifdef ZERO
# include "entryFrame_zero.hpp"
Expand Down Expand Up @@ -83,7 +82,6 @@ inline address frame::get_deopt_original_pc() const {
}

template <typename RegisterMapT>
ATTRIBUTE_NO_UBSAN
inline address frame::oopmapreg_to_location(VMReg reg, const RegisterMapT* reg_map) const {
if (reg->is_reg()) {
// If it is passed in a register, it got spilled in the stub frame.
Expand Down

0 comments on commit b6f5dcf

Please sign in to comment.