Mercurial > hg > graal-jvmci-8
diff src/share/vm/runtime/os.cpp @ 6948:e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Nov 2012 23:14:12 +0100 |
parents | 957c266d8bc5 716c64bda5ba |
children | 2cb439954abf |
line wrap: on
line diff
--- a/src/share/vm/runtime/os.cpp Mon Nov 12 18:11:17 2012 +0100 +++ b/src/share/vm/runtime/os.cpp Mon Nov 12 23:14:12 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -201,14 +201,21 @@ } } - +// The mapping from OS priority back to Java priority may be inexact because +// Java priorities can map M:1 with native priorities. If you want the definite +// Java priority then use JavaThread::java_priority() OSReturn os::get_priority(const Thread* const thread, ThreadPriority& priority) { int p; int os_prio; OSReturn ret = get_native_priority(thread, &os_prio); if (ret != OS_OK) return ret; - for (p = MaxPriority; p > MinPriority && java_to_os_priority[p] > os_prio; p--) ; + if (java_to_os_priority[MaxPriority] > java_to_os_priority[MinPriority]) { + for (p = MaxPriority; p > MinPriority && java_to_os_priority[p] > os_prio; p--) ; + } else { + // niceness values are in reverse order + for (p = MaxPriority; p > MinPriority && java_to_os_priority[p] < os_prio; p--) ; + } priority = (ThreadPriority)p; return OS_OK; } @@ -271,7 +278,7 @@ default: { // Dispatch the signal to java HandleMark hm(THREAD); - klassOop k = SystemDictionary::resolve_or_null(vmSymbols::sun_misc_Signal(), THREAD); + Klass* k = SystemDictionary::resolve_or_null(vmSymbols::sun_misc_Signal(), THREAD); KlassHandle klass (THREAD, k); if (klass.not_null()) { JavaValue result(T_VOID); @@ -294,7 +301,7 @@ char klass_name[256]; char tmp_sig_name[16]; const char* sig_name = "UNKNOWN"; - instanceKlass::cast(PENDING_EXCEPTION->klass())-> + InstanceKlass::cast(PENDING_EXCEPTION->klass())-> name()->as_klass_external_name(klass_name, 256); if (os::exception_name(sig, tmp_sig_name, 16) != NULL) sig_name = tmp_sig_name; @@ -314,7 +321,7 @@ if (!ReduceSignalUsage) { // Setup JavaThread for processing signals EXCEPTION_MARK; - klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK); + Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK); instanceKlassHandle klass (THREAD, k); instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); @@ -593,9 +600,7 @@ if (PrintMalloc && tty != NULL) tty->print_cr("os::malloc " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, memblock); // we do not track MallocCushion memory - if (MemTracker::is_on()) { MemTracker::record_malloc((address)memblock, size, memflags, caller == 0 ? CALLER_PC : caller); - } return memblock; } @@ -606,7 +611,7 @@ NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1)); NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size)); void* ptr = ::realloc(memblock, size); - if (ptr != NULL && MemTracker::is_on()) { + if (ptr != NULL) { MemTracker::record_realloc((address)memblock, (address)ptr, size, memflags, caller == 0 ? CALLER_PC : caller); } @@ -871,6 +876,7 @@ st->print(" for "); nm->method()->print_value_on(st); } + st->cr(); nm->print_nmethod(verbose); return; } @@ -891,19 +897,12 @@ print = true; } if (print) { - st->print_cr(INTPTR_FORMAT " is an oop", addr); + if (p == (HeapWord*) addr) { + st->print_cr(INTPTR_FORMAT " is an oop", addr); + } else { + st->print_cr(INTPTR_FORMAT " is pointing into object: " INTPTR_FORMAT, addr, p); + } oop(p)->print_on(st); - if (p != (HeapWord*)x && oop(p)->is_constMethod() && - constMethodOop(p)->contains(addr)) { - Thread *thread = Thread::current(); - HandleMark hm(thread); - methodHandle mh (thread, constMethodOop(p)->method()); - if (!mh->is_native()) { - st->print_cr("bci_from(%p) = %d; print_codes():", - addr, mh->bci_from(address(x))); - mh->print_codes_on(st); - } - } return; } } else { @@ -958,6 +957,17 @@ } } + +#ifndef PRODUCT + // Check if in metaspace. + if (ClassLoaderDataGraph::contains((address)addr)) { + // Use addr->print() from the debugger instead (not here) + st->print_cr(INTPTR_FORMAT + " is pointing into metadata", addr); + return; + } +#endif + // Try an OS specific find if (os::find(addr, st)) { return; @@ -1389,7 +1399,7 @@ char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint) { char* result = pd_reserve_memory(bytes, addr, alignment_hint); - if (result != NULL && MemTracker::is_on()) { + if (result != NULL) { MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); } @@ -1397,7 +1407,7 @@ } char* os::attempt_reserve_memory_at(size_t bytes, char* addr) { char* result = pd_attempt_reserve_memory_at(bytes, addr); - if (result != NULL && MemTracker::is_on()) { + if (result != NULL) { MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); } return result; @@ -1410,7 +1420,7 @@ bool os::commit_memory(char* addr, size_t bytes, bool executable) { bool res = pd_commit_memory(addr, bytes, executable); - if (res && MemTracker::is_on()) { + if (res) { MemTracker::record_virtual_memory_commit((address)addr, bytes, CALLER_PC); } return res; @@ -1419,7 +1429,7 @@ bool os::commit_memory(char* addr, size_t size, size_t alignment_hint, bool executable) { bool res = os::pd_commit_memory(addr, size, alignment_hint, executable); - if (res && MemTracker::is_on()) { + if (res) { MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC); } return res; @@ -1446,8 +1456,9 @@ char *addr, size_t bytes, bool read_only, bool allow_exec) { char* result = pd_map_memory(fd, file_name, file_offset, addr, bytes, read_only, allow_exec); - if (result != NULL && MemTracker::is_on()) { + if (result != NULL) { MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); + MemTracker::record_virtual_memory_commit((address)result, bytes, CALLER_PC); } return result; } @@ -1462,6 +1473,7 @@ bool os::unmap_memory(char *addr, size_t bytes) { bool result = pd_unmap_memory(addr, bytes); if (result) { + MemTracker::record_virtual_memory_uncommit((address)addr, bytes); MemTracker::record_virtual_memory_release((address)addr, bytes); } return result;