comparison src/os/windows/vm/os_windows.cpp @ 7482:989155e2d07a

Merge with hs25-b15.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 16 Jan 2013 01:34:24 +0100
parents 291ffc492eb6 4daebd4cc1dd
children 3ac7d10a6572
comparison
equal deleted inserted replaced
7381:6761a8f854a4 7482:989155e2d07a
180 char *bin = "\\bin"; 180 char *bin = "\\bin";
181 char home_dir[MAX_PATH]; 181 char home_dir[MAX_PATH];
182 182
183 if (!getenv("_ALT_JAVA_HOME_DIR", home_dir, MAX_PATH)) { 183 if (!getenv("_ALT_JAVA_HOME_DIR", home_dir, MAX_PATH)) {
184 os::jvm_path(home_dir, sizeof(home_dir)); 184 os::jvm_path(home_dir, sizeof(home_dir));
185 // Found the full path to jvm[_g].dll. 185 // Found the full path to jvm.dll.
186 // Now cut the path to <java_home>/jre if we can. 186 // Now cut the path to <java_home>/jre if we can.
187 *(strrchr(home_dir, '\\')) = '\0'; /* get rid of \jvm.dll */ 187 *(strrchr(home_dir, '\\')) = '\0'; /* get rid of \jvm.dll */
188 pslash = strrchr(home_dir, '\\'); 188 pslash = strrchr(home_dir, '\\');
189 if (pslash != NULL) { 189 if (pslash != NULL) {
190 *pslash = '\0'; /* get rid of \{client|server} */ 190 *pslash = '\0'; /* get rid of \{client|server} */
1713 // do nothing 1713 // do nothing
1714 } 1714 }
1715 1715
1716 static char saved_jvm_path[MAX_PATH] = {0}; 1716 static char saved_jvm_path[MAX_PATH] = {0};
1717 1717
1718 // Find the full path to the current module, jvm.dll or jvm_g.dll 1718 // Find the full path to the current module, jvm.dll
1719 void os::jvm_path(char *buf, jint buflen) { 1719 void os::jvm_path(char *buf, jint buflen) {
1720 // Error checking. 1720 // Error checking.
1721 if (buflen < MAX_PATH) { 1721 if (buflen < MAX_PATH) {
1722 assert(false, "must use a large-enough buffer"); 1722 assert(false, "must use a large-enough buffer");
1723 buf[0] = '\0'; 1723 buf[0] = '\0';
2895 reserve_memory(size - split, base + split); 2895 reserve_memory(size - split, base + split);
2896 } 2896 }
2897 } 2897 }
2898 } 2898 }
2899 2899
2900 // Multiple threads can race in this code but it's not possible to unmap small sections of
2901 // virtual space to get requested alignment, like posix-like os's.
2902 // Windows prevents multiple thread from remapping over each other so this loop is thread-safe.
2903 char* os::reserve_memory_aligned(size_t size, size_t alignment) {
2904 assert((alignment & (os::vm_allocation_granularity() - 1)) == 0,
2905 "Alignment must be a multiple of allocation granularity (page size)");
2906 assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned");
2907
2908 size_t extra_size = size + alignment;
2909 assert(extra_size >= size, "overflow, size is too large to allow alignment");
2910
2911 char* aligned_base = NULL;
2912
2913 do {
2914 char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
2915 if (extra_base == NULL) {
2916 return NULL;
2917 }
2918 // Do manual alignment
2919 aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);
2920
2921 os::release_memory(extra_base, extra_size);
2922
2923 aligned_base = os::reserve_memory(size, aligned_base);
2924
2925 } while (aligned_base == NULL);
2926
2927 return aligned_base;
2928 }
2929
2900 char* os::pd_reserve_memory(size_t bytes, char* addr, size_t alignment_hint) { 2930 char* os::pd_reserve_memory(size_t bytes, char* addr, size_t alignment_hint) {
2901 assert((size_t)addr % os::vm_allocation_granularity() == 0, 2931 assert((size_t)addr % os::vm_allocation_granularity() == 0,
2902 "reserve alignment"); 2932 "reserve alignment");
2903 assert(bytes % os::vm_allocation_granularity() == 0, "reserve block size"); 2933 assert(bytes % os::vm_allocation_granularity() == 0, "reserve block size");
2904 char* res; 2934 char* res;