Path: blob/master/src/hotspot/os/windows/os_windows.inline.hpp
40930 views
/*1* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef OS_WINDOWS_OS_WINDOWS_INLINE_HPP25#define OS_WINDOWS_OS_WINDOWS_INLINE_HPP2627// os_windows.hpp included by os.hpp2829#include "runtime/os.hpp"30#include "runtime/thread.hpp"3132inline bool os::uses_stack_guard_pages() {33return true;34}3536inline bool os::must_commit_stack_guard_pages() {37return true;38}3940// Bang the shadow pages if they need to be touched to be mapped.41inline void os::map_stack_shadow_pages(address sp) {42// Write to each page of our new frame to force OS mapping.43// If we decrement stack pointer more than one page44// the OS may not map an intervening page into our space45// and may fault on a memory access to interior of our frame.46const int page_size = os::win32::vm_page_size();47const size_t n_pages = StackOverflow::stack_shadow_zone_size() / page_size;48for (size_t pages = 1; pages <= n_pages; pages++) {49sp -= page_size;50*sp = 0;51}52}5354inline bool os::numa_has_static_binding() { return true; }55inline bool os::numa_has_group_homing() { return false; }5657// Platform Mutex/Monitor implementation5859inline os::PlatformMutex::PlatformMutex() {60InitializeCriticalSection(&_mutex);61}6263inline os::PlatformMutex::~PlatformMutex() {64DeleteCriticalSection(&_mutex);65}6667inline os::PlatformMonitor::PlatformMonitor() {68InitializeConditionVariable(&_cond);69}7071inline os::PlatformMonitor::~PlatformMonitor() {72// There is no DeleteConditionVariable API73}7475inline void os::PlatformMutex::lock() {76EnterCriticalSection(&_mutex);77}7879inline void os::PlatformMutex::unlock() {80LeaveCriticalSection(&_mutex);81}8283inline bool os::PlatformMutex::try_lock() {84return TryEnterCriticalSection(&_mutex);85}8687inline void os::PlatformMonitor::notify() {88WakeConditionVariable(&_cond);89}9091inline void os::PlatformMonitor::notify_all() {92WakeAllConditionVariable(&_cond);93}9495#endif // OS_WINDOWS_OS_WINDOWS_INLINE_HPP969798