0N/A/*
4170N/A * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "classfile/classLoader.hpp"
1879N/A#include "classfile/javaClasses.hpp"
1879N/A#include "classfile/systemDictionary.hpp"
1879N/A#include "classfile/vmSymbols.hpp"
1879N/A#include "code/scopeDesc.hpp"
1879N/A#include "compiler/compileBroker.hpp"
1879N/A#include "interpreter/interpreter.hpp"
1879N/A#include "interpreter/linkResolver.hpp"
2433N/A#include "interpreter/oopMapCache.hpp"
2011N/A#include "jvmtifiles/jvmtiEnv.hpp"
3158N/A#include "memory/gcLocker.inline.hpp"
1879N/A#include "memory/oopFactory.hpp"
1879N/A#include "memory/universe.inline.hpp"
1879N/A#include "oops/instanceKlass.hpp"
1879N/A#include "oops/objArrayOop.hpp"
1879N/A#include "oops/oop.inline.hpp"
2062N/A#include "oops/symbol.hpp"
1879N/A#include "prims/jvm_misc.hpp"
1879N/A#include "prims/jvmtiExport.hpp"
1879N/A#include "prims/jvmtiThreadState.hpp"
1879N/A#include "prims/privilegedStack.hpp"
1879N/A#include "runtime/aprofiler.hpp"
1879N/A#include "runtime/arguments.hpp"
1879N/A#include "runtime/biasedLocking.hpp"
1879N/A#include "runtime/deoptimization.hpp"
1879N/A#include "runtime/fprofiler.hpp"
1879N/A#include "runtime/frame.inline.hpp"
1879N/A#include "runtime/init.hpp"
1879N/A#include "runtime/interfaceSupport.hpp"
1879N/A#include "runtime/java.hpp"
1879N/A#include "runtime/javaCalls.hpp"
1879N/A#include "runtime/jniPeriodicChecker.hpp"
1879N/A#include "runtime/memprofiler.hpp"
1879N/A#include "runtime/mutexLocker.hpp"
1879N/A#include "runtime/objectMonitor.hpp"
1879N/A#include "runtime/osThread.hpp"
1879N/A#include "runtime/safepoint.hpp"
1879N/A#include "runtime/sharedRuntime.hpp"
1879N/A#include "runtime/statSampler.hpp"
1879N/A#include "runtime/stubRoutines.hpp"
1879N/A#include "runtime/task.hpp"
1879N/A#include "runtime/threadCritical.hpp"
1879N/A#include "runtime/threadLocalStorage.hpp"
1879N/A#include "runtime/vframe.hpp"
1879N/A#include "runtime/vframeArray.hpp"
1879N/A#include "runtime/vframe_hp.hpp"
1879N/A#include "runtime/vmThread.hpp"
1879N/A#include "runtime/vm_operations.hpp"
1879N/A#include "services/attachListener.hpp"
1879N/A#include "services/management.hpp"
3863N/A#include "services/memTracker.hpp"
1879N/A#include "services/threadService.hpp"
4141N/A#include "trace/tracing.hpp"
4141N/A#include "trace/traceMacros.hpp"
1879N/A#include "utilities/defaultStream.hpp"
1879N/A#include "utilities/dtrace.hpp"
1879N/A#include "utilities/events.hpp"
1879N/A#include "utilities/preserveException.hpp"
1879N/A#ifdef TARGET_OS_FAMILY_linux
1879N/A# include "os_linux.inline.hpp"
1879N/A# include "thread_linux.inline.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_OS_FAMILY_solaris
1879N/A# include "os_solaris.inline.hpp"
1879N/A# include "thread_solaris.inline.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_OS_FAMILY_windows
1879N/A# include "os_windows.inline.hpp"
1879N/A# include "thread_windows.inline.hpp"
1879N/A#endif
2796N/A#ifdef TARGET_OS_FAMILY_bsd
2796N/A# include "os_bsd.inline.hpp"
2796N/A# include "thread_bsd.inline.hpp"
2796N/A#endif
1879N/A#ifndef SERIALGC
1879N/A#include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
1879N/A#include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
1879N/A#include "gc_implementation/parallelScavenge/pcTasks.hpp"
1879N/A#endif
1879N/A#ifdef COMPILER1
1879N/A#include "c1/c1_Compiler.hpp"
1879N/A#endif
1879N/A#ifdef COMPILER2
1879N/A#include "opto/c2compiler.hpp"
1879N/A#include "opto/idealGraphPrinter.hpp"
1879N/A#endif
0N/A
0N/A#ifdef DTRACE_ENABLED
0N/A
0N/A// Only bother with this argument setup if dtrace is available
0N/A
2842N/A#ifndef USDT2
0N/AHS_DTRACE_PROBE_DECL(hotspot, vm__init__begin);
0N/AHS_DTRACE_PROBE_DECL(hotspot, vm__init__end);
0N/AHS_DTRACE_PROBE_DECL5(hotspot, thread__start, char*, intptr_t,
0N/A intptr_t, intptr_t, bool);
0N/AHS_DTRACE_PROBE_DECL5(hotspot, thread__stop, char*, intptr_t,
0N/A intptr_t, intptr_t, bool);
0N/A
0N/A#define DTRACE_THREAD_PROBE(probe, javathread) \
0N/A { \
0N/A ResourceMark rm(this); \
0N/A int len = 0; \
0N/A const char* name = (javathread)->get_thread_name(); \
0N/A len = strlen(name); \
0N/A HS_DTRACE_PROBE5(hotspot, thread__##probe, \
0N/A name, len, \
0N/A java_lang_Thread::thread_id((javathread)->threadObj()), \
0N/A (javathread)->osthread()->thread_id(), \
0N/A java_lang_Thread::is_daemon((javathread)->threadObj())); \
0N/A }
0N/A
2842N/A#else /* USDT2 */
2842N/A
2842N/A#define HOTSPOT_THREAD_PROBE_start HOTSPOT_THREAD_PROBE_START
2842N/A#define HOTSPOT_THREAD_PROBE_stop HOTSPOT_THREAD_PROBE_STOP
2842N/A
2842N/A#define DTRACE_THREAD_PROBE(probe, javathread) \
2842N/A { \
2842N/A ResourceMark rm(this); \
2842N/A int len = 0; \
2842N/A const char* name = (javathread)->get_thread_name(); \
2842N/A len = strlen(name); \
2842N/A HOTSPOT_THREAD_PROBE_##probe( /* probe = start, stop */ \
2842N/A (char *) name, len, \
2842N/A java_lang_Thread::thread_id((javathread)->threadObj()), \
2842N/A (uintptr_t) (javathread)->osthread()->thread_id(), \
2842N/A java_lang_Thread::is_daemon((javathread)->threadObj())); \
2842N/A }
2842N/A
2842N/A#endif /* USDT2 */
2842N/A
0N/A#else // ndef DTRACE_ENABLED
0N/A
0N/A#define DTRACE_THREAD_PROBE(probe, javathread)
0N/A
0N/A#endif // ndef DTRACE_ENABLED
0N/A
3863N/A
0N/A// Class hierarchy
0N/A// - Thread
0N/A// - VMThread
0N/A// - WatcherThread
0N/A// - ConcurrentMarkSweepThread
0N/A// - JavaThread
0N/A// - CompilerThread
0N/A
0N/A// ======= Thread ========
0N/A// Support for forcing alignment of thread objects for biased locking
3863N/Avoid* Thread::allocate(size_t size, bool throw_excpt, MEMFLAGS flags) {
0N/A if (UseBiasedLocking) {
0N/A const int alignment = markOopDesc::biased_lock_alignment;
0N/A size_t aligned_size = size + (alignment - sizeof(intptr_t));
3863N/A void* real_malloc_addr = throw_excpt? AllocateHeap(aligned_size, flags, CURRENT_PC)
3863N/A : os::malloc(aligned_size, flags, CURRENT_PC);
0N/A void* aligned_addr = (void*) align_size_up((intptr_t) real_malloc_addr, alignment);
0N/A assert(((uintptr_t) aligned_addr + (uintptr_t) size) <=
0N/A ((uintptr_t) real_malloc_addr + (uintptr_t) aligned_size),
0N/A "JavaThread alignment code overflowed allocated storage");
0N/A if (TraceBiasedLocking) {
0N/A if (aligned_addr != real_malloc_addr)
0N/A tty->print_cr("Aligned thread " INTPTR_FORMAT " to " INTPTR_FORMAT,
0N/A real_malloc_addr, aligned_addr);
0N/A }
0N/A ((Thread*) aligned_addr)->_real_malloc_address = real_malloc_addr;
0N/A return aligned_addr;
0N/A } else {
3863N/A return throw_excpt? AllocateHeap(size, flags, CURRENT_PC)
3863N/A : os::malloc(size, flags, CURRENT_PC);
0N/A }
0N/A}
0N/A
0N/Avoid Thread::operator delete(void* p) {
0N/A if (UseBiasedLocking) {
0N/A void* real_malloc_addr = ((Thread*) p)->_real_malloc_address;
3863N/A FreeHeap(real_malloc_addr, mtThread);
0N/A } else {
3863N/A FreeHeap(p, mtThread);
0N/A }
0N/A}
0N/A
0N/A
0N/A// Base class for all threads: VMThread, WatcherThread, ConcurrentMarkSweepThread,
0N/A// JavaThread
0N/A
0N/A
0N/AThread::Thread() {
1988N/A // stack and get_thread
1988N/A set_stack_base(NULL);
1988N/A set_stack_size(0);
1988N/A set_self_raw_id(0);
1988N/A set_lgrp_id(-1);
0N/A
0N/A // allocated data structures
1988N/A set_osthread(NULL);
3863N/A set_resource_area(new (mtThread)ResourceArea());
3863N/A set_handle_area(new (mtThread) HandleArea(NULL));
0N/A set_active_handles(NULL);
0N/A set_free_handle_block(NULL);
0N/A set_last_handle_mark(NULL);
0N/A
0N/A // This initial value ==> never claimed.
0N/A _oops_do_parity = 0;
0N/A
0N/A // the handle mark links itself to last_handle_mark
0N/A new HandleMark(this);
0N/A
0N/A // plain initialization
0N/A debug_only(_owned_locks = NULL;)
0N/A debug_only(_allow_allocation_count = 0;)
0N/A NOT_PRODUCT(_allow_safepoint_count = 0;)
806N/A NOT_PRODUCT(_skip_gcalot = false;)
0N/A CHECK_UNHANDLED_OOPS_ONLY(_gc_locked_out_count = 0;)
0N/A _jvmti_env_iteration_count = 0;
1988N/A set_allocated_bytes(0);
0N/A _vm_operation_started_count = 0;
Error!

 

There was an error!

null

java.lang.NullPointerException