equal
deleted
inserted
replaced
136 timeEndPeriod(1L); |
136 timeEndPeriod(1L); |
137 |
137 |
138 // Workaround for issue when a custom launcher doesn't call |
138 // Workaround for issue when a custom launcher doesn't call |
139 // DestroyJavaVM and NMT is trying to track memory when free is |
139 // DestroyJavaVM and NMT is trying to track memory when free is |
140 // called from a static destructor |
140 // called from a static destructor |
141 if (MemTracker::is_on()) { |
141 MemTracker::shutdown(); |
142 MemTracker::shutdown(MemTracker::NMT_normal); |
142 |
143 } |
|
144 break; |
143 break; |
145 default: |
144 default: |
146 break; |
145 break; |
147 } |
146 } |
148 return true; |
147 return true; |
161 bool os::getenv(const char* name, char* buffer, int len) { |
160 bool os::getenv(const char* name, char* buffer, int len) { |
162 int result = GetEnvironmentVariable(name, buffer, len); |
161 int result = GetEnvironmentVariable(name, buffer, len); |
163 return result > 0 && result < len; |
162 return result > 0 && result < len; |
164 } |
163 } |
165 |
164 |
|
165 bool os::unsetenv(const char* name) { |
|
166 assert(name != NULL, "Null pointer"); |
|
167 return (SetEnvironmentVariable(name, NULL) == TRUE); |
|
168 } |
166 |
169 |
167 // No setuid programs under Windows. |
170 // No setuid programs under Windows. |
168 bool os::have_special_privileges() { |
171 bool os::have_special_privileges() { |
169 return false; |
172 return false; |
170 } |
173 } |
317 /* |
320 /* |
318 * RtlCaptureStackBackTrace Windows API may not exist prior to Windows XP. |
321 * RtlCaptureStackBackTrace Windows API may not exist prior to Windows XP. |
319 * So far, this method is only used by Native Memory Tracking, which is |
322 * So far, this method is only used by Native Memory Tracking, which is |
320 * only supported on Windows XP or later. |
323 * only supported on Windows XP or later. |
321 */ |
324 */ |
322 address os::get_caller_pc(int n) { |
325 int os::get_native_stack(address* stack, int frames, int toSkip) { |
323 #ifdef _NMT_NOINLINE_ |
326 #ifdef _NMT_NOINLINE_ |
324 n++; |
327 toSkip ++; |
325 #endif |
328 #endif |
326 address pc; |
329 int captured = Kernel32Dll::RtlCaptureStackBackTrace(toSkip + 1, frames, |
327 if (os::Kernel32Dll::RtlCaptureStackBackTrace(n + 1, 1, (PVOID*)&pc, NULL) == 1) { |
330 (PVOID*)stack, NULL); |
328 return pc; |
331 for (int index = captured; index < frames; index ++) { |
329 } |
332 stack[index] = NULL; |
330 return NULL; |
333 } |
|
334 return captured; |
331 } |
335 } |
332 |
336 |
333 |
337 |
334 // os::current_stack_base() |
338 // os::current_stack_base() |
335 // |
339 // |
2899 size_of_reserve, // size of Reserve |
2903 size_of_reserve, // size of Reserve |
2900 MEM_RESERVE, |
2904 MEM_RESERVE, |
2901 PAGE_READWRITE); |
2905 PAGE_READWRITE); |
2902 // If reservation failed, return NULL |
2906 // If reservation failed, return NULL |
2903 if (p_buf == NULL) return NULL; |
2907 if (p_buf == NULL) return NULL; |
2904 MemTracker::record_virtual_memory_reserve((address)p_buf, size_of_reserve, mtNone, CALLER_PC); |
2908 MemTracker::record_virtual_memory_reserve((address)p_buf, size_of_reserve, CALLER_PC); |
2905 os::release_memory(p_buf, bytes + chunk_size); |
2909 os::release_memory(p_buf, bytes + chunk_size); |
2906 |
2910 |
2907 // we still need to round up to a page boundary (in case we are using large pages) |
2911 // we still need to round up to a page boundary (in case we are using large pages) |
2908 // but not to a chunk boundary (in case InterleavingGranularity doesn't align with page size) |
2912 // but not to a chunk boundary (in case InterleavingGranularity doesn't align with page size) |
2909 // instead we handle this in the bytes_to_rq computation below |
2913 // instead we handle this in the bytes_to_rq computation below |
2965 size_t bytes_to_release = bytes - bytes_remaining; |
2969 size_t bytes_to_release = bytes - bytes_remaining; |
2966 // NMT has yet to record any individual blocks, so it |
2970 // NMT has yet to record any individual blocks, so it |
2967 // need to create a dummy 'reserve' record to match |
2971 // need to create a dummy 'reserve' record to match |
2968 // the release. |
2972 // the release. |
2969 MemTracker::record_virtual_memory_reserve((address)p_buf, |
2973 MemTracker::record_virtual_memory_reserve((address)p_buf, |
2970 bytes_to_release, mtNone, CALLER_PC); |
2974 bytes_to_release, CALLER_PC); |
2971 os::release_memory(p_buf, bytes_to_release); |
2975 os::release_memory(p_buf, bytes_to_release); |
2972 } |
2976 } |
2973 #ifdef ASSERT |
2977 #ifdef ASSERT |
2974 if (should_inject_error) { |
2978 if (should_inject_error) { |
2975 if (TracePageSizes && Verbose) { |
2979 if (TracePageSizes && Verbose) { |
2984 next_alloc_addr += bytes_to_rq; |
2988 next_alloc_addr += bytes_to_rq; |
2985 count++; |
2989 count++; |
2986 } |
2990 } |
2987 // Although the memory is allocated individually, it is returned as one. |
2991 // Although the memory is allocated individually, it is returned as one. |
2988 // NMT records it as one block. |
2992 // NMT records it as one block. |
2989 address pc = CALLER_PC; |
|
2990 if ((flags & MEM_COMMIT) != 0) { |
2993 if ((flags & MEM_COMMIT) != 0) { |
2991 MemTracker::record_virtual_memory_reserve_and_commit((address)p_buf, bytes, mtNone, pc); |
2994 MemTracker::record_virtual_memory_reserve_and_commit((address)p_buf, bytes, CALLER_PC); |
2992 } else { |
2995 } else { |
2993 MemTracker::record_virtual_memory_reserve((address)p_buf, bytes, mtNone, pc); |
2996 MemTracker::record_virtual_memory_reserve((address)p_buf, bytes, CALLER_PC); |
2994 } |
2997 } |
2995 |
2998 |
2996 // made it this far, success |
2999 // made it this far, success |
2997 return p_buf; |
3000 return p_buf; |
2998 } |
3001 } |
3186 } |
3189 } |
3187 // normal policy just allocate it all at once |
3190 // normal policy just allocate it all at once |
3188 DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES; |
3191 DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES; |
3189 char * res = (char *)VirtualAlloc(addr, bytes, flag, prot); |
3192 char * res = (char *)VirtualAlloc(addr, bytes, flag, prot); |
3190 if (res != NULL) { |
3193 if (res != NULL) { |
3191 address pc = CALLER_PC; |
3194 MemTracker::record_virtual_memory_reserve_and_commit((address)res, bytes, CALLER_PC); |
3192 MemTracker::record_virtual_memory_reserve_and_commit((address)res, bytes, mtNone, pc); |
|
3193 } |
3195 } |
3194 |
3196 |
3195 return res; |
3197 return res; |
3196 } |
3198 } |
3197 } |
3199 } |