8290840: Refactor the "os" class

Reviewed-by: dholmes, gziemski, stuefe, stefank
This commit is contained in:
Ioi Lam 2022-08-04 01:20:29 +00:00
parent 4cfbb3b5ec
commit b6b0317f83
88 changed files with 624 additions and 615 deletions

View File

@ -28,13 +28,11 @@
#include "runtime/arguments.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"
#include "runtime/os.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/vm_version.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/macros.hpp"
#include OS_HEADER_INLINE(os)
int VM_Version::_cpu;
int VM_Version::_model;
int VM_Version::_model2;

View File

@ -38,6 +38,7 @@
#include "oops/compressedOops.hpp"
#include "oops/objArrayKlass.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubRoutines.hpp"

View File

@ -34,6 +34,7 @@
#include "gc/shared/barrierSetAssembler.hpp"
#include "oops/accessDecorators.hpp"
#include "oops/compressedOops.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/vm_version.hpp"
#include "utilities/powerOfTwo.hpp"

View File

@ -38,6 +38,7 @@
#include "oops/klass.inline.hpp"
#include "prims/methodHandles.hpp"
#include "runtime/jniHandles.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"

View File

@ -41,6 +41,7 @@
#include <sys/sysinfo.h>
#if defined(_AIX)
#include "os_aix.hpp"
#include <libperfstat.h>
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,8 +29,27 @@
#define __ _masm->
// SYSCALL_RISCV_FLUSH_ICACHE is used to flush instruction cache. The "fence.i" instruction
// only work on the current hart, so kernel provides the icache flush syscall to flush icache
// on each hart. You can pass a flag to determine a global or local icache flush.
static void icache_flush(long int start, long int end)
{
const int SYSCALL_RISCV_FLUSH_ICACHE = 259;
register long int __a7 asm ("a7") = SYSCALL_RISCV_FLUSH_ICACHE;
register long int __a0 asm ("a0") = start;
register long int __a1 asm ("a1") = end;
// the flush can be applied to either all threads or only the current.
// 0 means a global icache flush, and the icache flush will be applied
// to other harts concurrently executing.
register long int __a2 asm ("a2") = 0;
__asm__ volatile ("ecall\n\t"
: "+r" (__a0)
: "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a7)
: "memory");
}
static int icache_flush(address addr, int lines, int magic) {
os::icache_flush((long int) addr, (long int) (addr + (lines << ICache::log2_line_size)));
icache_flush((long int) addr, (long int) (addr + (lines << ICache::log2_line_size)));
return magic;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -25,13 +25,11 @@
#include "precompiled.hpp"
#include "runtime/java.hpp"
#include "runtime/os.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/vm_version.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/macros.hpp"
#include OS_HEADER_INLINE(os)
const char* VM_Version::_uarch = "";
uint32_t VM_Version::_initial_vector_length = 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2022, 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
@ -28,6 +28,7 @@
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "prims/jvmtiExport.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/stubRoutines.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, 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
@ -26,12 +26,10 @@
#include "rdtsc_x86.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/orderAccess.hpp"
#include "vm_version_x86.hpp"
// The following header contains the implementations of rdtsc()
#include OS_CPU_HEADER_INLINE(os)
static jlong _epoch = 0;
static bool rdtsc_elapsed_counter_enabled = false;
static jlong tsc_frequency = 0;

View File

@ -33,14 +33,12 @@
#include "memory/universe.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"
#include "runtime/os.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/stubCodeGenerator.hpp"
#include "runtime/vm_version.hpp"
#include "utilities/powerOfTwo.hpp"
#include "utilities/virtualizationSupport.hpp"
#include OS_HEADER_INLINE(os)
int VM_Version::_cpu;
int VM_Version::_model;
int VM_Version::_stepping;

View File

@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "logging/log.hpp"
#include "os_posix.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/os.inline.hpp"
#include "services/attachListener.hpp"

View File

@ -45,6 +45,7 @@
#include "misc_aix.hpp"
#include "oops/oop.inline.hpp"
#include "os_aix.inline.hpp"
#include "os_posix.hpp"
#include "porting_aix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2016 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -26,12 +26,11 @@
#ifndef OS_AIX_OS_AIX_HPP
#define OS_AIX_OS_AIX_HPP
// Information about the protection of the page at address '0' on this os.
static bool zero_page_read_protected() { return false; }
#include "runtime/os.hpp"
// Class Aix defines the interface to the Aix operating systems.
class Aix {
class os::Aix {
friend class os;
private:
@ -177,6 +176,9 @@ class Aix {
// (on AIX, using libperfstat, on PASE with libo4.so).
// Returns true if ok, false if error.
static bool get_meminfo(meminfo_t* pmi);
static bool platform_print_native_stack(outputStream* st, void* context, char *buf, int buf_size);
static void* resolve_function_descriptor(void* p);
};
#endif // OS_AIX_OS_AIX_HPP

View File

@ -26,11 +26,16 @@
#ifndef OS_AIX_OS_AIX_INLINE_HPP
#define OS_AIX_OS_AIX_INLINE_HPP
// os_aix.hpp included by os.hpp
#include "os_aix.hpp"
#include "runtime/os.hpp"
#include "os_posix.inline.hpp"
// Information about the protection of the page at address '0' on this os.
inline bool os::zero_page_read_protected() {
return false;
}
inline bool os::uses_stack_guard_pages() {
return true;
}

View File

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "logging/log.hpp"
#include "os_posix.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/os.inline.hpp"
#include "services/attachListener.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -25,12 +25,11 @@
#ifndef OS_BSD_OS_BSD_HPP
#define OS_BSD_OS_BSD_HPP
#include "runtime/os.hpp"
// Bsd_OS defines the interface to Bsd operating systems
// Information about the protection of the page at address '0' on this os.
static bool zero_page_read_protected() { return true; }
class Bsd {
class os::Bsd {
friend class os;
#ifdef __APPLE__

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -25,11 +25,15 @@
#ifndef OS_BSD_OS_BSD_INLINE_HPP
#define OS_BSD_OS_BSD_INLINE_HPP
// os_bsd.hpp included by os.hpp
#include "os_bsd.hpp"
#include "runtime/os.hpp"
#include "os_posix.inline.hpp"
inline bool os::zero_page_read_protected() {
return true;
}
inline bool os::uses_stack_guard_pages() {
return true;
}

View File

@ -27,6 +27,7 @@
#include "memory/allocation.inline.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/os.inline.hpp"
#include "os_posix.hpp"
#include "services/attachListener.hpp"
#include <unistd.h>

View File

@ -30,6 +30,7 @@
#include "cgroupV2Subsystem_linux.hpp"
#include "logging/log.hpp"
#include "memory/allocation.hpp"
#include "os_linux.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
#include "utilities/globalDefinitions.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, 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
@ -25,6 +25,7 @@
#include "gc/z/zErrno.hpp"
#include "gc/z/zNUMA.hpp"
#include "gc/z/zSyscall_linux.hpp"
#include "os_linux.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
#include "utilities/debug.hpp"

View File

@ -32,6 +32,7 @@
#include "gc/z/zPhysicalMemoryBacking_linux.hpp"
#include "gc/z/zSyscall_linux.hpp"
#include "logging/log.hpp"
#include "os_linux.hpp"
#include "runtime/init.hpp"
#include "runtime/os.hpp"
#include "runtime/safefetch.hpp"

View File

@ -28,6 +28,7 @@
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
#include "logging/log.hpp"
#include "os_linux.hpp"
#include "osContainer_linux.hpp"
#include "cgroupSubsystem_linux.hpp"

View File

@ -4455,6 +4455,89 @@ void os::Linux::numa_init() {
}
}
#if defined(IA32) && !defined(ZERO)
/*
* Work-around (execute code at a high address) for broken NX emulation using CS limit,
* Red Hat patch "Exec-Shield" (IA32 only).
*
* Map and execute at a high VA to prevent CS lazy updates race with SMP MM
* invalidation.Further code generation by the JVM will no longer cause CS limit
* updates.
*
* Affects IA32: RHEL 5 & 6, Ubuntu 10.04 (LTS), 10.10, 11.04, 11.10, 12.04.
* @see JDK-8023956
*/
static void workaround_expand_exec_shield_cs_limit() {
assert(os::Linux::initial_thread_stack_bottom() != NULL, "sanity");
size_t page_size = os::vm_page_size();
/*
* JDK-8197429
*
* Expand the stack mapping to the end of the initial stack before
* attempting to install the codebuf. This is needed because newer
* Linux kernels impose a distance of a megabyte between stack
* memory and other memory regions. If we try to install the
* codebuf before expanding the stack the installation will appear
* to succeed but we'll get a segfault later if we expand the stack
* in Java code.
*
*/
if (os::is_primordial_thread()) {
address limit = os::Linux::initial_thread_stack_bottom();
if (! DisablePrimordialThreadGuardPages) {
limit += StackOverflow::stack_red_zone_size() +
StackOverflow::stack_yellow_zone_size();
}
os::Linux::expand_stack_to(limit);
}
/*
* Take the highest VA the OS will give us and exec
*
* Although using -(pagesz) as mmap hint works on newer kernel as you would
* think, older variants affected by this work-around don't (search forward only).
*
* On the affected distributions, we understand the memory layout to be:
*
* TASK_LIMIT= 3G, main stack base close to TASK_LIMT.
*
* A few pages south main stack will do it.
*
* If we are embedded in an app other than launcher (initial != main stack),
* we don't have much control or understanding of the address space, just let it slide.
*/
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);
if (codebuf == NULL) {
// JDK-8197429: There may be a stack gap of one megabyte between
// the limit of the stack and the nearest memory region: this is a
// 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);
}
if ((codebuf == NULL) || (!os::commit_memory(codebuf, page_size, true))) {
return; // No matter, we tried, best effort.
}
MemTracker::record_virtual_memory_type((address)codebuf, mtInternal);
log_info(os)("[CS limit NX emulation work-around, exec code at: %p]", codebuf);
// Some code to exec: the 'ret' instruction
codebuf[0] = 0xC3;
// Call the code in the codebuf
__asm__ volatile("call *%0" : : "r"(codebuf));
// keep the page mapped so CS limit isn't reduced.
}
#endif // defined(IA32) && !defined(ZERO)
// this is called _after_ the global arguments have been parsed
jint os::init_2(void) {

View File

@ -25,12 +25,11 @@
#ifndef OS_LINUX_OS_LINUX_HPP
#define OS_LINUX_OS_LINUX_HPP
// Linux_OS defines the interface to Linux operating systems
#include "runtime/os.hpp"
// Information about the protection of the page at address '0' on this os.
static bool zero_page_read_protected() { return true; }
// os::Linux defines the interface to Linux operating systems
class Linux {
class os::Linux {
friend class CgroupSubsystem;
friend class os;
friend class OSContainer;
@ -157,6 +156,7 @@ class Linux {
// Stack overflow handling
static bool manually_expand_stack(JavaThread * t, address addr);
static void expand_stack_to(address bottom);
// fast POSIX clocks support
static void fast_thread_clock_init(void);
@ -198,7 +198,6 @@ class Linux {
private:
static void numa_init();
static void expand_stack_to(address bottom);
typedef int (*sched_getcpu_func_t)(void);
typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
@ -428,6 +427,8 @@ class Linux {
static const GrowableArray<int>* numa_nindex_to_node() {
return _nindex_to_node;
}
void* resolve_function_descriptor(void* p);
};
#endif // OS_LINUX_OS_LINUX_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -25,11 +25,15 @@
#ifndef OS_LINUX_OS_LINUX_INLINE_HPP
#define OS_LINUX_OS_LINUX_INLINE_HPP
// os_linux.hpp included by os.hpp
#include "os_linux.hpp"
#include "runtime/os.hpp"
#include "os_posix.inline.hpp"
inline bool os::zero_page_read_protected() {
return true;
}
inline bool os::uses_stack_guard_pages() {
return true;
}

View File

@ -26,6 +26,7 @@
#include "jvm.h"
#include "memory/allocation.inline.hpp"
#include "os_linux.inline.hpp"
#include "os_posix.hpp"
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "runtime/vm_version.hpp"

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2021 SAP SE. All rights reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "logging/log.hpp"
#include "os_linux.hpp"
#include "runtime/os.hpp"
#include "utilities/debug.hpp"
#include "utilities/ostream.hpp"

View File

@ -24,9 +24,7 @@
#include "jvm.h"
#ifdef LINUX
#include "classfile/classLoader.hpp"
#endif
#include "jvmtifiles/jvmti.h"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
@ -51,6 +49,9 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include "utilities/vmError.hpp"
#ifdef LINUX
#include "os_linux.hpp"
#endif
#include <dirent.h>
#include <dlfcn.h>
@ -554,7 +555,7 @@ void os::Posix::print_umask(outputStream* st, mode_t umsk) {
st->print((umsk & S_IXOTH) ? "x" : "-");
}
void os::Posix::print_user_info(outputStream* st) {
void os::print_user_info(outputStream* st) {
unsigned id = (unsigned) ::getuid();
st->print("uid : %u ", id);
id = (unsigned) ::geteuid();
@ -568,13 +569,13 @@ void os::Posix::print_user_info(outputStream* st) {
mode_t umsk = ::umask(0);
::umask(umsk);
st->print("umask: %04o (", (unsigned) umsk);
print_umask(st, umsk);
os::Posix::print_umask(st, umsk);
st->print_cr(")");
st->cr();
}
// Print all active locale categories, one line each
void os::Posix::print_active_locale(outputStream* st) {
void os::print_active_locale(outputStream* st) {
st->print_cr("Active Locale:");
// Posix is quiet about how exactly LC_ALL is implemented.
// Just print it out too, in case LC_ALL is held separately
@ -1128,8 +1129,8 @@ bool os::Posix::handle_stack_overflow(JavaThread* thread, address addr, address
"enabled executable stack (see man page execstack(8))");
} else {
#if !defined(AIX) && !defined(__APPLE__)
// bsd and aix don't have this
#ifdef LINUX
// This only works with os::Linux::manually_expand_stack()
// Accessing stack address below sp may cause SEGV if current
// thread has MAP_GROWSDOWN stack. This should only happen when
@ -1147,7 +1148,7 @@ bool os::Posix::handle_stack_overflow(JavaThread* thread, address addr, address
}
#else
tty->print_raw_cr("SIGSEGV happened inside stack but outside yellow and red zone.");
#endif // AIX or BSD
#endif // LINUX
}
return false;
}
@ -2010,3 +2011,8 @@ void os::die() {
::abort();
}
}
const char* os::file_separator() { return "/"; }
const char* os::line_separator() { return "\n"; }
const char* os::path_separator() { return ":"; }

View File

@ -25,6 +25,10 @@
#ifndef OS_POSIX_OS_POSIX_HPP
#define OS_POSIX_OS_POSIX_HPP
#include "runtime/os.hpp"
#include <errno.h>
// 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. For example, the use of lseek64 and ftruncate64.
@ -34,12 +38,19 @@
// behaviour in API's that are defined by Posix. For example, that SIGSTKSZ
// is not defined as a constant as of Glibc 2.34.
// File conventions
static const char* file_separator() { return "/"; }
static const char* line_separator() { return "\n"; }
static const char* path_separator() { return ":"; }
// macros for restartable system calls
class Posix {
#define RESTARTABLE(_cmd, _result) do { \
_result = _cmd; \
} while(((int)_result == OS_ERR) && (errno == EINTR))
#define RESTARTABLE_RETURN_INT(_cmd) do { \
int _result; \
RESTARTABLE(_cmd, _result); \
return _result; \
} while(false)
class os::Posix {
friend class os;
protected:
@ -81,8 +92,6 @@ public:
static void print_umask(outputStream* st, mode_t umsk);
static void print_user_info(outputStream* st);
// Set PC into context. Needed for continuation after signal.
static address ucontext_get_pc(const ucontext_t* ctx);
static void ucontext_set_pc(ucontext_t* ctx, address pc);
@ -92,8 +101,6 @@ public:
static bool handle_stack_overflow(JavaThread* thread, address addr, address pc,
const void* ucVoid,
address* stub);
static void print_active_locale(outputStream* st);
};
#endif // OS_POSIX_OS_POSIX_HPP

View File

@ -25,7 +25,7 @@
#ifndef OS_POSIX_OS_POSIX_INLINE_HPP
#define OS_POSIX_OS_POSIX_INLINE_HPP
// os_posix.hpp included by os.hpp
#include "os_posix.hpp"
#include "runtime/mutex.hpp"
#include "runtime/os.hpp"
@ -34,18 +34,6 @@
#include <sys/socket.h>
#include <netdb.h>
// macros for restartable system calls
#define RESTARTABLE(_cmd, _result) do { \
_result = _cmd; \
} while(((int)_result == OS_ERR) && (errno == EINTR))
#define RESTARTABLE_RETURN_INT(_cmd) do { \
int _result; \
RESTARTABLE(_cmd, _result); \
return _result; \
} while(false)
// Aix does not have NUMA support but need these for compilation.
inline bool os::numa_has_static_binding() { AIX_ONLY(ShouldNotReachHere();) return true; }
inline bool os::numa_has_group_homing() { AIX_ONLY(ShouldNotReachHere();) return false; }

View File

@ -37,6 +37,9 @@
#include "runtime/perfMemory.hpp"
#include "services/memTracker.hpp"
#include "utilities/exceptions.hpp"
#if defined(LINUX)
#include "os_linux.hpp"
#endif
// put OS-includes here
# include <sys/types.h>

View File

@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "os_posix.hpp"
#include "runtime/os.hpp"
#include "runtime/safefetch.hpp"
#include "utilities/globalDefinitions.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, 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
@ -24,6 +24,7 @@
#include "precompiled.hpp"
#ifndef __APPLE__
#include "os_posix.hpp"
#include "runtime/os.hpp"
// POSIX unnamed semaphores are not supported on OS X.
#include "semaphore_posix.hpp"

View File

@ -29,6 +29,7 @@
#include "code/compiledMethod.hpp"
#include "code/nativeInst.hpp"
#include "logging/log.hpp"
#include "os_posix.hpp"
#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
#include "runtime/interfaceSupport.inline.hpp"

View File

@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "cds/metaspaceShared.hpp"
#include "os_posix.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/os.hpp"
#include "runtime/safefetch.hpp"

View File

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "iphlp_interface.hpp"
#include "os_windows.hpp"
#include "runtime/os.hpp"
// IPHLP API

View File

@ -5938,3 +5938,16 @@ void os::print_memory_mappings(char* addr, size_t bytes, outputStream* st) {
}
}
}
// File conventions
const char* os::file_separator() { return "\\"; }
const char* os::line_separator() { return "\r\n"; }
const char* os::path_separator() { return ";"; }
void os::print_user_info(outputStream* st) {
// not implemented yet
}
void os::print_active_locale(outputStream* st) {
// not implemented yet
}

View File

@ -24,25 +24,17 @@
#ifndef OS_WINDOWS_OS_WINDOWS_HPP
#define OS_WINDOWS_OS_WINDOWS_HPP
#include "runtime/os.hpp"
// Win32_OS defines the interface to windows operating systems
// strtok_s is the Windows thread-safe equivalent of POSIX strtok_r
#define strtok_r strtok_s
class outputStream;
class Thread;
#define S_ISCHR(mode) (((mode) & _S_IFCHR) == _S_IFCHR)
#define S_ISFIFO(mode) (((mode) & _S_IFIFO) == _S_IFIFO)
// Information about the protection of the page at address '0' on this os.
static bool zero_page_read_protected() { return true; }
// File conventions
static const char* file_separator() { return "\\"; }
static const char* line_separator() { return "\r\n"; }
static const char* path_separator() { return ";"; }
class win32 {
class os::win32 {
friend class os;
friend unsigned __stdcall thread_native_entry(class Thread*);
friend unsigned __stdcall thread_native_entry(Thread*);
protected:
static int _vm_page_size;
@ -56,6 +48,11 @@ class win32 {
static void print_windows_version(outputStream* st);
static void print_uptime_info(outputStream* st);
static bool platform_print_native_stack(outputStream* st, const void* context,
char *buf, int buf_size);
static bool register_code_area(char *low, char *high);
public:
// Windows-specific interface:
static void initialize_system_info();

View File

@ -25,12 +25,16 @@
#ifndef OS_WINDOWS_OS_WINDOWS_INLINE_HPP
#define OS_WINDOWS_OS_WINDOWS_INLINE_HPP
// os_windows.hpp included by os.hpp
#include "os_windows.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/mutex.hpp"
#include "runtime/os.hpp"
inline bool os::zero_page_read_protected() {
return true;
}
inline bool os::uses_stack_guard_pages() {
return true;
}

View File

@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
#include "os_windows.hpp"
#include "pdh_interface.hpp"
#include "runtime/os.hpp"
#include "utilities/macros.hpp"

View File

@ -34,6 +34,8 @@
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "nativeInst_ppc.hpp"
#include "os_aix.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "porting_aix.hpp"
@ -508,12 +510,14 @@ int os::extra_bang_size_in_bytes() {
return 0;
}
bool os::platform_print_native_stack(outputStream* st, void* context, char *buf, int buf_size) {
bool os::Aix::platform_print_native_stack(outputStream* st, void* context, char *buf, int buf_size) {
AixNativeCallstack::print_callstack_for_context(st, (const ucontext_t*)context, true, buf, (size_t) buf_size);
return true;
}
// HAVE_FUNCTION_DESCRIPTORS
void* os::resolve_function_descriptor(void* p) {
void* os::Aix::resolve_function_descriptor(void* p) {
return ((const FunctionDescriptor*)p)->entry();
}
void os::setup_fpu() {}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -23,20 +23,19 @@
*
*/
#ifndef OS_CPU_AIX_PPC_OS_AIX_PPC_HPP
#define OS_CPU_AIX_PPC_OS_AIX_PPC_HPP
#ifndef OS_CPU_AIX_PPC_OS_AIX_PPC_INLINE_HPP
#define OS_CPU_AIX_PPC_OS_AIX_PPC_INLINE_HPP
static void setup_fpu() {}
#include "os_aix.hpp"
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
#define HAVE_PLATFORM_PRINT_NATIVE_STACK 1
inline bool os::platform_print_native_stack(outputStream* st, const void* context,
char *buf, int buf_size) {
return os::Aix::platform_print_native_stack(st, context, buf, buf_size);
}
#define PLATFORM_PRINT_NATIVE_STACK 1
static bool platform_print_native_stack(outputStream* st, void* context,
char *buf, int buf_size);
#define HAVE_FUNCTION_DESCRIPTORS 1
static void* resolve_function_descriptor(void* p);
#endif // OS_CPU_AIX_PPC_OS_AIX_PPC_HPP
#define HAVE_FUNCTION_DESCRIPTORS 1
inline void* os::resolve_function_descriptor(void* p) {
return os::Aix::resolve_function_descriptor(p);
}
#endif // OS_CPU_AIX_PPC_OS_AIX_PPC_INLINE_HPP

View File

@ -35,6 +35,8 @@
#include "interpreter/interpreter.hpp"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "os_bsd.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"
@ -337,10 +339,6 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
void os::Bsd::init_thread_fpu_state(void) {
}
bool os::is_allocatable(size_t bytes) {
return true;
}
////////////////////////////////////////////////////////////////////////////////
// thread stack

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
* Copyright (c) 2021, Azul Systems, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_BSD_AARCH64_OS_BSD_AARCH64_HPP
#define OS_CPU_BSD_AARCH64_OS_BSD_AARCH64_HPP
static void setup_fpu();
static bool is_allocatable(size_t bytes);
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
#endif // OS_CPU_BSD_AARCH64_OS_BSD_AARCH64_HPP

View File

@ -1,6 +1,5 @@
/*
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2010 Red Hat, Inc.
* Copyright (c) 2022, 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
@ -23,13 +22,7 @@
*
*/
#ifndef OS_CPU_BSD_ZERO_OS_BSD_ZERO_HPP
#define OS_CPU_BSD_ZERO_OS_BSD_ZERO_HPP
#ifndef OS_CPU_BSD_AARCH64_OS_BSD_AARCH64_INLINE_HPP
#define OS_CPU_BSD_AARCH64_OS_BSD_AARCH64_INLINE_HPP
static void setup_fpu() {}
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
#endif // OS_CPU_BSD_ZERO_OS_BSD_ZERO_HPP
#endif // OS_CPU_BSD_AARCH64_OS_BSD_AARCH64_INLINE_HPP

View File

@ -32,6 +32,8 @@
#include "interpreter/interpreter.hpp"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "os_bsd.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_BSD_X86_OS_BSD_X86_HPP
#define OS_CPU_BSD_X86_OS_BSD_X86_HPP
// Core region alignment is 16K to be able to run binaries built on MacOS x64
// on MacOS aarch64.
#if defined(__APPLE__) && defined(COMPATIBLE_CDS_ALIGNMENT)
#define CDS_CORE_REGION_ALIGNMENT (16*K)
#endif
static void setup_fpu();
static bool supports_sse();
static juint cpu_microcode_revision();
static jlong rdtsc();
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
#endif // OS_CPU_BSD_X86_OS_BSD_X86_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, 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
@ -27,6 +27,16 @@
#include "runtime/os.hpp"
#if defined(__APPLE__) && defined(COMPATIBLE_CDS_ALIGNMENT)
#define HAVE_CDS_CORE_REGION_ALIGNMENT 1
inline size_t os::cds_core_region_alignment() {
// Core region alignment is 16K to be able to run binaries built on MacOS x64
// on MacOS aarch64.
return (16*K);
}
#endif
// See http://www.technovelty.org/code/c/reading-rdtsc.htl for details
inline jlong os::rdtsc() {
#ifndef AMD64

View File

@ -38,6 +38,8 @@
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "nativeInst_zero.hpp"
#include "os_bsd.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_BSD_ZERO_OS_BSD_ZERO_INLINE_HPP
#define OS_CPU_BSD_ZERO_OS_BSD_ZERO_INLINE_HPP
#endif // OS_CPU_BSD_ZERO_OS_BSD_ZERO_INLINE_HPP

View File

@ -33,6 +33,8 @@
#include "code/nativeInst.hpp"
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "os_linux.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_LINUX_AARCH64_OS_LINUX_AARCH64_HPP
#define OS_CPU_LINUX_AARCH64_OS_LINUX_AARCH64_HPP
#if defined(COMPATIBLE_CDS_ALIGNMENT)
#define CDS_CORE_REGION_ALIGNMENT (64*K)
#endif
static void setup_fpu();
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
#endif // OS_CPU_LINUX_AARCH64_OS_LINUX_AARCH64_HPP

View File

@ -1,6 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016 SAP SE. All rights reserved.
* Copyright (c) 2022, 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
@ -23,12 +22,16 @@
*
*/
#ifndef OS_CPU_LINUX_S390_OS_LINUX_S390_HPP
#define OS_CPU_LINUX_S390_OS_LINUX_S390_HPP
#ifndef OS_CPU_LINUX_AARCH64_OS_LINUX_AARCH64_INLINE_HPP
#define OS_CPU_LINUX_AARCH64_OS_LINUX_AARCH64_INLINE_HPP
static void setup_fpu() {}
#include "runtime/os.hpp"
// Used to register dynamic code cache area with the OS.
static bool register_code_area(char *low, char *high) { return true; }
#if defined(COMPATIBLE_CDS_ALIGNMENT)
#define HAVE_CDS_CORE_REGION_ALIGNMENT 1
inline size_t os::cds_core_region_alignment() {
return (64*K);
}
#endif
#endif // OS_CPU_LINUX_S390_OS_LINUX_S390_HPP
#endif // OS_CPU_LINUX_AARCH64_OS_LINUX_AARCH64_INLINE_HPP

View File

@ -31,6 +31,8 @@
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "nativeInst_arm.hpp"
#include "os_linux.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 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
@ -22,13 +22,8 @@
*
*/
#ifndef OS_CPU_LINUX_ARM_OS_LINUX_ARM_HPP
#define OS_CPU_LINUX_ARM_OS_LINUX_ARM_HPP
#ifndef OS_CPU_LINUX_ARM_OS_LINUX_ARM_INLINE_HPP
#define OS_CPU_LINUX_ARM_OS_LINUX_ARM_INLINE_HPP
static void setup_fpu();
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
#endif // OS_CPU_LINUX_ARM_OS_LINUX_ARM_HPP
#endif // OS_CPU_LINUX_ARM_OS_LINUX_ARM_INLINE_HPP

View File

@ -34,6 +34,8 @@
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "nativeInst_ppc.hpp"
#include "os_linux.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"
@ -43,6 +45,7 @@
#include "runtime/javaCalls.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/osThread.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/sharedRuntime.hpp"
@ -515,7 +518,9 @@ int os::extra_bang_size_in_bytes() {
}
#ifdef HAVE_FUNCTION_DESCRIPTORS
void* os::resolve_function_descriptor(void* p) {
void* os::Linux::resolve_function_descriptor(void* p) {
return ((const FunctionDescriptor*)p)->entry();
}
#endif
void os::setup_fpu() {}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -23,19 +23,17 @@
*
*/
#ifndef OS_CPU_LINUX_PPC_OS_LINUX_PPC_HPP
#define OS_CPU_LINUX_PPC_OS_LINUX_PPC_HPP
#ifndef OS_CPU_LINUX_PPC_OS_LINUX_PPC_INLINE_HPP
#define OS_CPU_LINUX_PPC_OS_LINUX_PPC_INLINE_HPP
static void setup_fpu() {}
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
#include "os_linux.hpp"
#if !defined(ABI_ELFv2)
// ppc (not ppcle) has function descriptors
#define HAVE_FUNCTION_DESCRIPTORS 1
static void* resolve_function_descriptor(void* p);
#define HAVE_FUNCTION_DESCRIPTORS 1
inline void* os::resolve_function_descriptor(void* p) {
return os::Linux::resolve_function_descriptor(p);
}
#endif
#endif // OS_CPU_LINUX_PPC_OS_LINUX_PPC_HPP
#endif // OS_CPU_LINUX_PPC_OS_LINUX_PPC_INLINE_HPP

View File

@ -33,6 +33,8 @@
#include "interpreter/interpreter.hpp"
#include "jvm.h"
#include "memory/allocation.inline.hpp"
#include "os_linux.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"

View File

@ -1,54 +0,0 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_LINUX_RISCV_VM_OS_LINUX_RISCV_HPP
#define OS_CPU_LINUX_RISCV_VM_OS_LINUX_RISCV_HPP
static void setup_fpu();
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
// SYSCALL_RISCV_FLUSH_ICACHE is used to flush instruction cache. The "fence.i" instruction
// only work on the current hart, so kernel provides the icache flush syscall to flush icache
// on each hart. You can pass a flag to determine a global or local icache flush.
static void icache_flush(long int start, long int end)
{
const int SYSCALL_RISCV_FLUSH_ICACHE = 259;
register long int __a7 asm ("a7") = SYSCALL_RISCV_FLUSH_ICACHE;
register long int __a0 asm ("a0") = start;
register long int __a1 asm ("a1") = end;
// the flush can be applied to either all threads or only the current.
// 0 means a global icache flush, and the icache flush will be applied
// to other harts concurrently executing.
register long int __a2 asm ("a2") = 0;
__asm__ volatile ("ecall\n\t"
: "+r" (__a0)
: "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a7)
: "memory");
}
#endif // OS_CPU_LINUX_RISCV_VM_OS_LINUX_RISCV_HPP

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_LINUX_RISCV_OS_LINUX_RISCV_INLINE_HPP
#define OS_CPU_LINUX_RISCV_OS_LINUX_RISCV_INLINE_HPP
#endif // OS_CPU_LINUX_RISCV_OS_LINUX_RISCV_INLINE_HPP

View File

@ -36,6 +36,8 @@
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "nativeInst_s390.hpp"
#include "os_linux.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"
@ -477,3 +479,5 @@ int os::extra_bang_size_in_bytes() {
// z/Architecture does not require the additional stack bang.
return 0;
}
void os::setup_fpu() {}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_LINUX_S390_OS_LINUX_S390_INLINE_HPP
#define OS_CPU_LINUX_S390_OS_LINUX_S390_INLINE_HPP
#endif // OS_CPU_LINUX_S390_OS_LINUX_S390_INLINE_HPP

View File

@ -32,6 +32,8 @@
#include "interpreter/interpreter.hpp"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "os_linux.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/frame.inline.hpp"
@ -651,83 +653,6 @@ void os::verify_stack_alignment() {
}
#endif
/*
* IA32 only: execute code at a high address in case buggy NX emulation is present. I.e. avoid CS limit
* updates (JDK-8023956).
*/
void os::workaround_expand_exec_shield_cs_limit() {
#if defined(IA32)
assert(Linux::initial_thread_stack_bottom() != NULL, "sanity");
size_t page_size = os::vm_page_size();
/*
* JDK-8197429
*
* Expand the stack mapping to the end of the initial stack before
* attempting to install the codebuf. This is needed because newer
* Linux kernels impose a distance of a megabyte between stack
* memory and other memory regions. If we try to install the
* codebuf before expanding the stack the installation will appear
* to succeed but we'll get a segfault later if we expand the stack
* in Java code.
*
*/
if (os::is_primordial_thread()) {
address limit = Linux::initial_thread_stack_bottom();
if (! DisablePrimordialThreadGuardPages) {
limit += StackOverflow::stack_red_zone_size() +
StackOverflow::stack_yellow_zone_size();
}
os::Linux::expand_stack_to(limit);
}
/*
* Take the highest VA the OS will give us and exec
*
* Although using -(pagesz) as mmap hint works on newer kernel as you would
* think, older variants affected by this work-around don't (search forward only).
*
* On the affected distributions, we understand the memory layout to be:
*
* TASK_LIMIT= 3G, main stack base close to TASK_LIMT.
*
* A few pages south main stack will do it.
*
* If we are embedded in an app other than launcher (initial != main stack),
* we don't have much control or understanding of the address space, just let it slide.
*/
char* hint = (char*)(Linux::initial_thread_stack_bottom() -
(StackOverflow::stack_guard_zone_size() + page_size));
char* codebuf = os::attempt_reserve_memory_at(hint, page_size);
if (codebuf == NULL) {
// JDK-8197429: There may be a stack gap of one megabyte between
// the limit of the stack and the nearest memory region: this is a
// 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);
}
if ((codebuf == NULL) || (!os::commit_memory(codebuf, page_size, true))) {
return; // No matter, we tried, best effort.
}
MemTracker::record_virtual_memory_type((address)codebuf, mtInternal);
log_info(os)("[CS limit NX emulation work-around, exec code at: %p]", codebuf);
// Some code to exec: the 'ret' instruction
codebuf[0] = 0xC3;
// Call the code in the codebuf
__asm__ volatile("call *%0" : : "r"(codebuf));
// keep the page mapped so CS limit isn't reduced.
#endif
}
int os::extra_bang_size_in_bytes() {
// JDK-8050147 requires the full cache line bang for x86.
return VM_Version::L1_line_size();

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_LINUX_X86_OS_LINUX_X86_HPP
#define OS_CPU_LINUX_X86_OS_LINUX_X86_HPP
static void setup_fpu();
static bool supports_sse();
static juint cpu_microcode_revision();
static jlong rdtsc();
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
/*
* Work-around for broken NX emulation using CS limit, Red Hat patch "Exec-Shield"
* (IA32 only).
*
* Map and execute at a high VA to prevent CS lazy updates race with SMP MM
* invalidation.Further code generation by the JVM will no longer cause CS limit
* updates.
*
* Affects IA32: RHEL 5 & 6, Ubuntu 10.04 (LTS), 10.10, 11.04, 11.10, 12.04.
* @see JDK-8023956
*/
static void workaround_expand_exec_shield_cs_limit();
#endif // OS_CPU_LINUX_X86_OS_LINUX_X86_HPP

View File

@ -33,6 +33,8 @@
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "nativeInst_zero.hpp"
#include "os_linux.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"
@ -398,3 +400,5 @@ int os::extra_bang_size_in_bytes() {
// Zero does not require an additional stack banging.
return 0;
}
void os::setup_fpu() {}

View File

@ -1,48 +0,0 @@
/*
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2010, 2018, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_LINUX_ZERO_OS_LINUX_ZERO_HPP
#define OS_CPU_LINUX_ZERO_OS_LINUX_ZERO_HPP
static void setup_fpu() {}
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
/*
* Work-around for broken NX emulation using CS limit, Red Hat patch "Exec-Shield"
* (IA32 only).
*
* Map and execute at a high VA to prevent CS lazy updates race with SMP MM
* invalidation.Further code generation by the JVM will no longer cause CS limit
* updates.
*
* Affects IA32: RHEL 5 & 6, Ubuntu 10.04 (LTS), 10.10, 11.04, 11.10, 12.04.
* @see JDK-8023956
*/
static void workaround_expand_exec_shield_cs_limit();
#endif // OS_CPU_LINUX_ZERO_OS_LINUX_ZERO_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Microsoft Corporation. All rights reserved.
* Copyright (c) 2022, 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
@ -22,15 +22,9 @@
*
*/
#ifndef OS_CPU_WINDOWS_AARCH64_OS_WINDOWS_AARCH64_HPP
#define OS_CPU_WINDOWS_AARCH64_OS_WINDOWS_AARCH64_HPP
#ifndef OS_CPU_LINUX_ZERO_OS_LINUX_ZERO_INLINE_HPP
#define OS_CPU_LINUX_ZERO_OS_LINUX_ZERO_INLINE_HPP
static void setup_fpu();
static bool supports_sse();
static bool register_code_area(char *low, char *high) {
// Using Vectored Exception Handling
return true;
}
#endif // OS_CPU_WINDOWS_AARCH64_OS_WINDOWS_AARCH64_HPP
#endif // OS_CPU_LINUX_ZERO_OS_LINUX_ZERO_INLINE_HPP

View File

@ -33,6 +33,7 @@
#include "code/nativeInst.hpp"
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "os_windows.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"

View File

@ -27,4 +27,9 @@
#include "runtime/os.hpp"
inline bool os::register_code_area(char *low, char *high) {
// Using Vectored Exception Handling
return true;
}
#endif // OS_CPU_WINDOWS_AARCH64_OS_WINDOWS_AARCH64_INLINE_HPP

View File

@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "asm/macroAssembler.hpp"
#include "asm/macroAssembler.inline.hpp"
#include "os_windows.hpp"
#include "runtime/os.hpp"
void MacroAssembler::int3() {

View File

@ -32,6 +32,7 @@
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "nativeInst_x86.hpp"
#include "os_windows.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"
@ -41,6 +42,7 @@
#include "runtime/javaCalls.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/osThread.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubRoutines.hpp"
@ -165,7 +167,7 @@ typedef struct {
// Arguments: low and high are the address of the full reserved
// codeCache area
//
bool os::register_code_area(char *low, char *high) {
bool os::win32::register_code_area(char *low, char *high) {
#ifdef AMD64
ResourceMark rm;
@ -209,7 +211,7 @@ bool os::register_code_area(char *low, char *high) {
return true;
}
#ifdef AMD64
#ifdef HAVE_PLATFORM_PRINT_NATIVE_STACK
/*
* Windows/x64 does not use stack frames the way expected by Java:
* [1] in most cases, there is no frame pointer. All locals are addressed via RSP
@ -221,8 +223,8 @@ bool os::register_code_area(char *low, char *high) {
* while (...) {... fr = os::get_sender_for_C_frame(&fr); }
* loop in vmError.cpp. We need to roll our own loop.
*/
bool os::platform_print_native_stack(outputStream* st, const void* context,
char *buf, int buf_size)
bool os::win32::platform_print_native_stack(outputStream* st, const void* context,
char *buf, int buf_size)
{
CONTEXT ctx;
if (context != NULL) {
@ -293,7 +295,7 @@ bool os::platform_print_native_stack(outputStream* st, const void* context,
return true;
}
#endif // AMD64
#endif // HAVE_PLATFORM_PRINT_NATIVE_STACK
address os::fetch_frame_from_context(const void* ucVoid,
intptr_t** ret_sp, intptr_t** ret_fp) {
@ -558,3 +560,7 @@ int os::extra_bang_size_in_bytes() {
// JDK-8050147 requires the full cache line bang for x86.
return VM_Version::L1_line_size();
}
bool os::supports_sse() {
return true;
}

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_CPU_WINDOWS_X86_OS_WINDOWS_X86_HPP
#define OS_CPU_WINDOWS_X86_OS_WINDOWS_X86_HPP
//
// NOTE: we are back in class os here, not win32
//
static void setup_fpu();
static bool supports_sse() { return true; }
static juint cpu_microcode_revision();
static jlong rdtsc();
static bool register_code_area(char *low, char *high);
#ifdef AMD64
#define PLATFORM_PRINT_NATIVE_STACK 1
static bool platform_print_native_stack(outputStream* st, const void* context,
char *buf, int buf_size);
#endif
#endif // OS_CPU_WINDOWS_X86_OS_WINDOWS_X86_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, 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
@ -26,6 +26,15 @@
#define OS_CPU_WINDOWS_X86_OS_WINDOWS_X86_INLINE_HPP
#include "runtime/os.hpp"
#include "os_windows.hpp"
#ifdef AMD64
#define HAVE_PLATFORM_PRINT_NATIVE_STACK 1
inline bool os::platform_print_native_stack(outputStream* st, const void* context,
char *buf, int buf_size) {
return os::win32::platform_print_native_stack(st, context, buf, buf_size);
}
#endif
inline jlong os::rdtsc() {
// 32 bit: 64 bit result in edx:eax
@ -35,4 +44,8 @@ inline jlong os::rdtsc() {
return (jlong)res;
}
inline bool os::register_code_area(char *low, char *high) {
return os::win32::register_code_area(low, high);
}
#endif // OS_CPU_WINDOWS_X86_OS_WINDOWS_X86_INLINE_HPP

View File

@ -67,7 +67,7 @@
#include "runtime/arguments.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/vmThread.hpp"
@ -126,20 +126,17 @@ char* MetaspaceShared::symbol_space_alloc(size_t num_bytes) {
return _symbol_region.allocate(num_bytes);
}
// os::vm_allocation_granularity() is usually 4K for most OSes. However, on Linux/aarch64,
// it can be either 4K or 64K and on Macosx-arm it is 16K. To generate archives that are
// os::vm_allocation_granularity() is usually 4K for most OSes. However, some platforms
// such as linux-aarch64 and macos-x64 ...
// it can be either 4K or 64K and on macos-aarch64 it is 16K. To generate archives that are
// compatible for both settings, an alternative cds core region alignment can be enabled
// at building time:
// --enable-compactible-cds-alignment
// Upon successful configuration, the compactible alignment then can be defined as in:
// os_linux_aarch64.hpp
// which is the highest page size configured on the platform.
// Upon successful configuration, the compactible alignment then can be defined in:
// os_linux_aarch64.cpp
// os_bsd_x86.cpp
size_t MetaspaceShared::core_region_alignment() {
#if defined(CDS_CORE_REGION_ALIGNMENT)
return CDS_CORE_REGION_ALIGNMENT;
#else
return (size_t)os::vm_allocation_granularity();
#endif // CDS_CORE_REGION_ALIGNMENT
return os::cds_core_region_alignment();
}
static bool shared_base_valid(char* shared_base) {

View File

@ -57,6 +57,7 @@
#include "runtime/icache.hpp"
#include "runtime/java.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sweeper.hpp"
#include "runtime/vmThread.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, 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
@ -24,13 +24,11 @@
#include "precompiled.hpp"
#include "jfr/utilities/jfrTime.hpp"
#include "runtime/os.hpp"
#include "runtime/os.inline.hpp"
#if defined(X86) && !defined(ZERO)
#include "rdtsc_x86.hpp"
#endif
#include OS_HEADER_INLINE(os)
bool JfrTime::_ft_enabled = false;
bool JfrTime::initialize() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, 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
@ -25,9 +25,7 @@
#include "precompiled.hpp"
#include "jfr/utilities/jfrTimeConverter.hpp"
#include "jfr/utilities/jfrTime.hpp"
#include "runtime/os.hpp"
#include OS_HEADER_INLINE(os)
#include "runtime/os.inline.hpp"
static double ft_counter_to_nanos_factor = .0;
static double nanos_to_ft_counter_factor = .0;

View File

@ -39,6 +39,7 @@
#include "opto/rootnode.hpp"
#include "opto/runtime.hpp"
#include "opto/subnode.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "utilities/debug.hpp"

View File

@ -35,6 +35,7 @@
#include "opto/machnode.hpp"
#include "opto/runtime.hpp"
#include "opto/chaitin.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/sharedRuntime.hpp"
// Optimization - Graph Style

View File

@ -41,7 +41,7 @@
#include "opto/runtime.hpp"
#include "opto/type.hpp"
#include "opto/vectornode.hpp"
#include "runtime/os.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "utilities/align.hpp"

View File

@ -37,9 +37,73 @@
class AgentLibrary;
class frame;
// os defines the interface to operating system; this includes traditional
// OS services (time, I/O) as well as other functionality with system-
// dependent code.
// Rules for using and implementing methods declared in the "os" class
// ===================================================================
//
// The "os" class defines a number of the interfaces for porting HotSpot
// to different operating systems. For example, I/O, memory, timing, etc.
// Note that additional classes such as Semaphore, Mutex, etc., are used for
// porting specific groups of features.
//
// Structure of os*.{cpp, hpp} files
//
// - os.hpp
//
// (This file) declares the entire API of the "os" class.
//
// - os.inline.hpp
//
// To use any of the inline methods declared in the "os" class, this
// header file must be included.
//
// - src/hotspot/os/<os>/os_<os>.hpp
// - src/hotspot/os/posix/os_posix.hpp
//
// These headers declare APIs that should be used only within the
// platform-specific source files for that particular OS.
//
// For example, os_linux.hpp declares the os::Linux class, which provides
// many methods that can be used by files under os/linux/ and os_cpu/linux_*/
//
// os_posix.hpp can be used by platform-specific files for POSIX-like
// OSes such as aix, bsd and linux.
//
// Platform-independent source files should not include these header files
// (although sadly there are some rare exceptions ...)
//
// - os.cpp
//
// Platform-independent methods of the "os" class are defined
// in os.cpp. These are not part of the porting interface, but rather
// can be considered as convenience functions for accessing
// the porting interface. E.g., os::print_function_and_library_name().
//
// The methods declared in os.hpp but not implemented in os.cpp are
// a part the HotSpot Porting APIs. They must be implemented in one of
// the following four files:
//
// - src/hotspot/os/<os>/os_<os>.inline.hpp
// - src/hotspot/os_cpu/<os>_<cpu>/os_<os>_<cpu>.inline.hpp
// - src/hotspot/os/<os>/os_<os>.cpp
// - src/hotspot/os_cpu/<os>_<cpu>/os_<os>_<cpu>.cpp
//
// The Porting APIs declared as "inline" in os.hpp MUST be
// implemented in one of the two .inline.hpp files, depending on
// whether the feature is specific to a particular CPU architecture
// for this OS. These two files are automatically included by
// os.inline.hpp. Platform-independent source files must not include
// these two files directly.
//
// If the full definition of an inline method is too complex to fit in a
// header file, the actual implementation can be deferred to another
// method defined in the .cpp files.
//
// The Porting APIs that are *not* declared as "inline" in os.hpp MUST
// be implemented in one of the two .cpp files above. These files
// also implement OS-specific APIs such as os::Linux, os::Posix, etc.
//
// (Note: on the POSIX-like platforms, some of the Porting APIs are implemented
// in os_posix.cpp instead).
class Thread;
class JavaThread;
@ -279,9 +343,9 @@ class os: AllStatic {
// Interface for stack banging (predetect possible stack overflow for
// exception processing) There are guard pages, and above that shadow
// pages for stack overflow checking.
static bool uses_stack_guard_pages();
static bool must_commit_stack_guard_pages();
static void map_stack_shadow_pages(address sp);
inline static bool uses_stack_guard_pages();
inline static bool must_commit_stack_guard_pages();
inline static void map_stack_shadow_pages(address sp);
static bool stack_shadow_pages_available(Thread *thread, const methodHandle& method, address sp);
private:
@ -349,6 +413,7 @@ class os: AllStatic {
const size_t size);
static int vm_allocation_granularity();
inline static size_t cds_core_region_alignment();
// Reserves virtual memory.
static char* reserve_memory(size_t bytes, bool executable = false, MEMFLAGS flags = mtNone);
@ -632,6 +697,9 @@ class os: AllStatic {
bool demangle = true,
bool strip_arguments = false);
// Used only on PPC.
inline static void* resolve_function_descriptor(void* p);
// Find out whether the pc is in the static code for jvm.dll/libjvm.so.
static bool address_is_in_vm(address addr);
@ -695,6 +763,9 @@ class os: AllStatic {
static void print_date_and_time(outputStream* st, char* buf, size_t buflen);
static void print_instructions(outputStream* st, address pc, int unitsize);
static void print_user_info(outputStream* st);
static void print_active_locale(outputStream* st);
// helper for output of seconds in days , hours and months
static void print_dhm(outputStream* st, const char* startStr, long sec);
@ -870,25 +941,58 @@ class os: AllStatic {
public:
// Platform dependent stuff
#ifndef _WINDOWS
# include "os_posix.hpp"
// File conventions
static const char* file_separator();
static const char* line_separator();
static const char* path_separator();
// Information about the protection of the page at address '0' on this os.
inline static bool zero_page_read_protected();
static void setup_fpu();
static bool supports_sse();
static juint cpu_microcode_revision();
static inline jlong rdtsc();
// 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);
// Platform-specific code for interacting with individual OSes.
// TODO: This is for compatibility only with current usage of os::Linux, etc.
// We can get rid of the following block if we rename such a class to something
// like ::LinuxUtils
#if defined(AIX)
class Aix;
#elif defined(BSD)
class Bsd;
#elif defined(LINUX)
class Linux;
#elif defined(_WINDOWS)
class win32;
#endif
// Ditto - Posix-specific API. Ideally should be moved to something like ::PosixUtils.
#ifndef _WINDOWS
class Posix;
#endif
// FIXME - some random stuff that was in os_windows.hpp
#ifdef _WINDOWS
// strtok_s is the Windows thread-safe equivalent of POSIX strtok_r
# define strtok_r strtok_s
# define S_ISCHR(mode) (((mode) & _S_IFCHR) == _S_IFCHR)
# define S_ISFIFO(mode) (((mode) & _S_IFIFO) == _S_IFIFO)
#endif
#include OS_CPU_HEADER(os)
#include OS_HEADER(os)
#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
public:
#ifndef PLATFORM_PRINT_NATIVE_STACK
// No platform-specific code for printing the native stack.
static bool platform_print_native_stack(outputStream* st, const void* context,
char *buf, int buf_size) {
return false;
}
#endif
inline static bool platform_print_native_stack(outputStream* st, const void* context,
char *buf, int buf_size);
// debugging support (mostly used by debug.cpp but also fatal error handler)
static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, 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
@ -28,5 +28,35 @@
#include "runtime/os.hpp"
#include OS_HEADER_INLINE(os)
#include OS_CPU_HEADER_INLINE(os)
// Below are inline functions that are rarely implemented by the platforms.
// Provide default empty implementation.
#ifndef HAVE_PLATFORM_PRINT_NATIVE_STACK
inline bool os::platform_print_native_stack(outputStream* st, const void* context,
char *buf, int buf_size) {
return false;
}
#endif
#ifndef HAVE_CDS_CORE_REGION_ALIGNMENT
inline size_t os::cds_core_region_alignment() {
return (size_t)os::vm_allocation_granularity();
}
#endif
#ifndef _WINDOWS
// Currently used only on Windows.
inline bool os::register_code_area(char *low, char *high) {
return true;
}
#endif
#ifndef HAVE_FUNCTION_DESCRIPTORS
inline void* os::resolve_function_descriptor(void* p) {
return NULL;
}
#endif
#endif // SHARE_RUNTIME_OS_INLINE_HPP

View File

@ -44,7 +44,7 @@
#include "runtime/handles.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/os.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/safefetch.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubCodeGenerator.hpp"

View File

@ -1073,6 +1073,7 @@ bufferedStream::~bufferedStream() {
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#elif defined(_WINDOWS)
#include <winsock2.h>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, 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
@ -30,8 +30,6 @@
#include "rdtsc_x86.hpp"
#endif
#include OS_CPU_HEADER(os)
template <typename TimeSource, const int unit>
inline double conversion(typename TimeSource::Type& value) {
return (double)value * ((double)unit / (double)TimeSource::frequency());

View File

@ -43,7 +43,7 @@
#include "runtime/frame.inline.hpp"
#include "runtime/javaThread.inline.hpp"
#include "runtime/init.hpp"
#include "runtime/os.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/osThread.hpp"
#include "runtime/safefetch.hpp"
#include "runtime/safepointMechanism.hpp"
@ -993,13 +993,11 @@ void VMError::report(outputStream* st, bool _verbose) {
st->cr();
}
#ifndef _WIN32
STEP("printing user info")
if (ExtensiveErrorReports && _verbose) {
os::Posix::print_user_info(st);
os::print_user_info(st);
}
#endif
STEP("printing all threads")
@ -1158,14 +1156,12 @@ void VMError::report(outputStream* st, bool _verbose) {
st->cr();
}
#ifndef _WIN32
STEP("printing locale settings")
if (_verbose) {
os::Posix::print_active_locale(st);
os::print_active_locale(st);
st->cr();
}
#endif
STEP("printing signal handlers")
@ -1349,10 +1345,10 @@ void VMError::print_vm_info(outputStream* st) {
st->cr();
// STEP("printing locale settings")
#ifndef _WIN32
os::Posix::print_active_locale(st);
os::print_active_locale(st);
st->cr();
#endif
// STEP("printing signal handlers")

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, 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
@ -34,6 +34,9 @@
#include "unittest.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/threads.hpp"
#ifdef _WIN32
#include "os_windows.hpp"
#endif
static size_t small_page_size() {
return os::vm_page_size();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, 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
@ -31,6 +31,7 @@
#include "runtime/os.hpp"
#include "utilities/align.hpp"
#include "concurrentTestRunner.inline.hpp"
#include "os_linux.hpp"
#include "unittest.hpp"
namespace {