forked from openjdk/jdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: TheShermanTanker <[email protected]>
- Loading branch information
1 parent
63367ec
commit 4e6470a
Showing
12 changed files
with
781 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/hotspot/os_cpu/windows_zero/atomic_windows_zero.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
#ifndef OS_CPU_WINDOWS_ZERO_ATOMIC_WINDOWS_ZERO_HPP | ||
#define OS_CPU_WINDOWS_ZERO_ATOMIC_WINDOWS_ZERO_HPP | ||
|
||
#include <intrin.h> | ||
#include "runtime/os.hpp" | ||
|
||
template<size_t byte_size> | ||
struct Atomic::PlatformAdd { | ||
template<typename D, typename I> | ||
D add_then_fetch(D volatile* dest, I add_value, atomic_memory_order order) const; | ||
|
||
template<typename D, typename I> | ||
D fetch_then_add(D volatile* dest, I add_value, atomic_memory_order order) const { | ||
return add_then_fetch(dest, add_value, order) - add_value; | ||
} | ||
}; | ||
|
||
// The Interlocked* APIs only take long and will not accept __int32. That is | ||
// acceptable on Windows, since long is a 32-bits integer type. | ||
|
||
#define DEFINE_INTRINSIC_ADD(IntrinsicName, IntrinsicType) \ | ||
template<> \ | ||
template<typename D, typename I> \ | ||
inline D Atomic::PlatformAdd<sizeof(IntrinsicType)>::add_then_fetch(D volatile* dest, \ | ||
I add_value, \ | ||
atomic_memory_order order) const { \ | ||
STATIC_ASSERT(sizeof(IntrinsicType) == sizeof(D)); \ | ||
return PrimitiveConversions::cast<D>( \ | ||
IntrinsicName(reinterpret_cast<IntrinsicType volatile *>(dest), \ | ||
PrimitiveConversions::cast<IntrinsicType>(add_value))); \ | ||
} | ||
|
||
DEFINE_INTRINSIC_ADD(InterlockedAdd, long) | ||
DEFINE_INTRINSIC_ADD(InterlockedAdd64, long long) | ||
|
||
#undef DEFINE_INTRINSIC_ADD | ||
|
||
#define DEFINE_INTRINSIC_XCHG(IntrinsicName, IntrinsicType) \ | ||
template<> \ | ||
template<typename T> \ | ||
inline T Atomic::PlatformXchg<sizeof(IntrinsicType)>::operator()(T volatile* dest, \ | ||
T exchange_value, \ | ||
atomic_memory_order order) const { \ | ||
STATIC_ASSERT(sizeof(IntrinsicType) == sizeof(T)); \ | ||
return PrimitiveConversions::cast<T>( \ | ||
IntrinsicName(reinterpret_cast<IntrinsicType volatile *>(dest), \ | ||
PrimitiveConversions::cast<IntrinsicType>(exchange_value))); \ | ||
} | ||
|
||
DEFINE_INTRINSIC_XCHG(InterlockedExchange, long) | ||
DEFINE_INTRINSIC_XCHG(InterlockedExchange64, long long) | ||
|
||
#undef DEFINE_INTRINSIC_XCHG | ||
|
||
// Note: the order of the parameters is different between | ||
// Atomic::PlatformCmpxchg<*>::operator() and the | ||
// InterlockedCompareExchange* API. | ||
|
||
#define DEFINE_INTRINSIC_CMPXCHG(IntrinsicName, IntrinsicType) \ | ||
template<> \ | ||
template<typename T> \ | ||
inline T Atomic::PlatformCmpxchg<sizeof(IntrinsicType)>::operator()(T volatile* dest, \ | ||
T compare_value, \ | ||
T exchange_value, \ | ||
atomic_memory_order order) const { \ | ||
STATIC_ASSERT(sizeof(IntrinsicType) == sizeof(T)); \ | ||
return PrimitiveConversions::cast<T>( \ | ||
IntrinsicName(reinterpret_cast<IntrinsicType volatile *>(dest), \ | ||
PrimitiveConversions::cast<IntrinsicType>(exchange_value), \ | ||
PrimitiveConversions::cast<IntrinsicType>(compare_value))); \ | ||
} | ||
|
||
DEFINE_INTRINSIC_CMPXCHG(_InterlockedCompareExchange8, char) // Use the intrinsic as InterlockedCompareExchange8 does not exist | ||
DEFINE_INTRINSIC_CMPXCHG(InterlockedCompareExchange, long) | ||
DEFINE_INTRINSIC_CMPXCHG(InterlockedCompareExchange64, long long) | ||
|
||
#undef DEFINE_INTRINSIC_CMPXCHG | ||
|
||
#endif // OS_CPU_WINDOWS_ZERO_ATOMIC_WINDOWS_ZERO_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
#ifndef OS_CPU_WINDOWS_ZERO_GLOBALS_WINDOWS_ZERO_HPP | ||
#define OS_CPU_WINDOWS_ZERO_GLOBALS_WINDOWS_ZERO_HPP | ||
|
||
// Sets the default values for platform dependent flags used by the runtime system. | ||
// (see globals.hpp) | ||
|
||
define_pd_global(bool, DontYieldALot, false); | ||
|
||
// Default stack size on Windows is determined by the executable (java.exe | ||
// has a default value of 320K/1MB [32bit/64bit]). Depending on Windows version, changing | ||
// ThreadStackSize to non-zero may have significant impact on memory usage. | ||
// See comments in os_windows.cpp. | ||
define_pd_global(intx, ThreadStackSize, 0); // 0 => use system default | ||
define_pd_global(intx, VMThreadStackSize, 0); // 0 => use system default | ||
|
||
define_pd_global(intx, CompilerThreadStackSize, 0); | ||
|
||
define_pd_global(size_t, JVMInvokeMethodSlack, 8192); | ||
|
||
// Used on 64 bit platforms for UseCompressedOops base address | ||
define_pd_global(size_t, HeapBaseMinAddress, 2*G); | ||
|
||
#endif // OS_CPU_WINDOWS_ZERO_GLOBALS_WINDOWS_ZERO_HPP |
66 changes: 66 additions & 0 deletions
66
src/hotspot/os_cpu/windows_zero/javaThread_windows_zero.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
#include "precompiled.hpp" | ||
#include "runtime/frame.inline.hpp" | ||
#include "runtime/javaThread.hpp" | ||
|
||
frame JavaThread::pd_last_frame() { | ||
assert(has_last_Java_frame(), "must have last_Java_sp() when suspended"); | ||
return frame(last_Java_fp(), last_Java_sp()); | ||
} | ||
|
||
bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, | ||
void* ucontext, | ||
bool isInJava) { | ||
if (has_last_Java_frame()) { | ||
*fr_addr = pd_last_frame(); | ||
return true; | ||
} | ||
|
||
if (isInJava) { | ||
// We know we are in Java, but there is no frame? | ||
// Try to find the top-most Java frame on Zero stack then. | ||
intptr_t* sp = stack.sp(); | ||
ZeroFrame* zf = top; | ||
while (zf != nullptr) { | ||
if (zf->is_interpreter_frame()) { | ||
interpreterState istate = zf->as_interpreter_frame()->interpreter_state(); | ||
if (istate->self_link() == istate) { | ||
// Valid interpreter state found, this is our frame. | ||
*fr_addr = frame(zf, sp); | ||
return true; | ||
} | ||
} | ||
sp = reinterpret_cast<intptr_t *>(zf) + 1; | ||
zf = zf->next(); | ||
} | ||
} | ||
|
||
// No dice. | ||
return false; | ||
} | ||
|
||
void JavaThread::cache_global_variables() { | ||
} |
79 changes: 79 additions & 0 deletions
79
src/hotspot/os_cpu/windows_zero/javaThread_windows_zero.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
#ifndef OS_CPU_WINDOWS_ZERO_JAVATHREAD_WINDOWS_ZERO_HPP | ||
#define OS_CPU_WINDOWS_ZERO_JAVATHREAD_WINDOWS_ZERO_HPP | ||
|
||
ZeroStack* zero_stack() noexcept { | ||
return &stack; | ||
} | ||
|
||
ZeroFrame* top_zero_frame() const noexcept { | ||
return top; | ||
} | ||
|
||
void push_zero_frame(ZeroFrame* frame) noexcept { | ||
*reinterpret_cast<ZeroFrame**>(frame) = top; | ||
top = frame; | ||
} | ||
|
||
void pop_zero_frame() { | ||
stack.set_sp(reinterpret_cast<intptr_t*>(top) + 1); | ||
top = *reinterpret_cast<ZeroFrame**>(top); | ||
} | ||
|
||
void set_last_Java_frame() { | ||
set_last_Java_frame(top, stack.sp()); | ||
} | ||
|
||
void reset_last_Java_frame() { | ||
frame_anchor()->zap(); | ||
} | ||
void set_last_Java_frame(ZeroFrame* fp, intptr_t* sp) { | ||
frame_anchor()->set(sp, nullptr, fp); | ||
} | ||
|
||
ZeroFrame* last_Java_fp() { | ||
return frame_anchor()->last_Java_fp(); | ||
} | ||
|
||
bool has_special_condition_for_native_trans() const noexcept { | ||
return _suspend_flags != 0; | ||
} | ||
|
||
bool pd_get_top_frame_for_signal_handler(frame* fr_addr, | ||
void* ucontext, | ||
bool isInJava); | ||
|
||
private: | ||
void pd_initialize() noexcept { | ||
top = nullptr; | ||
} | ||
|
||
frame pd_last_frame(); | ||
|
||
ZeroStack stack; | ||
ZeroFrame* top; | ||
|
||
#endif // OS_CPU_WINDOWS_ZERO_JAVATHREAD_WINDOWS_ZERO_HPP |
Oops, something went wrong.