Mercurial > hg > graal-jvmci-8
comparison src/os/windows/vm/os_windows.cpp @ 7643:3ac7d10a6572
Merge with hsx25/hotspot.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 31 Jan 2013 15:42:25 +0100 |
parents | 989155e2d07a 2ef7061f13b4 |
children | fbbc2ea60c4d |
comparison
equal
deleted
inserted
replaced
7573:17b6a63fe7c2 | 7643:3ac7d10a6572 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
1872 if (sigbreakHandler != NULL) { | 1872 if (sigbreakHandler != NULL) { |
1873 (*sigbreakHandler)(SIGBREAK); | 1873 (*sigbreakHandler)(SIGBREAK); |
1874 } | 1874 } |
1875 return TRUE; | 1875 return TRUE; |
1876 break; | 1876 break; |
1877 case CTRL_LOGOFF_EVENT: { | |
1878 // Don't terminate JVM if it is running in a non-interactive session, | |
1879 // such as a service process. | |
1880 USEROBJECTFLAGS flags; | |
1881 HANDLE handle = GetProcessWindowStation(); | |
1882 if (handle != NULL && | |
1883 GetUserObjectInformation(handle, UOI_FLAGS, &flags, | |
1884 sizeof( USEROBJECTFLAGS), NULL)) { | |
1885 // If it is a non-interactive session, let next handler to deal | |
1886 // with it. | |
1887 if ((flags.dwFlags & WSF_VISIBLE) == 0) { | |
1888 return FALSE; | |
1889 } | |
1890 } | |
1891 } | |
1877 case CTRL_CLOSE_EVENT: | 1892 case CTRL_CLOSE_EVENT: |
1878 case CTRL_LOGOFF_EVENT: | |
1879 case CTRL_SHUTDOWN_EVENT: | 1893 case CTRL_SHUTDOWN_EVENT: |
1880 os::signal_raise(SIGTERM); | 1894 os::signal_raise(SIGTERM); |
1881 return TRUE; | 1895 return TRUE; |
1882 break; | 1896 break; |
1883 default: | 1897 default: |
2946 if (res == NULL) { | 2960 if (res == NULL) { |
2947 warning("NUMA page allocation failed"); | 2961 warning("NUMA page allocation failed"); |
2948 } | 2962 } |
2949 if( Verbose && PrintMiscellaneous ) { | 2963 if( Verbose && PrintMiscellaneous ) { |
2950 reserveTimer.stop(); | 2964 reserveTimer.stop(); |
2951 tty->print_cr("reserve_memory of %Ix bytes took %ld ms (%ld ticks)", bytes, | 2965 tty->print_cr("reserve_memory of %Ix bytes took " JLONG_FORMAT " ms (" JLONG_FORMAT " ticks)", bytes, |
2952 reserveTimer.milliseconds(), reserveTimer.ticks()); | 2966 reserveTimer.milliseconds(), reserveTimer.ticks()); |
2953 } | 2967 } |
2954 } | 2968 } |
2955 assert(res == NULL || addr == NULL || addr == res, | 2969 assert(res == NULL || addr == NULL || addr == res, |
2956 "Unexpected address from reserve."); | 2970 "Unexpected address from reserve."); |
4305 hFile = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, | 4319 hFile = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, |
4306 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); | 4320 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
4307 if (hFile == NULL) { | 4321 if (hFile == NULL) { |
4308 if (PrintMiscellaneous && Verbose) { | 4322 if (PrintMiscellaneous && Verbose) { |
4309 DWORD err = GetLastError(); | 4323 DWORD err = GetLastError(); |
4310 tty->print_cr("CreateFile() failed: GetLastError->%ld."); | 4324 tty->print_cr("CreateFile() failed: GetLastError->%ld.", err); |
4311 } | 4325 } |
4312 return NULL; | 4326 return NULL; |
4313 } | 4327 } |
4314 | 4328 |
4315 if (allow_exec) { | 4329 if (allow_exec) { |
4355 HANDLE hMap = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, | 4369 HANDLE hMap = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, |
4356 NULL /*file_name*/); | 4370 NULL /*file_name*/); |
4357 if (hMap == NULL) { | 4371 if (hMap == NULL) { |
4358 if (PrintMiscellaneous && Verbose) { | 4372 if (PrintMiscellaneous && Verbose) { |
4359 DWORD err = GetLastError(); | 4373 DWORD err = GetLastError(); |
4360 tty->print_cr("CreateFileMapping() failed: GetLastError->%ld."); | 4374 tty->print_cr("CreateFileMapping() failed: GetLastError->%ld.", err); |
4361 } | 4375 } |
4362 CloseHandle(hFile); | 4376 CloseHandle(hFile); |
4363 return NULL; | 4377 return NULL; |
4364 } | 4378 } |
4365 | 4379 |
4565 Millis -= prd ; | 4579 Millis -= prd ; |
4566 } | 4580 } |
4567 } | 4581 } |
4568 v = _Event ; | 4582 v = _Event ; |
4569 _Event = 0 ; | 4583 _Event = 0 ; |
4584 // see comment at end of os::PlatformEvent::park() below: | |
4570 OrderAccess::fence() ; | 4585 OrderAccess::fence() ; |
4571 // If we encounter a nearly simultanous timeout expiry and unpark() | 4586 // If we encounter a nearly simultanous timeout expiry and unpark() |
4572 // we return OS_OK indicating we awoke via unpark(). | 4587 // we return OS_OK indicating we awoke via unpark(). |
4573 // Implementor's license -- returning OS_TIMEOUT would be equally valid, however. | 4588 // Implementor's license -- returning OS_TIMEOUT would be equally valid, however. |
4574 return (v >= 0) ? OS_OK : OS_TIMEOUT ; | 4589 return (v >= 0) ? OS_OK : OS_TIMEOUT ; |
4602 guarantee (_Event >= 0, "invariant") ; | 4617 guarantee (_Event >= 0, "invariant") ; |
4603 } | 4618 } |
4604 | 4619 |
4605 void os::PlatformEvent::unpark() { | 4620 void os::PlatformEvent::unpark() { |
4606 guarantee (_ParkHandle != NULL, "Invariant") ; | 4621 guarantee (_ParkHandle != NULL, "Invariant") ; |
4607 int v ; | 4622 |
4608 for (;;) { | 4623 // Transitions for _Event: |
4609 v = _Event ; // Increment _Event if it's < 1. | 4624 // 0 :=> 1 |
4610 if (v > 0) { | 4625 // 1 :=> 1 |
4611 // If it's already signaled just return. | 4626 // -1 :=> either 0 or 1; must signal target thread |
4612 // The LD of _Event could have reordered or be satisfied | 4627 // That is, we can safely transition _Event from -1 to either |
4613 // by a read-aside from this processor's write buffer. | 4628 // 0 or 1. Forcing 1 is slightly more efficient for back-to-back |
4614 // To avoid problems execute a barrier and then | 4629 // unpark() calls. |
4615 // ratify the value. A degenerate CAS() would also work. | 4630 // See also: "Semaphores in Plan 9" by Mullender & Cox |
4616 // Viz., CAS (v+0, &_Event, v) == v). | 4631 // |
4617 OrderAccess::fence() ; | 4632 // Note: Forcing a transition from "-1" to "1" on an unpark() means |
4618 if (_Event == v) return ; | 4633 // that it will take two back-to-back park() calls for the owning |
4619 continue ; | 4634 // thread to block. This has the benefit of forcing a spurious return |
4620 } | 4635 // from the first park() call after an unpark() call which will help |
4621 if (Atomic::cmpxchg (v+1, &_Event, v) == v) break ; | 4636 // shake out uses of park() and unpark() without condition variables. |
4622 } | 4637 |
4623 if (v < 0) { | 4638 if (Atomic::xchg(1, &_Event) >= 0) return; |
4624 ::SetEvent (_ParkHandle) ; | 4639 |
4625 } | 4640 ::SetEvent(_ParkHandle); |
4626 } | 4641 } |
4627 | 4642 |
4628 | 4643 |
4629 // JSR166 | 4644 // JSR166 |
4630 // ------------------------------------------------------- | 4645 // ------------------------------------------------------- |