os.cpp revision 4499
1707N/A * or visit www.oracle.com if you need additional information or have any
1707N/A#include "precompiled.hpp"
5072N/A#include "classfile/classLoader.hpp"
1707N/A#include "classfile/javaClasses.hpp"
1707N/A#include "classfile/systemDictionary.hpp"
1920N/A#include "classfile/vmSymbols.hpp"
1707N/A#include "code/icBuffer.hpp"
3824N/A#include "code/vtableStubs.hpp"
3824N/A#include "gc_implementation/shared/vmGCOperations.hpp"
3824N/A#include "interpreter/interpreter.hpp"
3824N/A#include "memory/allocation.inline.hpp"
3824N/A#include "oops/oop.inline.hpp"
3842N/A#include "prims/jvm_misc.hpp"
3842N/A#include "prims/privilegedStack.hpp"
3824N/A#include "runtime/arguments.hpp"
3842N/A#include "runtime/frame.inline.hpp"
1707N/A#include "runtime/interfaceSupport.hpp"
2650N/A#include "runtime/javaCalls.hpp"
2976N/A#include "runtime/mutexLocker.hpp"
3824N/A#include "runtime/stubRoutines.hpp"
2976N/A#include "services/attachListener.hpp"
1707N/A#include "services/memTracker.hpp"
2549N/A#include "services/threadService.hpp"
2549N/A#include "utilities/defaultStream.hpp"
2549N/A#include "utilities/events.hpp"
3824N/A# include "os_linux.inline.hpp"
2549N/A# include "thread_linux.inline.hpp"
2549N/A# include "os_solaris.inline.hpp"
2976N/A# include "thread_solaris.inline.hpp"
1777N/A# include "os_windows.inline.hpp"
5072N/A# include "thread_windows.inline.hpp"
1707N/A#ifdef TARGET_OS_FAMILY_bsd
1777N/A# include "os_bsd.inline.hpp"
1777N/A# include "thread_bsd.inline.hpp"
#ifndef PRODUCT
void os_init_globals() {
// See Threads::create_vm() in thread.cpp, and init.cpp.
static const char* iso8601_format =
return NULL;
return NULL;
const int milliseconds_after_second =
return NULL;
#if defined(_ALLBSD_SOURCE)
if (local_to_UTC < 0) {
year,
zone_min);
if (printed == 0) {
return NULL;
return buffer;
#ifdef ASSERT
return OS_ERR;
int os_prio;
return OS_OK;
#ifndef SIGBREAK
int sig;
switch (sig) {
case SIGBREAK: {
if (PrintClassHistogram) {
&result,
&args,
if (HAS_PENDING_EXCEPTION) {
if (!ReduceSignalUsage) {
CHECK);
CHECK);
if (!ReduceSignalUsage)
#if defined(__OpenBSD__)
// Work-around OpenBSD's lack of $ORIGIN support by pre-loading libnet.so
if (onLoaded) {
return _native_java_library;
return dup_str;
#ifdef ASSERT
#define space_before 0
#define space_after 0
#define MallocCushion 0
#ifdef ASSERT
if (size < 0) {
return size;
while (*q == badResourceValue) q--;
while (*q == badResourceValue) q++;
return q - MallocCushion;
if (size <= 0 ) {
tty->print_cr("### previous object (not sure if correct): " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", obj, size);
tty->print_cr("### next object (not sure if correct): " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", next_obj, next_size);
tty->print_cr("## nof_mallocs = " UINT64_FORMAT ", nof_frees = " UINT64_FORMAT, os::num_mallocs, os::num_frees);
tty->print_cr("## memory stomp: byte at " PTR_FORMAT " %s object " PTR_FORMAT, bad, where, memblock);
if (MallocCushion) {
for (int i = 0; i < MallocCushion; i++) {
for (int j = -MallocCushion; j < 0; j++) {
if (size == 0) {
#ifdef ASSERT
if (MallocCushion) {
breakpoint();
if (PrintMalloc && tty != NULL) tty->print_cr("os::malloc " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, memblock);
return memblock;
#ifndef ASSERT
return ptr;
breakpoint();
if (PrintMalloc) tty->print_cr("os::remalloc " SIZE_FORMAT " bytes, " PTR_FORMAT " --> " PTR_FORMAT, size, memblock, ptr);
breakpoint();
return ptr;
#ifdef ASSERT
breakpoint();
if (MallocCushion) {
if (lo > m) {
lo &= m;
++lo;
if (lo > m) {
lo &= m;
++lo;
// However, when start_thread is called as a result of Thread.start, on a Java
int cols = 0;
int cols_per_line = 0;
switch (unitsize) {
while (p < end) {
switch (unitsize) {
p += unitsize;
cols++;
cols = 0;
if (env_list) {
// moved from debug.cpp (used to be find()) but still called from there
if (b != NULL) {
if (b->is_buffer_blob()) {
if (i != NULL) {
st->print_cr(INTPTR_FORMAT " is at code_begin+%d in an Interpreter codelet", addr, (int)(addr - i->code_begin()));
st->print_cr(INTPTR_FORMAT " is at code_begin+%d in an AdapterHandler", addr, (int)(addr - b->code_begin()));
if (d != NULL) {
if (v != NULL) {
st->print_cr(INTPTR_FORMAT " is at entry_point+%d in a vtable stub", addr, (int)(addr - v->entry_point()));
if (verbose) {
bool print = false;
print = true;
print = true;
if (print) {
#ifndef PRODUCT
if (verbose) {
#ifdef IA64
#ifdef ASSERT
long num;
for (int k = 0; k < reps; k++) {
double u = (double)num / m;
mean += u;
variance += (u*u);
const char* home,
int home_len,
char fileSep,
char pathSep) {
int formatted_path_len = 0;
for (p = format_string; *p != 0; ++p) {
return NULL;
char* q = formatted_path;
for (p = format_string; *p != 0; ++p) {
q += home_len;
*q++ = fileSep;
*q++ = pathSep;
return formatted_path;
static const char classpath_format[] =
"%/lib/resources.jar:"
"%/lib/sunrsasign.jar:"
"%/lib/charsets.jar:"
#ifdef __APPLE__
return NULL;
return NULL;
while (p != NULL) {
count++;
return NULL;
p = inpath;
for (int i = 0 ; i < count ; i++) {
return NULL;
if (s == NULL) {
return NULL;
opath[i] = s;
*n = count;
return opath;
if (TraceSafepoint) {
const int framesize_in_bytes =
if (UseLargePages) {
for (unsigned int i = 0; _page_sizes[i] != 0; ++i) {
return sz;
return sz;
return vm_page_size();
#ifndef PRODUCT
if (TracePageSizes) {
for (int i = 0; i < count; ++i) {
if (TracePageSizes) {
if (NeverActAsServerClassMachine) {
bool result = false;
const unsigned int logical_processors =
const unsigned int physical_packages =
result = true;
result = true;
return result;
buf[i] = 0;
char ch;
assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this");
_done = true;
return result;
return result;
return result;
if (res) {
return res;
bool executable) {
if (res) {
return res;
if (res) {
return res;
if (res) {
return res;
bool allow_exec) {
return result;
bool allow_exec) {
if (result) {
return result;