Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/hotspot/cpu/zero/frame_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "runtime/frame.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/signature.hpp"
#include "runtime/stackWatermarkSet.hpp"
#include "vmreg_zero.inline.hpp"

#ifdef ASSERT
Expand Down Expand Up @@ -82,10 +83,15 @@ frame frame::sender(RegisterMap* map) const {
// sender_for_xxx methods update this accordingly.
map->set_include_argument_oops(false);

if (is_entry_frame())
return sender_for_entry_frame(map);
else
return sender_for_nonentry_frame(map);
frame result = zeroframe()->is_entry_frame() ?
sender_for_entry_frame(map) :
sender_for_nonentry_frame(map);

if (map->process_frames()) {
StackWatermarkSet::on_iteration(map->thread(), result);
}

return result;
}

BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/cpu/zero/vm_version_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
class VM_Version : public Abstract_VM_Version {
public:
static void initialize();

constexpr static bool supports_stack_watermark_barrier() { return true; }
};

#endif // CPU_ZERO_VM_VERSION_ZERO_HPP
26 changes: 26 additions & 0 deletions src/hotspot/cpu/zero/zeroInterpreter_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ void ZeroInterpreter::main_loop(int recurse, TRAPS) {
}
fixup_after_potential_safepoint();

// If we are unwinding, notify the stack watermarks machinery.
// Should do this before resetting the frame anchor.
if (istate->msg() == BytecodeInterpreter::return_from_method ||
istate->msg() == BytecodeInterpreter::do_osr) {
stack_watermark_unwind_check(thread);
} else {
assert(istate->msg() == BytecodeInterpreter::call_method ||
istate->msg() == BytecodeInterpreter::more_monitors ||
istate->msg() == BytecodeInterpreter::throwing_exception,
"Should be one of these otherwise");
}

// Clear the frame anchor
thread->reset_last_Java_frame();

Expand Down Expand Up @@ -436,6 +448,10 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
thread->set_thread_state(_thread_in_Java);
fixup_after_potential_safepoint();

// Notify the stack watermarks machinery that we are unwinding.
// Should do this before resetting the frame anchor.
stack_watermark_unwind_check(thread);

// Clear the frame anchor
thread->reset_last_Java_frame();

Expand Down Expand Up @@ -869,3 +885,13 @@ address ZeroInterpreter::remove_activation_early_entry(TosState state) {
bool ZeroInterpreter::contains(address pc) {
return false; // make frame::print_value_on work
}

void ZeroInterpreter::stack_watermark_unwind_check(JavaThread* thread) {
// If frame pointer is in the danger zone, notify the runtime that
// it needs to act before continuing the unwinding.
uintptr_t fp = (uintptr_t)thread->last_Java_fp();
uintptr_t watermark = thread->poll_data()->get_polling_word();
if (fp > watermark) {
InterpreterRuntime::at_unwind(thread);
}
}
3 changes: 3 additions & 0 deletions src/hotspot/cpu/zero/zeroInterpreter_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
static int empty_entry(Method* method, intptr_t UNUSED, TRAPS);
static int Reference_get_entry(Method* method, intptr_t UNUSED, TRAPS);

// Stack watermark machinery
static void stack_watermark_unwind_check(JavaThread* thread);

public:
// Main loop of normal_entry
static void main_loop(int recurse, TRAPS);
Expand Down
20 changes: 3 additions & 17 deletions src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
There really shouldn't be any handles remaining to trash but this is cheap
in relation to a safepoint.
*/
#define SAFEPOINT \
#define RETURN_SAFEPOINT \
if (SafepointMechanism::should_process(THREAD)) { \
HandleMarkCleaner __hmc(THREAD); \
CALL_VM(SafepointMechanism::process_if_requested_with_exit_check(THREAD, true /* check asyncs */), \
Expand Down Expand Up @@ -1336,36 +1336,22 @@ void BytecodeInterpreter::run(interpreterState istate) {
CASE(_areturn):
CASE(_ireturn):
CASE(_freturn):
{
// Allow a safepoint before returning to frame manager.
SAFEPOINT;

goto handle_return;
}

CASE(_lreturn):
CASE(_dreturn):
{
CASE(_return): {
// Allow a safepoint before returning to frame manager.
SAFEPOINT;
RETURN_SAFEPOINT;
goto handle_return;
}

CASE(_return_register_finalizer): {

oop rcvr = LOCALS_OBJECT(0);
VERIFY_OOP(rcvr);
if (rcvr->klass()->has_finalizer()) {
CALL_VM(InterpreterRuntime::register_finalizer(THREAD, rcvr), handle_exception);
}
goto handle_return;
}
CASE(_return): {

// Allow a safepoint before returning to frame manager.
SAFEPOINT;
goto handle_return;
}

/* Array access byte-codes */

Expand Down