402 if (time_struct_ptr != NULL) {
403 *res = *time_struct_ptr;
404 return res;
405 }
406 return NULL;
407 }
408
409 LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
410
411 // Thread start routine for all new Java threads
412 static unsigned __stdcall java_start(Thread* thread) {
413 // Try to randomize the cache line index of hot stack frames.
414 // This helps when threads of the same stack traces evict each other's
415 // cache lines. The threads can be either from the same JVM instance, or
416 // from different JVM instances. The benefit is especially true for
417 // processors with hyperthreading technology.
418 static int counter = 0;
419 int pid = os::current_process_id();
420 _alloca(((pid ^ counter++) & 7) * 128);
421
422 OSThread* osthr = thread->osthread();
423 assert(osthr->get_state() == RUNNABLE, "invalid os thread state");
424
425 if (UseNUMA) {
426 int lgrp_id = os::numa_get_group_id();
427 if (lgrp_id != -1) {
428 thread->set_lgrp_id(lgrp_id);
429 }
430 }
431
432 // Diagnostic code to investigate JDK-6573254
433 int res = 30115; // non-java thread
434 if (thread->is_Java_thread()) {
435 res = 20115; // java thread
436 }
437
438 // Install a win32 structured exception handler around every thread created
439 // by VM, so VM can generate error dump when an exception occurred in non-
440 // Java thread (e.g. VM thread).
441 __try {
2129 assert(ret != 0, "ReleaseSemaphore() failed");
2130
2131 thread->java_suspend_self();
2132 }
2133 } while (threadIsSuspended);
2134 }
2135 }
2136
2137 int os::signal_lookup() {
2138 return check_pending_signals(false);
2139 }
2140
2141 int os::signal_wait() {
2142 return check_pending_signals(true);
2143 }
2144
2145 // Implicit OS exception handling
2146
2147 LONG Handle_Exception(struct _EXCEPTION_POINTERS* exceptionInfo,
2148 address handler) {
2149 JavaThread* thread = JavaThread::current();
2150 // Save pc in thread
2151 #ifdef _M_IA64
2152 // Do not blow up if no thread info available.
2153 if (thread) {
2154 // Saving PRECISE pc (with slot information) in thread.
2155 uint64_t precise_pc = (uint64_t) exceptionInfo->ExceptionRecord->ExceptionAddress;
2156 // Convert precise PC into "Unix" format
2157 precise_pc = (precise_pc & 0xFFFFFFFFFFFFFFF0) | ((precise_pc & 0xF) >> 2);
2158 thread->set_saved_exception_pc((address)precise_pc);
2159 }
2160 // Set pc to handler
2161 exceptionInfo->ContextRecord->StIIP = (DWORD64)handler;
2162 // Clear out psr.ri (= Restart Instruction) in order to continue
2163 // at the beginning of the target bundle.
2164 exceptionInfo->ContextRecord->StIPSR &= 0xFFFFF9FFFFFFFFFF;
2165 assert(((DWORD64)handler & 0xF) == 0, "Target address must point to the beginning of a bundle!");
2166 #else
2167 #ifdef _M_AMD64
2168 // Do not blow up if no thread info available.
2169 if (thread) {
2367 //-----------------------------------------------------------------------------
2368 LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
2369 if (InterceptOSException) return EXCEPTION_CONTINUE_SEARCH;
2370 DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;
2371 #ifdef _M_IA64
2372 // On Itanium, we need the "precise pc", which has the slot number coded
2373 // into the least 4 bits: 0000=slot0, 0100=slot1, 1000=slot2 (Windows format).
2374 address pc = (address) exceptionInfo->ExceptionRecord->ExceptionAddress;
2375 // Convert the pc to "Unix format", which has the slot number coded
2376 // into the least 2 bits: 0000=slot0, 0001=slot1, 0010=slot2
2377 // This is needed for IA64 because "relocation" / "implicit null check" / "poll instruction"
2378 // information is saved in the Unix format.
2379 address pc_unix_format = (address) ((((uint64_t)pc) & 0xFFFFFFFFFFFFFFF0) | ((((uint64_t)pc) & 0xF) >> 2));
2380 #else
2381 #ifdef _M_AMD64
2382 address pc = (address) exceptionInfo->ContextRecord->Rip;
2383 #else
2384 address pc = (address) exceptionInfo->ContextRecord->Eip;
2385 #endif
2386 #endif
2387 Thread* t = ThreadLocalStorage::get_thread_slow(); // slow & steady
2388
2389 // Handle SafeFetch32 and SafeFetchN exceptions.
2390 if (StubRoutines::is_safefetch_fault(pc)) {
2391 return Handle_Exception(exceptionInfo, StubRoutines::continuation_for_safefetch_fault(pc));
2392 }
2393
2394 #ifndef _WIN64
2395 // Execution protection violation - win32 running on AMD64 only
2396 // Handled first to avoid misdiagnosis as a "normal" access violation;
2397 // This is safe to do because we have a new/unique ExceptionInformation
2398 // code for this condition.
2399 if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
2400 PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
2401 int exception_subcode = (int) exceptionRecord->ExceptionInformation[0];
2402 address addr = (address) exceptionRecord->ExceptionInformation[1];
2403
2404 if (exception_subcode == EXCEPTION_INFO_EXEC_VIOLATION) {
2405 int page_size = os::vm_page_size();
2406
2407 // Make sure the pc and the faulting address are sane.
3994
3995 bool os::is_debugger_attached() {
3996 return IsDebuggerPresent() ? true : false;
3997 }
3998
3999
4000 void os::wait_for_keypress_at_exit(void) {
4001 if (PauseAtExit) {
4002 fprintf(stderr, "Press any key to continue...\n");
4003 fgetc(stdin);
4004 }
4005 }
4006
4007
4008 int os::message_box(const char* title, const char* message) {
4009 int result = MessageBox(NULL, message, title,
4010 MB_YESNO | MB_ICONERROR | MB_SYSTEMMODAL | MB_DEFAULT_DESKTOP_ONLY);
4011 return result == IDYES;
4012 }
4013
4014 int os::allocate_thread_local_storage() {
4015 return TlsAlloc();
4016 }
4017
4018
4019 void os::free_thread_local_storage(int index) {
4020 TlsFree(index);
4021 }
4022
4023
4024 void os::thread_local_storage_at_put(int index, void* value) {
4025 TlsSetValue(index, value);
4026 assert(thread_local_storage_at(index) == value, "Just checking");
4027 }
4028
4029
4030 void* os::thread_local_storage_at(int index) {
4031 return TlsGetValue(index);
4032 }
4033
4034
4035 #ifndef PRODUCT
4036 #ifndef _WIN64
4037 // Helpers to check whether NX protection is enabled
4038 int nx_exception_filter(_EXCEPTION_POINTERS *pex) {
4039 if (pex->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION &&
4040 pex->ExceptionRecord->NumberParameters > 0 &&
4041 pex->ExceptionRecord->ExceptionInformation[0] ==
4042 EXCEPTION_INFO_EXEC_VIOLATION) {
4043 return EXCEPTION_EXECUTE_HANDLER;
4044 }
4045 return EXCEPTION_CONTINUE_SEARCH;
4046 }
4047
4048 void nx_check_protection() {
4049 // If NX is enabled we'll get an exception calling into code on the stack
4050 char code[] = { (char)0xC3 }; // ret
4051 void *code_ptr = (void *)code;
4052 __try {
4053 __asm call code_ptr
4054 } __except(nx_exception_filter((_EXCEPTION_POINTERS*)_exception_info())) {
4062 void os::init(void) {
4063 _initial_pid = _getpid();
4064
4065 init_random(1234567);
4066
4067 win32::initialize_system_info();
4068 win32::setmode_streams();
4069 init_page_sizes((size_t) win32::vm_page_size());
4070
4071 // This may be overridden later when argument processing is done.
4072 FLAG_SET_ERGO(bool, UseLargePagesIndividualAllocation,
4073 os::win32::is_windows_2003());
4074
4075 // Initialize main_process and main_thread
4076 main_process = GetCurrentProcess(); // Remember main_process is a pseudo handle
4077 if (!DuplicateHandle(main_process, GetCurrentThread(), main_process,
4078 &main_thread, THREAD_ALL_ACCESS, false, 0)) {
4079 fatal("DuplicateHandle failed\n");
4080 }
4081 main_thread_id = (int) GetCurrentThreadId();
4082 }
4083
4084 // To install functions for atexit processing
4085 extern "C" {
4086 static void perfMemory_exit_helper() {
4087 perfMemory_exit();
4088 }
4089 }
4090
4091 static jint initSock();
4092
4093 // this is called _after_ the global arguments have been parsed
4094 jint os::init_2(void) {
4095 // Allocate a single page and mark it as readable for safepoint polling
4096 address polling_page = (address)VirtualAlloc(NULL, os::vm_page_size(), MEM_RESERVE, PAGE_READONLY);
4097 guarantee(polling_page != NULL, "Reserve Failed for polling page");
4098
4099 address return_page = (address)VirtualAlloc(polling_page, os::vm_page_size(), MEM_COMMIT, PAGE_READONLY);
4100 guarantee(return_page != NULL, "Commit Failed for polling page");
4101
5160
5161 void Parker::park(bool isAbsolute, jlong time) {
5162 guarantee(_ParkEvent != NULL, "invariant");
5163 // First, demultiplex/decode time arguments
5164 if (time < 0) { // don't wait
5165 return;
5166 } else if (time == 0 && !isAbsolute) {
5167 time = INFINITE;
5168 } else if (isAbsolute) {
5169 time -= os::javaTimeMillis(); // convert to relative time
5170 if (time <= 0) { // already elapsed
5171 return;
5172 }
5173 } else { // relative
5174 time /= 1000000; // Must coarsen from nanos to millis
5175 if (time == 0) { // Wait for the minimal time unit if zero
5176 time = 1;
5177 }
5178 }
5179
5180 JavaThread* thread = (JavaThread*)(Thread::current());
5181 assert(thread->is_Java_thread(), "Must be JavaThread");
5182 JavaThread *jt = (JavaThread *)thread;
5183
5184 // Don't wait if interrupted or already triggered
5185 if (Thread::is_interrupted(thread, false) ||
5186 WaitForSingleObject(_ParkEvent, 0) == WAIT_OBJECT_0) {
5187 ResetEvent(_ParkEvent);
5188 return;
5189 } else {
5190 ThreadBlockInVM tbivm(jt);
5191 OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
5192 jt->set_suspend_equivalent();
5193
5194 WaitForSingleObject(_ParkEvent, time);
5195 ResetEvent(_ParkEvent);
5196
5197 // If externally suspended while waiting, re-suspend
5198 if (jt->handle_special_suspend_equivalent_condition()) {
5199 jt->java_suspend_self();
5200 }
5201 }
5202 }
5203
5204 void Parker::unpark() {
5205 guarantee(_ParkEvent != NULL, "invariant");
5206 SetEvent(_ParkEvent);
5207 }
5208
5209 // Run the specified command in a separate process. Return its exit value,
5210 // or -1 on failure (e.g. can't create a new process).
5211 int os::fork_and_exec(char* cmd) {
5212 STARTUPINFO si;
5213 PROCESS_INFORMATION pi;
5214
5215 memset(&si, 0, sizeof(si));
5216 si.cb = sizeof(si);
5217 memset(&pi, 0, sizeof(pi));
5218 BOOL rslt = CreateProcess(NULL, // executable name - use command line
5219 cmd, // command line
5274 if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) {
5275 fatal("heap walk aborted with error %d", err);
5276 }
5277 HeapUnlock(heap);
5278 }
5279 mallocDebugIntervalCounter = 0;
5280 }
5281 return true;
5282 }
5283
5284
5285 bool os::find(address addr, outputStream* st) {
5286 // Nothing yet
5287 return false;
5288 }
5289
5290 LONG WINAPI os::win32::serialize_fault_filter(struct _EXCEPTION_POINTERS* e) {
5291 DWORD exception_code = e->ExceptionRecord->ExceptionCode;
5292
5293 if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
5294 JavaThread* thread = (JavaThread*)ThreadLocalStorage::get_thread_slow();
5295 PEXCEPTION_RECORD exceptionRecord = e->ExceptionRecord;
5296 address addr = (address) exceptionRecord->ExceptionInformation[1];
5297
5298 if (os::is_memory_serialize_page(thread, addr)) {
5299 return EXCEPTION_CONTINUE_EXECUTION;
5300 }
5301 }
5302
5303 return EXCEPTION_CONTINUE_SEARCH;
5304 }
5305
5306 // We don't build a headless jre for Windows
5307 bool os::is_headless_jre() { return false; }
5308
5309 static jint initSock() {
5310 WSADATA wsadata;
5311
5312 if (!os::WinSock2Dll::WinSock2Available()) {
5313 jio_fprintf(stderr, "Could not load Winsock (error: %d)\n",
5314 ::GetLastError());
5984 if (actual_location == NULL) {
5985 if (VerboseInternalVMTests) {
5986 gclog_or_tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.",
5987 expected_location, large_allocation_size);
5988 }
5989 } else {
5990 // release memory
5991 os::release_memory_special(actual_location, expected_allocation_size);
5992 // only now check, after releasing any memory to avoid any leaks.
5993 assert(actual_location == expected_location,
5994 "Failed to allocate memory at requested location " PTR_FORMAT " of size " SIZE_FORMAT ", is " PTR_FORMAT " instead",
5995 expected_location, expected_allocation_size, actual_location);
5996 }
5997 }
5998
5999 // restore globals
6000 UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation;
6001 UseNUMAInterleaving = old_use_numa_interleaving;
6002 }
6003 #endif // PRODUCT
|
402 if (time_struct_ptr != NULL) {
403 *res = *time_struct_ptr;
404 return res;
405 }
406 return NULL;
407 }
408
409 LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
410
411 // Thread start routine for all new Java threads
412 static unsigned __stdcall java_start(Thread* thread) {
413 // Try to randomize the cache line index of hot stack frames.
414 // This helps when threads of the same stack traces evict each other's
415 // cache lines. The threads can be either from the same JVM instance, or
416 // from different JVM instances. The benefit is especially true for
417 // processors with hyperthreading technology.
418 static int counter = 0;
419 int pid = os::current_process_id();
420 _alloca(((pid ^ counter++) & 7) * 128);
421
422 thread->initialize_thread_current();
423
424 OSThread* osthr = thread->osthread();
425 assert(osthr->get_state() == RUNNABLE, "invalid os thread state");
426
427 if (UseNUMA) {
428 int lgrp_id = os::numa_get_group_id();
429 if (lgrp_id != -1) {
430 thread->set_lgrp_id(lgrp_id);
431 }
432 }
433
434 // Diagnostic code to investigate JDK-6573254
435 int res = 30115; // non-java thread
436 if (thread->is_Java_thread()) {
437 res = 20115; // java thread
438 }
439
440 // Install a win32 structured exception handler around every thread created
441 // by VM, so VM can generate error dump when an exception occurred in non-
442 // Java thread (e.g. VM thread).
443 __try {
2131 assert(ret != 0, "ReleaseSemaphore() failed");
2132
2133 thread->java_suspend_self();
2134 }
2135 } while (threadIsSuspended);
2136 }
2137 }
2138
2139 int os::signal_lookup() {
2140 return check_pending_signals(false);
2141 }
2142
2143 int os::signal_wait() {
2144 return check_pending_signals(true);
2145 }
2146
2147 // Implicit OS exception handling
2148
2149 LONG Handle_Exception(struct _EXCEPTION_POINTERS* exceptionInfo,
2150 address handler) {
2151 JavaThread* thread = (JavaThread*) Thread::current_or_null();
2152 // Save pc in thread
2153 #ifdef _M_IA64
2154 // Do not blow up if no thread info available.
2155 if (thread) {
2156 // Saving PRECISE pc (with slot information) in thread.
2157 uint64_t precise_pc = (uint64_t) exceptionInfo->ExceptionRecord->ExceptionAddress;
2158 // Convert precise PC into "Unix" format
2159 precise_pc = (precise_pc & 0xFFFFFFFFFFFFFFF0) | ((precise_pc & 0xF) >> 2);
2160 thread->set_saved_exception_pc((address)precise_pc);
2161 }
2162 // Set pc to handler
2163 exceptionInfo->ContextRecord->StIIP = (DWORD64)handler;
2164 // Clear out psr.ri (= Restart Instruction) in order to continue
2165 // at the beginning of the target bundle.
2166 exceptionInfo->ContextRecord->StIPSR &= 0xFFFFF9FFFFFFFFFF;
2167 assert(((DWORD64)handler & 0xF) == 0, "Target address must point to the beginning of a bundle!");
2168 #else
2169 #ifdef _M_AMD64
2170 // Do not blow up if no thread info available.
2171 if (thread) {
2369 //-----------------------------------------------------------------------------
2370 LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
2371 if (InterceptOSException) return EXCEPTION_CONTINUE_SEARCH;
2372 DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;
2373 #ifdef _M_IA64
2374 // On Itanium, we need the "precise pc", which has the slot number coded
2375 // into the least 4 bits: 0000=slot0, 0100=slot1, 1000=slot2 (Windows format).
2376 address pc = (address) exceptionInfo->ExceptionRecord->ExceptionAddress;
2377 // Convert the pc to "Unix format", which has the slot number coded
2378 // into the least 2 bits: 0000=slot0, 0001=slot1, 0010=slot2
2379 // This is needed for IA64 because "relocation" / "implicit null check" / "poll instruction"
2380 // information is saved in the Unix format.
2381 address pc_unix_format = (address) ((((uint64_t)pc) & 0xFFFFFFFFFFFFFFF0) | ((((uint64_t)pc) & 0xF) >> 2));
2382 #else
2383 #ifdef _M_AMD64
2384 address pc = (address) exceptionInfo->ContextRecord->Rip;
2385 #else
2386 address pc = (address) exceptionInfo->ContextRecord->Eip;
2387 #endif
2388 #endif
2389 Thread* t = Thread::current_or_null_safe();
2390
2391 // Handle SafeFetch32 and SafeFetchN exceptions.
2392 if (StubRoutines::is_safefetch_fault(pc)) {
2393 return Handle_Exception(exceptionInfo, StubRoutines::continuation_for_safefetch_fault(pc));
2394 }
2395
2396 #ifndef _WIN64
2397 // Execution protection violation - win32 running on AMD64 only
2398 // Handled first to avoid misdiagnosis as a "normal" access violation;
2399 // This is safe to do because we have a new/unique ExceptionInformation
2400 // code for this condition.
2401 if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
2402 PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
2403 int exception_subcode = (int) exceptionRecord->ExceptionInformation[0];
2404 address addr = (address) exceptionRecord->ExceptionInformation[1];
2405
2406 if (exception_subcode == EXCEPTION_INFO_EXEC_VIOLATION) {
2407 int page_size = os::vm_page_size();
2408
2409 // Make sure the pc and the faulting address are sane.
3996
3997 bool os::is_debugger_attached() {
3998 return IsDebuggerPresent() ? true : false;
3999 }
4000
4001
4002 void os::wait_for_keypress_at_exit(void) {
4003 if (PauseAtExit) {
4004 fprintf(stderr, "Press any key to continue...\n");
4005 fgetc(stdin);
4006 }
4007 }
4008
4009
4010 int os::message_box(const char* title, const char* message) {
4011 int result = MessageBox(NULL, message, title,
4012 MB_YESNO | MB_ICONERROR | MB_SYSTEMMODAL | MB_DEFAULT_DESKTOP_ONLY);
4013 return result == IDYES;
4014 }
4015
4016 #ifndef PRODUCT
4017 #ifndef _WIN64
4018 // Helpers to check whether NX protection is enabled
4019 int nx_exception_filter(_EXCEPTION_POINTERS *pex) {
4020 if (pex->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION &&
4021 pex->ExceptionRecord->NumberParameters > 0 &&
4022 pex->ExceptionRecord->ExceptionInformation[0] ==
4023 EXCEPTION_INFO_EXEC_VIOLATION) {
4024 return EXCEPTION_EXECUTE_HANDLER;
4025 }
4026 return EXCEPTION_CONTINUE_SEARCH;
4027 }
4028
4029 void nx_check_protection() {
4030 // If NX is enabled we'll get an exception calling into code on the stack
4031 char code[] = { (char)0xC3 }; // ret
4032 void *code_ptr = (void *)code;
4033 __try {
4034 __asm call code_ptr
4035 } __except(nx_exception_filter((_EXCEPTION_POINTERS*)_exception_info())) {
4043 void os::init(void) {
4044 _initial_pid = _getpid();
4045
4046 init_random(1234567);
4047
4048 win32::initialize_system_info();
4049 win32::setmode_streams();
4050 init_page_sizes((size_t) win32::vm_page_size());
4051
4052 // This may be overridden later when argument processing is done.
4053 FLAG_SET_ERGO(bool, UseLargePagesIndividualAllocation,
4054 os::win32::is_windows_2003());
4055
4056 // Initialize main_process and main_thread
4057 main_process = GetCurrentProcess(); // Remember main_process is a pseudo handle
4058 if (!DuplicateHandle(main_process, GetCurrentThread(), main_process,
4059 &main_thread, THREAD_ALL_ACCESS, false, 0)) {
4060 fatal("DuplicateHandle failed\n");
4061 }
4062 main_thread_id = (int) GetCurrentThreadId();
4063
4064 // initialize fast thread access - only used for 32-bit
4065 win32::initialize_thread_ptr_offset();
4066 }
4067
4068 // To install functions for atexit processing
4069 extern "C" {
4070 static void perfMemory_exit_helper() {
4071 perfMemory_exit();
4072 }
4073 }
4074
4075 static jint initSock();
4076
4077 // this is called _after_ the global arguments have been parsed
4078 jint os::init_2(void) {
4079 // Allocate a single page and mark it as readable for safepoint polling
4080 address polling_page = (address)VirtualAlloc(NULL, os::vm_page_size(), MEM_RESERVE, PAGE_READONLY);
4081 guarantee(polling_page != NULL, "Reserve Failed for polling page");
4082
4083 address return_page = (address)VirtualAlloc(polling_page, os::vm_page_size(), MEM_COMMIT, PAGE_READONLY);
4084 guarantee(return_page != NULL, "Commit Failed for polling page");
4085
5144
5145 void Parker::park(bool isAbsolute, jlong time) {
5146 guarantee(_ParkEvent != NULL, "invariant");
5147 // First, demultiplex/decode time arguments
5148 if (time < 0) { // don't wait
5149 return;
5150 } else if (time == 0 && !isAbsolute) {
5151 time = INFINITE;
5152 } else if (isAbsolute) {
5153 time -= os::javaTimeMillis(); // convert to relative time
5154 if (time <= 0) { // already elapsed
5155 return;
5156 }
5157 } else { // relative
5158 time /= 1000000; // Must coarsen from nanos to millis
5159 if (time == 0) { // Wait for the minimal time unit if zero
5160 time = 1;
5161 }
5162 }
5163
5164 JavaThread* thread = JavaThread::current();
5165
5166 // Don't wait if interrupted or already triggered
5167 if (Thread::is_interrupted(thread, false) ||
5168 WaitForSingleObject(_ParkEvent, 0) == WAIT_OBJECT_0) {
5169 ResetEvent(_ParkEvent);
5170 return;
5171 } else {
5172 ThreadBlockInVM tbivm(thread);
5173 OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
5174 thread->set_suspend_equivalent();
5175
5176 WaitForSingleObject(_ParkEvent, time);
5177 ResetEvent(_ParkEvent);
5178
5179 // If externally suspended while waiting, re-suspend
5180 if (thread->handle_special_suspend_equivalent_condition()) {
5181 thread->java_suspend_self();
5182 }
5183 }
5184 }
5185
5186 void Parker::unpark() {
5187 guarantee(_ParkEvent != NULL, "invariant");
5188 SetEvent(_ParkEvent);
5189 }
5190
5191 // Run the specified command in a separate process. Return its exit value,
5192 // or -1 on failure (e.g. can't create a new process).
5193 int os::fork_and_exec(char* cmd) {
5194 STARTUPINFO si;
5195 PROCESS_INFORMATION pi;
5196
5197 memset(&si, 0, sizeof(si));
5198 si.cb = sizeof(si);
5199 memset(&pi, 0, sizeof(pi));
5200 BOOL rslt = CreateProcess(NULL, // executable name - use command line
5201 cmd, // command line
5256 if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) {
5257 fatal("heap walk aborted with error %d", err);
5258 }
5259 HeapUnlock(heap);
5260 }
5261 mallocDebugIntervalCounter = 0;
5262 }
5263 return true;
5264 }
5265
5266
5267 bool os::find(address addr, outputStream* st) {
5268 // Nothing yet
5269 return false;
5270 }
5271
5272 LONG WINAPI os::win32::serialize_fault_filter(struct _EXCEPTION_POINTERS* e) {
5273 DWORD exception_code = e->ExceptionRecord->ExceptionCode;
5274
5275 if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
5276 JavaThread* thread = JavaThread::current();
5277 PEXCEPTION_RECORD exceptionRecord = e->ExceptionRecord;
5278 address addr = (address) exceptionRecord->ExceptionInformation[1];
5279
5280 if (os::is_memory_serialize_page(thread, addr)) {
5281 return EXCEPTION_CONTINUE_EXECUTION;
5282 }
5283 }
5284
5285 return EXCEPTION_CONTINUE_SEARCH;
5286 }
5287
5288 // We don't build a headless jre for Windows
5289 bool os::is_headless_jre() { return false; }
5290
5291 static jint initSock() {
5292 WSADATA wsadata;
5293
5294 if (!os::WinSock2Dll::WinSock2Available()) {
5295 jio_fprintf(stderr, "Could not load Winsock (error: %d)\n",
5296 ::GetLastError());
5966 if (actual_location == NULL) {
5967 if (VerboseInternalVMTests) {
5968 gclog_or_tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.",
5969 expected_location, large_allocation_size);
5970 }
5971 } else {
5972 // release memory
5973 os::release_memory_special(actual_location, expected_allocation_size);
5974 // only now check, after releasing any memory to avoid any leaks.
5975 assert(actual_location == expected_location,
5976 "Failed to allocate memory at requested location " PTR_FORMAT " of size " SIZE_FORMAT ", is " PTR_FORMAT " instead",
5977 expected_location, expected_allocation_size, actual_location);
5978 }
5979 }
5980
5981 // restore globals
5982 UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation;
5983 UseNUMAInterleaving = old_use_numa_interleaving;
5984 }
5985 #endif // PRODUCT
5986
5987 // Fast current thread access
5988
5989 int os::win32::_thread_ptr_offset = 0;
5990
5991 static void call_wrapper_dummy() {}
5992
5993 // We need to call the os_exception_wrapper once so that it sets
5994 // up the offset from FS of the thread pointer.
5995 void os::win32::initialize_thread_ptr_offset() {
5996 os::os_exception_wrapper((java_call_t)call_wrapper_dummy,
5997 NULL, NULL, NULL, NULL);
5998 }
|