From 3a57096c1dd5331b29a11c84d65f1f79907d51b4 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Mon, 30 Jun 2025 10:27:20 +0200 Subject: [PATCH 1/7] svm: remove libcontainer namespace --- .../os/linux/cgroupSubsystem_linux.cpp | 6 --- .../os/linux/cgroupSubsystem_linux.hpp | 6 --- .../src/hotspot/os/linux/cgroupUtil_linux.cpp | 6 --- .../src/hotspot/os/linux/cgroupUtil_linux.hpp | 6 --- .../os/linux/cgroupV1Subsystem_linux.cpp | 6 --- .../os/linux/cgroupV1Subsystem_linux.hpp | 6 --- .../os/linux/cgroupV2Subsystem_linux.cpp | 6 --- .../os/linux/cgroupV2Subsystem_linux.hpp | 6 --- .../hotspot/os/linux/osContainer_linux.cpp | 6 --- .../hotspot/os/linux/osContainer_linux.hpp | 6 --- .../src/hotspot/os/linux/os_linux.cpp | 18 ------- .../src/hotspot/os/linux/os_linux.hpp | 6 --- .../src/hotspot/os/linux/os_linux.inline.hpp | 6 --- .../src/hotspot/os/posix/os_posix.cpp | 12 ----- .../src/hotspot/os/posix/os_posix.hpp | 6 --- .../src/hotspot/os/posix/os_posix.inline.hpp | 6 --- .../src/hotspot/share/memory/allStatic.hpp | 6 --- .../src/hotspot/share/memory/allocation.hpp | 6 --- .../share/memory/allocation.inline.hpp | 12 ----- .../src/hotspot/share/nmt/memTag.hpp | 6 --- .../src/hotspot/share/runtime/os.cpp | 12 ----- .../src/hotspot/share/runtime/os.hpp | 12 ----- .../src/hotspot/share/runtime/os.inline.hpp | 24 --------- .../hotspot/share/utilities/checkedCast.hpp | 6 --- .../share/utilities/globalDefinitions.hpp | 52 +------------------ .../share/utilities/globalDefinitions_gcc.hpp | 24 --------- .../src/hotspot/share/utilities/ostream.cpp | 24 --------- .../src/hotspot/share/utilities/ostream.hpp | 12 ----- .../src/java.base/share/native/include/jni.h | 6 --- .../java.base/unix/native/include/jni_md.h | 6 --- .../src/svm/share/memory/allocation.cpp | 6 --- .../src/svm/share/runtime/globals.hpp | 6 --- .../src/svm/share/utilities/debug.cpp | 12 ----- .../src/svm/share/utilities/debug.hpp | 12 ----- .../src/svm/svm_container.cpp | 6 --- .../src/svm/svm_container.hpp | 6 --- 36 files changed, 2 insertions(+), 368 deletions(-) diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp index 8c671388f573..463a97240b32 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp @@ -44,9 +44,6 @@ #endif // controller names have to match the *_IDX indices - -namespace svm_container { - static const char* cg_controller_name[] = { "cpuset", "cpu", "cpuacct", "memory", "pids" }; static inline int cg_v2_controller_index(const char* name) { if (strcmp(name, "cpuset") == 0) { @@ -893,6 +890,3 @@ void CgroupSubsystem::print_version_specific_info(outputStream* st) { memory_controller()->controller()->print_version_specific_info(st, phys_mem); } #endif // !NATIVE_IMAGE - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp index a2ea1476d09a..a55e8d775ff7 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp @@ -103,9 +103,6 @@ log_trace(os, container)(log_string " is: %s", retval); \ } - -namespace svm_container { - class CgroupController: public CHeapObj { protected: char* _cgroup_path; @@ -347,7 +344,4 @@ class CgroupSubsystemFactory: AllStatic { static void cleanup(CgroupInfo* cg_infos); }; - -} // namespace svm_container - #endif // CGROUP_SUBSYSTEM_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp index f7bdfe3b3785..863d4fadf3fd 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp @@ -27,9 +27,6 @@ #include "os_linux.hpp" #include "cgroupUtil_linux.hpp" - -namespace svm_container { - int CgroupUtil::processor_count(CgroupCpuController* cpu_ctrl, int host_cpus) { assert(host_cpus > 0, "physical host cpus must be positive"); int limit_count = host_cpus; @@ -178,6 +175,3 @@ void CgroupUtil::adjust_controller(CgroupCpuController* cpu) { os::free(orig); os::free(limit_cg_path); } - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp index f915da085b78..b97e7406f56c 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp @@ -30,9 +30,6 @@ #include "utilities/globalDefinitions.hpp" #include "cgroupSubsystem_linux.hpp" - -namespace svm_container { - class CgroupUtil: AllStatic { public: @@ -45,7 +42,4 @@ class CgroupUtil: AllStatic { static void adjust_controller(CgroupCpuController* c); }; - -} // namespace svm_container - #endif // CGROUP_UTIL_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp index a21f4ab8446d..12329dd45594 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp @@ -80,9 +80,6 @@ * component is found. The subsystem path will be set to * the _mount_point joined with the subgroup path. */ - -namespace svm_container { - void CgroupV1Controller::set_subsystem_path(const char* cgroup_path) { if (_cgroup_path != nullptr) { os::free(_cgroup_path); @@ -452,6 +449,3 @@ jlong CgroupV1Subsystem::pids_current() { CONTAINER_READ_NUMBER_CHECKED(_pids, "/pids.current", "Current number of tasks", pids_current); return (jlong)pids_current; } - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp index 28c9a8166e61..b909b7415432 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp @@ -33,9 +33,6 @@ // Cgroups version 1 specific implementation - -namespace svm_container { - class CgroupV1Controller: public CgroupController { private: /* mountinfo contents */ @@ -182,7 +179,4 @@ class CgroupV1Subsystem: public CgroupSubsystem { }; - -} // namespace svm_container - #endif // CGROUP_V1_SUBSYSTEM_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp index 519f3eef814d..cb570e65debc 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp @@ -28,9 +28,6 @@ #include "cgroupUtil_linux.hpp" // Constructor - -namespace svm_container { - CgroupV2Controller::CgroupV2Controller(char* mount_path, char *cgroup_path, bool ro) : _read_only(ro), @@ -359,6 +356,3 @@ jlong CgroupV2Subsystem::pids_current() { CONTAINER_READ_NUMBER_CHECKED(unified(), "/pids.current", "Current number of tasks", pids_current); return pids_current; } - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp index 3dd6000d4202..e90d886d1006 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp @@ -30,9 +30,6 @@ #include "cgroupSubsystem_linux.hpp" #include "cgroupUtil_linux.hpp" - -namespace svm_container { - class CgroupV2Controller: public CgroupController { private: bool _read_only; @@ -146,7 +143,4 @@ class CgroupV2Subsystem: public CgroupSubsystem { CachingCgroupController* cpu_controller() override { return _cpu; } }; - -} // namespace svm_container - #endif // CGROUP_V2_SUBSYSTEM_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp index 5f18730f1d0f..336924e2c468 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp @@ -34,9 +34,6 @@ #include "cgroupSubsystem_linux.hpp" - -namespace svm_container { - bool OSContainer::_is_initialized = false; bool OSContainer::_is_containerized = false; CgroupSubsystem* cgroup_subsystem; @@ -207,6 +204,3 @@ void OSContainer::print_container_helper(outputStream* st, jlong j, const char* } } #endif // !NATIVE_IMAGE - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp index 1e9484c40d8f..cec65a73f20f 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp @@ -36,9 +36,6 @@ // 20ms timeout between re-reads of memory limit and _active_processor_count. #define OSCONTAINER_CACHE_TIMEOUT (NANOSECS_PER_SEC/50) - -namespace svm_container { - class OSContainer: AllStatic { private: @@ -83,7 +80,4 @@ inline bool OSContainer::is_containerized() { return _is_containerized; } - -} // namespace svm_container - #endif // OS_LINUX_OSCONTAINER_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp index b5d5bc1bd235..eb4c65a369e8 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp @@ -159,39 +159,24 @@ #ifdef MUSL_LIBC // dlvsym is not a part of POSIX // and musl libc doesn't implement it. - -namespace svm_container { - static void *dlvsym(void *handle, const char *symbol, const char *version) { // load the latest version of symbol return dlsym(handle, symbol); } - -} // namespace svm_container - #endif - -namespace svm_container { - enum CoredumpFilterBit { FILE_BACKED_PVT_BIT = 1 << 2, FILE_BACKED_SHARED_BIT = 1 << 3, LARGEPAGES_BIT = 1 << 6, DAX_SHARED_BIT = 1 << 8 }; - -} // namespace svm_container - #endif // !NATIVE_IMAGE //////////////////////////////////////////////////////////////////////////////// // global variables - -namespace svm_container { - julong os::Linux::_physical_memory = 0; #ifndef NATIVE_IMAGE @@ -5566,6 +5551,3 @@ bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) { } // end: os::pd_dll_unload() #endif // !NATIVE_IMAGE - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp index ab500317165b..969290b0ea51 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp @@ -30,9 +30,6 @@ // os::Linux defines the interface to Linux operating systems - -namespace svm_container { - class os::Linux { friend class os; @@ -478,7 +475,4 @@ class os::Linux { #endif // !NATIVE_IMAGE }; - -} // namespace svm_container - #endif // OS_LINUX_OS_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp index 4ebdfc8623d5..a31cfbf30cd4 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp @@ -32,9 +32,6 @@ #include "os_posix.inline.hpp" #ifndef NATIVE_IMAGE - -namespace svm_container { - inline bool os::zero_page_read_protected() { return true; } @@ -60,9 +57,6 @@ inline bool os::can_trim_native_heap() { return false; // musl #endif } - -} // namespace svm_container - #endif // !NATIVE_IMAGE #endif // OS_LINUX_OS_LINUX_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp index 08f1fed53010..6808d0a046cb 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp @@ -100,9 +100,6 @@ #endif /* Input/Output types for mincore(2) */ - -namespace svm_container { - typedef LINUX_ONLY(unsigned) char mincore_vec_t; static jlong initial_time_count = 0; @@ -1027,14 +1024,8 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { return result; } - -} // namespace svm_container - #endif // !NATIVE_IMAGE - -namespace svm_container { - int os::stat(const char *path, struct stat *sbuf) { return ::stat(path, sbuf); } @@ -2206,6 +2197,3 @@ const void* os::get_saved_assert_context(const void** sigInfo) { return nullptr; } #endif // !NATIVE_IMAGE - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp index b6dae92257c5..0d314af0d8d0 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp @@ -52,9 +52,6 @@ return _result; \ } while(false) - -namespace svm_container { - class os::Posix { friend class os; @@ -100,9 +97,6 @@ class os::Posix { const void* ucVoid, address* stub); }; - -} // namespace svm_container - #endif // !NATIVE_IMAGE #endif // OS_POSIX_OS_POSIX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp index a0a2bf66dabb..de050c3c4453 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp @@ -37,9 +37,6 @@ #include // Aix does not have NUMA support but need these for compilation. - -namespace svm_container { - inline bool os::numa_has_group_homing() { AIX_ONLY(ShouldNotReachHere();) return false; } // Platform Mutex/Monitor implementation @@ -69,9 +66,6 @@ inline void PlatformMonitor::notify_all() { int status = pthread_cond_broadcast(cond()); assert_status(status == 0, status, "cond_broadcast"); } - -} // namespace svm_container - #endif // !NATIVE_IMAGE #endif // OS_POSIX_OS_POSIX_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp index 031c8b19df40..4f3761b470ee 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp @@ -30,15 +30,9 @@ // using classes for grouping. Deriving from this class indicates the // derived class is intended to be a namespace, with no instances ever // created. - -namespace svm_container { - struct AllStatic { AllStatic() = delete; ~AllStatic() = delete; }; - -} // namespace svm_container - #endif // SHARE_MEMORY_ALLSTATIC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp index 092e55a722ea..b1d069fcfb74 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp @@ -34,9 +34,6 @@ #include - -namespace svm_container { - class outputStream; class Thread; class JavaThread; @@ -591,7 +588,4 @@ class MallocArrayAllocator : public AllStatic { }; #endif // !NATIVE_IMAGE - -} // namespace svm_container - #endif // SHARE_MEMORY_ALLOCATION_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp index 39047a40e010..3db943678d99 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp @@ -39,9 +39,6 @@ #ifndef PRODUCT // Increments unsigned long value for statistics (not atomic on MP, but avoids word-tearing on 32 bit). - -namespace svm_container { - inline void inc_stat_counter(volatile julong* dest, julong add_value) { #ifdef _LP64 *dest += add_value; @@ -50,14 +47,8 @@ inline void inc_stat_counter(volatile julong* dest, julong add_value) { Atomic::store(dest, value + add_value); #endif } - -} // namespace svm_container - #endif - -namespace svm_container { - template size_t MmapArrayAllocator::size_for(size_t length) { size_t size = length * sizeof(E); @@ -121,9 +112,6 @@ template void MallocArrayAllocator::free(E* addr) { FreeHeap(addr); } - -} // namespace svm_container - #endif // !NATIVE_IMAGE #endif // SHARE_MEMORY_ALLOCATION_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp index 5489e919d4d5..1bf27dce8db2 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp @@ -65,9 +65,6 @@ #define MEMORY_TAG_DECLARE_ENUM(mem_tag, human_readable) \ mem_tag, - -namespace svm_container { - enum class MemTag : uint8_t { MEMORY_TAG_DO(MEMORY_TAG_DECLARE_ENUM) mt_number_of_tags // number of memory tags (mtDontTrack @@ -83,7 +80,4 @@ MEMORY_TAG_DO(MEMORY_TAG_SHORTNAME) // Make an int version of the sentinel end value. constexpr int mt_number_of_tags = static_cast(MemTag::mt_number_of_tags); - -} // namespace svm_container - #endif // SHARE_NMT_MEM_TAG_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp index d4f7b258f954..c513e247f67e 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp @@ -98,18 +98,9 @@ # include # include - -namespace svm_container { - OSThread* os::_starting_thread = nullptr; volatile unsigned int os::_rand_seed = 1234567; - -} // namespace svm_container - #endif // !NATIVE_IMAGE - -namespace svm_container { - int os::_processor_count = 0; #ifndef NATIVE_IMAGE int os::_initial_active_processor_count = 0; @@ -2626,6 +2617,3 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name, return agent_entry_name; } #endif // !NATIVE_IMAGE - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp index c443cd12adaa..05061b034d17 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp @@ -40,9 +40,6 @@ # include #endif - -namespace svm_container { - class frame; class JvmtiAgent; @@ -160,16 +157,10 @@ const bool ExecMem = true; typedef void (*java_call_t)(JavaValue* value, const methodHandle& method, JavaCallArguments* args, JavaThread* thread); class MallocTracker; - -} // namespace svm_container - #endif // !NATIVE_IMAGE // Preserve errno across a range of calls - -namespace svm_container { - class ErrnoPreserver { int _e; @@ -1142,7 +1133,4 @@ class os: AllStatic { extern "C" int SpinPause(); #endif // !NATIVE_IMAGE - -} // namespace svm_container - #endif // SHARE_RUNTIME_OS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp index 0b4f2b1602ba..0719c472f3f8 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp @@ -36,53 +36,29 @@ // Provide default empty implementation. #ifndef HAVE_PLATFORM_PRINT_NATIVE_STACK - -namespace svm_container { - inline bool os::platform_print_native_stack(outputStream* st, const void* context, char *buf, int buf_size, address& lastpc) { return false; } - -} // namespace svm_container - #endif #ifndef HAVE_CDS_CORE_REGION_ALIGNMENT - -namespace svm_container { - inline size_t os::cds_core_region_alignment() { return (size_t)os::vm_allocation_granularity(); } - -} // namespace svm_container - #endif #ifndef _WINDOWS // Currently used only on Windows. - -namespace svm_container { - inline bool os::register_code_area(char *low, char *high) { return true; } - -} // namespace svm_container - #endif #ifndef HAVE_FUNCTION_DESCRIPTORS - -namespace svm_container { - inline void* os::resolve_function_descriptor(void* p) { return nullptr; } - -} // namespace svm_container - #endif #endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp index 27922a92b909..3379586aded9 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp @@ -36,9 +36,6 @@ // reversible without loss of information. It doesn't check // everything: it isn't intended to make sure that pointer types are // compatible, for example. - -namespace svm_container { - template constexpr T2 checked_cast(T1 thing) { T2 result = static_cast(thing); @@ -46,8 +43,5 @@ constexpr T2 checked_cast(T1 thing) { return result; } - -} // namespace svm_container - #endif // SHARE_UTILITIES_CHECKEDCAST_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp index 5223f0f8ed4b..dc0ae41fdcc9 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp @@ -43,13 +43,7 @@ #include #ifndef NATIVE_IMAGE - -namespace svm_container { - class oopDesc; - -} // namespace svm_container - #endif // !NATIVE_IMAGE // Defaults for macros that might be defined per compiler. @@ -176,9 +170,6 @@ class oopDesc; #endif // _LP64 // Convert pointer to intptr_t, for use in printing pointers. - -namespace svm_container { - inline intptr_t p2i(const volatile void* p) { return (intptr_t) p; } @@ -303,9 +294,6 @@ inline size_t heap_word_size(size_t byte_size) { inline jfloat jfloat_cast(jint x); inline jdouble jdouble_cast(jlong x); - -} // namespace svm_container - #endif // !NATIVE_IMAGE //------------------------------------------- @@ -315,9 +303,6 @@ inline jdouble jdouble_cast(jlong x); #define CONST64(x) (x ## LL) #define UCONST64(x) (x ## ULL) - -namespace svm_container { - const jlong min_jlong = CONST64(0x8000000000000000); const jlong max_jlong = CONST64(0x7fffffffffffffff); @@ -563,13 +548,7 @@ typedef jshort s2; typedef jint s4; typedef jlong s8; - -} // namespace svm_container - #ifndef NATIVE_IMAGE - -namespace svm_container { - const jbyte min_jbyte = -(1 << 7); // smallest jbyte const jbyte max_jbyte = (1 << 7) - 1; // largest jbyte const jshort min_jshort = -(1 << 15); // smallest jshort @@ -626,9 +605,6 @@ extern uint64_t OopEncodingHeapMax; // Machine dependent stuff - -} // namespace svm_container - #include CPU_HEADER(globalDefinitions) // The maximum size of the code cache. Can be overridden by targets. @@ -646,23 +622,11 @@ extern uint64_t OopEncodingHeapMax; // by Luc Maranget, Susmit Sarkar and Peter Sewell, INRIA/Cambridge) #ifdef CPU_MULTI_COPY_ATOMIC // Not needed. - -namespace svm_container { - const bool support_IRIW_for_not_multiple_copy_atomic_cpu = false; - -} // namespace svm_container - #else // From all non-multi-copy-atomic architectures, only PPC64 supports IRIW at the moment. // Final decision is subject to JEP 188: Java Memory Model Update. - -namespace svm_container { - const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_PPC64(false); - -} // namespace svm_container - #endif // The expected size in bytes of a cache line. @@ -683,9 +647,6 @@ const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_ // All fabs() callers should call this function instead, which will implicitly // convert the operand to double, avoiding a dependency on __fabsf which // doesn't exist in early versions of Solaris 8. - -namespace svm_container { - inline double fabsd(double value) { return fabs(value); } @@ -1112,8 +1073,8 @@ const intptr_t badDispHeaderOSR = 0xDEAD05A0; // value to fill unu // (These must be implemented as #defines because C++ compilers are // not obligated to inline non-integral constants!) -#define badAddress ((address)svm_container::badAddressVal) -#define badHeapWord (svm_container::badHeapWordVal) +#define badAddress ((address)::badAddressVal) +#define badHeapWord (::badHeapWordVal) // Default TaskQueue size is 16K (32-bit) or 128K (64-bit) const uint TASKQUEUE_SIZE = (NOT_LP64(1<<14) LP64_ONLY(1<<17)); @@ -1161,9 +1122,6 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) { #ifdef min #undef min #endif - -} // namespace svm_container - #endif // !NATIVE_IMAGE // It is necessary to use templates here. Having normal overloaded @@ -1171,9 +1129,6 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) { // and 64-bit overloaded functions, which does not work, and having // explicitly-typed versions of these routines (i.e., MAX2I, MAX2L) // will be even more error-prone than macros. - -namespace svm_container { - template constexpr T MAX2(T a, T b) { return (a > b) ? a : b; } template constexpr T MIN2(T a, T b) { return (a < b) ? a : b; } #ifndef NATIVE_IMAGE @@ -1430,7 +1385,4 @@ std::add_rvalue_reference_t declval() noexcept; bool IEEE_subnormal_handling_OK(); #endif // !NATIVE_IMAGE - -} // namespace svm_container - #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index 81d9e6360d75..10d7501b715b 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp @@ -47,13 +47,7 @@ #if (defined(__VEC__) || defined(__AIXVEC)) && defined(AIX) \ && defined(__open_xl_version__) && __open_xl_version__ >= 17 #undef malloc - -namespace svm_container { - extern void *malloc(size_t) asm("vec_malloc"); - -} // namespace svm_container - #endif #include @@ -80,31 +74,16 @@ namespace svm_container { // checking for nanness #if defined(__APPLE__) - -namespace svm_container { - inline int g_isnan(double f) { return isnan(f); } - -} // namespace svm_container - #elif defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(_AIX) - -namespace svm_container { - inline int g_isnan(float f) { return isnan(f); } inline int g_isnan(double f) { return isnan(f); } - -} // namespace svm_container - #else #error "missing platform-specific definition here" #endif // Checking for finiteness - -namespace svm_container { - inline int g_isfinite(jfloat f) { return isfinite(f); } inline int g_isfinite(jdouble f) { return isfinite(f); } @@ -138,7 +117,4 @@ inline int g_isfinite(jdouble f) { return isfinite(f); } #define ALWAYSINLINE inline __attribute__ ((always_inline)) #define ATTRIBUTE_FLATTEN __attribute__ ((flatten)) - -} // namespace svm_container - #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_GCC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp index 812c6ba19afb..ff42b8ccbc11 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp @@ -46,9 +46,6 @@ #include "utilities/xmlstream.hpp" // Declarations of jvm methods - -namespace svm_container { - extern "C" void jio_print(const char* s, size_t len); extern "C" int jio_printf(const char *fmt, ...); @@ -192,13 +189,7 @@ void outputStream::vprint_cr(const char* format, va_list argptr) { do_vsnprintf_and_write(format, argptr, true); } - -} // namespace svm_container - #endif // !NATIVE_IMAGE - -namespace svm_container { - void outputStream::print_raw(const char* str, size_t len) { #ifndef NATIVE_IMAGE if (_autoindent && _position == 0) { @@ -476,9 +467,6 @@ stringStream::~stringStream() { } } - -} // namespace svm_container - #ifndef NATIVE_IMAGE // tty needs to be always accessible since there are code paths that may write to it // outside of the VM lifespan. @@ -489,9 +477,6 @@ stringStream::~stringStream() { // The policy followed here is a compromise reached during review of JDK-8292351: // - pre-init: we silently swallow all output. We won't see anything, but at least won't crash // - post-exit: we write to a simple fdStream, but somewhat mimic the behavior of the real defaultStream - -namespace svm_container { - static nullStream tty_preinit_stream; outputStream* tty = &tty_preinit_stream; @@ -1111,9 +1096,6 @@ bufferedStream::~bufferedStream() { FREE_C_HEAP_ARRAY(char, buffer); } - -} // namespace svm_container - #ifndef PRODUCT #if defined(LINUX) || defined(AIX) || defined(_ALLBSD_SOURCE) @@ -1127,9 +1109,6 @@ bufferedStream::~bufferedStream() { #endif // Network access - -namespace svm_container { - networkStream::networkStream() : bufferedStream(1024*10, 1024*10) { _socket = -1; @@ -1193,9 +1172,6 @@ bool networkStream::connect(const char *host, short port) { freeaddrinfo(addr_info); return (conn >= 0); } - -} // namespace svm_container - #endif // !NATIVE_IMAGE #endif diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp index 494d90d5ce8d..e466acdc5c44 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp @@ -34,13 +34,7 @@ #include "utilities/macros.hpp" #ifndef NATIVE_IMAGE - -namespace svm_container { - DEBUG_ONLY(class ResourceMark;) - -} // namespace svm_container - #endif // !NATIVE_IMAGE // Output streams for printing @@ -54,9 +48,6 @@ DEBUG_ONLY(class ResourceMark;) // This allows for redirection via -XX:+DisplayVMOutputToStdout and // -XX:+DisplayVMOutputToStderr. - -namespace svm_container { - class outputStream : public CHeapObjBase { #ifndef NATIVE_IMAGE private: @@ -408,7 +399,4 @@ class networkStream : public bufferedStream { #endif #endif // !NATIVE_IMAGE - -} // namespace svm_container - #endif // SHARE_UTILITIES_OSTREAM_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/share/native/include/jni.h b/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/share/native/include/jni.h index 0e53f0635438..1a31c38b3ce7 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/share/native/include/jni.h +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/share/native/include/jni.h @@ -44,9 +44,6 @@ #include "jni_md.h" - -namespace svm_container { - #ifdef __cplusplus extern "C" { #endif @@ -2013,7 +2010,4 @@ JNI_OnUnload(JavaVM *vm, void *reserved); } /* extern "C" */ #endif /* __cplusplus */ - -} // namespace svm_container - #endif /* !_JAVASOFT_JNI_H_ */ diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/unix/native/include/jni_md.h b/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/unix/native/include/jni_md.h index dc0b96c38eec..b4ed87e0c48b 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/unix/native/include/jni_md.h +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/unix/native/include/jni_md.h @@ -52,9 +52,6 @@ #define JNIIMPORT #endif - -namespace svm_container { - typedef int jint; #ifdef _LP64 typedef long jlong; @@ -64,7 +61,4 @@ typedef long long jlong; typedef signed char jbyte; - -} // namespace svm_container - #endif /* !_JAVASOFT_JNI_MD_H_ */ diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/memory/allocation.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/memory/allocation.cpp index 606919e7fd76..e72481e07bb9 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/memory/allocation.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/memory/allocation.cpp @@ -26,9 +26,6 @@ #include "memory/allocation.hpp" #include "runtime/os.hpp" - -namespace svm_container { - char* AllocateHeap(size_t size, MemTag mem_tag, AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) { @@ -49,6 +46,3 @@ char* ReallocateHeap(char* old, void FreeHeap(void* p) { os::free(p); } - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/runtime/globals.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/runtime/globals.hpp index bc0aecdd8151..8c6b3cb6cf6c 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/runtime/globals.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/runtime/globals.hpp @@ -29,13 +29,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" - -namespace svm_container { - constexpr bool UseCpuAllocPath = false; constexpr bool UseContainerSupport = true; - -} // namespace svm_container - #endif // SHARE_RUNTIME_GLOBALS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.cpp index 73d1d316813a..0be1d5d79791 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.cpp @@ -31,9 +31,6 @@ #include #ifdef PRINT_WARNINGS - -namespace svm_container { - ATTRIBUTE_PRINTF(1, 2) void warning(const char* format, ...) { FILE* const err = stderr; @@ -43,15 +40,9 @@ void warning(const char* format, ...) { va_end(ap); fputc('\n', err); } - -} // namespace svm_container - #endif #ifdef ASSERT - -namespace svm_container { - ATTRIBUTE_PRINTF(4, 5) void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...) { FILE* const err = stderr; @@ -67,7 +58,4 @@ void report_vm_error(const char* file, int line, const char* error_msg) { report_vm_error(file, line, error_msg, "%s", ""); } - -} // namespace svm_container - #endif diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.hpp index dc125fb09ed9..8056a057a722 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.hpp @@ -30,9 +30,6 @@ #ifdef ASSERT // error reporting helper functions - -namespace svm_container { - [[noreturn]] void report_vm_error(const char* file, int line, const char* error_msg); @@ -40,9 +37,6 @@ void report_vm_error(const char* file, int line, const char* error_msg); ATTRIBUTE_PRINTF(4, 5) void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...); - -} // namespace svm_container - #endif #ifdef ASSERT @@ -70,13 +64,7 @@ do { \ #ifndef PRINT_WARNINGS #define warning(format, ...) #else - -namespace svm_container { - void warning(const char* format, ...); - -} // namespace svm_container - #endif #define STATIC_ASSERT(Cond) static_assert((Cond), #Cond) diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.cpp index accce218d6ab..7b1ed8c88201 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.cpp @@ -28,9 +28,6 @@ #include "osContainer_linux.hpp" #include "svm_container.hpp" - -namespace svm_container { - extern "C" { // keep in sync with ContainerLibrary.java @@ -114,6 +111,3 @@ EXPORT_FOR_SVM int svm_container_active_processor_count() { } } // extern C - -} // namespace svm_container - diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.hpp index dc22951769d6..d7a3c958b27f 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.hpp @@ -40,9 +40,6 @@ #endif #endif - -namespace svm_container { - extern "C" { EXPORT_FOR_SVM int svm_container_initialize(int version); EXPORT_FOR_SVM jlong svm_container_physical_memory(); @@ -56,7 +53,4 @@ extern "C" { EXPORT_FOR_SVM int svm_container_active_processor_count(); } - -} // namespace svm_container - #endif // SVM_CONTAINER_HPP From 867a44abd3e98ca1db8f9628dcb0549b8c8a0a44 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Mon, 30 Jun 2025 10:28:34 +0200 Subject: [PATCH 2/7] svm: revert libcontainer to 25+18 --- .../os/linux/cgroupSubsystem_linux.cpp | 7 +-- .../os/linux/cgroupSubsystem_linux.hpp | 16 +----- .../src/hotspot/os/linux/cgroupUtil_linux.cpp | 8 ++- .../src/hotspot/os/linux/cgroupUtil_linux.hpp | 8 ++- .../os/linux/cgroupV1Subsystem_linux.cpp | 7 +-- .../os/linux/cgroupV1Subsystem_linux.hpp | 7 +-- .../os/linux/cgroupV2Subsystem_linux.cpp | 10 ++-- .../os/linux/cgroupV2Subsystem_linux.hpp | 10 ++-- .../hotspot/os/linux/osContainer_linux.cpp | 9 +--- .../hotspot/os/linux/osContainer_linux.hpp | 7 +-- .../src/hotspot/os/linux/os_linux.cpp | 32 ++--------- .../src/hotspot/os/linux/os_linux.hpp | 18 +------ .../src/hotspot/os/linux/os_linux.inline.hpp | 7 +-- .../src/hotspot/os/posix/os_posix.cpp | 15 +----- .../src/hotspot/os/posix/os_posix.hpp | 7 +-- .../src/hotspot/os/posix/os_posix.inline.hpp | 7 +-- .../src/hotspot/share/memory/allStatic.hpp | 5 +- .../src/hotspot/share/memory/allocation.hpp | 9 +--- .../share/memory/allocation.inline.hpp | 7 +-- .../src/hotspot/share/nmt/memTag.hpp | 5 +- .../src/hotspot/share/runtime/os.cpp | 54 +------------------ .../src/hotspot/share/runtime/os.hpp | 43 +-------------- .../src/hotspot/share/runtime/os.inline.hpp | 7 +-- .../hotspot/share/utilities/checkedCast.hpp | 5 +- .../share/utilities/compilerWarnings.hpp | 5 +- .../share/utilities/compilerWarnings_gcc.hpp | 5 +- .../share/utilities/globalDefinitions.hpp | 23 +------- .../share/utilities/globalDefinitions_gcc.hpp | 5 +- .../src/hotspot/share/utilities/macros.hpp | 5 +- .../src/hotspot/share/utilities/ostream.cpp | 23 +------- .../src/hotspot/share/utilities/ostream.hpp | 25 +-------- 31 files changed, 67 insertions(+), 334 deletions(-) diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp index 463a97240b32..612cb9a93023 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 @@ -884,9 +883,7 @@ int CgroupSubsystem::cpu_shares() { return cpu_controller()->controller()->cpu_shares(); } -#ifndef NATIVE_IMAGE void CgroupSubsystem::print_version_specific_info(outputStream* st) { julong phys_mem = os::Linux::physical_memory(); memory_controller()->controller()->print_version_specific_info(st, phys_mem); } -#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp index a55e8d775ff7..53b178397f83 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 CGROUP_SUBSYSTEM_LINUX_HPP @@ -173,24 +172,17 @@ class CachedMetric : public CHeapObj{ _next_check_counter = min_jlong; } bool should_check_metric() { -#ifdef NATIVE_IMAGE - // NOTE (chaeubl): we do all caching on the Java-side instead of the C-side - return true; -#else return os::elapsed_counter() > _next_check_counter; -#endif // NATIVE_IMAGE } jlong value() { return _metric; } void set_value(jlong value, jlong timeout) { _metric = value; -#ifndef NATIVE_IMAGE // Metric is unlikely to change, but we want to remain // responsive to configuration changes. A very short grace time // between re-read avoids excessive overhead during startup without // significantly reducing the VMs ability to promptly react to changed // metric config _next_check_counter = os::elapsed_counter() + timeout; -#endif // !NATIVE_IMAGE } }; @@ -235,9 +227,7 @@ class CgroupMemoryController: public CHeapObj { virtual jlong memory_max_usage_in_bytes() = 0; virtual jlong rss_usage_in_bytes() = 0; virtual jlong cache_usage_in_bytes() = 0; -#ifndef NATIVE_IMAGE virtual void print_version_specific_info(outputStream* st, julong host_mem) = 0; -#endif // !NATIVE_IMAGE virtual bool needs_hierarchy_adjustment() = 0; virtual bool is_read_only() = 0; virtual const char* subsystem_path() = 0; @@ -272,9 +262,7 @@ class CgroupSubsystem: public CHeapObj { jlong memory_max_usage_in_bytes(); jlong rss_usage_in_bytes(); jlong cache_usage_in_bytes(); -#ifndef NATIVE_IMAGE void print_version_specific_info(outputStream* st); -#endif // !NATIVE_IMAGE }; // Utility class for storing info retrieved from /proc/cgroups, diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp index 863d4fadf3fd..b52ef87dcaee 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp @@ -1,13 +1,10 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2024, 2025, Red Hat Inc. All rights reserved. + * Copyright (c) 2024, 2025, Red Hat, Inc. * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,6 +19,7 @@ * 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 "os_linux.hpp" diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp index b97e7406f56c..19220af31776 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp @@ -1,13 +1,10 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2024, 2024, Red Hat Inc. All rights reserved. + * Copyright (c) 2024, Red Hat, Inc. * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,6 +19,7 @@ * 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 CGROUP_UTIL_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp index 12329dd45594..8d9c3edb72a2 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 @@ -345,7 +344,6 @@ jlong CgroupV1MemoryController::kernel_memory_max_usage_in_bytes() { return (jlong)kmem_max_usage; } -#ifndef NATIVE_IMAGE void CgroupV1MemoryController::print_version_specific_info(outputStream* st, julong phys_mem) { jlong kmem_usage = kernel_memory_usage_in_bytes(); jlong kmem_limit = kernel_memory_limit_in_bytes(phys_mem); @@ -355,7 +353,6 @@ void CgroupV1MemoryController::print_version_specific_info(outputStream* st, jul OSContainer::print_container_helper(st, kmem_usage, "kernel_memory_usage_in_bytes"); OSContainer::print_container_helper(st, kmem_max_usage, "kernel_memory_max_usage_in_bytes"); } -#endif // !NATIVE_IMAGE char* CgroupV1Subsystem::cpu_cpuset_cpus() { char cpus[1024]; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp index b909b7415432..0c191ab91c7f 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 CGROUP_V1_SUBSYSTEM_LINUX_HPP @@ -89,9 +88,7 @@ class CgroupV1MemoryController final : public CgroupMemoryController { jlong kernel_memory_usage_in_bytes(); jlong kernel_memory_limit_in_bytes(julong host_mem); jlong kernel_memory_max_usage_in_bytes(); -#ifndef NATIVE_IMAGE void print_version_specific_info(outputStream* st, julong host_mem) override; -#endif // !NATIVE_IMAGE bool needs_hierarchy_adjustment() override { return reader()->needs_hierarchy_adjustment(); } diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp index cb570e65debc..cbadbb9db02f 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp @@ -1,13 +1,10 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2025, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2025, Red Hat Inc. * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,6 +19,7 @@ * 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 "cgroupV2Subsystem_linux.hpp" @@ -309,7 +307,6 @@ bool CgroupV2Controller::needs_hierarchy_adjustment() { return strcmp(_cgroup_path, "/") != 0; } -#ifndef NATIVE_IMAGE void CgroupV2MemoryController::print_version_specific_info(outputStream* st, julong phys_mem) { jlong swap_current = memory_swap_current_value(reader()); jlong swap_limit = memory_swap_limit_value(reader()); @@ -317,7 +314,6 @@ void CgroupV2MemoryController::print_version_specific_info(outputStream* st, jul OSContainer::print_container_helper(st, swap_current, "memory_swap_current_in_bytes"); OSContainer::print_container_helper(st, swap_limit, "memory_swap_max_limit_in_bytes"); } -#endif // !NATIVE_IMAGE char* CgroupV2Controller::construct_path(char* mount_path, const char* cgroup_path) { stringStream ss; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp index e90d886d1006..56dcadd670f8 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp @@ -1,13 +1,10 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,6 +19,7 @@ * 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 CGROUP_V2_SUBSYSTEM_LINUX_HPP @@ -95,9 +93,7 @@ class CgroupV2MemoryController final: public CgroupMemoryController { jlong memory_max_usage_in_bytes() override; jlong rss_usage_in_bytes() override; jlong cache_usage_in_bytes() override; -#ifndef NATIVE_IMAGE void print_version_specific_info(outputStream* st, julong host_mem) override; -#endif // !NATIVE_IMAGE bool is_read_only() override { return reader()->is_read_only(); } diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp index 336924e2c468..ecac7307c300 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 @@ -143,12 +142,10 @@ jlong OSContainer::cache_usage_in_bytes() { return cgroup_subsystem->cache_usage_in_bytes(); } -#ifndef NATIVE_IMAGE void OSContainer::print_version_specific_info(outputStream* st) { assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); cgroup_subsystem->print_version_specific_info(st); } -#endif // !NATIVE_IMAGE char * OSContainer::cpu_cpuset_cpus() { assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); @@ -190,7 +187,6 @@ jlong OSContainer::pids_current() { return cgroup_subsystem->pids_current(); } -#ifndef NATIVE_IMAGE void OSContainer::print_container_helper(outputStream* st, jlong j, const char* metrics) { st->print("%s: ", metrics); if (j >= 0) { @@ -203,4 +199,3 @@ void OSContainer::print_container_helper(outputStream* st, jlong j, const char* st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "unlimited"); } } -#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp index cec65a73f20f..dd29c7a4769d 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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_LINUX_OSCONTAINER_LINUX_HPP @@ -45,10 +44,8 @@ class OSContainer: AllStatic { public: static void init(); -#ifndef NATIVE_IMAGE static void print_version_specific_info(outputStream* st); static void print_container_helper(outputStream* st, jlong j, const char* metrics); -#endif // !NATIVE_IMAGE static inline bool is_containerized(); static const char * container_type(); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp index eb4c65a369e8..35455b7b4ad4 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp @@ -1,13 +1,11 @@ /* * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2024, SAP SE. All rights reserved. + * Copyright (c) 2015, 2024 SAP SE. 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,9 +20,9 @@ * 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 NATIVE_IMAGE #include "classfile/vmSymbols.hpp" #include "code/vtableStubs.hpp" #include "compiler/compileBroker.hpp" @@ -33,25 +31,19 @@ #include "interpreter/interpreter.hpp" #include "jvm.h" #include "jvmtifiles/jvmti.h" -#endif // !NATIVE_IMAGE #include "logging/log.hpp" -#ifndef NATIVE_IMAGE #include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" #include "nmt/memTracker.hpp" #include "oops/oop.inline.hpp" -#endif // !NATIVE_IMAGE #include "osContainer_linux.hpp" #include "os_linux.inline.hpp" #include "os_posix.inline.hpp" -#ifndef NATIVE_IMAGE #include "prims/jniFastGetField.hpp" #include "prims/jvm_misc.hpp" #include "runtime/arguments.hpp" #include "runtime/atomic.hpp" -#endif // !NATIVE_IMAGE #include "runtime/globals.hpp" -#ifndef NATIVE_IMAGE #include "runtime/globals_extension.hpp" #include "runtime/init.hpp" #include "runtime/interfaceSupport.inline.hpp" @@ -75,9 +67,7 @@ #include "services/runtimeService.hpp" #include "signals_posix.hpp" #include "utilities/align.hpp" -#endif // !NATIVE_IMAGE #include "utilities/checkedCast.hpp" -#ifndef NATIVE_IMAGE #include "utilities/debug.hpp" #include "utilities/decoder.hpp" #include "utilities/defaultStream.hpp" @@ -92,7 +82,6 @@ #include "jfr/jfrEvents.hpp" #include "jfr/support/jfrNativeLibraryLoadEvent.hpp" #endif -#endif // !NATIVE_IMAGE // put OS-includes here # include @@ -142,7 +131,6 @@ #include #endif -#ifndef NATIVE_IMAGE // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling // getrusage() is prepared to handle the associated failure. #ifndef RUSAGE_THREAD @@ -173,13 +161,11 @@ enum CoredumpFilterBit { LARGEPAGES_BIT = 1 << 6, DAX_SHARED_BIT = 1 << 8 }; -#endif // !NATIVE_IMAGE //////////////////////////////////////////////////////////////////////////////// // global variables julong os::Linux::_physical_memory = 0; -#ifndef NATIVE_IMAGE address os::Linux::_initial_thread_stack_bottom = nullptr; uintptr_t os::Linux::_initial_thread_stack_size = 0; @@ -356,7 +342,6 @@ jlong os::free_swap_space() { } return host_free_swap_val; } -#endif // !NATIVE_IMAGE julong os::physical_memory() { jlong phys_mem = 0; @@ -373,7 +358,6 @@ julong os::physical_memory() { return phys_mem; } -#ifndef NATIVE_IMAGE size_t os::rss() { size_t size = 0; os::Linux::meminfo_t info; @@ -515,7 +499,6 @@ pid_t os::Linux::gettid() { assert(rslt != -1, "must be."); // old linuxthreads implementation? return (pid_t)rslt; } -#endif // !NATIVE_IMAGE // Returns the amount of swap currently configured, in bytes. // This can change at any time. @@ -525,7 +508,6 @@ julong os::Linux::host_swap() { return (julong)(si.totalswap * si.mem_unit); } -#ifndef NATIVE_IMAGE // Most versions of linux have a bug where the number of processors are // determined by looking at the /proc file system. In a chroot environment, // the system call returns 1. @@ -533,11 +515,9 @@ static bool unsafe_chroot_detected = false; static const char *unstable_chroot_error = "/proc file system not found.\n" "Java may be unstable running multithreaded in a chroot " "environment on Linux when /proc filesystem is not mounted."; -#endif // !NATIVE_IMAGE void os::Linux::initialize_system_info() { set_processor_count((int)sysconf(_SC_NPROCESSORS_CONF)); -#ifndef NATIVE_IMAGE if (processor_count() == 1) { pid_t pid = os::Linux::gettid(); char fname[32]; @@ -549,12 +529,10 @@ void os::Linux::initialize_system_info() { fclose(fp); } } -#endif // !NATIVE_IMAGE _physical_memory = (julong)sysconf(_SC_PHYS_PAGES) * (julong)sysconf(_SC_PAGESIZE); assert(processor_count() > 0, "linux error"); } -#ifndef NATIVE_IMAGE void os::init_system_properties_values() { // The next steps are taken in the product version: // @@ -4779,7 +4757,6 @@ static int _cpu_count(const cpu_set_t* cpus) { #define CPU_COUNT(cpus) _cpu_count(cpus) #endif // CPU_COUNT -#endif // !NATIVE_IMAGE // Get the current number of available processors for this process. // This value can change at any time during a process's lifetime. @@ -4865,7 +4842,6 @@ int os::Linux::active_processor_count() { return get_active_processor_count(); } -#ifndef NATIVE_IMAGE // Determine the active processor count from one of // three different sources: // @@ -5549,5 +5525,3 @@ bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) { return res; } // end: os::pd_dll_unload() - -#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp index 969290b0ea51..bd2e1ea32304 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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_LINUX_OS_LINUX_HPP @@ -33,7 +32,6 @@ class os::Linux { friend class os; -#ifndef NATIVE_IMAGE static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *); static int (*_pthread_setname_np)(pthread_t, const char*); @@ -49,25 +47,18 @@ class os::Linux { static GrowableArray* _nindex_to_node; static julong available_memory_in_container(); -#endif // !NATIVE_IMAGE protected: static julong _physical_memory; -#ifndef NATIVE_IMAGE static pthread_t _main_thread; static julong available_memory(); static julong free_memory(); -#endif // !NATIVE_IMAGE -#ifdef NATIVE_IMAGE - public: -#endif // NATIVE_IMAGE static void initialize_system_info(); -#ifndef NATIVE_IMAGE static int commit_memory_impl(char* addr, size_t bytes, bool exec); static int commit_memory_impl(char* addr, size_t bytes, size_t alignment_hint, bool exec); @@ -99,9 +90,7 @@ class os::Linux { bool has_steal_ticks; }; -#endif // !NATIVE_IMAGE static int active_processor_count(); -#ifndef NATIVE_IMAGE static void kernel_version(long* major, long* minor, long* patch); // If kernel1 > kernel2 return 1 @@ -127,12 +116,10 @@ class os::Linux { static address initial_thread_stack_bottom(void) { return _initial_thread_stack_bottom; } static uintptr_t initial_thread_stack_size(void) { return _initial_thread_stack_size; } -#endif // !NATIVE_IMAGE static julong physical_memory() { return _physical_memory; } static julong host_swap(); -#ifndef NATIVE_IMAGE static intptr_t* ucontext_get_sp(const ucontext_t* uc); static intptr_t* ucontext_get_fp(const ucontext_t* uc); @@ -472,7 +459,6 @@ class os::Linux { // otherwise does nothing and returns -2. static int malloc_info(FILE* stream); #endif // GLIBC -#endif // !NATIVE_IMAGE }; #endif // OS_LINUX_OS_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp index a31cfbf30cd4..f9d798404b5f 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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_LINUX_OS_LINUX_INLINE_HPP @@ -31,7 +30,6 @@ #include "runtime/os.hpp" #include "os_posix.inline.hpp" -#ifndef NATIVE_IMAGE inline bool os::zero_page_read_protected() { return true; } @@ -57,6 +55,5 @@ inline bool os::can_trim_native_heap() { return false; // musl #endif } -#endif // !NATIVE_IMAGE #endif // OS_LINUX_OS_LINUX_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp index 6808d0a046cb..a36d6b87641e 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,18 +19,16 @@ * 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 NATIVE_IMAGE #include "classfile/classLoader.hpp" #include "jvm.h" #include "jvmtifiles/jvmti.h" #include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "nmt/memTracker.hpp" -#endif // !NATIVE_IMAGE #include "os_posix.inline.hpp" -#ifndef NATIVE_IMAGE #include "runtime/arguments.hpp" #include "runtime/atomic.hpp" #include "runtime/frame.inline.hpp" @@ -46,10 +42,8 @@ #include "runtime/sharedRuntime.hpp" #include "services/attachListener.hpp" #include "utilities/align.hpp" -#endif // !NATIVE_IMAGE #include "utilities/checkedCast.hpp" #include "utilities/debug.hpp" -#ifndef NATIVE_IMAGE #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" #include "utilities/formatBuffer.hpp" @@ -1024,14 +1018,10 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { return result; } -#endif // !NATIVE_IMAGE - int os::stat(const char *path, struct stat *sbuf) { return ::stat(path, sbuf); } -#ifndef NATIVE_IMAGE - char * os::native_path(char *path) { return path; } @@ -2196,4 +2186,3 @@ const void* os::get_saved_assert_context(const void** sigInfo) { *sigInfo = nullptr; return nullptr; } -#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp index 0d314af0d8d0..248a30d04adb 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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_POSIX_OS_POSIX_HPP @@ -30,7 +29,6 @@ #include -#ifndef NATIVE_IMAGE // Note: the Posix API aims to capture functionality available on all Posix // compliant platforms, but in practice the implementations may depend on // non-Posix functionality. @@ -97,6 +95,5 @@ class os::Posix { const void* ucVoid, address* stub); }; -#endif // !NATIVE_IMAGE #endif // OS_POSIX_OS_POSIX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp index de050c3c4453..cf81c5d62863 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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_POSIX_OS_POSIX_INLINE_HPP @@ -28,7 +27,6 @@ #include "os_posix.hpp" -#ifndef NATIVE_IMAGE #include "runtime/mutex.hpp" #include "runtime/os.hpp" @@ -66,6 +64,5 @@ inline void PlatformMonitor::notify_all() { int status = pthread_cond_broadcast(cond()); assert_status(status == 0, status, "cond_broadcast"); } -#endif // !NATIVE_IMAGE #endif // OS_POSIX_OS_POSIX_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp index 4f3761b470ee..79191de0dd17 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_MEMORY_ALLSTATIC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp index b1d069fcfb74..b67dcd43e4d4 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_MEMORY_ALLOCATION_HPP @@ -234,7 +233,6 @@ class StackObj { void operator delete [](void* p) = delete; }; -#ifndef NATIVE_IMAGE // Base class for objects stored in Metaspace. // Calling delete will result in fatal error. // @@ -517,7 +515,6 @@ class AnyObj { #define NEW_C_HEAP_ARRAY2(type, size, mem_tag, pc)\ (type*) (AllocateHeap((size) * sizeof(type), mem_tag, pc)) -#endif // !NATIVE_IMAGE #define NEW_C_HEAP_ARRAY(type, size, mem_tag)\ (type*) (AllocateHeap((size) * sizeof(type), mem_tag)) @@ -547,7 +544,6 @@ class AnyObj { #define FREE_C_HEAP_OBJ(objname)\ FreeHeap((char*)objname); -#ifndef NATIVE_IMAGE //------------------------------ReallocMark--------------------------------- // Code which uses REALLOC_RESOURCE_ARRAY should check an associated @@ -586,6 +582,5 @@ class MallocArrayAllocator : public AllStatic { static E* reallocate(E* addr, size_t new_length, MemTag mem_tag); static void free(E* addr); }; -#endif // !NATIVE_IMAGE #endif // SHARE_MEMORY_ALLOCATION_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp index 3db943678d99..8d531c6dd231 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_MEMORY_ALLOCATION_INLINE_HPP @@ -28,7 +27,6 @@ #include "memory/allocation.hpp" -#ifndef NATIVE_IMAGE #include "runtime/atomic.hpp" #include "runtime/globals.hpp" #include "runtime/os.hpp" @@ -112,6 +110,5 @@ template void MallocArrayAllocator::free(E* addr) { FreeHeap(addr); } -#endif // !NATIVE_IMAGE #endif // SHARE_MEMORY_ALLOCATION_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp index 1bf27dce8db2..9255645638d8 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_NMT_MEM_TAG_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp index c513e247f67e..cbe40ca214bb 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,9 +19,9 @@ * 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 NATIVE_IMAGE #include "cds/cdsConfig.hpp" #include "classfile/javaClasses.hpp" #include "classfile/moduleEntry.hpp" @@ -38,9 +36,7 @@ #include "jvm.h" #include "logging/log.hpp" #include "logging/logStream.hpp" -#endif // !NATIVE_IMAGE #include "memory/allocation.inline.hpp" -#ifndef NATIVE_IMAGE #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "nmt/mallocHeader.inline.hpp" @@ -63,9 +59,7 @@ #include "runtime/javaThread.hpp" #include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" -#endif // !NATIVE_IMAGE #include "runtime/os.inline.hpp" -#ifndef NATIVE_IMAGE #include "runtime/osThread.hpp" #include "runtime/safefetch.hpp" #include "runtime/sharedRuntime.hpp" @@ -77,9 +71,7 @@ #include "services/attachListener.hpp" #include "services/threadService.hpp" #include "utilities/align.hpp" -#endif // !NATIVE_IMAGE #include "utilities/checkedCast.hpp" -#ifndef NATIVE_IMAGE #include "utilities/count_trailing_zeros.hpp" #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" @@ -100,9 +92,7 @@ OSThread* os::_starting_thread = nullptr; volatile unsigned int os::_rand_seed = 1234567; -#endif // !NATIVE_IMAGE int os::_processor_count = 0; -#ifndef NATIVE_IMAGE int os::_initial_active_processor_count = 0; os::PageSizes os::_page_sizes; @@ -115,7 +105,6 @@ int os::snprintf(char* buf, size_t len, const char* fmt, ...) { va_end(args); return result; } -#endif // !NATIVE_IMAGE int os::snprintf_checked(char* buf, size_t len, const char* fmt, ...) { va_list args; @@ -137,7 +126,6 @@ int os::vsnprintf(char* buf, size_t len, const char* fmt, va_list args) { return result; } -#ifndef NATIVE_IMAGE // Fill in buffer with current local time as an ISO-8601 string. // E.g., YYYY-MM-DDThh:mm:ss.mmm+zzzz. // Returns buffer, or null if it failed. @@ -601,7 +589,6 @@ bool os::find_builtin_agent(JvmtiAgent* agent, const char* sym) { agent->set_os_lib(save_handle); return false; } -#endif // !NATIVE_IMAGE // --------------------- heap allocation utilities --------------------- @@ -613,7 +600,6 @@ char *os::strdup(const char *str, MemTag mem_tag) { return dup_str; } -#ifndef NATIVE_IMAGE char* os::strdup_check_oom(const char* str, MemTag mem_tag) { char* p = os::strdup(str, mem_tag); if (p == nullptr) { @@ -634,36 +620,7 @@ static void break_if_ptr_caught(void* ptr) { } } #endif // ASSERT -#endif // !NATIVE_IMAGE - -#ifdef NATIVE_IMAGE -void* os::malloc(size_t size, MemTag mem_tag) { - // On malloc(0), implementations of malloc(3) have the choice to return either - // null or a unique non-null pointer. To unify libc behavior across our platforms - // we chose the latter. - size = MAX2((size_t)1, size); - return ::malloc(size); -} - -void* os::realloc(void *memblock, size_t size, MemTag mem_tag) { - if (memblock == nullptr) { - return os::malloc(size, mem_tag); - } - // On realloc(p, 0), implementers of realloc(3) have the choice to return either - // null or a unique non-null pointer. To unify libc behavior across our platforms - // we chose the latter. - size = MAX2((size_t)1, size); - return ::realloc(memblock, size); -} - -void os::free(void *memblock) { - if (memblock == nullptr) { - return; - } - ::free(memblock); -} -#else void* os::malloc(size_t size, MemTag mem_tag) { return os::malloc(size, mem_tag, CALLER_PC); } @@ -1519,7 +1476,6 @@ char* os::format_boot_path(const char* format_string, assert((q - formatted_path) == formatted_path_len, "formatted_path size botched"); return formatted_path; } -#endif // !NATIVE_IMAGE // This function is a proxy to fopen, it tries to add a non standard flag ('e' or 'N') // that ensures automatic closing of the file on exec. If it can not find support in @@ -1548,7 +1504,6 @@ FILE* os::fopen(const char* path, const char* mode) { return file; } -#ifndef NATIVE_IMAGE bool os::set_boot_path(char fileSep, char pathSep) { const char* home = Arguments::get_java_home(); int home_len = (int)strlen(home); @@ -1579,7 +1534,6 @@ bool os::set_boot_path(char fileSep, char pathSep) { return false; } -#endif // !NATIVE_IMAGE bool os::file_exists(const char* filename) { struct stat statbuf; if (filename == nullptr || strlen(filename) == 0) { @@ -1587,7 +1541,6 @@ bool os::file_exists(const char* filename) { } return os::stat(filename, &statbuf) == 0; } -#ifndef NATIVE_IMAGE bool os::write(int fd, const void *buf, size_t nBytes) { ssize_t res; @@ -1730,7 +1683,6 @@ void os::pause() { "Could not open pause file '%s', continuing immediately.\n", filename); } } -#endif // !NATIVE_IMAGE static const char* errno_to_string (int e, bool short_text) { #define ALL_SHARED_ENUMS(X) \ @@ -1857,7 +1809,6 @@ const char* os::errno_name(int e) { return errno_to_string(e, true); } -#ifndef NATIVE_IMAGE // create binary file, rewriting existing file if required int os::create_binary_file(const char* path, bool rewrite_existing) { int oflags = O_WRONLY | O_CREAT WINDOWS_ONLY(| O_BINARY); @@ -2616,4 +2567,3 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name, } return agent_entry_name; } -#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp index 05061b034d17..242959034afb 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,21 +19,19 @@ * 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 SHARE_RUNTIME_OS_HPP #define SHARE_RUNTIME_OS_HPP #include "jvm_md.h" -#ifndef NATIVE_IMAGE #include "runtime/osInfo.hpp" #include "utilities/align.hpp" #include "utilities/exceptions.hpp" -#endif // !NATIVE_IMAGE #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" #include "utilities/ostream.hpp" -#ifndef NATIVE_IMAGE #ifdef __APPLE__ # include #endif @@ -157,7 +153,6 @@ const bool ExecMem = true; typedef void (*java_call_t)(JavaValue* value, const methodHandle& method, JavaCallArguments* args, JavaThread* thread); class MallocTracker; -#endif // !NATIVE_IMAGE // Preserve errno across a range of calls @@ -177,7 +172,6 @@ class os: AllStatic { friend class JVMCIVMStructs; friend class MallocTracker; -#ifndef NATIVE_IMAGE #ifdef ASSERT private: static bool _mutex_init_done; @@ -262,10 +256,8 @@ class os: AllStatic { static void initialize_initial_active_processor_count(); LINUX_ONLY(static void pd_init_container_support();) -#endif // !NATIVE_IMAGE public: -#ifndef NATIVE_IMAGE static void init(void); // Called before command line parsing static void init_container_support() { // Called during command line parsing. @@ -351,10 +343,8 @@ class os: AllStatic { static jlong total_swap_space(); static jlong free_swap_space(); -#endif // !NATIVE_IMAGE static julong physical_memory(); -#ifndef NATIVE_IMAGE static bool has_allocatable_memory_limit(size_t* limit); static bool is_server_class_machine(); static size_t rss(); @@ -362,7 +352,6 @@ class os: AllStatic { // Returns the id of the processor on which the calling thread is currently executing. // The returned value is guaranteed to be between 0 and (os::processor_count() - 1). static uint processor_id(); -#endif // !NATIVE_IMAGE // number of CPUs static int processor_count() { @@ -370,7 +359,6 @@ class os: AllStatic { } static void set_processor_count(int count) { _processor_count = count; } -#ifndef NATIVE_IMAGE // Returns the number of CPUs this process is currently allowed to run on. // Note that on some OSes this can change dynamically. static int active_processor_count(); @@ -679,13 +667,9 @@ class os: AllStatic { // File i/o operations static int open(const char *path, int oflag, int mode); static FILE* fdopen(int fd, const char* mode); -#endif // !NATIVE_IMAGE static FILE* fopen(const char* path, const char* mode); -#ifndef NATIVE_IMAGE static jlong lseek(int fd, jlong offset, int whence); -#endif // !NATIVE_IMAGE static bool file_exists(const char* file); -#ifndef NATIVE_IMAGE // This function, on Windows, canonicalizes a given path (see os_windows.cpp for details). // On Posix, this function is a noop: it does not change anything and just returns // the input pointer. @@ -807,20 +791,16 @@ class os: AllStatic { // Find agent entry point static void* find_agent_function(JvmtiAgent* agent_lib, bool check_lib, const char* sym); -#endif // !NATIVE_IMAGE // Provide wrapper versions of these functions to guarantee NUL-termination // in all cases. static int vsnprintf(char* buf, size_t len, const char* fmt, va_list args) ATTRIBUTE_PRINTF(3, 0); -#ifndef NATIVE_IMAGE static int snprintf(char* buf, size_t len, const char* fmt, ...) ATTRIBUTE_PRINTF(3, 4); -#endif // !NATIVE_IMAGE // Performs snprintf and asserts the result is non-negative (so there was not // an encoding error) and that the output was not truncated. static int snprintf_checked(char* buf, size_t len, const char* fmt, ...) ATTRIBUTE_PRINTF(3, 4); -#ifndef NATIVE_IMAGE // Get host name in buffer provided static bool get_host_name(char* buf, size_t buflen); @@ -859,7 +839,6 @@ class os: AllStatic { // Send JFR memory info event static void jfr_report_memory_info() NOT_JFR_RETURN(); -#endif // !NATIVE_IMAGE // Replacement for strerror(). // Will return the english description of the error (e.g. "File not found", as @@ -877,7 +856,6 @@ class os: AllStatic { // Will not change the value of errno. static const char* errno_name(int e); -#ifndef NATIVE_IMAGE // wait for a key press if PauseAtExit is set static void wait_for_keypress_at_exit(void); @@ -919,10 +897,8 @@ class os: AllStatic { // Init os specific system properties values static void init_system_properties_values(); -#endif // !NATIVE_IMAGE // IO operations, non-JVM_ version. static int stat(const char* path, struct stat* sbuf); -#ifndef NATIVE_IMAGE static bool dir_is_empty(const char* path); // IO operations on binary files @@ -937,22 +913,16 @@ class os: AllStatic { // toSkip: number of stack frames to skip at the beginning. // Return: number of stack frames captured. static int get_native_stack(address* stack, int size, int toSkip = 0); -#endif // !NATIVE_IMAGE // General allocation (must be MT-safe) -#ifndef NATIVE_IMAGE static void* malloc (size_t size, MemTag mem_tag, const NativeCallStack& stack); -#endif // !NATIVE_IMAGE static void* malloc (size_t size, MemTag mem_tag); -#ifndef NATIVE_IMAGE static void* realloc (void *memblock, size_t size, MemTag mem_tag, const NativeCallStack& stack); -#endif // !NATIVE_IMAGE static void* realloc (void *memblock, size_t size, MemTag mem_tag); // handles null pointers static void free (void *memblock); static char* strdup(const char *, MemTag mem_tag = mtInternal); // Like strdup -#ifndef NATIVE_IMAGE // Like strdup, but exit VM when strdup() returns null static char* strdup_check_oom(const char*, MemTag mem_tag = mtInternal); @@ -1045,7 +1015,6 @@ class os: AllStatic { // Used to register dynamic code cache area with the OS // Note: Currently only used in 64 bit Windows implementations inline static bool register_code_area(char *low, char *high); -#endif // !NATIVE_IMAGE // Platform-specific code for interacting with individual OSes. // TODO: This is for compatibility only with current usage of os::Linux, etc. @@ -1066,7 +1035,6 @@ class os: AllStatic { class Posix; #endif -#ifndef NATIVE_IMAGE #ifndef OS_NATIVE_THREAD_CREATION_FAILED_MSG #define OS_NATIVE_THREAD_CREATION_FAILED_MSG "unable to create native thread: possibly out of memory or process/resource limits reached" #endif @@ -1103,14 +1071,10 @@ class os: AllStatic { // Enables write or execute access to writeable and executable pages. static void current_thread_enable_wx(WXMode mode); #endif // __APPLE__ && AARCH64 -#endif // !NATIVE_IMAGE protected: -#ifndef NATIVE_IMAGE static volatile unsigned int _rand_seed; // seed for random number generator -#endif // !NATIVE_IMAGE static int _processor_count; // number of processors -#ifndef NATIVE_IMAGE static int _initial_active_processor_count; // number of active processors during initialization. static char* format_boot_path(const char* format_string, @@ -1121,16 +1085,13 @@ class os: AllStatic { static bool set_boot_path(char fileSep, char pathSep); static bool pd_dll_unload(void* libhandle, char* ebuf, int ebuflen); -#endif // !NATIVE_IMAGE }; -#ifndef NATIVE_IMAGE // Note that "PAUSE" is almost always used with synchronization // so arguably we should provide Atomic::SpinPause() instead // of the global SpinPause() with C linkage. // It'd also be eligible for inlining on many platforms. extern "C" int SpinPause(); -#endif // !NATIVE_IMAGE #endif // SHARE_RUNTIME_OS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp index 0719c472f3f8..d5cd1b922302 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_RUNTIME_OS_INLINE_HPP @@ -28,7 +27,6 @@ #include "runtime/os.hpp" -#ifndef NATIVE_IMAGE #include OS_HEADER_INLINE(os) #include OS_CPU_HEADER_INLINE(os) @@ -60,6 +58,5 @@ inline void* os::resolve_function_descriptor(void* p) { return nullptr; } #endif -#endif // !NATIVE_IMAGE #endif // SHARE_RUNTIME_OS_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp index 3379586aded9..290028f99e3a 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_UTILITIES_CHECKEDCAST_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp index a71f641b3311..ddcaf022fa69 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_UTILITIES_COMPILERWARNINGS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp index f11b4eb8af24..1dd5892e4c34 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp index dc0ae41fdcc9..95ebc77d1c98 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_UTILITIES_GLOBALDEFINITIONS_HPP @@ -30,10 +29,8 @@ #include "utilities/debug.hpp" #include "utilities/macros.hpp" -#ifndef NATIVE_IMAGE // Get constants like JVM_T_CHAR and JVM_SIGNATURE_INT, before pulling in . #include "classfile_constants.h" -#endif // !NATIVE_IMAGE #include COMPILER_HEADER(utilities/globalDefinitions) @@ -42,9 +39,7 @@ #include #include -#ifndef NATIVE_IMAGE class oopDesc; -#endif // !NATIVE_IMAGE // Defaults for macros that might be defined per compiler. #ifndef NOINLINE @@ -54,7 +49,6 @@ class oopDesc; #define ALWAYSINLINE inline #endif -#ifndef NATIVE_IMAGE #ifndef ATTRIBUTE_ALIGNED #define ATTRIBUTE_ALIGNED(x) alignas(x) #endif @@ -127,7 +121,6 @@ class oopDesc; #define UINT32_FORMAT_X "0x%" PRIx32 #define UINT32_FORMAT_X_0 "0x%08" PRIx32 #define UINT32_FORMAT_W(width) "%" #width PRIu32 -#endif // !NATIVE_IMAGE // Format 64-bit quantities. #define INT64_FORMAT "%" PRId64 @@ -155,7 +148,6 @@ class oopDesc; #define JULONG_FORMAT_X UINT64_FORMAT_X #endif -#ifndef NATIVE_IMAGE // Format pointers and padded integral values which change size between 32- and 64-bit. #ifdef _LP64 #define INTPTR_FORMAT "0x%016" PRIxPTR @@ -294,7 +286,6 @@ inline size_t heap_word_size(size_t byte_size) { inline jfloat jfloat_cast(jint x); inline jdouble jdouble_cast(jlong x); -#endif // !NATIVE_IMAGE //------------------------------------------- // Constant for jlong (standardized by C++11) @@ -306,19 +297,16 @@ inline jdouble jdouble_cast(jlong x); const jlong min_jlong = CONST64(0x8000000000000000); const jlong max_jlong = CONST64(0x7fffffffffffffff); -#ifndef NATIVE_IMAGE //------------------------------------------- // Constant for jdouble const jlong min_jlongDouble = CONST64(0x0000000000000001); const jdouble min_jdouble = jdouble_cast(min_jlongDouble); const jlong max_jlongDouble = CONST64(0x7fefffffffffffff); const jdouble max_jdouble = jdouble_cast(max_jlongDouble); -#endif // !NATIVE_IMAGE const size_t K = 1024; const size_t M = K*K; const size_t G = M*K; -#ifndef NATIVE_IMAGE const size_t HWperKB = K / sizeof(HeapWord); // Constants for converting from a base unit to milli-base units. For @@ -328,13 +316,11 @@ const int MILLIUNITS = 1000; // milli units per base unit const int MICROUNITS = 1000000; // micro units per base unit const int NANOUNITS = 1000000000; // nano units per base unit const int NANOUNITS_PER_MILLIUNIT = NANOUNITS / MILLIUNITS; -#endif // !NATIVE_IMAGE const jlong NANOSECS_PER_SEC = CONST64(1000000000); const jint NANOSECS_PER_MILLISEC = 1000000; -#ifndef NATIVE_IMAGE // Unit conversion functions // The caller is responsible for considering overflow. @@ -519,7 +505,6 @@ inline int pointer_delta_as_int(const volatile T* left, const volatile T* right) extern "C" { typedef int (*_sort_Fn)(const void *, const void *); } -#endif // !NATIVE_IMAGE // Additional Java basic types @@ -548,7 +533,6 @@ typedef jshort s2; typedef jint s4; typedef jlong s8; -#ifndef NATIVE_IMAGE const jbyte min_jbyte = -(1 << 7); // smallest jbyte const jbyte max_jbyte = (1 << 7) - 1; // largest jbyte const jshort min_jshort = -(1 << 15); // smallest jshort @@ -1122,7 +1106,6 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) { #ifdef min #undef min #endif -#endif // !NATIVE_IMAGE // It is necessary to use templates here. Having normal overloaded // functions does not work because it is necessary to provide both 32- @@ -1131,7 +1114,6 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) { // will be even more error-prone than macros. template constexpr T MAX2(T a, T b) { return (a > b) ? a : b; } template constexpr T MIN2(T a, T b) { return (a < b) ? a : b; } -#ifndef NATIVE_IMAGE template constexpr T MAX3(T a, T b, T c) { return MAX2(MAX2(a, b), c); } template constexpr T MIN3(T a, T b, T c) { return MIN2(MIN2(a, b), c); } template constexpr T MAX4(T a, T b, T c, T d) { return MAX2(MAX3(a, b, c), d); } @@ -1383,6 +1365,5 @@ std::add_rvalue_reference_t declval() noexcept; // Quickly test to make sure IEEE-754 subnormal numbers are correctly // handled. bool IEEE_subnormal_handling_OK(); -#endif // !NATIVE_IMAGE #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index 10d7501b715b..94f37e7954e4 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_UTILITIES_GLOBALDEFINITIONS_GCC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp index 5dbec43da020..5c3cfaa0dd55 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,6 +19,7 @@ * 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 SHARE_UTILITIES_MACROS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp index ff42b8ccbc11..e95bc776ce5e 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,15 +19,13 @@ * 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 NATIVE_IMAGE #include "cds/classListWriter.hpp" #include "compiler/compileLog.hpp" #include "jvm.h" -#endif // !NATIVE_IMAGE #include "memory/allocation.inline.hpp" -#ifndef NATIVE_IMAGE #include "oops/oop.inline.hpp" #include "runtime/arguments.hpp" #include "runtime/mutexLocker.hpp" @@ -38,10 +34,8 @@ #include "runtime/safepoint.hpp" #include "runtime/vm_version.hpp" #include "utilities/defaultStream.hpp" -#endif // !NATIVE_IMAGE #include "utilities/macros.hpp" #include "utilities/ostream.hpp" -#ifndef NATIVE_IMAGE #include "utilities/vmError.hpp" #include "utilities/xmlstream.hpp" @@ -189,16 +183,12 @@ void outputStream::vprint_cr(const char* format, va_list argptr) { do_vsnprintf_and_write(format, argptr, true); } -#endif // !NATIVE_IMAGE void outputStream::print_raw(const char* str, size_t len) { -#ifndef NATIVE_IMAGE if (_autoindent && _position == 0) { indent(); } -#endif // !NATIVE_IMAGE write(str, len); } -#ifndef NATIVE_IMAGE int outputStream::fill_to(int col) { const int need_fill = MAX2(col - position(), 0); @@ -345,7 +335,6 @@ void outputStream::print_data(void* data, size_t len, bool with_ascii, bool rel_ } } } -#endif // !NATIVE_IMAGE stringStream::stringStream(size_t initial_capacity) : outputStream(), @@ -360,7 +349,6 @@ stringStream::stringStream(size_t initial_capacity) : zero_terminate(); } -#ifndef NATIVE_IMAGE // useful for output to fixed chunks of memory, such as performance counters stringStream::stringStream(char* fixed_buffer, size_t fixed_buffer_size) : outputStream(), @@ -371,7 +359,6 @@ stringStream::stringStream(char* fixed_buffer, size_t fixed_buffer_size) : { zero_terminate(); } -#endif // !NATIVE_IMAGE // Grow backing buffer to desired capacity. Don't call for fixed buffers void stringStream::grow(size_t new_capacity) { @@ -419,12 +406,10 @@ void stringStream::write(const char* s, size_t len) { zero_terminate(); } -#ifndef NATIVE_IMAGE // Note that the following does not depend on write_len. // This means that position and count get updated // even when overflow occurs. update_position(s, len); -#endif // !NATIVE_IMAGE } void stringStream::zero_terminate() { @@ -433,7 +418,6 @@ void stringStream::zero_terminate() { _buffer[_written] = '\0'; } -#ifndef NATIVE_IMAGE void stringStream::reset() { assert(_is_frozen == false, "Modification forbidden"); _written = 0; _precount = 0; _position = 0; @@ -459,7 +443,6 @@ char* stringStream::as_string(Arena* arena) const { copy[_written] = '\0'; // terminating null return copy; } -#endif // !NATIVE_IMAGE stringStream::~stringStream() { if (!_is_fixed && _buffer != _small_buffer) { @@ -467,7 +450,6 @@ stringStream::~stringStream() { } } -#ifndef NATIVE_IMAGE // tty needs to be always accessible since there are code paths that may write to it // outside of the VM lifespan. // Examples for pre-VM-init accesses: Early NMT init, Early UL init @@ -1172,6 +1154,5 @@ bool networkStream::connect(const char *host, short port) { freeaddrinfo(addr_info); return (conn >= 0); } -#endif // !NATIVE_IMAGE #endif diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp index e466acdc5c44..46bd0b673c16 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -21,21 +19,18 @@ * 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 SHARE_UTILITIES_OSTREAM_HPP #define SHARE_UTILITIES_OSTREAM_HPP #include "memory/allocation.hpp" -#ifndef NATIVE_IMAGE #include "runtime/timer.hpp" -#endif // !NATIVE_IMAGE #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" -#ifndef NATIVE_IMAGE DEBUG_ONLY(class ResourceMark;) -#endif // !NATIVE_IMAGE // Output streams for printing // @@ -49,7 +44,6 @@ DEBUG_ONLY(class ResourceMark;) // -XX:+DisplayVMOutputToStderr. class outputStream : public CHeapObjBase { -#ifndef NATIVE_IMAGE private: NONCOPYABLE(outputStream); int _indentation; // current indentation @@ -92,10 +86,8 @@ class outputStream : public CHeapObjBase { void do_vsnprintf_and_write_with_scratch_buffer(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); // calls do_vsnprintf, then writes output to stream. void do_vsnprintf_and_write(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); -#endif // !NATIVE_IMAGE public: -#ifndef NATIVE_IMAGE class TestSupport; // Unit test support // creation @@ -135,10 +127,8 @@ class outputStream : public CHeapObjBase { void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); -#endif // !NATIVE_IMAGE void print_raw(const char* str) { print_raw(str, strlen(str)); } void print_raw(const char* str, size_t len); -#ifndef NATIVE_IMAGE void print_raw_cr(const char* str) { print_raw(str); cr(); } void print_raw_cr(const char* str, size_t len) { print_raw(str, len); cr(); } void print_data(void* data, size_t len, bool with_ascii, bool rel_addr=true); @@ -169,9 +159,7 @@ class outputStream : public CHeapObjBase { // flushing virtual void flush() {} -#endif // !NATIVE_IMAGE virtual void write(const char* str, size_t len) = 0; -#ifndef NATIVE_IMAGE virtual void rotate_log(bool force, outputStream* out = nullptr) {} // GC log rotation virtual ~outputStream() {} // close properly on deletion @@ -181,10 +169,8 @@ class outputStream : public CHeapObjBase { void dec_cr() { dec(); cr(); } void inc_cr() { inc(); cr(); } -#endif // !NATIVE_IMAGE }; -#ifndef NATIVE_IMAGE // standard output // ANSI C++ name collision extern outputStream* tty; // tty output @@ -241,7 +227,6 @@ class ttyUnlocker: StackObj { } } }; -#endif // !NATIVE_IMAGE // for writing to strings; buffer will expand automatically. // Buffer will always be zero-terminated. @@ -263,11 +248,9 @@ class stringStream : public outputStream { // Create a stringStream using an internal buffer of initially initial_bufsize size; // will be enlarged on demand. There is no maximum cap. stringStream(size_t initial_capacity = 0); -#ifndef NATIVE_IMAGE // Creates a stringStream using a caller-provided buffer. Will truncate silently if // it overflows. stringStream(char* fixed_buffer, size_t fixed_buffer_size); -#endif // !NATIVE_IMAGE ~stringStream(); virtual void write(const char* c, size_t len); // Return number of characters written into buffer, excluding terminating zero and @@ -283,16 +266,13 @@ class stringStream : public outputStream { DEBUG_ONLY(_is_frozen = true); return _buffer; }; -#ifndef NATIVE_IMAGE void reset(); bool is_empty() const { return _buffer[0] == '\0'; } // Copy to a resource, or C-heap, array as requested char* as_string(bool c_heap = false) const; char* as_string(Arena* arena) const; -#endif // !NATIVE_IMAGE }; -#ifndef NATIVE_IMAGE class fileStream : public outputStream { protected: FILE* _file; @@ -397,6 +377,5 @@ class networkStream : public bufferedStream { }; #endif -#endif // !NATIVE_IMAGE #endif // SHARE_UTILITIES_OSTREAM_HPP From 652bca9107e3d4317e50a6ed9ed4a8fdb53a1f38 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Mon, 30 Jun 2025 10:29:15 +0200 Subject: [PATCH 3/7] svm: import libcontainer 26+4 --- .../os/linux/cgroupSubsystem_linux.cpp | 20 +- .../os/linux/cgroupSubsystem_linux.hpp | 19 +- .../os/linux/cgroupV1Subsystem_linux.cpp | 15 +- .../os/linux/cgroupV1Subsystem_linux.hpp | 37 +++- .../os/linux/cgroupV2Subsystem_linux.cpp | 26 ++- .../os/linux/cgroupV2Subsystem_linux.hpp | 34 ++++ .../hotspot/os/linux/osContainer_linux.cpp | 12 +- .../hotspot/os/linux/osContainer_linux.hpp | 5 +- .../src/hotspot/os/linux/os_linux.cpp | 185 ++++-------------- .../src/hotspot/os/posix/os_posix.cpp | 124 ++++++++++-- .../src/hotspot/os/posix/os_posix.hpp | 7 +- .../src/hotspot/share/memory/allocation.hpp | 9 +- .../share/memory/allocation.inline.hpp | 4 +- .../src/hotspot/share/runtime/os.cpp | 93 +++++++-- .../src/hotspot/share/runtime/os.hpp | 22 ++- .../share/utilities/compilerWarnings.hpp | 67 +++++-- .../share/utilities/compilerWarnings_gcc.hpp | 91 ++++++--- .../share/utilities/globalDefinitions.hpp | 42 +--- .../src/hotspot/share/utilities/macros.hpp | 3 - .../src/hotspot/share/utilities/ostream.cpp | 22 +-- .../src/hotspot/share/utilities/ostream.hpp | 54 ++--- 21 files changed, 566 insertions(+), 325 deletions(-) diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp index 612cb9a93023..a9cabc873356 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -62,7 +62,7 @@ CgroupSubsystem* CgroupSubsystemFactory::create() { CgroupV1MemoryController* memory = nullptr; CgroupV1Controller* cpuset = nullptr; CgroupV1CpuController* cpu = nullptr; - CgroupV1Controller* cpuacct = nullptr; + CgroupV1CpuacctController* cpuacct = nullptr; CgroupV1Controller* pids = nullptr; CgroupInfo cg_infos[CG_INFO_LENGTH]; u1 cg_type_flags = INVALID_CGROUPS_GENERIC; @@ -105,9 +105,10 @@ CgroupSubsystem* CgroupSubsystemFactory::create() { CgroupV2CpuController* cpu = new CgroupV2CpuController(CgroupV2Controller(cg_infos[CPU_IDX]._mount_path, cg_infos[CPU_IDX]._cgroup_path, cg_infos[CPU_IDX]._read_only)); + CgroupV2CpuacctController* cpuacct = new CgroupV2CpuacctController(cpu); log_debug(os, container)("Detected cgroups v2 unified hierarchy"); cleanup(cg_infos); - return new CgroupV2Subsystem(memory, cpu, mem_other); + return new CgroupV2Subsystem(memory, cpu, cpuacct, mem_other); } /* @@ -150,7 +151,7 @@ CgroupSubsystem* CgroupSubsystemFactory::create() { cpu = new CgroupV1CpuController(CgroupV1Controller(info._root_mount_path, info._mount_path, info._read_only)); cpu->set_subsystem_path(info._cgroup_path); } else if (strcmp(info._name, "cpuacct") == 0) { - cpuacct = new CgroupV1Controller(info._root_mount_path, info._mount_path, info._read_only); + cpuacct = new CgroupV1CpuacctController(CgroupV1Controller(info._root_mount_path, info._mount_path, info._read_only)); cpuacct->set_subsystem_path(info._cgroup_path); } else if (strcmp(info._name, "pids") == 0) { pids = new CgroupV1Controller(info._root_mount_path, info._mount_path, info._read_only); @@ -297,6 +298,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos, } else { log_debug(os, container)("Can't read %s, %s", controllers_file, os::strerror(errno)); *flags = INVALID_CGROUPS_V2; + fclose(controllers); return false; } for (int i = 0; i < CG_INFO_LENGTH; i++) { @@ -357,7 +359,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos, all_required_controllers_enabled = all_required_controllers_enabled && cg_infos[i]._enabled; } if (log_is_enabled(Debug, os, container) && !cg_infos[i]._enabled) { - log_debug(os, container)("controller %s is not enabled\n", cg_controller_name[i]); + log_debug(os, container)("controller %s is not enabled", cg_controller_name[i]); } } } @@ -855,6 +857,10 @@ jlong CgroupSubsystem::memory_soft_limit_in_bytes() { return memory_controller()->controller()->memory_soft_limit_in_bytes(phys_mem); } +jlong CgroupSubsystem::memory_throttle_limit_in_bytes() { + return memory_controller()->controller()->memory_throttle_limit_in_bytes(); +} + jlong CgroupSubsystem::memory_usage_in_bytes() { return memory_controller()->controller()->memory_usage_in_bytes(); } @@ -883,6 +889,10 @@ int CgroupSubsystem::cpu_shares() { return cpu_controller()->controller()->cpu_shares(); } +jlong CgroupSubsystem::cpu_usage_in_micros() { + return cpuacct_controller()->cpu_usage_in_micros(); +} + void CgroupSubsystem::print_version_specific_info(outputStream* st) { julong phys_mem = os::Linux::physical_memory(); memory_controller()->controller()->print_version_specific_info(st, phys_mem); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp index 53b178397f83..f72d1a7fb1e5 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -216,6 +216,18 @@ class CgroupCpuController: public CHeapObj { virtual const char* cgroup_path() = 0; }; +// Pure virtual class representing version agnostic CPU accounting controllers +class CgroupCpuacctController: public CHeapObj { + public: + virtual jlong cpu_usage_in_micros() = 0; + virtual bool needs_hierarchy_adjustment() = 0; + virtual bool is_read_only() = 0; + virtual const char* subsystem_path() = 0; + virtual void set_subsystem_path(const char* cgroup_path) = 0; + virtual const char* mount_point() = 0; + virtual const char* cgroup_path() = 0; +}; + // Pure virtual class representing version agnostic memory controllers class CgroupMemoryController: public CHeapObj { public: @@ -224,6 +236,7 @@ class CgroupMemoryController: public CHeapObj { virtual jlong memory_and_swap_limit_in_bytes(julong host_mem, julong host_swap) = 0; virtual jlong memory_and_swap_usage_in_bytes(julong host_mem, julong host_swap) = 0; virtual jlong memory_soft_limit_in_bytes(julong upper_bound) = 0; + virtual jlong memory_throttle_limit_in_bytes() = 0; virtual jlong memory_max_usage_in_bytes() = 0; virtual jlong rss_usage_in_bytes() = 0; virtual jlong cache_usage_in_bytes() = 0; @@ -250,15 +263,19 @@ class CgroupSubsystem: public CHeapObj { virtual const char * container_type() = 0; virtual CachingCgroupController* memory_controller() = 0; virtual CachingCgroupController* cpu_controller() = 0; + virtual CgroupCpuacctController* cpuacct_controller() = 0; int cpu_quota(); int cpu_period(); int cpu_shares(); + jlong cpu_usage_in_micros(); + jlong memory_usage_in_bytes(); jlong memory_and_swap_limit_in_bytes(); jlong memory_and_swap_usage_in_bytes(); jlong memory_soft_limit_in_bytes(); + jlong memory_throttle_limit_in_bytes(); jlong memory_max_usage_in_bytes(); jlong rss_usage_in_bytes(); jlong cache_usage_in_bytes(); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp index 8d9c3edb72a2..f65da2070628 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp @@ -248,10 +248,16 @@ jlong CgroupV1MemoryController::memory_soft_limit_in_bytes(julong phys_mem) { } } +jlong CgroupV1MemoryController::memory_throttle_limit_in_bytes() { + // Log this string at trace level so as to make tests happy. + log_trace(os, container)("Memory Throttle Limit is not supported."); + return OSCONTAINER_ERROR; // not supported +} + // Constructor CgroupV1Subsystem::CgroupV1Subsystem(CgroupV1Controller* cpuset, CgroupV1CpuController* cpu, - CgroupV1Controller* cpuacct, + CgroupV1CpuacctController* cpuacct, CgroupV1Controller* pids, CgroupV1MemoryController* memory) : _cpuset(cpuset), @@ -416,6 +422,13 @@ int CgroupV1CpuController::cpu_shares() { return shares_int; } +jlong CgroupV1CpuacctController::cpu_usage_in_micros() { + julong cpu_usage; + CONTAINER_READ_NUMBER_CHECKED(reader(), "/cpuacct.usage", "CPU Usage", cpu_usage); + // Output is in nanoseconds, convert to microseconds. + return (jlong)cpu_usage / 1000; +} + /* pids_max * * Return the maximum number of tasks available to the process diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp index 0c191ab91c7f..a56ad4551651 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -82,6 +82,7 @@ class CgroupV1MemoryController final : public CgroupMemoryController { jlong memory_and_swap_limit_in_bytes(julong host_mem, julong host_swap) override; jlong memory_and_swap_usage_in_bytes(julong host_mem, julong host_swap) override; jlong memory_soft_limit_in_bytes(julong upper_bound) override; + jlong memory_throttle_limit_in_bytes() override; jlong memory_max_usage_in_bytes() override; jlong rss_usage_in_bytes() override; jlong cache_usage_in_bytes() override; @@ -140,12 +141,41 @@ class CgroupV1CpuController final : public CgroupCpuController { } }; +class CgroupV1CpuacctController final : public CgroupCpuacctController { + + private: + CgroupV1Controller _reader; + CgroupV1Controller* reader() { return &_reader; } + public: + jlong cpu_usage_in_micros() override; + void set_subsystem_path(const char *cgroup_path) override { + reader()->set_subsystem_path(cgroup_path); + } + bool is_read_only() override { + return reader()->is_read_only(); + } + const char* subsystem_path() override { + return reader()->subsystem_path(); + } + const char* mount_point() override { + return reader()->mount_point(); + } + bool needs_hierarchy_adjustment() override { + return reader()->needs_hierarchy_adjustment(); + } + const char* cgroup_path() override { return reader()->cgroup_path(); } + + public: + CgroupV1CpuacctController(const CgroupV1Controller& reader) : _reader(reader) { + } +}; + class CgroupV1Subsystem: public CgroupSubsystem { public: CgroupV1Subsystem(CgroupV1Controller* cpuset, CgroupV1CpuController* cpu, - CgroupV1Controller* cpuacct, + CgroupV1CpuacctController* cpuacct, CgroupV1Controller* pids, CgroupV1MemoryController* memory); @@ -165,13 +195,14 @@ class CgroupV1Subsystem: public CgroupSubsystem { } CachingCgroupController* memory_controller() { return _memory; } CachingCgroupController* cpu_controller() { return _cpu; } + CgroupCpuacctController* cpuacct_controller() { return _cpuacct; } private: /* controllers */ CachingCgroupController* _memory = nullptr; CgroupV1Controller* _cpuset = nullptr; CachingCgroupController* _cpu = nullptr; - CgroupV1Controller* _cpuacct = nullptr; + CgroupV1CpuacctController* _cpuacct = nullptr; CgroupV1Controller* _pids = nullptr; }; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp index cbadbb9db02f..6472fdfccc5d 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, 2025, Red Hat Inc. + * Copyright (c) 2025, 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 @@ -114,12 +115,14 @@ int CgroupV2CpuController::cpu_quota() { // Constructor CgroupV2Subsystem::CgroupV2Subsystem(CgroupV2MemoryController * memory, CgroupV2CpuController* cpu, + CgroupV2CpuacctController* cpuacct, CgroupV2Controller unified) : _unified(unified) { CgroupUtil::adjust_controller(memory); CgroupUtil::adjust_controller(cpu); _memory = new CachingCgroupController(memory); _cpu = new CachingCgroupController(cpu); + _cpuacct = cpuacct; } bool CgroupV2Subsystem::is_containerized() { @@ -152,6 +155,17 @@ int CgroupV2CpuController::cpu_period() { return period; } +jlong CgroupV2CpuController::cpu_usage_in_micros() { + julong cpu_usage; + bool is_ok = reader()->read_numerical_key_value("/cpu.stat", "usage_usec", &cpu_usage); + if (!is_ok) { + log_trace(os, container)("CPU Usage failed: %d", OSCONTAINER_ERROR); + return OSCONTAINER_ERROR; + } + log_trace(os, container)("CPU Usage is: " JULONG_FORMAT, cpu_usage); + return (jlong)cpu_usage; +} + /* memory_usage_in_bytes * * Return the amount of used memory used by this cgroup and descendents @@ -173,10 +187,16 @@ jlong CgroupV2MemoryController::memory_soft_limit_in_bytes(julong phys_mem) { return mem_soft_limit; } +jlong CgroupV2MemoryController::memory_throttle_limit_in_bytes() { + jlong mem_throttle_limit; + CONTAINER_READ_NUMBER_CHECKED_MAX(reader(), "/memory.high", "Memory Throttle Limit", mem_throttle_limit); + return mem_throttle_limit; +} + jlong CgroupV2MemoryController::memory_max_usage_in_bytes() { - // Log this string at trace level so as to make tests happy. - log_trace(os, container)("Maximum Memory Usage is not supported."); - return OSCONTAINER_ERROR; // not supported + julong mem_max_usage; + CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.peak", "Maximum Memory Usage", mem_max_usage); + return mem_max_usage; } jlong CgroupV2MemoryController::rss_usage_in_bytes() { diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp index 56dcadd670f8..e26f37925ca8 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, 2024, Red Hat Inc. + * Copyright (c) 2025, 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 @@ -61,6 +62,34 @@ class CgroupV2CpuController: public CgroupCpuController { int cpu_quota() override; int cpu_period() override; int cpu_shares() override; + jlong cpu_usage_in_micros(); + bool is_read_only() override { + return reader()->is_read_only(); + } + const char* subsystem_path() override { + return reader()->subsystem_path(); + } + bool needs_hierarchy_adjustment() override { + return reader()->needs_hierarchy_adjustment(); + } + void set_subsystem_path(const char* cgroup_path) override { + reader()->set_subsystem_path(cgroup_path); + } + const char* mount_point() override { return reader()->mount_point(); } + const char* cgroup_path() override { return reader()->cgroup_path(); } +}; + +class CgroupV2CpuacctController: public CgroupCpuacctController { + private: + CgroupV2CpuController* _reader; + CgroupV2CpuController* reader() { return _reader; } + public: + CgroupV2CpuacctController(CgroupV2CpuController* reader) : _reader(reader) { + } + // In cgroup v2, cpu usage is a part of the cpu controller. + jlong cpu_usage_in_micros() override { + return reader()->cpu_usage_in_micros(); + } bool is_read_only() override { return reader()->is_read_only(); } @@ -89,6 +118,7 @@ class CgroupV2MemoryController final: public CgroupMemoryController { jlong memory_and_swap_limit_in_bytes(julong host_mem, julong host_swp) override; jlong memory_and_swap_usage_in_bytes(julong host_mem, julong host_swp) override; jlong memory_soft_limit_in_bytes(julong upper_bound) override; + jlong memory_throttle_limit_in_bytes() override; jlong memory_usage_in_bytes() override; jlong memory_max_usage_in_bytes() override; jlong rss_usage_in_bytes() override; @@ -118,11 +148,14 @@ class CgroupV2Subsystem: public CgroupSubsystem { CachingCgroupController* _memory = nullptr; CachingCgroupController* _cpu = nullptr; + CgroupCpuacctController* _cpuacct = nullptr; + CgroupV2Controller* unified() { return &_unified; } public: CgroupV2Subsystem(CgroupV2MemoryController * memory, CgroupV2CpuController* cpu, + CgroupV2CpuacctController* cpuacct, CgroupV2Controller unified); char * cpu_cpuset_cpus() override; @@ -137,6 +170,7 @@ class CgroupV2Subsystem: public CgroupSubsystem { } CachingCgroupController* memory_controller() override { return _memory; } CachingCgroupController* cpu_controller() override { return _cpu; } + CgroupCpuacctController* cpuacct_controller() override { return _cpuacct; }; }; #endif // CGROUP_V2_SUBSYSTEM_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp index ecac7307c300..2ba4c2526594 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -122,6 +122,11 @@ jlong OSContainer::memory_soft_limit_in_bytes() { return cgroup_subsystem->memory_soft_limit_in_bytes(); } +jlong OSContainer::memory_throttle_limit_in_bytes() { + assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); + return cgroup_subsystem->memory_throttle_limit_in_bytes(); +} + jlong OSContainer::memory_usage_in_bytes() { assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); return cgroup_subsystem->memory_usage_in_bytes(); @@ -177,6 +182,11 @@ int OSContainer::cpu_shares() { return cgroup_subsystem->cpu_shares(); } +jlong OSContainer::cpu_usage_in_micros() { + assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); + return cgroup_subsystem->cpu_usage_in_micros(); +} + jlong OSContainer::pids_max() { assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); return cgroup_subsystem->pids_max(); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp index dd29c7a4769d..3c270e8ea509 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -54,6 +54,7 @@ class OSContainer: AllStatic { static jlong memory_and_swap_limit_in_bytes(); static jlong memory_and_swap_usage_in_bytes(); static jlong memory_soft_limit_in_bytes(); + static jlong memory_throttle_limit_in_bytes(); static jlong memory_usage_in_bytes(); static jlong memory_max_usage_in_bytes(); static jlong rss_usage_in_bytes(); @@ -69,6 +70,8 @@ class OSContainer: AllStatic { static int cpu_shares(); + static jlong cpu_usage_in_micros(); + static jlong pids_max(); static jlong pids_current(); }; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp index 35455b7b4ad4..1a23c956f354 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp @@ -56,9 +56,7 @@ #include "runtime/osThread.hpp" #include "runtime/perfMemory.hpp" #include "runtime/sharedRuntime.hpp" -#include "runtime/statSampler.hpp" #include "runtime/stubRoutines.hpp" -#include "runtime/threadCritical.hpp" #include "runtime/threads.hpp" #include "runtime/threadSMR.hpp" #include "runtime/timer.hpp" @@ -139,11 +137,6 @@ #define MAX_PATH (2 * K) -#define MAX_SECS 100000000 - -// for timer info max values which include all bits -#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) - #ifdef MUSL_LIBC // dlvsym is not a part of POSIX // and musl libc doesn't implement it. @@ -215,8 +208,6 @@ typedef int (*malloc_info_func_t)(int options, FILE *stream); static malloc_info_func_t g_malloc_info = nullptr; #endif // __GLIBC__ -static int clock_tics_per_sec = 100; - // If the VM might have been created on the primordial thread, we need to resolve the // primordial thread stack bounds and check if the current thread might be the // primordial thread in places. If we know that the primordial thread is never used, @@ -1064,10 +1055,23 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, ResourceMark rm; pthread_t tid; int ret = 0; - int limit = 3; - do { + int trials_remaining = 4; + useconds_t next_delay = 1000; + while (true) { ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); - } while (ret == EAGAIN && limit-- > 0); + + if (ret != EAGAIN) { + break; + } + + if (--trials_remaining <= 0) { + break; + } + + log_debug(os, thread)("Failed to start native thread (%s), retrying after %dus.", os::errno_name(ret), next_delay); + ::usleep(next_delay); + next_delay *= 2; + } char buf[64]; if (ret == 0) { @@ -1669,7 +1673,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) { } ThreadInVMfromNative tiv(jt); - debug_only(VMNativeEntryWrapper vew;) + DEBUG_ONLY(VMNativeEntryWrapper vew;) VM_LinuxDllLoad op(filename, ebuf, ebuflen); VMThread::execute(&op); @@ -2483,9 +2487,18 @@ bool os::Linux::print_container_info(outputStream* st) { st->print_cr("%s", i == OSCONTAINER_ERROR ? "not supported" : "no shares"); } + jlong j = OSContainer::cpu_usage_in_micros(); + st->print("cpu_usage_in_micros: "); + if (j >= 0) { + st->print_cr(JLONG_FORMAT, j); + } else { + st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "no usage"); + } + OSContainer::print_container_helper(st, OSContainer::memory_limit_in_bytes(), "memory_limit_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_and_swap_limit_in_bytes(), "memory_and_swap_limit_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_soft_limit_in_bytes(), "memory_soft_limit_in_bytes"); + OSContainer::print_container_helper(st, OSContainer::memory_throttle_limit_in_bytes(), "memory_throttle_limit_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_usage_in_bytes(), "memory_usage_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_max_usage_in_bytes(), "memory_max_usage_in_bytes"); OSContainer::print_container_helper(st, OSContainer::rss_usage_in_bytes(), "rss_usage_in_bytes"); @@ -2493,7 +2506,7 @@ bool os::Linux::print_container_info(outputStream* st) { OSContainer::print_version_specific_info(st); - jlong j = OSContainer::pids_max(); + j = OSContainer::pids_max(); st->print("maximum number of tasks: "); if (j > 0) { st->print_cr(JLONG_FORMAT, j); @@ -2742,139 +2755,9 @@ void os::get_summary_cpu_info(char* cpuinfo, size_t length) { #endif } -static char saved_jvm_path[MAXPATHLEN] = {0}; - -// Find the full path to the current module, libjvm.so -void os::jvm_path(char *buf, jint buflen) { - // Error checking. - if (buflen < MAXPATHLEN) { - assert(false, "must use a large-enough buffer"); - buf[0] = '\0'; - return; - } - // Lazy resolve the path to current module. - if (saved_jvm_path[0] != 0) { - strcpy(buf, saved_jvm_path); - return; - } - - char dli_fname[MAXPATHLEN]; - dli_fname[0] = '\0'; - bool ret = dll_address_to_library_name( - CAST_FROM_FN_PTR(address, os::jvm_path), - dli_fname, sizeof(dli_fname), nullptr); - assert(ret, "cannot locate libjvm"); - char *rp = nullptr; - if (ret && dli_fname[0] != '\0') { - rp = os::realpath(dli_fname, buf, buflen); - } - if (rp == nullptr) { - return; - } - - if (Arguments::sun_java_launcher_is_altjvm()) { - // Support for the java launcher's '-XXaltjvm=' option. Typical - // value for buf is "/jre/lib//libjvm.so". - // If "/jre/lib/" appears at the right place in the string, then - // assume we are installed in a JDK and we're done. Otherwise, check - // for a JAVA_HOME environment variable and fix up the path so it - // looks like libjvm.so is installed there (append a fake suffix - // hotspot/libjvm.so). - const char *p = buf + strlen(buf) - 1; - for (int count = 0; p > buf && count < 5; ++count) { - for (--p; p > buf && *p != '/'; --p) - /* empty */ ; - } - - if (strncmp(p, "/jre/lib/", 9) != 0) { - // Look for JAVA_HOME in the environment. - char* java_home_var = ::getenv("JAVA_HOME"); - if (java_home_var != nullptr && java_home_var[0] != 0) { - char* jrelib_p; - int len; - - // Check the current module name "libjvm.so". - p = strrchr(buf, '/'); - if (p == nullptr) { - return; - } - assert(strstr(p, "/libjvm") == p, "invalid library name"); - - rp = os::realpath(java_home_var, buf, buflen); - if (rp == nullptr) { - return; - } - - // determine if this is a legacy image or modules image - // modules image doesn't have "jre" subdirectory - len = checked_cast(strlen(buf)); - assert(len < buflen, "Ran out of buffer room"); - jrelib_p = buf + len; - snprintf(jrelib_p, buflen-len, "/jre/lib"); - if (0 != access(buf, F_OK)) { - snprintf(jrelib_p, buflen-len, "/lib"); - } - - if (0 == access(buf, F_OK)) { - // Use current module name "libjvm.so" - len = (int)strlen(buf); - snprintf(buf + len, buflen-len, "/hotspot/libjvm.so"); - } else { - // Go back to path of .so - rp = os::realpath(dli_fname, buf, buflen); - if (rp == nullptr) { - return; - } - } - } - } - } - - strncpy(saved_jvm_path, buf, MAXPATHLEN); - saved_jvm_path[MAXPATHLEN - 1] = '\0'; -} - //////////////////////////////////////////////////////////////////////////////// // Virtual Memory -// Rationale behind this function: -// current (Mon Apr 25 20:12:18 MSD 2005) oprofile drops samples without executable -// mapping for address (see lookup_dcookie() in the kernel module), thus we cannot get -// samples for JITted code. Here we create private executable mapping over the code cache -// and then we can use standard (well, almost, as mapping can change) way to provide -// info for the reporting script by storing timestamp and location of symbol -void linux_wrap_code(char* base, size_t size) { - static volatile jint cnt = 0; - - static_assert(sizeof(off_t) == 8, "Expected Large File Support in this file"); - - if (!UseOprofile) { - return; - } - - char buf[PATH_MAX+1]; - int num = Atomic::add(&cnt, 1); - - snprintf(buf, sizeof(buf), "%s/hs-vm-%d-%d", - os::get_temp_directory(), os::current_process_id(), num); - unlink(buf); - - int fd = ::open(buf, O_CREAT | O_RDWR, S_IRWXU); - - if (fd != -1) { - off_t rv = ::lseek(fd, size-2, SEEK_SET); - if (rv != (off_t)-1) { - if (::write(fd, "", 1) == 1) { - mmap(base, size, - PROT_READ|PROT_WRITE|PROT_EXEC, - MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE, fd, 0); - } - } - ::close(fd); - unlink(buf); - } -} - static bool recoverable_mmap_error(int err) { // See if the error is one we can let the caller handle. This // list of errno values comes from JBS-6843484. I can't find a @@ -4404,8 +4287,6 @@ static void check_pax(void) { // this is called _before_ most of the global arguments have been parsed void os::init(void) { char dummy; // used to get a guess on initial stack address - - clock_tics_per_sec = checked_cast(sysconf(_SC_CLK_TCK)); int sys_pg_size = checked_cast(sysconf(_SC_PAGESIZE)); if (sys_pg_size < 0) { fatal("os_linux.cpp: os::init: sysconf failed (%s)", @@ -4598,7 +4479,7 @@ static void workaround_expand_exec_shield_cs_limit() { */ char* hint = (char*)(os::Linux::initial_thread_stack_bottom() - (StackOverflow::stack_guard_zone_size() + page_size)); - char* codebuf = os::attempt_reserve_memory_at(hint, page_size, false, mtThread); + char* codebuf = os::attempt_reserve_memory_at(hint, page_size, mtThread); if (codebuf == nullptr) { // JDK-8197429: There may be a stack gap of one megabyte between @@ -4606,7 +4487,7 @@ static void workaround_expand_exec_shield_cs_limit() { // Linux kernel workaround for CVE-2017-1000364. If we failed to // map our codebuf, try again at an address one megabyte lower. hint -= 1 * M; - codebuf = os::attempt_reserve_memory_at(hint, page_size, false, mtThread); + codebuf = os::attempt_reserve_memory_at(hint, page_size, mtThread); } if ((codebuf == nullptr) || (!os::commit_memory(codebuf, page_size, true))) { @@ -5158,21 +5039,21 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { &user_time, &sys_time); if (count != 13) return -1; if (user_sys_cpu_time) { - return ((jlong)sys_time + (jlong)user_time) * (1000000000 / clock_tics_per_sec); + return ((jlong)sys_time + (jlong)user_time) * (1000000000 / os::Posix::clock_tics_per_second()); } else { - return (jlong)user_time * (1000000000 / clock_tics_per_sec); + return (jlong)user_time * (1000000000 / os::Posix::clock_tics_per_second()); } } void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { - info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits + info_ptr->max_value = all_bits_jlong; // will not wrap in less than 64 bits info_ptr->may_skip_backward = false; // elapsed time not wall time info_ptr->may_skip_forward = false; // elapsed time not wall time info_ptr->kind = JVMTI_TIMER_TOTAL_CPU; // user+system time is returned } void os::thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { - info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits + info_ptr->max_value = all_bits_jlong; // will not wrap in less than 64 bits info_ptr->may_skip_backward = false; // elapsed time not wall time info_ptr->may_skip_forward = false; // elapsed time not wall time info_ptr->kind = JVMTI_TIMER_TOTAL_CPU; // user+system time is returned diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp index a36d6b87641e..303e44eadcb8 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp @@ -23,6 +23,7 @@ */ #include "classfile/classLoader.hpp" +#include "interpreter/interpreter.hpp" #include "jvm.h" #include "jvmtifiles/jvmti.h" #include "logging/log.hpp" @@ -49,6 +50,7 @@ #include "utilities/formatBuffer.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" +#include "utilities/permitForbiddenFunctions.hpp" #include "utilities/vmError.hpp" #if INCLUDE_JFR #include "jfr/support/jfrNativeLibraryLoadEvent.hpp" @@ -57,6 +59,7 @@ #ifdef AIX #include "loadlib_aix.hpp" #include "os_aix.hpp" +#include "porting_aix.hpp" #endif #ifdef LINUX #include "os_linux.hpp" @@ -491,9 +494,9 @@ static char* chop_extra_memory(size_t size, size_t alignment, char* extra_base, // Multiple threads can race in this code, and can remap over each other with MAP_FIXED, // so on posix, unmap the section at the start and at the end of the chunk that we mapped // rather than unmapping and remapping the whole chunk to get requested alignment. -char* os::reserve_memory_aligned(size_t size, size_t alignment, bool exec) { +char* os::reserve_memory_aligned(size_t size, size_t alignment, MemTag mem_tag, bool exec) { size_t extra_size = calculate_aligned_extra_size(size, alignment); - char* extra_base = os::reserve_memory(extra_size, exec); + char* extra_base = os::reserve_memory(extra_size, mem_tag, exec); if (extra_base == nullptr) { return nullptr; } @@ -930,11 +933,11 @@ ssize_t os::connect(int fd, struct sockaddr* him, socklen_t len) { } void os::exit(int num) { - ALLOW_C_FUNCTION(::exit, ::exit(num);) + permit_forbidden_function::exit(num); } void os::_exit(int num) { - ALLOW_C_FUNCTION(::_exit, ::_exit(num);) + permit_forbidden_function::_exit(num); } void os::naked_yield() { @@ -991,7 +994,7 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { // This assumes platform realpath() is implemented according to POSIX.1-2008. // POSIX.1-2008 allows to specify null for the output buffer, in which case // output buffer is dynamically allocated and must be ::free()'d by the caller. - ALLOW_C_FUNCTION(::realpath, char* p = ::realpath(filename, nullptr);) + char* p = permit_forbidden_function::realpath(filename, nullptr); if (p != nullptr) { if (strlen(p) < outbuflen) { strcpy(outbuf, p); @@ -999,7 +1002,7 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { } else { errno = ENAMETOOLONG; } - ALLOW_C_FUNCTION(::free, ::free(p);) // *not* os::free + permit_forbidden_function::free(p); // *not* os::free } else { // Fallback for platforms struggling with modern Posix standards (AIX 5.3, 6.1). If realpath // returns EINVAL, this may indicate that realpath is not POSIX.1-2008 compatible and @@ -1008,7 +1011,7 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { // a memory overwrite. if (errno == EINVAL) { outbuf[outbuflen - 1] = '\0'; - ALLOW_C_FUNCTION(::realpath, p = ::realpath(filename, outbuf);) + p = permit_forbidden_function::realpath(filename, outbuf); if (p != nullptr) { guarantee(outbuf[outbuflen - 1] == '\0', "realpath buffer overwrite detected."); result = p; @@ -1058,6 +1061,95 @@ bool os::same_files(const char* file1, const char* file2) { return is_same; } +static char saved_jvm_path[MAXPATHLEN] = {0}; + +// Find the full path to the current module, libjvm.so +void os::jvm_path(char *buf, jint buflen) { + // Error checking. + if (buflen < MAXPATHLEN) { + assert(false, "must use a large-enough buffer"); + buf[0] = '\0'; + return; + } + // Lazy resolve the path to current module. + if (saved_jvm_path[0] != 0) { + strcpy(buf, saved_jvm_path); + return; + } + + const char* fname; +#ifdef AIX + Dl_info dlinfo; + int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo); + assert(ret != 0, "cannot locate libjvm"); + if (ret == 0) { + return; + } + fname = dlinfo.dli_fname; +#else + char dli_fname[MAXPATHLEN]; + dli_fname[0] = '\0'; + bool ret = dll_address_to_library_name( + CAST_FROM_FN_PTR(address, os::jvm_path), + dli_fname, sizeof(dli_fname), nullptr); + assert(ret, "cannot locate libjvm"); + if (!ret) { + return; + } + fname = dli_fname; +#endif // AIX + char* rp = nullptr; + if (fname[0] != '\0') { + rp = os::realpath(fname, buf, buflen); + } + if (rp == nullptr) { + return; + } + + // If executing unit tests we require JAVA_HOME to point to the real JDK. + if (Arguments::executing_unit_tests()) { + // Look for JAVA_HOME in the environment. + char* java_home_var = ::getenv("JAVA_HOME"); + if (java_home_var != nullptr && java_home_var[0] != 0) { + + // Check the current module name "libjvm.so". + const char* p = strrchr(buf, '/'); + if (p == nullptr) { + return; + } + assert(strstr(p, "/libjvm") == p, "invalid library name"); + + stringStream ss(buf, buflen); + rp = os::realpath(java_home_var, buf, buflen); + if (rp == nullptr) { + return; + } + + assert((int)strlen(buf) < buflen, "Ran out of buffer room"); + ss.print("%s/lib", buf); + + // If the path exists within JAVA_HOME, add the VM variant directory and JVM + // library name to complete the path to JVM being overridden. Otherwise fallback + // to the path to the current library. + if (0 == access(buf, F_OK)) { + // Use current module name "libjvm.so" + ss.print("/%s/libjvm%s", Abstract_VM_Version::vm_variant(), JNI_LIB_SUFFIX); + assert(strcmp(buf + strlen(buf) - strlen(JNI_LIB_SUFFIX), JNI_LIB_SUFFIX) == 0, + "buf has been truncated"); + } else { + // Go back to path of .so + rp = os::realpath(fname, buf, buflen); + if (rp == nullptr) { + return; + } + } + } + } + + strncpy(saved_jvm_path, buf, MAXPATHLEN); + saved_jvm_path[MAXPATHLEN - 1] = '\0'; +} + // Called when creating the thread. The minimum stack sizes have already been calculated size_t os::Posix::get_initial_stack_size(ThreadType thr_type, size_t req_stack_size) { size_t stack_size; @@ -1325,6 +1417,19 @@ void os::Posix::init_2(void) { _use_clock_monotonic_condattr ? "CLOCK_MONOTONIC" : "the default clock"); } +int os::Posix::clock_tics_per_second() { + return clock_tics_per_sec; +} + +#ifdef ASSERT +bool os::Posix::ucontext_is_interpreter(const ucontext_t* uc) { + assert(uc != nullptr, "invariant"); + address pc = os::Posix::ucontext_get_pc(uc); + assert(pc != nullptr, "invariant"); + return Interpreter::contains(pc); +} +#endif + // Utility to convert the given timeout to an absolute timespec // (based on the appropriate clock) to use with pthread_cond_timewait, // and sem_timedwait(). @@ -1472,12 +1577,9 @@ jlong os::javaTimeNanos() { return result; } -// for timer info max values which include all bits -#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) - void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { // CLOCK_MONOTONIC - amount of time since some arbitrary point in the past - info_ptr->max_value = ALL_64_BITS; + info_ptr->max_value = all_bits_jlong; info_ptr->may_skip_backward = false; // not subject to resetting or drifting info_ptr->may_skip_forward = false; // not subject to resetting or drifting info_ptr->kind = JVMTI_TIMER_ELAPSED; // elapsed not CPU time diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp index 248a30d04adb..4b8b75ea07ef 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, 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 @@ -89,8 +89,13 @@ class os::Posix { static address ucontext_get_pc(const ucontext_t* ctx); static void ucontext_set_pc(ucontext_t* ctx, address pc); + DEBUG_ONLY(static bool ucontext_is_interpreter(const ucontext_t* ctx);) + static void to_RTC_abstime(timespec* abstime, int64_t millis); + // clock ticks per second of the system + static int clock_tics_per_second(); + static bool handle_stack_overflow(JavaThread* thread, address addr, address pc, const void* ucVoid, address* stub); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp index b67dcd43e4d4..9e500135d0b0 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp @@ -314,7 +314,12 @@ class MetaspaceObj { f(ConstantPoolCache) \ f(Annotations) \ f(MethodCounters) \ - f(RecordComponent) + f(RecordComponent) \ + f(KlassTrainingData) \ + f(MethodTrainingData) \ + f(CompileTrainingData) \ + f(AdapterHandlerEntry) \ + f(AdapterFingerPrint) #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type, #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name; @@ -352,6 +357,8 @@ class MetaspaceObj { void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, Type type) throw(); + // This is used for allocating training data. We are allocating training data in many cases where a GC cannot be triggered. + void* operator new(size_t size, MemTag flags); void operator delete(void* p) = delete; // Declare a *static* method with the same signature in any subclass of MetaspaceObj diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp index 8d531c6dd231..01af1616ce18 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp @@ -58,7 +58,7 @@ template E* MmapArrayAllocator::allocate_or_null(size_t length, MemTag mem_tag) { size_t size = size_for(length); - char* addr = os::reserve_memory(size, !ExecMem, mem_tag); + char* addr = os::reserve_memory(size, mem_tag); if (addr == nullptr) { return nullptr; } @@ -75,7 +75,7 @@ template E* MmapArrayAllocator::allocate(size_t length, MemTag mem_tag) { size_t size = size_for(length); - char* addr = os::reserve_memory(size, !ExecMem, mem_tag); + char* addr = os::reserve_memory(size, mem_tag); if (addr == nullptr) { vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "Allocator (reserve)"); } diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp index cbe40ca214bb..ee1f0a3b0817 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp @@ -76,7 +76,9 @@ #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" #include "utilities/fastrand.hpp" +#include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" +#include "utilities/permitForbiddenFunctions.hpp" #include "utilities/powerOfTwo.hpp" #ifdef LINUX @@ -117,7 +119,7 @@ int os::snprintf_checked(char* buf, size_t len, const char* fmt, ...) { } int os::vsnprintf(char* buf, size_t len, const char* fmt, va_list args) { - ALLOW_C_FUNCTION(::vsnprintf, int result = ::vsnprintf(buf, len, fmt, args);) + int result = permit_forbidden_function::vsnprintf(buf, len, fmt, args); // If an encoding error occurred (result < 0) then it's not clear // whether the buffer is NUL terminated, so ensure it is. if ((result < 0) && (len > 0)) { @@ -241,7 +243,7 @@ char* os::iso8601_time(jlong milliseconds_since_19700101, char* buffer, size_t b } OSReturn os::set_priority(Thread* thread, ThreadPriority p) { - debug_only(Thread::check_for_dangling_thread_pointer(thread);) + DEBUG_ONLY(Thread::check_for_dangling_thread_pointer(thread);) if ((p >= MinPriority && p <= MaxPriority) || (p == CriticalPriority && thread->is_ConcurrentGC_thread())) { @@ -596,7 +598,7 @@ char *os::strdup(const char *str, MemTag mem_tag) { size_t size = strlen(str); char *dup_str = (char *)malloc(size + 1, mem_tag); if (dup_str == nullptr) return nullptr; - strcpy(dup_str, str); + memcpy(dup_str, str, size + 1); return dup_str; } @@ -654,7 +656,7 @@ void* os::malloc(size_t size, MemTag mem_tag, const NativeCallStack& stack) { return nullptr; } - ALLOW_C_FUNCTION(::malloc, void* const outer_ptr = ::malloc(outer_size);) + void* const outer_ptr = permit_forbidden_function::malloc(outer_size); if (outer_ptr == nullptr) { return nullptr; } @@ -721,7 +723,7 @@ void* os::realloc(void *memblock, size_t size, MemTag mem_tag, const NativeCallS header->mark_block_as_dead(); // the real realloc - ALLOW_C_FUNCTION(::realloc, void* const new_outer_ptr = ::realloc(header, new_outer_size);) + void* const new_outer_ptr = permit_forbidden_function::realloc(header, new_outer_size); if (new_outer_ptr == nullptr) { // realloc(3) failed and the block still exists. @@ -749,7 +751,7 @@ void* os::realloc(void *memblock, size_t size, MemTag mem_tag, const NativeCallS } else { // NMT disabled. - ALLOW_C_FUNCTION(::realloc, rc = ::realloc(memblock, size);) + rc = permit_forbidden_function::realloc(memblock, size); if (rc == nullptr) { return nullptr; } @@ -777,7 +779,7 @@ void os::free(void *memblock) { // When NMT is enabled this checks for heap overwrites, then deaccounts the old block. void* const old_outer_ptr = MemTracker::record_free(memblock); - ALLOW_C_FUNCTION(::free, ::free(old_outer_ptr);) + permit_forbidden_function::free(old_outer_ptr); } void os::init_random(unsigned int initval) { @@ -1166,7 +1168,7 @@ void os::print_cpu_info(outputStream* st, char* buf, size_t buflen) { // We access the raw value here because the assert in the accessor will // fail if the crash occurs before initialization of this value. st->print(" (initial active %d)", _initial_active_processor_count); - st->print(" %s", VM_Version::features_string()); + st->print(" %s", VM_Version::cpu_info_string()); st->cr(); pd_print_cpu_info(st, buf, buflen); } @@ -1534,6 +1536,57 @@ bool os::set_boot_path(char fileSep, char pathSep) { return false; } +static char* _image_release_file_content = nullptr; + +void os::read_image_release_file() { + assert(_image_release_file_content == nullptr, "release file content must not be already set"); + const char* home = Arguments::get_java_home(); + stringStream ss; + ss.print("%s/release", home); + + FILE* file = fopen(ss.base(), "rb"); + if (file == nullptr) { + return; + } + fseek(file, 0, SEEK_END); + long sz = ftell(file); + if (sz == -1) { + fclose(file); + return; + } + fseek(file, 0, SEEK_SET); + + char* tmp = (char*) os::malloc(sz + 1, mtInternal); + if (tmp == nullptr) { + fclose(file); + return; + } + + size_t elements_read = fread(tmp, 1, sz, file); + if (elements_read < (size_t)sz) { + tmp[elements_read] = '\0'; + } else { + tmp[sz] = '\0'; + } + // issues with \r in line endings on Windows, so better replace those + for (size_t i = 0; i < elements_read; i++) { + if (tmp[i] == '\r') { + tmp[i] = ' '; + } + } + Atomic::release_store(&_image_release_file_content, tmp); + fclose(file); +} + +void os::print_image_release_file(outputStream* st) { + char* ifrc = Atomic::load_acquire(&_image_release_file_content); + if (ifrc != nullptr) { + st->print_cr("%s", ifrc); + } else { + st->print_cr(""); + } +} + bool os::file_exists(const char* filename) { struct stat statbuf; if (filename == nullptr || strlen(filename) == 0) { @@ -1916,7 +1969,7 @@ bool os::create_stack_guard_pages(char* addr, size_t bytes) { return os::pd_create_stack_guard_pages(addr, bytes); } -char* os::reserve_memory(size_t bytes, bool executable, MemTag mem_tag) { +char* os::reserve_memory(size_t bytes, MemTag mem_tag, bool executable) { char* result = pd_reserve_memory(bytes, executable); if (result != nullptr) { MemTracker::record_virtual_memory_reserve(result, bytes, CALLER_PC, mem_tag); @@ -1927,7 +1980,7 @@ char* os::reserve_memory(size_t bytes, bool executable, MemTag mem_tag) { return result; } -char* os::attempt_reserve_memory_at(char* addr, size_t bytes, bool executable, MemTag mem_tag) { +char* os::attempt_reserve_memory_at(char* addr, size_t bytes, MemTag mem_tag, bool executable) { char* result = SimulateFullAddressSpace ? nullptr : pd_attempt_reserve_memory_at(addr, bytes, executable); if (result != nullptr) { MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC, mem_tag); @@ -2133,7 +2186,7 @@ char* os::attempt_reserve_memory_between(char* min, char* max, size_t bytes, siz assert(is_aligned(result, alignment), "alignment invalid (" ERRFMT ")", ERRFMTARGS); log_trace(os, map)(ERRFMT, ERRFMTARGS); log_debug(os, map)("successfully attached at " PTR_FORMAT, p2i(result)); - MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); + MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC, mtNone); } else { log_debug(os, map)("failed to attach anywhere in [" PTR_FORMAT "-" PTR_FORMAT ")", p2i(min), p2i(max)); } @@ -2201,6 +2254,11 @@ void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint, MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC); } +// The scope of NmtVirtualMemoryLocker covers both pd_uncommit_memory and record_virtual_memory_uncommit because +// these operations must happen atomically to avoid races causing NMT to fall out os sync with the OS reality. +// We do not have the same lock protection for pd_commit_memory and record_virtual_memory_commit. +// We assume that there is some external synchronization that prevents a region from being uncommitted +// before it is finished being committed. bool os::uncommit_memory(char* addr, size_t bytes, bool executable) { assert_nonempty_range(addr, bytes); bool res; @@ -2223,6 +2281,11 @@ bool os::uncommit_memory(char* addr, size_t bytes, bool executable) { return res; } +// The scope of NmtVirtualMemoryLocker covers both pd_release_memory and record_virtual_memory_release because +// these operations must happen atomically to avoid races causing NMT to fall out os sync with the OS reality. +// We do not have the same lock protection for pd_reserve_memory and record_virtual_memory_reserve. +// We assume that there is some external synchronization that prevents a region from being released +// before it is finished being reserved. bool os::release_memory(char* addr, size_t bytes) { assert_nonempty_range(addr, bytes); bool res; @@ -2300,8 +2363,8 @@ char* os::attempt_map_memory_to_file_at(char* addr, size_t bytes, int file_desc, } char* os::map_memory(int fd, const char* file_name, size_t file_offset, - char *addr, size_t bytes, bool read_only, - bool allow_exec, MemTag mem_tag) { + char *addr, size_t bytes, MemTag mem_tag, + bool read_only, bool allow_exec) { char* result = pd_map_memory(fd, file_name, file_offset, addr, bytes, read_only, allow_exec); if (result != nullptr) { MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC, mem_tag); @@ -2339,7 +2402,7 @@ char* os::reserve_memory_special(size_t size, size_t alignment, size_t page_size char* result = pd_reserve_memory_special(size, alignment, page_size, addr, executable); if (result != nullptr) { // The memory is committed - MemTracker::record_virtual_memory_reserve_and_commit((address)result, size, CALLER_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)result, size, CALLER_PC, mtNone); log_debug(os, map)("Reserved and committed " RANGEFMT, RANGEFMTARGS(result, size)); } else { log_info(os, map)("Reserve and commit failed (%zu bytes)", size); @@ -2535,7 +2598,7 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name, if ((start = strrchr(lib_name, *os::file_separator())) != nullptr) { lib_name = ++start; } -#ifdef WINDOWS +#ifdef _WINDOWS else { // Need to check for drive prefix e.g. C:L.dll if ((start = strchr(lib_name, ':')) != nullptr) { lib_name = ++start; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp index 242959034afb..b26ec280e724 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp @@ -457,14 +457,14 @@ class os: AllStatic { inline static size_t cds_core_region_alignment(); // Reserves virtual memory. - static char* reserve_memory(size_t bytes, bool executable = false, MemTag mem_tag = mtNone); + static char* reserve_memory(size_t bytes, MemTag mem_tag, bool executable = false); // Reserves virtual memory that starts at an address that is aligned to 'alignment'. - static char* reserve_memory_aligned(size_t size, size_t alignment, bool executable = false); + static char* reserve_memory_aligned(size_t size, size_t alignment, MemTag mem_tag, bool executable = false); // Attempts to reserve the virtual memory at [addr, addr + bytes). // Does not overwrite existing mappings. - static char* attempt_reserve_memory_at(char* addr, size_t bytes, bool executable = false, MemTag mem_tag = mtNone); + static char* attempt_reserve_memory_at(char* addr, size_t bytes, MemTag mem_tag, bool executable = false); // Given an address range [min, max), attempts to reserve memory within this area, with the given alignment. // If randomize is true, the location will be randomized. @@ -516,16 +516,16 @@ class os: AllStatic { static int create_file_for_heap(const char* dir); // Map memory to the file referred by fd. This function is slightly different from map_memory() // and is added to be used for implementation of -XX:AllocateHeapAt - static char* map_memory_to_file(size_t size, int fd, MemTag mem_tag = mtNone); - static char* map_memory_to_file_aligned(size_t size, size_t alignment, int fd, MemTag mem_tag = mtNone); + static char* map_memory_to_file(size_t size, int fd, MemTag mem_tag); + static char* map_memory_to_file_aligned(size_t size, size_t alignment, int fd, MemTag mem_tag); static char* map_memory_to_file(char* base, size_t size, int fd); - static char* attempt_map_memory_to_file_at(char* base, size_t size, int fd, MemTag mem_tag = mtNone); + static char* attempt_map_memory_to_file_at(char* base, size_t size, int fd, MemTag mem_tag); // Replace existing reserved memory with file mapping static char* replace_existing_mapping_with_file_mapping(char* base, size_t size, int fd); static char* map_memory(int fd, const char* file_name, size_t file_offset, - char *addr, size_t bytes, bool read_only = false, - bool allow_exec = false, MemTag mem_tag = mtNone); + char *addr, size_t bytes, MemTag mem_tag, bool read_only = false, + bool allow_exec = false); static bool unmap_memory(char *addr, size_t bytes); static void disclaim_memory(char *addr, size_t bytes); static void realign_memory(char *addr, size_t bytes, size_t alignment_hint); @@ -623,6 +623,7 @@ class os: AllStatic { static address fetch_frame_from_context(const void* ucVoid, intptr_t** sp, intptr_t** fp); static frame fetch_frame_from_context(const void* ucVoid); static frame fetch_compiled_frame_from_context(const void* ucVoid); + static intptr_t* fetch_bcp_from_context(const void* ucVoid); // For saving an os specific context generated by an assert or guarantee. static void save_assert_context(const void* ucVoid); @@ -670,6 +671,11 @@ class os: AllStatic { static FILE* fopen(const char* path, const char* mode); static jlong lseek(int fd, jlong offset, int whence); static bool file_exists(const char* file); + + // read/store and print the release file of the image + static void read_image_release_file(); + static void print_image_release_file(outputStream* st); + // This function, on Windows, canonicalizes a given path (see os_windows.cpp for details). // On Posix, this function is a noop: it does not change anything and just returns // the input pointer. diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp index ddcaf022fa69..bf5ca5b48939 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -62,9 +62,6 @@ #ifndef PRAGMA_FORMAT_NONLITERAL_IGNORED #define PRAGMA_FORMAT_NONLITERAL_IGNORED #endif -#ifndef PRAGMA_FORMAT_IGNORED -#define PRAGMA_FORMAT_IGNORED -#endif #ifndef PRAGMA_STRINGOP_TRUNCATION_IGNORED #define PRAGMA_STRINGOP_TRUNCATION_IGNORED @@ -88,23 +85,61 @@ // Support warnings for use of certain C functions, except where explicitly // permitted. + +// FORBID_C_FUNCTION(Signature, Alternative) +// - Signature: the function that should not normally be used. +// - Alternative: a string literal that may be used in a warning about a use, +// often suggesting an alternative. +// Declares the C-linkage function designated by Signature to be deprecated, +// using the `deprecated` attribute with Alternative as an argument. // -// FORBID_C_FUNCTION(signature, alternative) -// - signature: the function that should not normally be used. -// - alternative: a string that may be used in a warning about a use, typically -// suggesting an alternative. +// The variants with IMPORTED in the name are to deal with Windows +// requirements, using FORBIDDEN_FUNCTION_IMPORT_SPEC. See the Visual +// Studio definition of that macro for more details. The default has +// an empty expansion. The potentially added spec must precede the +// base signature but follow all attributes. // -// ALLOW_C_FUNCTION(name, ... using statement ...) -// - name: the name of a forbidden function whose use is permitted in statement. -// - statement: a use of the otherwise forbidden function. Using a variadic -// tail allows the statement to contain non-nested commas. +// FORBID_NORETURN_C_FUNCTION deals with a clang issue. See the clang +// definition of FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE for more +// details. The default expands to `[[noreturn]]`. +#define FORBID_C_FUNCTION(Signature, Alternative) \ + extern "C" { [[deprecated(Alternative)]] Signature; } -#ifndef FORBID_C_FUNCTION -#define FORBID_C_FUNCTION(signature, alternative) +#ifndef FORBIDDEN_FUNCTION_IMPORT_SPEC +#define FORBIDDEN_FUNCTION_IMPORT_SPEC #endif -#ifndef ALLOW_C_FUNCTION -#define ALLOW_C_FUNCTION(name, ...) __VA_ARGS__ +#ifndef FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE +#define FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE [[noreturn]] #endif +#ifndef FORBIDDEN_FUNCTION_IGNORE_CLANG_FORTIFY_WARNING +#define FORBIDDEN_FUNCTION_IGNORE_CLANG_FORTIFY_WARNING +#endif + +#define FORBID_IMPORTED_C_FUNCTION(Signature, Alternative) \ + FORBID_C_FUNCTION(FORBIDDEN_FUNCTION_IMPORT_SPEC Signature, Alternative) + +#define FORBID_NORETURN_C_FUNCTION(Signature, Alternative) \ + FORBID_C_FUNCTION(FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE Signature, Alternative) + +#define FORBID_IMPORTED_NORETURN_C_FUNCTION(Signature, Alternative) \ + FORBID_NORETURN_C_FUNCTION(FORBIDDEN_FUNCTION_IMPORT_SPEC Signature, Alternative) + +// A BEGIN/END_ALLOW_FORBIDDEN_FUNCTIONS pair establishes a scope in which the +// deprecation warnings used to forbid the use of certain functions are +// suppressed. These macros are not intended for warning suppression at +// individual call sites; see permitForbiddenFunctions.hpp for the approach +// taken for that where needed. Rather, these are used to suppress warnings +// from 3rd-party code included by HotSpot, such as the gtest framework and +// C++ Standard Library headers, which may refer to functions that are +// disallowed in other parts of HotSpot. They are also used in the +// implementation of the "permit" mechanism. +#define BEGIN_ALLOW_FORBIDDEN_FUNCTIONS \ + PRAGMA_DIAG_PUSH \ + PRAGMA_DEPRECATED_IGNORED + +#define END_ALLOW_FORBIDDEN_FUNCTIONS \ + PRAGMA_DIAG_POP + #endif // SHARE_UTILITIES_COMPILERWARNINGS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp index 1dd5892e4c34..c10650598cd2 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -51,8 +51,6 @@ PRAGMA_DISABLE_GCC_WARNING("-Wformat-nonliteral") \ PRAGMA_DISABLE_GCC_WARNING("-Wformat-security") -#define PRAGMA_FORMAT_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wformat") - // Disable -Wstringop-truncation which is introduced in GCC 8. // https://gcc.gnu.org/gcc-8/changes.html #if !defined(__clang_major__) && (__GNUC__ >= 8) @@ -70,32 +68,71 @@ #define PRAGMA_ZERO_AS_NULL_POINTER_CONSTANT_IGNORED \ PRAGMA_DISABLE_GCC_WARNING("-Wzero-as-null-pointer-constant") -#if (__GNUC__ >= 10) -// TODO: Re-enable warning attribute for Clang once -// https://github.com/llvm/llvm-project/issues/56519 is fixed and released. -// || (defined(__clang_major__) && (__clang_major__ >= 14)) +#define PRAGMA_DEPRECATED_IGNORED \ + PRAGMA_DISABLE_GCC_WARNING("-Wdeprecated-declarations") + +// This macro is used by the NORETURN variants of FORBID_C_FUNCTION. +// +// The [[noreturn]] attribute requires that the first declaration of a +// function has it if any have it. +// +// gcc, clang, and MSVC all provide compiler-specific alternatives to that +// attribute: __attribute__((noreturn)) for gcc and clang, +// __declspec(noreturn) for MSVC and clang. gcc and MSVC treat their +// respective compiler-specific alternatives as satisfying that requirement. +// clang does not. +// +// So clang warns if we use [[noreturn]] in the forbidding declaration and the +// library header has already been included and uses the compiler-specific +// attribute. Similarly, clang warns if we use the compiler-specific attribute +// while the library uses [[noreturn]] and the library header is included +// after the forbidding declaration. +// +// For now, we're only going to worry about the standard library, and not +// noreturn functions in some other library that we might want to forbid in +// the future. If there's more than one library to be accounted for, then +// things may get more complicated. +// +// There are several ways we could deal with this. +// +// Probably the most robust is to use the same style of noreturn attribute as +// is used by the library providing the function. That way it doesn't matter +// in which order the inclusion of the library header and the forbidding are +// performed. We could use configure to determine which to use and provide a +// macro to select on here. +// +// Another approach is to always use __attribute__ noreturn in the forbidding +// declaration, but ensure the relevant library header has been included +// before the forbidding declaration. Since there are currently only a couple +// of affected functions, this is easier to implement. So this is the +// approach being taken for now. +// +// clang's failure to treat the compiler-specific form as counting toward the +// [[noreturn]] requirement is arguably a clang bug. +// https://github.com/llvm/llvm-project/issues/131700 + +#ifdef __clang__ +#define FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE __attribute__((__noreturn__)) +#endif -// Use "warning" attribute to detect uses of "forbidden" functions. +// This macro is used to suppress a warning for some uses of FORBID_C_FUNCTION. // -// Note: The warning attribute is available since GCC 9, but disabling pragmas -// does not work reliably in ALLOW_C_FUNCTION. GCC 10+ and up work fine. +// libstdc++ provides inline definitions of some functions to support +// _FORTIFY_SOURCE. clang warns about our forbidding declaration adding the +// [[deprecated]] attribute following such a definition: +// "warning: attribute declaration must precede definition [-Wignored-attributes]" +// Use this macro to suppress the warning, not getting protection when using +// that combination. Other build combinations should provide sufficient +// coverage. // -// Note: _FORTIFY_SOURCE transforms calls to certain functions into calls to -// associated "checking" functions, and that transformation seems to occur -// *before* the attribute check. We use fortification in fastdebug builds, -// so uses of functions that are both forbidden and fortified won't cause -// forbidden warnings in such builds. -#define FORBID_C_FUNCTION(signature, alternative) \ - extern "C" __attribute__((__warning__(alternative))) signature; - -// Disable warning attribute over the scope of the affected statement. -// The name serves only to document the intended function. -#define ALLOW_C_FUNCTION(name, ...) \ - PRAGMA_DIAG_PUSH \ - PRAGMA_DISABLE_GCC_WARNING("-Wattribute-warning") \ - __VA_ARGS__ \ - PRAGMA_DIAG_POP - -#endif // gcc10+ +// clang's warning in this case is arguably a clang bug. +// https://github.com/llvm/llvm-project/issues/135481 +// This issue has been fixed, with the fix probably appearing in clang 21. +#if defined(__clang__) && defined(_FORTIFY_SOURCE) +#if _FORTIFY_SOURCE > 0 +#define FORBIDDEN_FUNCTION_IGNORE_CLANG_FORTIFY_WARNING \ + PRAGMA_DISABLE_GCC_WARNING("-Wignored-attributes") +#endif +#endif #endif // SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp index 95ebc77d1c98..4ec61babec3d 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp @@ -27,6 +27,7 @@ #include "utilities/compilerWarnings.hpp" #include "utilities/debug.hpp" +#include "utilities/forbiddenFunctions.hpp" #include "utilities/macros.hpp" // Get constants like JVM_T_CHAR and JVM_SIGNATURE_INT, before pulling in . @@ -173,35 +174,6 @@ inline uintptr_t p2u(const volatile void* p) { #define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false") -//---------------------------------------------------------------------------------------------------- -// Forbid the use of various C library functions. -// Some of these have os:: replacements that should normally be used instead. -// Others are considered security concerns, with preferred alternatives. - -FORBID_C_FUNCTION(void exit(int), "use os::exit"); -FORBID_C_FUNCTION(void _exit(int), "use os::exit"); -FORBID_C_FUNCTION(char* strerror(int), "use os::strerror"); -FORBID_C_FUNCTION(char* strtok(char*, const char*), "use strtok_r"); -FORBID_C_FUNCTION(int sprintf(char*, const char*, ...), "use os::snprintf"); -FORBID_C_FUNCTION(int vsprintf(char*, const char*, va_list), "use os::vsnprintf"); -FORBID_C_FUNCTION(int vsnprintf(char*, size_t, const char*, va_list), "use os::vsnprintf"); - -// All of the following functions return raw C-heap pointers (sometimes as an option, e.g. realpath or getwd) -// or, in case of free(), take raw C-heap pointers. Don't use them unless you are really sure you must. -FORBID_C_FUNCTION(void* malloc(size_t size), "use os::malloc"); -FORBID_C_FUNCTION(void* calloc(size_t nmemb, size_t size), "use os::malloc and zero out manually"); -FORBID_C_FUNCTION(void free(void *ptr), "use os::free"); -FORBID_C_FUNCTION(void* realloc(void *ptr, size_t size), "use os::realloc"); -FORBID_C_FUNCTION(char* strdup(const char *s), "use os::strdup"); -FORBID_C_FUNCTION(char* strndup(const char *s, size_t n), "don't use"); -FORBID_C_FUNCTION(int posix_memalign(void **memptr, size_t alignment, size_t size), "don't use"); -FORBID_C_FUNCTION(void* aligned_alloc(size_t alignment, size_t size), "don't use"); -FORBID_C_FUNCTION(char* realpath(const char* path, char* resolved_path), "use os::realpath"); -FORBID_C_FUNCTION(char* get_current_dir_name(void), "use os::get_current_directory()"); -FORBID_C_FUNCTION(char* getwd(char *buf), "use os::get_current_directory()"); -FORBID_C_FUNCTION(wchar_t* wcsdup(const wchar_t *s), "don't use"); -FORBID_C_FUNCTION(void* reallocf(void *ptr, size_t size), "don't use"); - //---------------------------------------------------------------------------------------------------- // Constants @@ -297,6 +269,9 @@ inline jdouble jdouble_cast(jlong x); const jlong min_jlong = CONST64(0x8000000000000000); const jlong max_jlong = CONST64(0x7fffffffffffffff); +// for timer info max values which include all bits, 0xffffffffffffffff +const jlong all_bits_jlong = ~jlong(0); + //------------------------------------------- // Constant for jdouble const jlong min_jlongDouble = CONST64(0x0000000000000001); @@ -307,7 +282,6 @@ const jdouble max_jdouble = jdouble_cast(max_jlongDouble); const size_t K = 1024; const size_t M = K*K; const size_t G = M*K; -const size_t HWperKB = K / sizeof(HeapWord); // Constants for converting from a base unit to milli-base units. For // example from seconds to milliseconds and microseconds @@ -1144,7 +1118,7 @@ inline bool is_even(intx x) { return !is_odd(x); } // abs methods which cannot overflow and so are well-defined across // the entire domain of integer types. -static inline unsigned int uabs(unsigned int n) { +static inline unsigned int g_uabs(unsigned int n) { union { unsigned int result; int value; @@ -1153,7 +1127,7 @@ static inline unsigned int uabs(unsigned int n) { if (value < 0) result = 0-result; return result; } -static inline julong uabs(julong n) { +static inline julong g_uabs(julong n) { union { julong result; jlong value; @@ -1162,8 +1136,8 @@ static inline julong uabs(julong n) { if (value < 0) result = 0-result; return result; } -static inline julong uabs(jlong n) { return uabs((julong)n); } -static inline unsigned int uabs(int n) { return uabs((unsigned int)n); } +static inline julong g_uabs(jlong n) { return g_uabs((julong)n); } +static inline unsigned int g_uabs(int n) { return g_uabs((unsigned int)n); } // "to" should be greater than "from." inline size_t byte_size(void* from, void* to) { diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp index 5c3cfaa0dd55..a5caf316aa3b 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp @@ -377,13 +377,10 @@ #define DEBUG_ONLY(code) code #define NOT_DEBUG(code) #define NOT_DEBUG_RETURN /*next token must be ;*/ -// Historical. -#define debug_only(code) code #else // ASSERT #define DEBUG_ONLY(code) #define NOT_DEBUG(code) code #define NOT_DEBUG_RETURN {} -#define debug_only(code) #endif // ASSERT #ifdef _LP64 diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp index e95bc776ce5e..f3c469f14864 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp @@ -161,6 +161,12 @@ void outputStream::do_vsnprintf_and_write(const char* format, va_list ap, bool a } } +bool outputStream::set_autoindent(bool value) { + const bool old = _autoindent; + _autoindent = value; + return old; +} + void outputStream::print(const char* format, ...) { va_list ap; va_start(ap, format); @@ -225,10 +231,6 @@ void outputStream::cr() { this->write("\n", 1); } -void outputStream::cr_indent() { - cr(); indent(); -} - void outputStream::stamp() { if (! _stamp.is_updated()) { _stamp.update(); // start at 0 on first call to stamp() @@ -277,12 +279,6 @@ outputStream& outputStream::indent() { return *this; } -bool outputStream::set_autoindent(bool value) { - const bool old = _autoindent; - _autoindent = value; - return old; -} - void outputStream::print_jlong(jlong value) { print(JLONG_FORMAT, value); } @@ -300,16 +296,16 @@ void outputStream::print_julong(julong value) { * 0000020: 0000 0000 0000 0040 0000 0000 0000 015d .......@.......] * ... * - * indent is applied to each line. Ends with a CR. + * Ends with a CR. */ void outputStream::print_data(void* data, size_t len, bool with_ascii, bool rel_addr) { size_t limit = (len + 16) / 16 * 16; for (size_t i = 0; i < limit; ++i) { if (i % 16 == 0) { if (rel_addr) { - indent().print("%07" PRIxPTR ":", i); + print("%07" PRIxPTR ":", i); } else { - indent().print(PTR_FORMAT ":", p2i((unsigned char*)data + i)); + print(PTR_FORMAT ":", p2i((unsigned char*)data + i)); } } if (i % 2 == 0) { diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp index 46bd0b673c16..79e95734a534 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -44,6 +44,8 @@ DEBUG_ONLY(class ResourceMark;) // -XX:+DisplayVMOutputToStderr. class outputStream : public CHeapObjBase { + friend class StreamIndentor; + private: NONCOPYABLE(outputStream); int _indentation; // current indentation @@ -87,6 +89,9 @@ class outputStream : public CHeapObjBase { // calls do_vsnprintf, then writes output to stream. void do_vsnprintf_and_write(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); + // Automatic indentation. Returns old autoindent state. + bool set_autoindent(bool value); + public: class TestSupport; // Unit test support @@ -104,14 +109,6 @@ class outputStream : public CHeapObjBase { int fill_to(int col); void move_to(int col, int slop = 6, int min_space = 2); - // Automatic indentation: - // If autoindent mode is on, the following APIs will automatically indent - // line starts depending on the current indentation level: - // print(), print_cr(), print_raw(), print_raw_cr() - // Other APIs are unaffected - // Returns old autoindent state. - bool set_autoindent(bool value); - // sizing int position() const { return _position; } julong count() const { return _precount + _position; } @@ -135,7 +132,6 @@ class outputStream : public CHeapObjBase { void put(char ch); void sp(int count = 1); void cr(); - void cr_indent(); void bol() { if (_position > 0) cr(); } @@ -175,25 +171,29 @@ class outputStream : public CHeapObjBase { // ANSI C++ name collision extern outputStream* tty; // tty output -class streamIndentor : public StackObj { - outputStream* const _str; - const int _amount; - NONCOPYABLE(streamIndentor); -public: - streamIndentor(outputStream* str, int amt = 2) : _str(str), _amount(amt) { - _str->inc(_amount); - } - ~streamIndentor() { _str->dec(_amount); } -}; +// outputStream indentation. When used, indentation is automatically applied +// when printing on the stream using the following APIs: +// print(), print_cr(), print_raw(), print_raw_cr() +class StreamIndentor { + private: + outputStream* const _stream; + const int _indentation; + const bool _old_autoindent; + NONCOPYABLE(StreamIndentor); -class StreamAutoIndentor : public StackObj { - outputStream* const _os; - const bool _old; - NONCOPYABLE(StreamAutoIndentor); public: - StreamAutoIndentor(outputStream* os) : - _os(os), _old(os->set_autoindent(true)) {} - ~StreamAutoIndentor() { _os->set_autoindent(_old); } + StreamIndentor(outputStream* os, int indentation) : + _stream(os), + _indentation(indentation), + _old_autoindent(_stream->set_autoindent(true)) { + + _stream->inc(_indentation); + } + + ~StreamIndentor() { + _stream->dec(_indentation); + _stream->set_autoindent(_old_autoindent); + } }; // advisory locking for the shared tty stream: From 006b59b8a70096ea6d64de90eaad1ce82524095a Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Mon, 30 Jun 2025 10:35:01 +0200 Subject: [PATCH 4/7] svm: reapply the libcontainer changes --- .../os/linux/cgroupSubsystem_linux.cpp | 7 ++- .../os/linux/cgroupSubsystem_linux.hpp | 16 +++++- .../src/hotspot/os/linux/cgroupUtil_linux.cpp | 8 +-- .../src/hotspot/os/linux/cgroupUtil_linux.hpp | 8 +-- .../os/linux/cgroupV1Subsystem_linux.cpp | 7 ++- .../os/linux/cgroupV1Subsystem_linux.hpp | 7 ++- .../os/linux/cgroupV2Subsystem_linux.cpp | 9 ++-- .../os/linux/cgroupV2Subsystem_linux.hpp | 9 ++-- .../hotspot/os/linux/osContainer_linux.cpp | 9 +++- .../hotspot/os/linux/osContainer_linux.hpp | 7 ++- .../src/hotspot/os/linux/os_linux.cpp | 32 +++++++++-- .../src/hotspot/os/linux/os_linux.hpp | 18 ++++++- .../src/hotspot/os/linux/os_linux.inline.hpp | 7 ++- .../src/hotspot/os/posix/os_posix.cpp | 15 +++++- .../src/hotspot/os/posix/os_posix.hpp | 7 ++- .../src/hotspot/os/posix/os_posix.inline.hpp | 7 ++- .../src/hotspot/share/memory/allStatic.hpp | 5 +- .../src/hotspot/share/memory/allocation.hpp | 9 +++- .../share/memory/allocation.inline.hpp | 7 ++- .../src/hotspot/share/nmt/memTag.hpp | 5 +- .../src/hotspot/share/runtime/os.cpp | 54 ++++++++++++++++++- .../src/hotspot/share/runtime/os.hpp | 43 ++++++++++++++- .../src/hotspot/share/runtime/os.inline.hpp | 7 ++- .../hotspot/share/utilities/checkedCast.hpp | 5 +- .../share/utilities/compilerWarnings.hpp | 5 +- .../share/utilities/compilerWarnings_gcc.hpp | 5 +- .../share/utilities/globalDefinitions.hpp | 23 +++++++- .../share/utilities/globalDefinitions_gcc.hpp | 5 +- .../src/hotspot/share/utilities/macros.hpp | 5 +- .../src/hotspot/share/utilities/ostream.cpp | 23 +++++++- .../src/hotspot/share/utilities/ostream.hpp | 25 ++++++++- 31 files changed, 332 insertions(+), 67 deletions(-) diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp index a9cabc873356..03b003d05fb2 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 @@ -893,7 +894,9 @@ jlong CgroupSubsystem::cpu_usage_in_micros() { return cpuacct_controller()->cpu_usage_in_micros(); } +#ifndef NATIVE_IMAGE void CgroupSubsystem::print_version_specific_info(outputStream* st) { julong phys_mem = os::Linux::physical_memory(); memory_controller()->controller()->print_version_specific_info(st, phys_mem); } +#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp index f72d1a7fb1e5..c504d61ef49b 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 CGROUP_SUBSYSTEM_LINUX_HPP @@ -172,17 +173,24 @@ class CachedMetric : public CHeapObj{ _next_check_counter = min_jlong; } bool should_check_metric() { +#ifdef NATIVE_IMAGE + // NOTE (chaeubl): we do all caching on the Java-side instead of the C-side + return true; +#else return os::elapsed_counter() > _next_check_counter; +#endif // NATIVE_IMAGE } jlong value() { return _metric; } void set_value(jlong value, jlong timeout) { _metric = value; +#ifndef NATIVE_IMAGE // Metric is unlikely to change, but we want to remain // responsive to configuration changes. A very short grace time // between re-read avoids excessive overhead during startup without // significantly reducing the VMs ability to promptly react to changed // metric config _next_check_counter = os::elapsed_counter() + timeout; +#endif // !NATIVE_IMAGE } }; @@ -240,7 +248,9 @@ class CgroupMemoryController: public CHeapObj { virtual jlong memory_max_usage_in_bytes() = 0; virtual jlong rss_usage_in_bytes() = 0; virtual jlong cache_usage_in_bytes() = 0; +#ifndef NATIVE_IMAGE virtual void print_version_specific_info(outputStream* st, julong host_mem) = 0; +#endif // !NATIVE_IMAGE virtual bool needs_hierarchy_adjustment() = 0; virtual bool is_read_only() = 0; virtual const char* subsystem_path() = 0; @@ -279,7 +289,9 @@ class CgroupSubsystem: public CHeapObj { jlong memory_max_usage_in_bytes(); jlong rss_usage_in_bytes(); jlong cache_usage_in_bytes(); +#ifndef NATIVE_IMAGE void print_version_specific_info(outputStream* st); +#endif // !NATIVE_IMAGE }; // Utility class for storing info retrieved from /proc/cgroups, diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp index b52ef87dcaee..863d4fadf3fd 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp @@ -1,10 +1,13 @@ /* - * Copyright (c) 2024, 2025, Red Hat, Inc. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Red Hat Inc. 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +22,6 @@ * 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 "os_linux.hpp" diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp index 19220af31776..b97e7406f56c 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp @@ -1,10 +1,13 @@ /* - * Copyright (c) 2024, Red Hat, Inc. + * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2024, Red Hat Inc. 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +22,6 @@ * 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 CGROUP_UTIL_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp index f65da2070628..8d0a664b92e5 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 @@ -350,6 +351,7 @@ jlong CgroupV1MemoryController::kernel_memory_max_usage_in_bytes() { return (jlong)kmem_max_usage; } +#ifndef NATIVE_IMAGE void CgroupV1MemoryController::print_version_specific_info(outputStream* st, julong phys_mem) { jlong kmem_usage = kernel_memory_usage_in_bytes(); jlong kmem_limit = kernel_memory_limit_in_bytes(phys_mem); @@ -359,6 +361,7 @@ void CgroupV1MemoryController::print_version_specific_info(outputStream* st, jul OSContainer::print_container_helper(st, kmem_usage, "kernel_memory_usage_in_bytes"); OSContainer::print_container_helper(st, kmem_max_usage, "kernel_memory_max_usage_in_bytes"); } +#endif // !NATIVE_IMAGE char* CgroupV1Subsystem::cpu_cpuset_cpus() { char cpus[1024]; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp index a56ad4551651..ce0c5acee6ac 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 CGROUP_V1_SUBSYSTEM_LINUX_HPP @@ -89,7 +90,9 @@ class CgroupV1MemoryController final : public CgroupMemoryController { jlong kernel_memory_usage_in_bytes(); jlong kernel_memory_limit_in_bytes(julong host_mem); jlong kernel_memory_max_usage_in_bytes(); +#ifndef NATIVE_IMAGE void print_version_specific_info(outputStream* st, julong host_mem) override; +#endif // !NATIVE_IMAGE bool needs_hierarchy_adjustment() override { return reader()->needs_hierarchy_adjustment(); } diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp index 6472fdfccc5d..cc1b7e770008 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp @@ -1,11 +1,13 @@ /* - * Copyright (c) 2020, 2025, Red Hat Inc. * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Red Hat Inc. 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -20,7 +22,6 @@ * 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 "cgroupV2Subsystem_linux.hpp" @@ -327,6 +328,7 @@ bool CgroupV2Controller::needs_hierarchy_adjustment() { return strcmp(_cgroup_path, "/") != 0; } +#ifndef NATIVE_IMAGE void CgroupV2MemoryController::print_version_specific_info(outputStream* st, julong phys_mem) { jlong swap_current = memory_swap_current_value(reader()); jlong swap_limit = memory_swap_limit_value(reader()); @@ -334,6 +336,7 @@ void CgroupV2MemoryController::print_version_specific_info(outputStream* st, jul OSContainer::print_container_helper(st, swap_current, "memory_swap_current_in_bytes"); OSContainer::print_container_helper(st, swap_limit, "memory_swap_max_limit_in_bytes"); } +#endif // !NATIVE_IMAGE char* CgroupV2Controller::construct_path(char* mount_path, const char* cgroup_path) { stringStream ss; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp index e26f37925ca8..6b25ca0be127 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp @@ -1,11 +1,13 @@ /* - * Copyright (c) 2020, 2024, Red Hat Inc. * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -20,7 +22,6 @@ * 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 CGROUP_V2_SUBSYSTEM_LINUX_HPP @@ -123,7 +124,9 @@ class CgroupV2MemoryController final: public CgroupMemoryController { jlong memory_max_usage_in_bytes() override; jlong rss_usage_in_bytes() override; jlong cache_usage_in_bytes() override; +#ifndef NATIVE_IMAGE void print_version_specific_info(outputStream* st, julong host_mem) override; +#endif // !NATIVE_IMAGE bool is_read_only() override { return reader()->is_read_only(); } diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp index 2ba4c2526594..de3273595754 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 @@ -147,10 +148,12 @@ jlong OSContainer::cache_usage_in_bytes() { return cgroup_subsystem->cache_usage_in_bytes(); } +#ifndef NATIVE_IMAGE void OSContainer::print_version_specific_info(outputStream* st) { assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); cgroup_subsystem->print_version_specific_info(st); } +#endif // !NATIVE_IMAGE char * OSContainer::cpu_cpuset_cpus() { assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); @@ -197,6 +200,7 @@ jlong OSContainer::pids_current() { return cgroup_subsystem->pids_current(); } +#ifndef NATIVE_IMAGE void OSContainer::print_container_helper(outputStream* st, jlong j, const char* metrics) { st->print("%s: ", metrics); if (j >= 0) { @@ -209,3 +213,4 @@ void OSContainer::print_container_helper(outputStream* st, jlong j, const char* st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "unlimited"); } } +#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp index 3c270e8ea509..bcaa47e33e2e 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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_LINUX_OSCONTAINER_LINUX_HPP @@ -44,8 +45,10 @@ class OSContainer: AllStatic { public: static void init(); +#ifndef NATIVE_IMAGE static void print_version_specific_info(outputStream* st); static void print_container_helper(outputStream* st, jlong j, const char* metrics); +#endif // !NATIVE_IMAGE static inline bool is_containerized(); static const char * container_type(); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp index 1a23c956f354..589c4ae39347 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp @@ -1,11 +1,13 @@ /* * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2024 SAP SE. All rights reserved. + * Copyright (c) 2015, 2024, SAP SE. 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -20,9 +22,9 @@ * 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 NATIVE_IMAGE #include "classfile/vmSymbols.hpp" #include "code/vtableStubs.hpp" #include "compiler/compileBroker.hpp" @@ -31,19 +33,25 @@ #include "interpreter/interpreter.hpp" #include "jvm.h" #include "jvmtifiles/jvmti.h" +#endif // !NATIVE_IMAGE #include "logging/log.hpp" +#ifndef NATIVE_IMAGE #include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" #include "nmt/memTracker.hpp" #include "oops/oop.inline.hpp" +#endif // !NATIVE_IMAGE #include "osContainer_linux.hpp" #include "os_linux.inline.hpp" #include "os_posix.inline.hpp" +#ifndef NATIVE_IMAGE #include "prims/jniFastGetField.hpp" #include "prims/jvm_misc.hpp" #include "runtime/arguments.hpp" #include "runtime/atomic.hpp" +#endif // !NATIVE_IMAGE #include "runtime/globals.hpp" +#ifndef NATIVE_IMAGE #include "runtime/globals_extension.hpp" #include "runtime/init.hpp" #include "runtime/interfaceSupport.inline.hpp" @@ -65,7 +73,9 @@ #include "services/runtimeService.hpp" #include "signals_posix.hpp" #include "utilities/align.hpp" +#endif // !NATIVE_IMAGE #include "utilities/checkedCast.hpp" +#ifndef NATIVE_IMAGE #include "utilities/debug.hpp" #include "utilities/decoder.hpp" #include "utilities/defaultStream.hpp" @@ -80,6 +90,7 @@ #include "jfr/jfrEvents.hpp" #include "jfr/support/jfrNativeLibraryLoadEvent.hpp" #endif +#endif // !NATIVE_IMAGE // put OS-includes here # include @@ -129,6 +140,7 @@ #include #endif +#ifndef NATIVE_IMAGE // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling // getrusage() is prepared to handle the associated failure. #ifndef RUSAGE_THREAD @@ -154,11 +166,13 @@ enum CoredumpFilterBit { LARGEPAGES_BIT = 1 << 6, DAX_SHARED_BIT = 1 << 8 }; +#endif // !NATIVE_IMAGE //////////////////////////////////////////////////////////////////////////////// // global variables julong os::Linux::_physical_memory = 0; +#ifndef NATIVE_IMAGE address os::Linux::_initial_thread_stack_bottom = nullptr; uintptr_t os::Linux::_initial_thread_stack_size = 0; @@ -333,6 +347,7 @@ jlong os::free_swap_space() { } return host_free_swap_val; } +#endif // !NATIVE_IMAGE julong os::physical_memory() { jlong phys_mem = 0; @@ -349,6 +364,7 @@ julong os::physical_memory() { return phys_mem; } +#ifndef NATIVE_IMAGE size_t os::rss() { size_t size = 0; os::Linux::meminfo_t info; @@ -490,6 +506,7 @@ pid_t os::Linux::gettid() { assert(rslt != -1, "must be."); // old linuxthreads implementation? return (pid_t)rslt; } +#endif // !NATIVE_IMAGE // Returns the amount of swap currently configured, in bytes. // This can change at any time. @@ -499,6 +516,7 @@ julong os::Linux::host_swap() { return (julong)(si.totalswap * si.mem_unit); } +#ifndef NATIVE_IMAGE // Most versions of linux have a bug where the number of processors are // determined by looking at the /proc file system. In a chroot environment, // the system call returns 1. @@ -506,9 +524,11 @@ static bool unsafe_chroot_detected = false; static const char *unstable_chroot_error = "/proc file system not found.\n" "Java may be unstable running multithreaded in a chroot " "environment on Linux when /proc filesystem is not mounted."; +#endif // !NATIVE_IMAGE void os::Linux::initialize_system_info() { set_processor_count((int)sysconf(_SC_NPROCESSORS_CONF)); +#ifndef NATIVE_IMAGE if (processor_count() == 1) { pid_t pid = os::Linux::gettid(); char fname[32]; @@ -520,10 +540,12 @@ void os::Linux::initialize_system_info() { fclose(fp); } } +#endif // !NATIVE_IMAGE _physical_memory = (julong)sysconf(_SC_PHYS_PAGES) * (julong)sysconf(_SC_PAGESIZE); assert(processor_count() > 0, "linux error"); } +#ifndef NATIVE_IMAGE void os::init_system_properties_values() { // The next steps are taken in the product version: // @@ -4638,6 +4660,7 @@ static int _cpu_count(const cpu_set_t* cpus) { #define CPU_COUNT(cpus) _cpu_count(cpus) #endif // CPU_COUNT +#endif // !NATIVE_IMAGE // Get the current number of available processors for this process. // This value can change at any time during a process's lifetime. @@ -4723,6 +4746,7 @@ int os::Linux::active_processor_count() { return get_active_processor_count(); } +#ifndef NATIVE_IMAGE // Determine the active processor count from one of // three different sources: // @@ -5406,3 +5430,5 @@ bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) { return res; } // end: os::pd_dll_unload() + +#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp index bd2e1ea32304..969290b0ea51 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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_LINUX_OS_LINUX_HPP @@ -32,6 +33,7 @@ class os::Linux { friend class os; +#ifndef NATIVE_IMAGE static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *); static int (*_pthread_setname_np)(pthread_t, const char*); @@ -47,18 +49,25 @@ class os::Linux { static GrowableArray* _nindex_to_node; static julong available_memory_in_container(); +#endif // !NATIVE_IMAGE protected: static julong _physical_memory; +#ifndef NATIVE_IMAGE static pthread_t _main_thread; static julong available_memory(); static julong free_memory(); +#endif // !NATIVE_IMAGE +#ifdef NATIVE_IMAGE + public: +#endif // NATIVE_IMAGE static void initialize_system_info(); +#ifndef NATIVE_IMAGE static int commit_memory_impl(char* addr, size_t bytes, bool exec); static int commit_memory_impl(char* addr, size_t bytes, size_t alignment_hint, bool exec); @@ -90,7 +99,9 @@ class os::Linux { bool has_steal_ticks; }; +#endif // !NATIVE_IMAGE static int active_processor_count(); +#ifndef NATIVE_IMAGE static void kernel_version(long* major, long* minor, long* patch); // If kernel1 > kernel2 return 1 @@ -116,10 +127,12 @@ class os::Linux { static address initial_thread_stack_bottom(void) { return _initial_thread_stack_bottom; } static uintptr_t initial_thread_stack_size(void) { return _initial_thread_stack_size; } +#endif // !NATIVE_IMAGE static julong physical_memory() { return _physical_memory; } static julong host_swap(); +#ifndef NATIVE_IMAGE static intptr_t* ucontext_get_sp(const ucontext_t* uc); static intptr_t* ucontext_get_fp(const ucontext_t* uc); @@ -459,6 +472,7 @@ class os::Linux { // otherwise does nothing and returns -2. static int malloc_info(FILE* stream); #endif // GLIBC +#endif // !NATIVE_IMAGE }; #endif // OS_LINUX_OS_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp index f9d798404b5f..a31cfbf30cd4 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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_LINUX_OS_LINUX_INLINE_HPP @@ -30,6 +31,7 @@ #include "runtime/os.hpp" #include "os_posix.inline.hpp" +#ifndef NATIVE_IMAGE inline bool os::zero_page_read_protected() { return true; } @@ -55,5 +57,6 @@ inline bool os::can_trim_native_heap() { return false; // musl #endif } +#endif // !NATIVE_IMAGE #endif // OS_LINUX_OS_LINUX_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp index 303e44eadcb8..00f18bd05b72 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,9 +21,9 @@ * 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 NATIVE_IMAGE #include "classfile/classLoader.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" @@ -29,7 +31,9 @@ #include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "nmt/memTracker.hpp" +#endif // !NATIVE_IMAGE #include "os_posix.inline.hpp" +#ifndef NATIVE_IMAGE #include "runtime/arguments.hpp" #include "runtime/atomic.hpp" #include "runtime/frame.inline.hpp" @@ -43,8 +47,10 @@ #include "runtime/sharedRuntime.hpp" #include "services/attachListener.hpp" #include "utilities/align.hpp" +#endif // !NATIVE_IMAGE #include "utilities/checkedCast.hpp" #include "utilities/debug.hpp" +#ifndef NATIVE_IMAGE #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" #include "utilities/formatBuffer.hpp" @@ -1021,10 +1027,14 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { return result; } +#endif // !NATIVE_IMAGE + int os::stat(const char *path, struct stat *sbuf) { return ::stat(path, sbuf); } +#ifndef NATIVE_IMAGE + char * os::native_path(char *path) { return path; } @@ -2288,3 +2298,4 @@ const void* os::get_saved_assert_context(const void** sigInfo) { *sigInfo = nullptr; return nullptr; } +#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp index 4b8b75ea07ef..969901c864d0 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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_POSIX_OS_POSIX_HPP @@ -29,6 +30,7 @@ #include +#ifndef NATIVE_IMAGE // Note: the Posix API aims to capture functionality available on all Posix // compliant platforms, but in practice the implementations may depend on // non-Posix functionality. @@ -100,5 +102,6 @@ class os::Posix { const void* ucVoid, address* stub); }; +#endif // !NATIVE_IMAGE #endif // OS_POSIX_OS_POSIX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp index cf81c5d62863..de050c3c4453 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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_POSIX_OS_POSIX_INLINE_HPP @@ -27,6 +28,7 @@ #include "os_posix.hpp" +#ifndef NATIVE_IMAGE #include "runtime/mutex.hpp" #include "runtime/os.hpp" @@ -64,5 +66,6 @@ inline void PlatformMonitor::notify_all() { int status = pthread_cond_broadcast(cond()); assert_status(status == 0, status, "cond_broadcast"); } +#endif // !NATIVE_IMAGE #endif // OS_POSIX_OS_POSIX_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp index 79191de0dd17..4f3761b470ee 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_MEMORY_ALLSTATIC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp index 9e500135d0b0..eaf613bb6ab2 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_MEMORY_ALLOCATION_HPP @@ -233,6 +234,7 @@ class StackObj { void operator delete [](void* p) = delete; }; +#ifndef NATIVE_IMAGE // Base class for objects stored in Metaspace. // Calling delete will result in fatal error. // @@ -522,6 +524,7 @@ class AnyObj { #define NEW_C_HEAP_ARRAY2(type, size, mem_tag, pc)\ (type*) (AllocateHeap((size) * sizeof(type), mem_tag, pc)) +#endif // !NATIVE_IMAGE #define NEW_C_HEAP_ARRAY(type, size, mem_tag)\ (type*) (AllocateHeap((size) * sizeof(type), mem_tag)) @@ -551,6 +554,7 @@ class AnyObj { #define FREE_C_HEAP_OBJ(objname)\ FreeHeap((char*)objname); +#ifndef NATIVE_IMAGE //------------------------------ReallocMark--------------------------------- // Code which uses REALLOC_RESOURCE_ARRAY should check an associated @@ -589,5 +593,6 @@ class MallocArrayAllocator : public AllStatic { static E* reallocate(E* addr, size_t new_length, MemTag mem_tag); static void free(E* addr); }; +#endif // !NATIVE_IMAGE #endif // SHARE_MEMORY_ALLOCATION_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp index 01af1616ce18..04594aa91148 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_MEMORY_ALLOCATION_INLINE_HPP @@ -27,6 +28,7 @@ #include "memory/allocation.hpp" +#ifndef NATIVE_IMAGE #include "runtime/atomic.hpp" #include "runtime/globals.hpp" #include "runtime/os.hpp" @@ -110,5 +112,6 @@ template void MallocArrayAllocator::free(E* addr) { FreeHeap(addr); } +#endif // !NATIVE_IMAGE #endif // SHARE_MEMORY_ALLOCATION_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp index 9255645638d8..1bf27dce8db2 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_NMT_MEM_TAG_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp index ee1f0a3b0817..9d2b31f40104 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,9 +21,9 @@ * 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 NATIVE_IMAGE #include "cds/cdsConfig.hpp" #include "classfile/javaClasses.hpp" #include "classfile/moduleEntry.hpp" @@ -36,7 +38,9 @@ #include "jvm.h" #include "logging/log.hpp" #include "logging/logStream.hpp" +#endif // !NATIVE_IMAGE #include "memory/allocation.inline.hpp" +#ifndef NATIVE_IMAGE #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "nmt/mallocHeader.inline.hpp" @@ -59,7 +63,9 @@ #include "runtime/javaThread.hpp" #include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" +#endif // !NATIVE_IMAGE #include "runtime/os.inline.hpp" +#ifndef NATIVE_IMAGE #include "runtime/osThread.hpp" #include "runtime/safefetch.hpp" #include "runtime/sharedRuntime.hpp" @@ -71,7 +77,9 @@ #include "services/attachListener.hpp" #include "services/threadService.hpp" #include "utilities/align.hpp" +#endif // !NATIVE_IMAGE #include "utilities/checkedCast.hpp" +#ifndef NATIVE_IMAGE #include "utilities/count_trailing_zeros.hpp" #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" @@ -94,7 +102,9 @@ OSThread* os::_starting_thread = nullptr; volatile unsigned int os::_rand_seed = 1234567; +#endif // !NATIVE_IMAGE int os::_processor_count = 0; +#ifndef NATIVE_IMAGE int os::_initial_active_processor_count = 0; os::PageSizes os::_page_sizes; @@ -107,6 +117,7 @@ int os::snprintf(char* buf, size_t len, const char* fmt, ...) { va_end(args); return result; } +#endif // !NATIVE_IMAGE int os::snprintf_checked(char* buf, size_t len, const char* fmt, ...) { va_list args; @@ -128,6 +139,7 @@ int os::vsnprintf(char* buf, size_t len, const char* fmt, va_list args) { return result; } +#ifndef NATIVE_IMAGE // Fill in buffer with current local time as an ISO-8601 string. // E.g., YYYY-MM-DDThh:mm:ss.mmm+zzzz. // Returns buffer, or null if it failed. @@ -591,6 +603,7 @@ bool os::find_builtin_agent(JvmtiAgent* agent, const char* sym) { agent->set_os_lib(save_handle); return false; } +#endif // !NATIVE_IMAGE // --------------------- heap allocation utilities --------------------- @@ -602,6 +615,7 @@ char *os::strdup(const char *str, MemTag mem_tag) { return dup_str; } +#ifndef NATIVE_IMAGE char* os::strdup_check_oom(const char* str, MemTag mem_tag) { char* p = os::strdup(str, mem_tag); if (p == nullptr) { @@ -622,7 +636,36 @@ static void break_if_ptr_caught(void* ptr) { } } #endif // ASSERT +#endif // !NATIVE_IMAGE + +#ifdef NATIVE_IMAGE +void* os::malloc(size_t size, MemTag mem_tag) { + // On malloc(0), implementations of malloc(3) have the choice to return either + // null or a unique non-null pointer. To unify libc behavior across our platforms + // we chose the latter. + size = MAX2((size_t)1, size); + return ::malloc(size); +} + +void* os::realloc(void *memblock, size_t size, MemTag mem_tag) { + if (memblock == nullptr) { + return os::malloc(size, mem_tag); + } + // On realloc(p, 0), implementers of realloc(3) have the choice to return either + // null or a unique non-null pointer. To unify libc behavior across our platforms + // we chose the latter. + size = MAX2((size_t)1, size); + return ::realloc(memblock, size); +} + +void os::free(void *memblock) { + if (memblock == nullptr) { + return; + } + ::free(memblock); +} +#else void* os::malloc(size_t size, MemTag mem_tag) { return os::malloc(size, mem_tag, CALLER_PC); } @@ -1478,6 +1521,7 @@ char* os::format_boot_path(const char* format_string, assert((q - formatted_path) == formatted_path_len, "formatted_path size botched"); return formatted_path; } +#endif // !NATIVE_IMAGE // This function is a proxy to fopen, it tries to add a non standard flag ('e' or 'N') // that ensures automatic closing of the file on exec. If it can not find support in @@ -1506,6 +1550,7 @@ FILE* os::fopen(const char* path, const char* mode) { return file; } +#ifndef NATIVE_IMAGE bool os::set_boot_path(char fileSep, char pathSep) { const char* home = Arguments::get_java_home(); int home_len = (int)strlen(home); @@ -1587,6 +1632,7 @@ void os::print_image_release_file(outputStream* st) { } } +#endif // !NATIVE_IMAGE bool os::file_exists(const char* filename) { struct stat statbuf; if (filename == nullptr || strlen(filename) == 0) { @@ -1594,6 +1640,7 @@ bool os::file_exists(const char* filename) { } return os::stat(filename, &statbuf) == 0; } +#ifndef NATIVE_IMAGE bool os::write(int fd, const void *buf, size_t nBytes) { ssize_t res; @@ -1736,6 +1783,7 @@ void os::pause() { "Could not open pause file '%s', continuing immediately.\n", filename); } } +#endif // !NATIVE_IMAGE static const char* errno_to_string (int e, bool short_text) { #define ALL_SHARED_ENUMS(X) \ @@ -1862,6 +1910,7 @@ const char* os::errno_name(int e) { return errno_to_string(e, true); } +#ifndef NATIVE_IMAGE // create binary file, rewriting existing file if required int os::create_binary_file(const char* path, bool rewrite_existing) { int oflags = O_WRONLY | O_CREAT WINDOWS_ONLY(| O_BINARY); @@ -2630,3 +2679,4 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name, } return agent_entry_name; } +#endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp index b26ec280e724..5f49329c15dc 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,19 +21,21 @@ * 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 SHARE_RUNTIME_OS_HPP #define SHARE_RUNTIME_OS_HPP #include "jvm_md.h" +#ifndef NATIVE_IMAGE #include "runtime/osInfo.hpp" #include "utilities/align.hpp" #include "utilities/exceptions.hpp" +#endif // !NATIVE_IMAGE #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" #include "utilities/ostream.hpp" +#ifndef NATIVE_IMAGE #ifdef __APPLE__ # include #endif @@ -153,6 +157,7 @@ const bool ExecMem = true; typedef void (*java_call_t)(JavaValue* value, const methodHandle& method, JavaCallArguments* args, JavaThread* thread); class MallocTracker; +#endif // !NATIVE_IMAGE // Preserve errno across a range of calls @@ -172,6 +177,7 @@ class os: AllStatic { friend class JVMCIVMStructs; friend class MallocTracker; +#ifndef NATIVE_IMAGE #ifdef ASSERT private: static bool _mutex_init_done; @@ -256,8 +262,10 @@ class os: AllStatic { static void initialize_initial_active_processor_count(); LINUX_ONLY(static void pd_init_container_support();) +#endif // !NATIVE_IMAGE public: +#ifndef NATIVE_IMAGE static void init(void); // Called before command line parsing static void init_container_support() { // Called during command line parsing. @@ -343,8 +351,10 @@ class os: AllStatic { static jlong total_swap_space(); static jlong free_swap_space(); +#endif // !NATIVE_IMAGE static julong physical_memory(); +#ifndef NATIVE_IMAGE static bool has_allocatable_memory_limit(size_t* limit); static bool is_server_class_machine(); static size_t rss(); @@ -352,6 +362,7 @@ class os: AllStatic { // Returns the id of the processor on which the calling thread is currently executing. // The returned value is guaranteed to be between 0 and (os::processor_count() - 1). static uint processor_id(); +#endif // !NATIVE_IMAGE // number of CPUs static int processor_count() { @@ -359,6 +370,7 @@ class os: AllStatic { } static void set_processor_count(int count) { _processor_count = count; } +#ifndef NATIVE_IMAGE // Returns the number of CPUs this process is currently allowed to run on. // Note that on some OSes this can change dynamically. static int active_processor_count(); @@ -668,10 +680,14 @@ class os: AllStatic { // File i/o operations static int open(const char *path, int oflag, int mode); static FILE* fdopen(int fd, const char* mode); +#endif // !NATIVE_IMAGE static FILE* fopen(const char* path, const char* mode); +#ifndef NATIVE_IMAGE static jlong lseek(int fd, jlong offset, int whence); +#endif // !NATIVE_IMAGE static bool file_exists(const char* file); +#ifndef NATIVE_IMAGE // read/store and print the release file of the image static void read_image_release_file(); static void print_image_release_file(outputStream* st); @@ -797,16 +813,20 @@ class os: AllStatic { // Find agent entry point static void* find_agent_function(JvmtiAgent* agent_lib, bool check_lib, const char* sym); +#endif // !NATIVE_IMAGE // Provide wrapper versions of these functions to guarantee NUL-termination // in all cases. static int vsnprintf(char* buf, size_t len, const char* fmt, va_list args) ATTRIBUTE_PRINTF(3, 0); +#ifndef NATIVE_IMAGE static int snprintf(char* buf, size_t len, const char* fmt, ...) ATTRIBUTE_PRINTF(3, 4); +#endif // !NATIVE_IMAGE // Performs snprintf and asserts the result is non-negative (so there was not // an encoding error) and that the output was not truncated. static int snprintf_checked(char* buf, size_t len, const char* fmt, ...) ATTRIBUTE_PRINTF(3, 4); +#ifndef NATIVE_IMAGE // Get host name in buffer provided static bool get_host_name(char* buf, size_t buflen); @@ -845,6 +865,7 @@ class os: AllStatic { // Send JFR memory info event static void jfr_report_memory_info() NOT_JFR_RETURN(); +#endif // !NATIVE_IMAGE // Replacement for strerror(). // Will return the english description of the error (e.g. "File not found", as @@ -862,6 +883,7 @@ class os: AllStatic { // Will not change the value of errno. static const char* errno_name(int e); +#ifndef NATIVE_IMAGE // wait for a key press if PauseAtExit is set static void wait_for_keypress_at_exit(void); @@ -903,8 +925,10 @@ class os: AllStatic { // Init os specific system properties values static void init_system_properties_values(); +#endif // !NATIVE_IMAGE // IO operations, non-JVM_ version. static int stat(const char* path, struct stat* sbuf); +#ifndef NATIVE_IMAGE static bool dir_is_empty(const char* path); // IO operations on binary files @@ -919,16 +943,22 @@ class os: AllStatic { // toSkip: number of stack frames to skip at the beginning. // Return: number of stack frames captured. static int get_native_stack(address* stack, int size, int toSkip = 0); +#endif // !NATIVE_IMAGE // General allocation (must be MT-safe) +#ifndef NATIVE_IMAGE static void* malloc (size_t size, MemTag mem_tag, const NativeCallStack& stack); +#endif // !NATIVE_IMAGE static void* malloc (size_t size, MemTag mem_tag); +#ifndef NATIVE_IMAGE static void* realloc (void *memblock, size_t size, MemTag mem_tag, const NativeCallStack& stack); +#endif // !NATIVE_IMAGE static void* realloc (void *memblock, size_t size, MemTag mem_tag); // handles null pointers static void free (void *memblock); static char* strdup(const char *, MemTag mem_tag = mtInternal); // Like strdup +#ifndef NATIVE_IMAGE // Like strdup, but exit VM when strdup() returns null static char* strdup_check_oom(const char*, MemTag mem_tag = mtInternal); @@ -1021,6 +1051,7 @@ class os: AllStatic { // Used to register dynamic code cache area with the OS // Note: Currently only used in 64 bit Windows implementations inline static bool register_code_area(char *low, char *high); +#endif // !NATIVE_IMAGE // Platform-specific code for interacting with individual OSes. // TODO: This is for compatibility only with current usage of os::Linux, etc. @@ -1041,6 +1072,7 @@ class os: AllStatic { class Posix; #endif +#ifndef NATIVE_IMAGE #ifndef OS_NATIVE_THREAD_CREATION_FAILED_MSG #define OS_NATIVE_THREAD_CREATION_FAILED_MSG "unable to create native thread: possibly out of memory or process/resource limits reached" #endif @@ -1077,10 +1109,14 @@ class os: AllStatic { // Enables write or execute access to writeable and executable pages. static void current_thread_enable_wx(WXMode mode); #endif // __APPLE__ && AARCH64 +#endif // !NATIVE_IMAGE protected: +#ifndef NATIVE_IMAGE static volatile unsigned int _rand_seed; // seed for random number generator +#endif // !NATIVE_IMAGE static int _processor_count; // number of processors +#ifndef NATIVE_IMAGE static int _initial_active_processor_count; // number of active processors during initialization. static char* format_boot_path(const char* format_string, @@ -1091,13 +1127,16 @@ class os: AllStatic { static bool set_boot_path(char fileSep, char pathSep); static bool pd_dll_unload(void* libhandle, char* ebuf, int ebuflen); +#endif // !NATIVE_IMAGE }; +#ifndef NATIVE_IMAGE // Note that "PAUSE" is almost always used with synchronization // so arguably we should provide Atomic::SpinPause() instead // of the global SpinPause() with C linkage. // It'd also be eligible for inlining on many platforms. extern "C" int SpinPause(); +#endif // !NATIVE_IMAGE #endif // SHARE_RUNTIME_OS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp index d5cd1b922302..0719c472f3f8 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_RUNTIME_OS_INLINE_HPP @@ -27,6 +28,7 @@ #include "runtime/os.hpp" +#ifndef NATIVE_IMAGE #include OS_HEADER_INLINE(os) #include OS_CPU_HEADER_INLINE(os) @@ -58,5 +60,6 @@ inline void* os::resolve_function_descriptor(void* p) { return nullptr; } #endif +#endif // !NATIVE_IMAGE #endif // SHARE_RUNTIME_OS_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp index 290028f99e3a..3379586aded9 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_UTILITIES_CHECKEDCAST_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp index bf5ca5b48939..56f19cb5f4f6 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_UTILITIES_COMPILERWARNINGS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp index c10650598cd2..0687b784399a 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp index 4ec61babec3d..0dc49ff21952 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_UTILITIES_GLOBALDEFINITIONS_HPP @@ -30,8 +31,10 @@ #include "utilities/forbiddenFunctions.hpp" #include "utilities/macros.hpp" +#ifndef NATIVE_IMAGE // Get constants like JVM_T_CHAR and JVM_SIGNATURE_INT, before pulling in . #include "classfile_constants.h" +#endif // !NATIVE_IMAGE #include COMPILER_HEADER(utilities/globalDefinitions) @@ -40,7 +43,9 @@ #include #include +#ifndef NATIVE_IMAGE class oopDesc; +#endif // !NATIVE_IMAGE // Defaults for macros that might be defined per compiler. #ifndef NOINLINE @@ -50,6 +55,7 @@ class oopDesc; #define ALWAYSINLINE inline #endif +#ifndef NATIVE_IMAGE #ifndef ATTRIBUTE_ALIGNED #define ATTRIBUTE_ALIGNED(x) alignas(x) #endif @@ -122,6 +128,7 @@ class oopDesc; #define UINT32_FORMAT_X "0x%" PRIx32 #define UINT32_FORMAT_X_0 "0x%08" PRIx32 #define UINT32_FORMAT_W(width) "%" #width PRIu32 +#endif // !NATIVE_IMAGE // Format 64-bit quantities. #define INT64_FORMAT "%" PRId64 @@ -149,6 +156,7 @@ class oopDesc; #define JULONG_FORMAT_X UINT64_FORMAT_X #endif +#ifndef NATIVE_IMAGE // Format pointers and padded integral values which change size between 32- and 64-bit. #ifdef _LP64 #define INTPTR_FORMAT "0x%016" PRIxPTR @@ -258,6 +266,7 @@ inline size_t heap_word_size(size_t byte_size) { inline jfloat jfloat_cast(jint x); inline jdouble jdouble_cast(jlong x); +#endif // !NATIVE_IMAGE //------------------------------------------- // Constant for jlong (standardized by C++11) @@ -272,16 +281,19 @@ const jlong max_jlong = CONST64(0x7fffffffffffffff); // for timer info max values which include all bits, 0xffffffffffffffff const jlong all_bits_jlong = ~jlong(0); +#ifndef NATIVE_IMAGE //------------------------------------------- // Constant for jdouble const jlong min_jlongDouble = CONST64(0x0000000000000001); const jdouble min_jdouble = jdouble_cast(min_jlongDouble); const jlong max_jlongDouble = CONST64(0x7fefffffffffffff); const jdouble max_jdouble = jdouble_cast(max_jlongDouble); +#endif // !NATIVE_IMAGE const size_t K = 1024; const size_t M = K*K; const size_t G = M*K; +#ifndef NATIVE_IMAGE // Constants for converting from a base unit to milli-base units. For // example from seconds to milliseconds and microseconds @@ -290,11 +302,13 @@ const int MILLIUNITS = 1000; // milli units per base unit const int MICROUNITS = 1000000; // micro units per base unit const int NANOUNITS = 1000000000; // nano units per base unit const int NANOUNITS_PER_MILLIUNIT = NANOUNITS / MILLIUNITS; +#endif // !NATIVE_IMAGE const jlong NANOSECS_PER_SEC = CONST64(1000000000); const jint NANOSECS_PER_MILLISEC = 1000000; +#ifndef NATIVE_IMAGE // Unit conversion functions // The caller is responsible for considering overflow. @@ -479,6 +493,7 @@ inline int pointer_delta_as_int(const volatile T* left, const volatile T* right) extern "C" { typedef int (*_sort_Fn)(const void *, const void *); } +#endif // !NATIVE_IMAGE // Additional Java basic types @@ -507,6 +522,7 @@ typedef jshort s2; typedef jint s4; typedef jlong s8; +#ifndef NATIVE_IMAGE const jbyte min_jbyte = -(1 << 7); // smallest jbyte const jbyte max_jbyte = (1 << 7) - 1; // largest jbyte const jshort min_jshort = -(1 << 15); // smallest jshort @@ -1080,6 +1096,7 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) { #ifdef min #undef min #endif +#endif // !NATIVE_IMAGE // It is necessary to use templates here. Having normal overloaded // functions does not work because it is necessary to provide both 32- @@ -1088,6 +1105,7 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) { // will be even more error-prone than macros. template constexpr T MAX2(T a, T b) { return (a > b) ? a : b; } template constexpr T MIN2(T a, T b) { return (a < b) ? a : b; } +#ifndef NATIVE_IMAGE template constexpr T MAX3(T a, T b, T c) { return MAX2(MAX2(a, b), c); } template constexpr T MIN3(T a, T b, T c) { return MIN2(MIN2(a, b), c); } template constexpr T MAX4(T a, T b, T c, T d) { return MAX2(MAX3(a, b, c), d); } @@ -1339,5 +1357,6 @@ std::add_rvalue_reference_t declval() noexcept; // Quickly test to make sure IEEE-754 subnormal numbers are correctly // handled. bool IEEE_subnormal_handling_OK(); +#endif // !NATIVE_IMAGE #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index 94f37e7954e4..10d7501b715b 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_UTILITIES_GLOBALDEFINITIONS_GCC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp index a5caf316aa3b..876af4e1e74c 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,7 +21,6 @@ * 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 SHARE_UTILITIES_MACROS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp index f3c469f14864..afbb3c6b7b5d 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,13 +21,15 @@ * 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 NATIVE_IMAGE #include "cds/classListWriter.hpp" #include "compiler/compileLog.hpp" #include "jvm.h" +#endif // !NATIVE_IMAGE #include "memory/allocation.inline.hpp" +#ifndef NATIVE_IMAGE #include "oops/oop.inline.hpp" #include "runtime/arguments.hpp" #include "runtime/mutexLocker.hpp" @@ -34,8 +38,10 @@ #include "runtime/safepoint.hpp" #include "runtime/vm_version.hpp" #include "utilities/defaultStream.hpp" +#endif // !NATIVE_IMAGE #include "utilities/macros.hpp" #include "utilities/ostream.hpp" +#ifndef NATIVE_IMAGE #include "utilities/vmError.hpp" #include "utilities/xmlstream.hpp" @@ -189,12 +195,16 @@ void outputStream::vprint_cr(const char* format, va_list argptr) { do_vsnprintf_and_write(format, argptr, true); } +#endif // !NATIVE_IMAGE void outputStream::print_raw(const char* str, size_t len) { +#ifndef NATIVE_IMAGE if (_autoindent && _position == 0) { indent(); } +#endif // !NATIVE_IMAGE write(str, len); } +#ifndef NATIVE_IMAGE int outputStream::fill_to(int col) { const int need_fill = MAX2(col - position(), 0); @@ -331,6 +341,7 @@ void outputStream::print_data(void* data, size_t len, bool with_ascii, bool rel_ } } } +#endif // !NATIVE_IMAGE stringStream::stringStream(size_t initial_capacity) : outputStream(), @@ -345,6 +356,7 @@ stringStream::stringStream(size_t initial_capacity) : zero_terminate(); } +#ifndef NATIVE_IMAGE // useful for output to fixed chunks of memory, such as performance counters stringStream::stringStream(char* fixed_buffer, size_t fixed_buffer_size) : outputStream(), @@ -355,6 +367,7 @@ stringStream::stringStream(char* fixed_buffer, size_t fixed_buffer_size) : { zero_terminate(); } +#endif // !NATIVE_IMAGE // Grow backing buffer to desired capacity. Don't call for fixed buffers void stringStream::grow(size_t new_capacity) { @@ -402,10 +415,12 @@ void stringStream::write(const char* s, size_t len) { zero_terminate(); } +#ifndef NATIVE_IMAGE // Note that the following does not depend on write_len. // This means that position and count get updated // even when overflow occurs. update_position(s, len); +#endif // !NATIVE_IMAGE } void stringStream::zero_terminate() { @@ -414,6 +429,7 @@ void stringStream::zero_terminate() { _buffer[_written] = '\0'; } +#ifndef NATIVE_IMAGE void stringStream::reset() { assert(_is_frozen == false, "Modification forbidden"); _written = 0; _precount = 0; _position = 0; @@ -439,6 +455,7 @@ char* stringStream::as_string(Arena* arena) const { copy[_written] = '\0'; // terminating null return copy; } +#endif // !NATIVE_IMAGE stringStream::~stringStream() { if (!_is_fixed && _buffer != _small_buffer) { @@ -446,6 +463,7 @@ stringStream::~stringStream() { } } +#ifndef NATIVE_IMAGE // tty needs to be always accessible since there are code paths that may write to it // outside of the VM lifespan. // Examples for pre-VM-init accesses: Early NMT init, Early UL init @@ -1150,5 +1168,6 @@ bool networkStream::connect(const char *host, short port) { freeaddrinfo(addr_info); return (conn >= 0); } +#endif // !NATIVE_IMAGE #endif diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp index 79e95734a534..bb1b4d106458 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp @@ -4,7 +4,9 @@ * * 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. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,18 +21,21 @@ * 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 SHARE_UTILITIES_OSTREAM_HPP #define SHARE_UTILITIES_OSTREAM_HPP #include "memory/allocation.hpp" +#ifndef NATIVE_IMAGE #include "runtime/timer.hpp" +#endif // !NATIVE_IMAGE #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" +#ifndef NATIVE_IMAGE DEBUG_ONLY(class ResourceMark;) +#endif // !NATIVE_IMAGE // Output streams for printing // @@ -46,6 +51,7 @@ DEBUG_ONLY(class ResourceMark;) class outputStream : public CHeapObjBase { friend class StreamIndentor; +#ifndef NATIVE_IMAGE private: NONCOPYABLE(outputStream); int _indentation; // current indentation @@ -88,11 +94,13 @@ class outputStream : public CHeapObjBase { void do_vsnprintf_and_write_with_scratch_buffer(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); // calls do_vsnprintf, then writes output to stream. void do_vsnprintf_and_write(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); +#endif // !NATIVE_IMAGE // Automatic indentation. Returns old autoindent state. bool set_autoindent(bool value); public: +#ifndef NATIVE_IMAGE class TestSupport; // Unit test support // creation @@ -124,8 +132,10 @@ class outputStream : public CHeapObjBase { void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); +#endif // !NATIVE_IMAGE void print_raw(const char* str) { print_raw(str, strlen(str)); } void print_raw(const char* str, size_t len); +#ifndef NATIVE_IMAGE void print_raw_cr(const char* str) { print_raw(str); cr(); } void print_raw_cr(const char* str, size_t len) { print_raw(str, len); cr(); } void print_data(void* data, size_t len, bool with_ascii, bool rel_addr=true); @@ -155,7 +165,9 @@ class outputStream : public CHeapObjBase { // flushing virtual void flush() {} +#endif // !NATIVE_IMAGE virtual void write(const char* str, size_t len) = 0; +#ifndef NATIVE_IMAGE virtual void rotate_log(bool force, outputStream* out = nullptr) {} // GC log rotation virtual ~outputStream() {} // close properly on deletion @@ -165,8 +177,10 @@ class outputStream : public CHeapObjBase { void dec_cr() { dec(); cr(); } void inc_cr() { inc(); cr(); } +#endif // !NATIVE_IMAGE }; +#ifndef NATIVE_IMAGE // standard output // ANSI C++ name collision extern outputStream* tty; // tty output @@ -227,6 +241,7 @@ class ttyUnlocker: StackObj { } } }; +#endif // !NATIVE_IMAGE // for writing to strings; buffer will expand automatically. // Buffer will always be zero-terminated. @@ -248,9 +263,11 @@ class stringStream : public outputStream { // Create a stringStream using an internal buffer of initially initial_bufsize size; // will be enlarged on demand. There is no maximum cap. stringStream(size_t initial_capacity = 0); +#ifndef NATIVE_IMAGE // Creates a stringStream using a caller-provided buffer. Will truncate silently if // it overflows. stringStream(char* fixed_buffer, size_t fixed_buffer_size); +#endif // !NATIVE_IMAGE ~stringStream(); virtual void write(const char* c, size_t len); // Return number of characters written into buffer, excluding terminating zero and @@ -266,13 +283,16 @@ class stringStream : public outputStream { DEBUG_ONLY(_is_frozen = true); return _buffer; }; +#ifndef NATIVE_IMAGE void reset(); bool is_empty() const { return _buffer[0] == '\0'; } // Copy to a resource, or C-heap, array as requested char* as_string(bool c_heap = false) const; char* as_string(Arena* arena) const; +#endif // !NATIVE_IMAGE }; +#ifndef NATIVE_IMAGE class fileStream : public outputStream { protected: FILE* _file; @@ -377,5 +397,6 @@ class networkStream : public bufferedStream { }; #endif +#endif // !NATIVE_IMAGE #endif // SHARE_UTILITIES_OSTREAM_HPP From b3bebe4e207e877bebc20a99c6188a2833085853 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Mon, 30 Jun 2025 11:01:33 +0200 Subject: [PATCH 5/7] svm: adopt "JDK-8347719: [REDO] Portable implementation of FORBID_C_FUNCTION and ALLOW_C_FUNCTION" --- .../src/hotspot/share/runtime/os.cpp | 2 + .../share/utilities/globalDefinitions.hpp | 2 + .../utilities/permitForbiddenFunctions.hpp | 80 +++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp index 9d2b31f40104..9cb23a06ab27 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp @@ -86,7 +86,9 @@ #include "utilities/fastrand.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" +#endif // !NATIVE_IMAGE #include "utilities/permitForbiddenFunctions.hpp" +#ifndef NATIVE_IMAGE #include "utilities/powerOfTwo.hpp" #ifdef LINUX diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp index 0dc49ff21952..97471b44875f 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp @@ -28,7 +28,9 @@ #include "utilities/compilerWarnings.hpp" #include "utilities/debug.hpp" +#ifndef NATIVE_IMAGE #include "utilities/forbiddenFunctions.hpp" +#endif // !NATIVE_IMAGE #include "utilities/macros.hpp" #ifndef NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp new file mode 100644 index 000000000000..32b2b0859092 --- /dev/null +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024, 2025, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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 SHARE_UTILITIES_PERMITFORBIDDENFUNCTIONS_HPP +#define SHARE_UTILITIES_PERMITFORBIDDENFUNCTIONS_HPP + +#include "utilities/compilerWarnings.hpp" +#include "utilities/globalDefinitions.hpp" + +#ifndef NATIVE_IMAGE +#ifdef _WINDOWS +#include "permitForbiddenFunctions_windows.hpp" +#else +#include "permitForbiddenFunctions_posix.hpp" +#endif +#endif // !NATIVE_IMAGE + +// Provide wrappers for some functions otherwise forbidden from use in HotSpot. +// +// There may be special circumstances where an otherwise forbidden function +// really does need to be used. One example is in the implementation of a +// corresponding os:: function. +// +// Wrapper functions are provided for such forbidden functions. These +// wrappers are defined in a context where the forbidding warnings are +// suppressed. They are defined in a special namespace, to highlight uses as +// unusual and requiring increased scrutiny. +// +// Note that there are several seemingly plausible shorter alternatives to +// these written-out wrapper functions. All that have been tried don't work +// for one reason or another. + +namespace permit_forbidden_function { +BEGIN_ALLOW_FORBIDDEN_FUNCTIONS + +#ifndef NATIVE_IMAGE +[[noreturn]] inline void exit(int status) { ::exit(status); } +[[noreturn]] inline void _exit(int status) { ::_exit(status); } +#endif // !NATIVE_IMAGE + +ATTRIBUTE_PRINTF(3, 0) +inline int vsnprintf(char* str, size_t size, const char* format, va_list ap) { + return ::vsnprintf(str, size, format, ap); +} + +#ifndef NATIVE_IMAGE +inline void* malloc(size_t size) { return ::malloc(size); } +inline void free(void* ptr) { return ::free(ptr); } +inline void* calloc(size_t nmemb, size_t size) { return ::calloc(nmemb, size); } +inline void* realloc(void* ptr, size_t size) { return ::realloc(ptr, size); } + +inline char* strdup(const char* s) { return ::strdup(s); } +#endif // !NATIVE_IMAGE + +END_ALLOW_FORBIDDEN_FUNCTIONS +} // namespace permit_forbidden_function + +#endif // SHARE_UTILITIES_PERMITFORBIDDENFUNCTIONS_HPP From 293b184f05a938018cb2b512350c86c4150dd6ba Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Mon, 30 Jun 2025 11:05:23 +0200 Subject: [PATCH 6/7] svm: readd libcontainer namespace --- .../os/linux/cgroupSubsystem_linux.cpp | 6 +++ .../os/linux/cgroupSubsystem_linux.hpp | 6 +++ .../src/hotspot/os/linux/cgroupUtil_linux.cpp | 6 +++ .../src/hotspot/os/linux/cgroupUtil_linux.hpp | 6 +++ .../os/linux/cgroupV1Subsystem_linux.cpp | 6 +++ .../os/linux/cgroupV1Subsystem_linux.hpp | 6 +++ .../os/linux/cgroupV2Subsystem_linux.cpp | 6 +++ .../os/linux/cgroupV2Subsystem_linux.hpp | 6 +++ .../hotspot/os/linux/osContainer_linux.cpp | 6 +++ .../hotspot/os/linux/osContainer_linux.hpp | 6 +++ .../src/hotspot/os/linux/os_linux.cpp | 18 +++++++ .../src/hotspot/os/linux/os_linux.hpp | 6 +++ .../src/hotspot/os/linux/os_linux.inline.hpp | 6 +++ .../src/hotspot/os/posix/os_posix.cpp | 12 +++++ .../src/hotspot/os/posix/os_posix.hpp | 6 +++ .../src/hotspot/os/posix/os_posix.inline.hpp | 6 +++ .../src/hotspot/share/memory/allStatic.hpp | 6 +++ .../src/hotspot/share/memory/allocation.hpp | 6 +++ .../share/memory/allocation.inline.hpp | 12 +++++ .../src/hotspot/share/nmt/memTag.hpp | 6 +++ .../src/hotspot/share/runtime/os.cpp | 12 +++++ .../src/hotspot/share/runtime/os.hpp | 12 +++++ .../src/hotspot/share/runtime/os.inline.hpp | 24 +++++++++ .../hotspot/share/utilities/checkedCast.hpp | 6 +++ .../share/utilities/globalDefinitions.hpp | 52 ++++++++++++++++++- .../share/utilities/globalDefinitions_gcc.hpp | 24 +++++++++ .../src/hotspot/share/utilities/ostream.cpp | 24 +++++++++ .../src/hotspot/share/utilities/ostream.hpp | 12 +++++ .../utilities/permitForbiddenFunctions.hpp | 6 +++ .../src/java.base/share/native/include/jni.h | 6 +++ .../java.base/unix/native/include/jni_md.h | 6 +++ .../src/svm/share/memory/allocation.cpp | 6 +++ .../src/svm/share/runtime/globals.hpp | 6 +++ .../src/svm/share/utilities/debug.cpp | 12 +++++ .../src/svm/share/utilities/debug.hpp | 12 +++++ .../src/svm/svm_container.cpp | 6 +++ .../src/svm/svm_container.hpp | 6 +++ 37 files changed, 374 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp index 03b003d05fb2..3e74f42f618c 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp @@ -44,6 +44,9 @@ #endif // controller names have to match the *_IDX indices + +namespace svm_container { + static const char* cg_controller_name[] = { "cpuset", "cpu", "cpuacct", "memory", "pids" }; static inline int cg_v2_controller_index(const char* name) { if (strcmp(name, "cpuset") == 0) { @@ -900,3 +903,6 @@ void CgroupSubsystem::print_version_specific_info(outputStream* st) { memory_controller()->controller()->print_version_specific_info(st, phys_mem); } #endif // !NATIVE_IMAGE + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp index c504d61ef49b..514d84c786bc 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp @@ -103,6 +103,9 @@ log_trace(os, container)(log_string " is: %s", retval); \ } + +namespace svm_container { + class CgroupController: public CHeapObj { protected: char* _cgroup_path; @@ -361,4 +364,7 @@ class CgroupSubsystemFactory: AllStatic { static void cleanup(CgroupInfo* cg_infos); }; + +} // namespace svm_container + #endif // CGROUP_SUBSYSTEM_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp index 863d4fadf3fd..f7bdfe3b3785 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp @@ -27,6 +27,9 @@ #include "os_linux.hpp" #include "cgroupUtil_linux.hpp" + +namespace svm_container { + int CgroupUtil::processor_count(CgroupCpuController* cpu_ctrl, int host_cpus) { assert(host_cpus > 0, "physical host cpus must be positive"); int limit_count = host_cpus; @@ -175,3 +178,6 @@ void CgroupUtil::adjust_controller(CgroupCpuController* cpu) { os::free(orig); os::free(limit_cg_path); } + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp index b97e7406f56c..f915da085b78 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.hpp @@ -30,6 +30,9 @@ #include "utilities/globalDefinitions.hpp" #include "cgroupSubsystem_linux.hpp" + +namespace svm_container { + class CgroupUtil: AllStatic { public: @@ -42,4 +45,7 @@ class CgroupUtil: AllStatic { static void adjust_controller(CgroupCpuController* c); }; + +} // namespace svm_container + #endif // CGROUP_UTIL_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp index 8d0a664b92e5..ee5c09bd51c2 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp @@ -80,6 +80,9 @@ * component is found. The subsystem path will be set to * the _mount_point joined with the subgroup path. */ + +namespace svm_container { + void CgroupV1Controller::set_subsystem_path(const char* cgroup_path) { if (_cgroup_path != nullptr) { os::free(_cgroup_path); @@ -462,3 +465,6 @@ jlong CgroupV1Subsystem::pids_current() { CONTAINER_READ_NUMBER_CHECKED(_pids, "/pids.current", "Current number of tasks", pids_current); return (jlong)pids_current; } + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp index ce0c5acee6ac..4019e46d52e5 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp @@ -33,6 +33,9 @@ // Cgroups version 1 specific implementation + +namespace svm_container { + class CgroupV1Controller: public CgroupController { private: /* mountinfo contents */ @@ -210,4 +213,7 @@ class CgroupV1Subsystem: public CgroupSubsystem { }; + +} // namespace svm_container + #endif // CGROUP_V1_SUBSYSTEM_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp index cc1b7e770008..7015bc6c9206 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp @@ -28,6 +28,9 @@ #include "cgroupUtil_linux.hpp" // Constructor + +namespace svm_container { + CgroupV2Controller::CgroupV2Controller(char* mount_path, char *cgroup_path, bool ro) : _read_only(ro), @@ -375,3 +378,6 @@ jlong CgroupV2Subsystem::pids_current() { CONTAINER_READ_NUMBER_CHECKED(unified(), "/pids.current", "Current number of tasks", pids_current); return pids_current; } + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp index 6b25ca0be127..1d754321265f 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp @@ -30,6 +30,9 @@ #include "cgroupSubsystem_linux.hpp" #include "cgroupUtil_linux.hpp" + +namespace svm_container { + class CgroupV2Controller: public CgroupController { private: bool _read_only; @@ -176,4 +179,7 @@ class CgroupV2Subsystem: public CgroupSubsystem { CgroupCpuacctController* cpuacct_controller() override { return _cpuacct; }; }; + +} // namespace svm_container + #endif // CGROUP_V2_SUBSYSTEM_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp index de3273595754..9c8c2ee1eeee 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp @@ -34,6 +34,9 @@ #include "cgroupSubsystem_linux.hpp" + +namespace svm_container { + bool OSContainer::_is_initialized = false; bool OSContainer::_is_containerized = false; CgroupSubsystem* cgroup_subsystem; @@ -214,3 +217,6 @@ void OSContainer::print_container_helper(outputStream* st, jlong j, const char* } } #endif // !NATIVE_IMAGE + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp index bcaa47e33e2e..50437e8649f6 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp @@ -36,6 +36,9 @@ // 20ms timeout between re-reads of memory limit and _active_processor_count. #define OSCONTAINER_CACHE_TIMEOUT (NANOSECS_PER_SEC/50) + +namespace svm_container { + class OSContainer: AllStatic { private: @@ -83,4 +86,7 @@ inline bool OSContainer::is_containerized() { return _is_containerized; } + +} // namespace svm_container + #endif // OS_LINUX_OSCONTAINER_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp index 589c4ae39347..d78947241ad8 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp @@ -152,24 +152,39 @@ #ifdef MUSL_LIBC // dlvsym is not a part of POSIX // and musl libc doesn't implement it. + +namespace svm_container { + static void *dlvsym(void *handle, const char *symbol, const char *version) { // load the latest version of symbol return dlsym(handle, symbol); } + +} // namespace svm_container + #endif + +namespace svm_container { + enum CoredumpFilterBit { FILE_BACKED_PVT_BIT = 1 << 2, FILE_BACKED_SHARED_BIT = 1 << 3, LARGEPAGES_BIT = 1 << 6, DAX_SHARED_BIT = 1 << 8 }; + +} // namespace svm_container + #endif // !NATIVE_IMAGE //////////////////////////////////////////////////////////////////////////////// // global variables + +namespace svm_container { + julong os::Linux::_physical_memory = 0; #ifndef NATIVE_IMAGE @@ -5432,3 +5447,6 @@ bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) { } // end: os::pd_dll_unload() #endif // !NATIVE_IMAGE + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp index 969290b0ea51..ab500317165b 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.hpp @@ -30,6 +30,9 @@ // os::Linux defines the interface to Linux operating systems + +namespace svm_container { + class os::Linux { friend class os; @@ -475,4 +478,7 @@ class os::Linux { #endif // !NATIVE_IMAGE }; + +} // namespace svm_container + #endif // OS_LINUX_OS_LINUX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp index a31cfbf30cd4..4ebdfc8623d5 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.inline.hpp @@ -32,6 +32,9 @@ #include "os_posix.inline.hpp" #ifndef NATIVE_IMAGE + +namespace svm_container { + inline bool os::zero_page_read_protected() { return true; } @@ -57,6 +60,9 @@ inline bool os::can_trim_native_heap() { return false; // musl #endif } + +} // namespace svm_container + #endif // !NATIVE_IMAGE #endif // OS_LINUX_OS_LINUX_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp index 00f18bd05b72..dc1026104838 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp @@ -103,6 +103,9 @@ #endif /* Input/Output types for mincore(2) */ + +namespace svm_container { + typedef LINUX_ONLY(unsigned) char mincore_vec_t; static jlong initial_time_count = 0; @@ -1027,8 +1030,14 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { return result; } + +} // namespace svm_container + #endif // !NATIVE_IMAGE + +namespace svm_container { + int os::stat(const char *path, struct stat *sbuf) { return ::stat(path, sbuf); } @@ -2299,3 +2308,6 @@ const void* os::get_saved_assert_context(const void** sigInfo) { return nullptr; } #endif // !NATIVE_IMAGE + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp index 969901c864d0..bd92702bd097 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp @@ -52,6 +52,9 @@ return _result; \ } while(false) + +namespace svm_container { + class os::Posix { friend class os; @@ -102,6 +105,9 @@ class os::Posix { const void* ucVoid, address* stub); }; + +} // namespace svm_container + #endif // !NATIVE_IMAGE #endif // OS_POSIX_OS_POSIX_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp index de050c3c4453..a0a2bf66dabb 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.inline.hpp @@ -37,6 +37,9 @@ #include // Aix does not have NUMA support but need these for compilation. + +namespace svm_container { + inline bool os::numa_has_group_homing() { AIX_ONLY(ShouldNotReachHere();) return false; } // Platform Mutex/Monitor implementation @@ -66,6 +69,9 @@ inline void PlatformMonitor::notify_all() { int status = pthread_cond_broadcast(cond()); assert_status(status == 0, status, "cond_broadcast"); } + +} // namespace svm_container + #endif // !NATIVE_IMAGE #endif // OS_POSIX_OS_POSIX_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp index 4f3761b470ee..031c8b19df40 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allStatic.hpp @@ -30,9 +30,15 @@ // using classes for grouping. Deriving from this class indicates the // derived class is intended to be a namespace, with no instances ever // created. + +namespace svm_container { + struct AllStatic { AllStatic() = delete; ~AllStatic() = delete; }; + +} // namespace svm_container + #endif // SHARE_MEMORY_ALLSTATIC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp index eaf613bb6ab2..970446354c0e 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp @@ -34,6 +34,9 @@ #include + +namespace svm_container { + class outputStream; class Thread; class JavaThread; @@ -595,4 +598,7 @@ class MallocArrayAllocator : public AllStatic { }; #endif // !NATIVE_IMAGE + +} // namespace svm_container + #endif // SHARE_MEMORY_ALLOCATION_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp index 04594aa91148..9304d21b704b 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp @@ -39,6 +39,9 @@ #ifndef PRODUCT // Increments unsigned long value for statistics (not atomic on MP, but avoids word-tearing on 32 bit). + +namespace svm_container { + inline void inc_stat_counter(volatile julong* dest, julong add_value) { #ifdef _LP64 *dest += add_value; @@ -47,8 +50,14 @@ inline void inc_stat_counter(volatile julong* dest, julong add_value) { Atomic::store(dest, value + add_value); #endif } + +} // namespace svm_container + #endif + +namespace svm_container { + template size_t MmapArrayAllocator::size_for(size_t length) { size_t size = length * sizeof(E); @@ -112,6 +121,9 @@ template void MallocArrayAllocator::free(E* addr) { FreeHeap(addr); } + +} // namespace svm_container + #endif // !NATIVE_IMAGE #endif // SHARE_MEMORY_ALLOCATION_INLINE_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp index 1bf27dce8db2..5489e919d4d5 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/nmt/memTag.hpp @@ -65,6 +65,9 @@ #define MEMORY_TAG_DECLARE_ENUM(mem_tag, human_readable) \ mem_tag, + +namespace svm_container { + enum class MemTag : uint8_t { MEMORY_TAG_DO(MEMORY_TAG_DECLARE_ENUM) mt_number_of_tags // number of memory tags (mtDontTrack @@ -80,4 +83,7 @@ MEMORY_TAG_DO(MEMORY_TAG_SHORTNAME) // Make an int version of the sentinel end value. constexpr int mt_number_of_tags = static_cast(MemTag::mt_number_of_tags); + +} // namespace svm_container + #endif // SHARE_NMT_MEM_TAG_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp index 9cb23a06ab27..714fcc806931 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp @@ -102,9 +102,18 @@ # include # include + +namespace svm_container { + OSThread* os::_starting_thread = nullptr; volatile unsigned int os::_rand_seed = 1234567; + +} // namespace svm_container + #endif // !NATIVE_IMAGE + +namespace svm_container { + int os::_processor_count = 0; #ifndef NATIVE_IMAGE int os::_initial_active_processor_count = 0; @@ -2682,3 +2691,6 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name, return agent_entry_name; } #endif // !NATIVE_IMAGE + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp index 5f49329c15dc..187f48caccac 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp @@ -40,6 +40,9 @@ # include #endif + +namespace svm_container { + class frame; class JvmtiAgent; @@ -157,10 +160,16 @@ const bool ExecMem = true; typedef void (*java_call_t)(JavaValue* value, const methodHandle& method, JavaCallArguments* args, JavaThread* thread); class MallocTracker; + +} // namespace svm_container + #endif // !NATIVE_IMAGE // Preserve errno across a range of calls + +namespace svm_container { + class ErrnoPreserver { int _e; @@ -1139,4 +1148,7 @@ class os: AllStatic { extern "C" int SpinPause(); #endif // !NATIVE_IMAGE + +} // namespace svm_container + #endif // SHARE_RUNTIME_OS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp index 0719c472f3f8..0b4f2b1602ba 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.inline.hpp @@ -36,29 +36,53 @@ // Provide default empty implementation. #ifndef HAVE_PLATFORM_PRINT_NATIVE_STACK + +namespace svm_container { + inline bool os::platform_print_native_stack(outputStream* st, const void* context, char *buf, int buf_size, address& lastpc) { return false; } + +} // namespace svm_container + #endif #ifndef HAVE_CDS_CORE_REGION_ALIGNMENT + +namespace svm_container { + inline size_t os::cds_core_region_alignment() { return (size_t)os::vm_allocation_granularity(); } + +} // namespace svm_container + #endif #ifndef _WINDOWS // Currently used only on Windows. + +namespace svm_container { + inline bool os::register_code_area(char *low, char *high) { return true; } + +} // namespace svm_container + #endif #ifndef HAVE_FUNCTION_DESCRIPTORS + +namespace svm_container { + inline void* os::resolve_function_descriptor(void* p) { return nullptr; } + +} // namespace svm_container + #endif #endif // !NATIVE_IMAGE diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp index 3379586aded9..27922a92b909 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/checkedCast.hpp @@ -36,6 +36,9 @@ // reversible without loss of information. It doesn't check // everything: it isn't intended to make sure that pointer types are // compatible, for example. + +namespace svm_container { + template constexpr T2 checked_cast(T1 thing) { T2 result = static_cast(thing); @@ -43,5 +46,8 @@ constexpr T2 checked_cast(T1 thing) { return result; } + +} // namespace svm_container + #endif // SHARE_UTILITIES_CHECKEDCAST_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp index 97471b44875f..b475b02dbcee 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp @@ -46,7 +46,13 @@ #include #ifndef NATIVE_IMAGE + +namespace svm_container { + class oopDesc; + +} // namespace svm_container + #endif // !NATIVE_IMAGE // Defaults for macros that might be defined per compiler. @@ -173,6 +179,9 @@ class oopDesc; #endif // _LP64 // Convert pointer to intptr_t, for use in printing pointers. + +namespace svm_container { + inline intptr_t p2i(const volatile void* p) { return (intptr_t) p; } @@ -268,6 +277,9 @@ inline size_t heap_word_size(size_t byte_size) { inline jfloat jfloat_cast(jint x); inline jdouble jdouble_cast(jlong x); + +} // namespace svm_container + #endif // !NATIVE_IMAGE //------------------------------------------- @@ -277,6 +289,9 @@ inline jdouble jdouble_cast(jlong x); #define CONST64(x) (x ## LL) #define UCONST64(x) (x ## ULL) + +namespace svm_container { + const jlong min_jlong = CONST64(0x8000000000000000); const jlong max_jlong = CONST64(0x7fffffffffffffff); @@ -524,7 +539,13 @@ typedef jshort s2; typedef jint s4; typedef jlong s8; + +} // namespace svm_container + #ifndef NATIVE_IMAGE + +namespace svm_container { + const jbyte min_jbyte = -(1 << 7); // smallest jbyte const jbyte max_jbyte = (1 << 7) - 1; // largest jbyte const jshort min_jshort = -(1 << 15); // smallest jshort @@ -581,6 +602,9 @@ extern uint64_t OopEncodingHeapMax; // Machine dependent stuff + +} // namespace svm_container + #include CPU_HEADER(globalDefinitions) // The maximum size of the code cache. Can be overridden by targets. @@ -598,11 +622,23 @@ extern uint64_t OopEncodingHeapMax; // by Luc Maranget, Susmit Sarkar and Peter Sewell, INRIA/Cambridge) #ifdef CPU_MULTI_COPY_ATOMIC // Not needed. + +namespace svm_container { + const bool support_IRIW_for_not_multiple_copy_atomic_cpu = false; + +} // namespace svm_container + #else // From all non-multi-copy-atomic architectures, only PPC64 supports IRIW at the moment. // Final decision is subject to JEP 188: Java Memory Model Update. + +namespace svm_container { + const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_PPC64(false); + +} // namespace svm_container + #endif // The expected size in bytes of a cache line. @@ -623,6 +659,9 @@ const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_ // All fabs() callers should call this function instead, which will implicitly // convert the operand to double, avoiding a dependency on __fabsf which // doesn't exist in early versions of Solaris 8. + +namespace svm_container { + inline double fabsd(double value) { return fabs(value); } @@ -1049,8 +1088,8 @@ const intptr_t badDispHeaderOSR = 0xDEAD05A0; // value to fill unu // (These must be implemented as #defines because C++ compilers are // not obligated to inline non-integral constants!) -#define badAddress ((address)::badAddressVal) -#define badHeapWord (::badHeapWordVal) +#define badAddress ((address)svm_container::badAddressVal) +#define badHeapWord (svm_container::badHeapWordVal) // Default TaskQueue size is 16K (32-bit) or 128K (64-bit) const uint TASKQUEUE_SIZE = (NOT_LP64(1<<14) LP64_ONLY(1<<17)); @@ -1098,6 +1137,9 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) { #ifdef min #undef min #endif + +} // namespace svm_container + #endif // !NATIVE_IMAGE // It is necessary to use templates here. Having normal overloaded @@ -1105,6 +1147,9 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) { // and 64-bit overloaded functions, which does not work, and having // explicitly-typed versions of these routines (i.e., MAX2I, MAX2L) // will be even more error-prone than macros. + +namespace svm_container { + template constexpr T MAX2(T a, T b) { return (a > b) ? a : b; } template constexpr T MIN2(T a, T b) { return (a < b) ? a : b; } #ifndef NATIVE_IMAGE @@ -1361,4 +1406,7 @@ std::add_rvalue_reference_t declval() noexcept; bool IEEE_subnormal_handling_OK(); #endif // !NATIVE_IMAGE + +} // namespace svm_container + #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index 10d7501b715b..81d9e6360d75 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions_gcc.hpp @@ -47,7 +47,13 @@ #if (defined(__VEC__) || defined(__AIXVEC)) && defined(AIX) \ && defined(__open_xl_version__) && __open_xl_version__ >= 17 #undef malloc + +namespace svm_container { + extern void *malloc(size_t) asm("vec_malloc"); + +} // namespace svm_container + #endif #include @@ -74,16 +80,31 @@ // checking for nanness #if defined(__APPLE__) + +namespace svm_container { + inline int g_isnan(double f) { return isnan(f); } + +} // namespace svm_container + #elif defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(_AIX) + +namespace svm_container { + inline int g_isnan(float f) { return isnan(f); } inline int g_isnan(double f) { return isnan(f); } + +} // namespace svm_container + #else #error "missing platform-specific definition here" #endif // Checking for finiteness + +namespace svm_container { + inline int g_isfinite(jfloat f) { return isfinite(f); } inline int g_isfinite(jdouble f) { return isfinite(f); } @@ -117,4 +138,7 @@ inline int g_isfinite(jdouble f) { return isfinite(f); } #define ALWAYSINLINE inline __attribute__ ((always_inline)) #define ATTRIBUTE_FLATTEN __attribute__ ((flatten)) + +} // namespace svm_container + #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_GCC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp index afbb3c6b7b5d..d1b72989cb67 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp @@ -46,6 +46,9 @@ #include "utilities/xmlstream.hpp" // Declarations of jvm methods + +namespace svm_container { + extern "C" void jio_print(const char* s, size_t len); extern "C" int jio_printf(const char *fmt, ...); @@ -195,7 +198,13 @@ void outputStream::vprint_cr(const char* format, va_list argptr) { do_vsnprintf_and_write(format, argptr, true); } + +} // namespace svm_container + #endif // !NATIVE_IMAGE + +namespace svm_container { + void outputStream::print_raw(const char* str, size_t len) { #ifndef NATIVE_IMAGE if (_autoindent && _position == 0) { @@ -463,6 +472,9 @@ stringStream::~stringStream() { } } + +} // namespace svm_container + #ifndef NATIVE_IMAGE // tty needs to be always accessible since there are code paths that may write to it // outside of the VM lifespan. @@ -473,6 +485,9 @@ stringStream::~stringStream() { // The policy followed here is a compromise reached during review of JDK-8292351: // - pre-init: we silently swallow all output. We won't see anything, but at least won't crash // - post-exit: we write to a simple fdStream, but somewhat mimic the behavior of the real defaultStream + +namespace svm_container { + static nullStream tty_preinit_stream; outputStream* tty = &tty_preinit_stream; @@ -1092,6 +1107,9 @@ bufferedStream::~bufferedStream() { FREE_C_HEAP_ARRAY(char, buffer); } + +} // namespace svm_container + #ifndef PRODUCT #if defined(LINUX) || defined(AIX) || defined(_ALLBSD_SOURCE) @@ -1105,6 +1123,9 @@ bufferedStream::~bufferedStream() { #endif // Network access + +namespace svm_container { + networkStream::networkStream() : bufferedStream(1024*10, 1024*10) { _socket = -1; @@ -1168,6 +1189,9 @@ bool networkStream::connect(const char *host, short port) { freeaddrinfo(addr_info); return (conn >= 0); } + +} // namespace svm_container + #endif // !NATIVE_IMAGE #endif diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp index bb1b4d106458..24c66ca59d74 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp @@ -34,7 +34,13 @@ #include "utilities/macros.hpp" #ifndef NATIVE_IMAGE + +namespace svm_container { + DEBUG_ONLY(class ResourceMark;) + +} // namespace svm_container + #endif // !NATIVE_IMAGE // Output streams for printing @@ -48,6 +54,9 @@ DEBUG_ONLY(class ResourceMark;) // This allows for redirection via -XX:+DisplayVMOutputToStdout and // -XX:+DisplayVMOutputToStderr. + +namespace svm_container { + class outputStream : public CHeapObjBase { friend class StreamIndentor; @@ -399,4 +408,7 @@ class networkStream : public bufferedStream { #endif #endif // !NATIVE_IMAGE + +} // namespace svm_container + #endif // SHARE_UTILITIES_OSTREAM_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp index 32b2b0859092..6b9e406bcdee 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp @@ -52,6 +52,9 @@ // these written-out wrapper functions. All that have been tried don't work // for one reason or another. + +namespace svm_container { + namespace permit_forbidden_function { BEGIN_ALLOW_FORBIDDEN_FUNCTIONS @@ -77,4 +80,7 @@ inline char* strdup(const char* s) { return ::strdup(s); } END_ALLOW_FORBIDDEN_FUNCTIONS } // namespace permit_forbidden_function + +} // namespace svm_container + #endif // SHARE_UTILITIES_PERMITFORBIDDENFUNCTIONS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/share/native/include/jni.h b/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/share/native/include/jni.h index 1a31c38b3ce7..0e53f0635438 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/share/native/include/jni.h +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/share/native/include/jni.h @@ -44,6 +44,9 @@ #include "jni_md.h" + +namespace svm_container { + #ifdef __cplusplus extern "C" { #endif @@ -2010,4 +2013,7 @@ JNI_OnUnload(JavaVM *vm, void *reserved); } /* extern "C" */ #endif /* __cplusplus */ + +} // namespace svm_container + #endif /* !_JAVASOFT_JNI_H_ */ diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/unix/native/include/jni_md.h b/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/unix/native/include/jni_md.h index b4ed87e0c48b..dc0b96c38eec 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/unix/native/include/jni_md.h +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/java.base/unix/native/include/jni_md.h @@ -52,6 +52,9 @@ #define JNIIMPORT #endif + +namespace svm_container { + typedef int jint; #ifdef _LP64 typedef long jlong; @@ -61,4 +64,7 @@ typedef long long jlong; typedef signed char jbyte; + +} // namespace svm_container + #endif /* !_JAVASOFT_JNI_MD_H_ */ diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/memory/allocation.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/memory/allocation.cpp index e72481e07bb9..606919e7fd76 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/memory/allocation.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/memory/allocation.cpp @@ -26,6 +26,9 @@ #include "memory/allocation.hpp" #include "runtime/os.hpp" + +namespace svm_container { + char* AllocateHeap(size_t size, MemTag mem_tag, AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) { @@ -46,3 +49,6 @@ char* ReallocateHeap(char* old, void FreeHeap(void* p) { os::free(p); } + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/runtime/globals.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/runtime/globals.hpp index 8c6b3cb6cf6c..bc0aecdd8151 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/runtime/globals.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/runtime/globals.hpp @@ -29,7 +29,13 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" + +namespace svm_container { + constexpr bool UseCpuAllocPath = false; constexpr bool UseContainerSupport = true; + +} // namespace svm_container + #endif // SHARE_RUNTIME_GLOBALS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.cpp index 0be1d5d79791..73d1d316813a 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.cpp @@ -31,6 +31,9 @@ #include #ifdef PRINT_WARNINGS + +namespace svm_container { + ATTRIBUTE_PRINTF(1, 2) void warning(const char* format, ...) { FILE* const err = stderr; @@ -40,9 +43,15 @@ void warning(const char* format, ...) { va_end(ap); fputc('\n', err); } + +} // namespace svm_container + #endif #ifdef ASSERT + +namespace svm_container { + ATTRIBUTE_PRINTF(4, 5) void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...) { FILE* const err = stderr; @@ -58,4 +67,7 @@ void report_vm_error(const char* file, int line, const char* error_msg) { report_vm_error(file, line, error_msg, "%s", ""); } + +} // namespace svm_container + #endif diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.hpp index 8056a057a722..dc125fb09ed9 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/share/utilities/debug.hpp @@ -30,6 +30,9 @@ #ifdef ASSERT // error reporting helper functions + +namespace svm_container { + [[noreturn]] void report_vm_error(const char* file, int line, const char* error_msg); @@ -37,6 +40,9 @@ void report_vm_error(const char* file, int line, const char* error_msg); ATTRIBUTE_PRINTF(4, 5) void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...); + +} // namespace svm_container + #endif #ifdef ASSERT @@ -64,7 +70,13 @@ do { \ #ifndef PRINT_WARNINGS #define warning(format, ...) #else + +namespace svm_container { + void warning(const char* format, ...); + +} // namespace svm_container + #endif #define STATIC_ASSERT(Cond) static_assert((Cond), #Cond) diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.cpp index 7b1ed8c88201..accce218d6ab 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.cpp @@ -28,6 +28,9 @@ #include "osContainer_linux.hpp" #include "svm_container.hpp" + +namespace svm_container { + extern "C" { // keep in sync with ContainerLibrary.java @@ -111,3 +114,6 @@ EXPORT_FOR_SVM int svm_container_active_processor_count() { } } // extern C + +} // namespace svm_container + diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.hpp index d7a3c958b27f..dc22951769d6 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/svm/svm_container.hpp @@ -40,6 +40,9 @@ #endif #endif + +namespace svm_container { + extern "C" { EXPORT_FOR_SVM int svm_container_initialize(int version); EXPORT_FOR_SVM jlong svm_container_physical_memory(); @@ -53,4 +56,7 @@ extern "C" { EXPORT_FOR_SVM int svm_container_active_processor_count(); } + +} // namespace svm_container + #endif // SVM_CONTAINER_HPP From 14bffd664c909c68bd73cd8a5a32d05ab919ebd1 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Mon, 30 Jun 2025 11:07:35 +0200 Subject: [PATCH 7/7] svm: update ContainerLibrary @BasedOnJDKFile annotations to 26+4 --- .../svm/core/container/ContainerLibrary.java | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java index de197ccd459d..0d5021fed17e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java @@ -48,12 +48,12 @@ @CContext(ContainerLibraryDirectives.class) @CLibrary(value = "svm_container", requireStatic = true, dependsOn = "m") // The following annotations are for files in `src/hotspot`, which are copied from the JDK -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/java.base/share/native/include/jni.h") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/java.base/unix/native/include/jni_md.h") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/java.base/share/native/include/jni.h") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/java.base/unix/native/include/jni_md.h") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupSubsystem_linux.cpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupSubsystem_linux.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupUtil_linux.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupUtil_linux.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupUtil_linux.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupUtil_linux.hpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp") @@ -61,33 +61,34 @@ @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/osContainer_linux.cpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/osContainer_linux.hpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/os_linux.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/os_linux.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/os_linux.inline.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/posix/include/jvm_md.h") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/os_linux.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/os_linux.inline.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/posix/include/jvm_md.h") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+2/src/hotspot/os/posix/os_posix.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+25/src/hotspot/os/posix/os_posix.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/posix/os_posix.inline.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+26/src/hotspot/share/memory/allocation.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/memory/allocation.inline.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/memory/allStatic.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/nmt/memTag.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+22/src/hotspot/share/runtime/os.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+25/src/hotspot/share/runtime/os.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/runtime/os.inline.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/utilities/checkedCast.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+22/src/hotspot/share/utilities/compilerWarnings_gcc.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+22/src/hotspot/share/utilities/compilerWarnings.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/utilities/globalDefinitions_gcc.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/share/utilities/globalDefinitions.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/utilities/macros.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/share/utilities/ostream.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/share/utilities/ostream.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/posix/os_posix.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/posix/os_posix.inline.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/memory/allocation.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/memory/allocation.inline.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/memory/allStatic.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/nmt/memTag.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/runtime/os.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/runtime/os.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/runtime/os.inline.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/checkedCast.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/compilerWarnings_gcc.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/compilerWarnings.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/globalDefinitions_gcc.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/globalDefinitions.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/macros.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/ostream.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/ostream.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/permitForbiddenFunctions.hpp") // The following annotations are for files in `src/svm`, which are completely customized for SVM -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/logging/log.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+26/src/hotspot/share/memory/allocation.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/logging/log.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/memory/allocation.cpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/runtime/globals.hpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+3/src/hotspot/share/utilities/debug.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/utilities/debug.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/debug.hpp") public class ContainerLibrary { static final int VERSION = 240100;