994 path_buf[0]='\0'; |
994 path_buf[0]='\0'; |
995 return path_buf; |
995 return path_buf; |
996 } |
996 } |
997 } |
997 } |
998 |
998 |
|
999 void os::dll_build_name(char *holder, size_t holderlen, |
|
1000 const char* pname, const char* fname) |
|
1001 { |
|
1002 // copied from libhpi |
|
1003 const size_t pnamelen = pname ? strlen(pname) : 0; |
|
1004 const char c = (pnamelen > 0) ? pname[pnamelen-1] : 0; |
|
1005 |
|
1006 /* Quietly truncates on buffer overflow. Should be an error. */ |
|
1007 if (pnamelen + strlen(fname) + 10 > holderlen) { |
|
1008 *holder = '\0'; |
|
1009 return; |
|
1010 } |
|
1011 |
|
1012 if (pnamelen == 0) { |
|
1013 sprintf(holder, "%s.dll", fname); |
|
1014 } else if (c == ':' || c == '\\') { |
|
1015 sprintf(holder, "%s%s.dll", pname, fname); |
|
1016 } else { |
|
1017 sprintf(holder, "%s\\%s.dll", pname, fname); |
|
1018 } |
|
1019 } |
|
1020 |
999 // Needs to be in os specific directory because windows requires another |
1021 // Needs to be in os specific directory because windows requires another |
1000 // header file <direct.h> |
1022 // header file <direct.h> |
1001 const char* os::get_current_directory(char *buf, int buflen) { |
1023 const char* os::get_current_directory(char *buf, int buflen) { |
1002 return _getcwd(buf, buflen); |
1024 return _getcwd(buf, buflen); |
1003 } |
1025 } |
1255 // for every module. That's too much work to do after a fatal error. |
1277 // for every module. That's too much work to do after a fatal error. |
1256 // For an example on how to implement this function, see 1.4.2. |
1278 // For an example on how to implement this function, see 1.4.2. |
1257 if (offset) *offset = -1; |
1279 if (offset) *offset = -1; |
1258 if (buf) buf[0] = '\0'; |
1280 if (buf) buf[0] = '\0'; |
1259 return false; |
1281 return false; |
|
1282 } |
|
1283 |
|
1284 void* os::dll_lookup(void* handle, const char* name) { |
|
1285 return GetProcAddress((HMODULE)handle, name); |
1260 } |
1286 } |
1261 |
1287 |
1262 // save the start and end address of jvm.dll into param[0] and param[1] |
1288 // save the start and end address of jvm.dll into param[0] and param[1] |
1263 static int _locate_jvm_dll(int pid, char* mod_fname, address base_addr, |
1289 static int _locate_jvm_dll(int pid, char* mod_fname, address base_addr, |
1264 unsigned size, void * param) { |
1290 unsigned size, void * param) { |
1430 int pid = os::current_process_id(); |
1456 int pid = os::current_process_id(); |
1431 st->print_cr("Dynamic libraries:"); |
1457 st->print_cr("Dynamic libraries:"); |
1432 enumerate_modules(pid, _print_module, (void *)st); |
1458 enumerate_modules(pid, _print_module, (void *)st); |
1433 } |
1459 } |
1434 |
1460 |
|
1461 // function pointer to Windows API "GetNativeSystemInfo". |
|
1462 typedef void (WINAPI *GetNativeSystemInfo_func_type)(LPSYSTEM_INFO); |
|
1463 static GetNativeSystemInfo_func_type _GetNativeSystemInfo; |
|
1464 |
1435 void os::print_os_info(outputStream* st) { |
1465 void os::print_os_info(outputStream* st) { |
1436 st->print("OS:"); |
1466 st->print("OS:"); |
1437 |
1467 |
1438 OSVERSIONINFOEX osvi; |
1468 OSVERSIONINFOEX osvi; |
1439 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); |
1469 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); |
1440 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
1470 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
1441 |
1471 |
1442 if (!GetVersionEx((OSVERSIONINFO *)&osvi)) { |
1472 if (!GetVersionEx((OSVERSIONINFO *)&osvi)) { |
1443 st->print_cr("N/A"); |
1473 st->print_cr("N/A"); |
1444 return; |
1474 return; |
1445 } |
1475 } |
1446 |
1476 |
1447 int os_vers = osvi.dwMajorVersion * 1000 + osvi.dwMinorVersion; |
1477 int os_vers = osvi.dwMajorVersion * 1000 + osvi.dwMinorVersion; |
1448 |
1478 if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) { |
1449 if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) { |
1479 switch (os_vers) { |
1450 switch (os_vers) { |
1480 case 3051: st->print(" Windows NT 3.51"); break; |
1451 case 3051: st->print(" Windows NT 3.51"); break; |
1481 case 4000: st->print(" Windows NT 4.0"); break; |
1452 case 4000: st->print(" Windows NT 4.0"); break; |
1482 case 5000: st->print(" Windows 2000"); break; |
1453 case 5000: st->print(" Windows 2000"); break; |
1483 case 5001: st->print(" Windows XP"); break; |
1454 case 5001: st->print(" Windows XP"); break; |
1484 case 5002: |
1455 case 5002: st->print(" Windows Server 2003 family"); break; |
1485 case 6000: { |
1456 case 6000: st->print(" Windows Vista"); break; |
1486 // Retrieve SYSTEM_INFO from GetNativeSystemInfo call so that we could |
1457 default: // future windows, print out its major and minor versions |
1487 // find out whether we are running on 64 bit processor or not. |
1458 st->print(" Windows NT %d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion); |
1488 SYSTEM_INFO si; |
1459 } |
1489 ZeroMemory(&si, sizeof(SYSTEM_INFO)); |
1460 } else { |
1490 // Check to see if _GetNativeSystemInfo has been initialized. |
1461 switch (os_vers) { |
1491 if (_GetNativeSystemInfo == NULL) { |
1462 case 4000: st->print(" Windows 95"); break; |
1492 HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32.dll")); |
1463 case 4010: st->print(" Windows 98"); break; |
1493 _GetNativeSystemInfo = |
1464 case 4090: st->print(" Windows Me"); break; |
1494 CAST_TO_FN_PTR(GetNativeSystemInfo_func_type, |
1465 default: // future windows, print out its major and minor versions |
1495 GetProcAddress(hKernel32, |
1466 st->print(" Windows %d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion); |
1496 "GetNativeSystemInfo")); |
1467 } |
1497 if (_GetNativeSystemInfo == NULL) |
1468 } |
1498 GetSystemInfo(&si); |
1469 |
1499 } else { |
1470 st->print(" Build %d", osvi.dwBuildNumber); |
1500 _GetNativeSystemInfo(&si); |
1471 st->print(" %s", osvi.szCSDVersion); // service pack |
1501 } |
1472 st->cr(); |
1502 if (os_vers == 5002) { |
|
1503 if (osvi.wProductType == VER_NT_WORKSTATION && |
|
1504 si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) |
|
1505 st->print(" Windows XP x64 Edition"); |
|
1506 else |
|
1507 st->print(" Windows Server 2003 family"); |
|
1508 } else { // os_vers == 6000 |
|
1509 if (osvi.wProductType == VER_NT_WORKSTATION) |
|
1510 st->print(" Windows Vista"); |
|
1511 else |
|
1512 st->print(" Windows Server 2008"); |
|
1513 if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) |
|
1514 st->print(" , 64 bit"); |
|
1515 } |
|
1516 break; |
|
1517 } |
|
1518 default: // future windows, print out its major and minor versions |
|
1519 st->print(" Windows NT %d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion); |
|
1520 } |
|
1521 } else { |
|
1522 switch (os_vers) { |
|
1523 case 4000: st->print(" Windows 95"); break; |
|
1524 case 4010: st->print(" Windows 98"); break; |
|
1525 case 4090: st->print(" Windows Me"); break; |
|
1526 default: // future windows, print out its major and minor versions |
|
1527 st->print(" Windows %d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion); |
|
1528 } |
|
1529 } |
|
1530 st->print(" Build %d", osvi.dwBuildNumber); |
|
1531 st->print(" %s", osvi.szCSDVersion); // service pack |
|
1532 st->cr(); |
1473 } |
1533 } |
1474 |
1534 |
1475 void os::print_memory_info(outputStream* st) { |
1535 void os::print_memory_info(outputStream* st) { |
1476 st->print("Memory:"); |
1536 st->print("Memory:"); |
1477 st->print(" %dk page", os::vm_page_size()>>10); |
1537 st->print(" %dk page", os::vm_page_size()>>10); |
2179 #else /* !IA64 */ |
2239 #else /* !IA64 */ |
2180 |
2240 |
2181 // Windows 98 reports faulting addresses incorrectly |
2241 // Windows 98 reports faulting addresses incorrectly |
2182 if (!MacroAssembler::needs_explicit_null_check((intptr_t)addr) || |
2242 if (!MacroAssembler::needs_explicit_null_check((intptr_t)addr) || |
2183 !os::win32::is_nt()) { |
2243 !os::win32::is_nt()) { |
|
2244 |
2184 return Handle_Exception(exceptionInfo, |
2245 return Handle_Exception(exceptionInfo, |
2185 SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL)); |
2246 SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL)); |
2186 } |
2247 } |
2187 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
2248 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
2188 exceptionInfo->ContextRecord); |
2249 exceptionInfo->ContextRecord); |
2572 |
2633 |
2573 bool os::release_memory(char* addr, size_t bytes) { |
2634 bool os::release_memory(char* addr, size_t bytes) { |
2574 return VirtualFree(addr, 0, MEM_RELEASE) != 0; |
2635 return VirtualFree(addr, 0, MEM_RELEASE) != 0; |
2575 } |
2636 } |
2576 |
2637 |
2577 bool os::protect_memory(char* addr, size_t bytes) { |
2638 // Set protections specified |
|
2639 bool os::protect_memory(char* addr, size_t bytes, ProtType prot, |
|
2640 bool is_committed) { |
|
2641 unsigned int p = 0; |
|
2642 switch (prot) { |
|
2643 case MEM_PROT_NONE: p = PAGE_NOACCESS; break; |
|
2644 case MEM_PROT_READ: p = PAGE_READONLY; break; |
|
2645 case MEM_PROT_RW: p = PAGE_READWRITE; break; |
|
2646 case MEM_PROT_RWX: p = PAGE_EXECUTE_READWRITE; break; |
|
2647 default: |
|
2648 ShouldNotReachHere(); |
|
2649 } |
|
2650 |
2578 DWORD old_status; |
2651 DWORD old_status; |
2579 return VirtualProtect(addr, bytes, PAGE_READONLY, &old_status) != 0; |
2652 |
|
2653 // Strange enough, but on Win32 one can change protection only for committed |
|
2654 // memory, not a big deal anyway, as bytes less or equal than 64K |
|
2655 if (!is_committed && !commit_memory(addr, bytes)) { |
|
2656 fatal("cannot commit protection page"); |
|
2657 } |
|
2658 // One cannot use os::guard_memory() here, as on Win32 guard page |
|
2659 // have different (one-shot) semantics, from MSDN on PAGE_GUARD: |
|
2660 // |
|
2661 // Pages in the region become guard pages. Any attempt to access a guard page |
|
2662 // causes the system to raise a STATUS_GUARD_PAGE exception and turn off |
|
2663 // the guard page status. Guard pages thus act as a one-time access alarm. |
|
2664 return VirtualProtect(addr, bytes, p, &old_status) != 0; |
2580 } |
2665 } |
2581 |
2666 |
2582 bool os::guard_memory(char* addr, size_t bytes) { |
2667 bool os::guard_memory(char* addr, size_t bytes) { |
2583 DWORD old_status; |
2668 DWORD old_status; |
2584 return VirtualProtect(addr, bytes, PAGE_EXECUTE_READWRITE | PAGE_GUARD, &old_status) != 0; |
2669 return VirtualProtect(addr, bytes, PAGE_EXECUTE_READWRITE | PAGE_GUARD, &old_status) != 0; |