comparison src/share/vm/runtime/thread.cpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents a29e6e7b7a86 a45a4f5a9609
children 40074f6ac788
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
1 /* 1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
113 #endif 113 #endif
114 #ifdef COMPILER2 114 #ifdef COMPILER2
115 #include "opto/c2compiler.hpp" 115 #include "opto/c2compiler.hpp"
116 #include "opto/idealGraphPrinter.hpp" 116 #include "opto/idealGraphPrinter.hpp"
117 #endif 117 #endif
118 #if INCLUDE_RTM_OPT
119 #include "runtime/rtmLocking.hpp"
120 #endif
121
122 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
118 123
119 #ifdef DTRACE_ENABLED 124 #ifdef DTRACE_ENABLED
120 125
121 // Only bother with this argument setup if dtrace is available 126 // Only bother with this argument setup if dtrace is available
122 127
242 // plain initialization 247 // plain initialization
243 debug_only(_owned_locks = NULL;) 248 debug_only(_owned_locks = NULL;)
244 debug_only(_allow_allocation_count = 0;) 249 debug_only(_allow_allocation_count = 0;)
245 NOT_PRODUCT(_allow_safepoint_count = 0;) 250 NOT_PRODUCT(_allow_safepoint_count = 0;)
246 NOT_PRODUCT(_skip_gcalot = false;) 251 NOT_PRODUCT(_skip_gcalot = false;)
247 CHECK_UNHANDLED_OOPS_ONLY(_gc_locked_out_count = 0;)
248 _jvmti_env_iteration_count = 0; 252 _jvmti_env_iteration_count = 0;
249 set_allocated_bytes(0); 253 set_allocated_bytes(0);
250 _vm_operation_started_count = 0; 254 _vm_operation_started_count = 0;
251 _vm_operation_completed_count = 0; 255 _vm_operation_completed_count = 0;
252 _current_pending_monitor = NULL; 256 _current_pending_monitor = NULL;
318 } 322 }
319 323
320 void Thread::record_stack_base_and_size() { 324 void Thread::record_stack_base_and_size() {
321 set_stack_base(os::current_stack_base()); 325 set_stack_base(os::current_stack_base());
322 set_stack_size(os::current_stack_size()); 326 set_stack_size(os::current_stack_size());
327 if (is_Java_thread()) {
328 ((JavaThread*) this)->set_stack_overflow_limit();
329 }
323 // CR 7190089: on Solaris, primordial thread's stack is adjusted 330 // CR 7190089: on Solaris, primordial thread's stack is adjusted
324 // in initialize_thread(). Without the adjustment, stack size is 331 // in initialize_thread(). Without the adjustment, stack size is
325 // incorrect if stack is set to unlimited (ulimit -s unlimited). 332 // incorrect if stack is set to unlimited (ulimit -s unlimited).
326 // So far, only Solaris has real implementation of initialize_thread(). 333 // So far, only Solaris has real implementation of initialize_thread().
327 // 334 //
1449 // A JavaThread is a normal Java thread 1456 // A JavaThread is a normal Java thread
1450 1457
1451 void JavaThread::initialize() { 1458 void JavaThread::initialize() {
1452 // Initialize fields 1459 // Initialize fields
1453 1460
1454 // Set the claimed par_id to -1 (ie not claiming any par_ids) 1461 // Set the claimed par_id to UINT_MAX (ie not claiming any par_ids)
1455 set_claimed_par_id(-1); 1462 set_claimed_par_id(UINT_MAX);
1456 1463
1457 _buffer_blob = NULL; 1464 _buffer_blob = NULL;
1458 set_saved_exception_pc(NULL); 1465 set_saved_exception_pc(NULL);
1459 set_threadObj(NULL); 1466 set_threadObj(NULL);
1460 _anchor.clear(); 1467 _anchor.clear();
1461 set_entry_point(NULL); 1468 set_entry_point(NULL);
3663 3670
3664 // Set flag that basic initialization has completed. Used by exceptions and various 3671 // Set flag that basic initialization has completed. Used by exceptions and various
3665 // debug stuff, that does not work until all basic classes have been initialized. 3672 // debug stuff, that does not work until all basic classes have been initialized.
3666 set_init_completed(); 3673 set_init_completed();
3667 3674
3675 Metaspace::post_initialize();
3676
3668 #ifndef USDT2 3677 #ifndef USDT2
3669 HS_DTRACE_PROBE(hotspot, vm__init__end); 3678 HS_DTRACE_PROBE(hotspot, vm__init__end);
3670 #else /* USDT2 */ 3679 #else /* USDT2 */
3671 HOTSPOT_VM_INIT_END(); 3680 HOTSPOT_VM_INIT_END();
3672 #endif /* USDT2 */ 3681 #endif /* USDT2 */
3778 if (MemProfiling) MemProfiler::engage(); 3787 if (MemProfiling) MemProfiler::engage();
3779 StatSampler::engage(); 3788 StatSampler::engage();
3780 if (CheckJNICalls) JniPeriodicChecker::engage(); 3789 if (CheckJNICalls) JniPeriodicChecker::engage();
3781 3790
3782 BiasedLocking::init(); 3791 BiasedLocking::init();
3792
3793 #if INCLUDE_RTM_OPT
3794 RTMLockingCounters::init();
3795 #endif
3783 3796
3784 if (JDK_Version::current().post_vm_init_hook_enabled()) { 3797 if (JDK_Version::current().post_vm_init_hook_enabled()) {
3785 call_postVMInitHook(THREAD); 3798 call_postVMInitHook(THREAD);
3786 // The Java side of PostVMInitHook.run must deal with all 3799 // The Java side of PostVMInitHook.run must deal with all
3787 // exceptions and provide means of diagnosis. 3800 // exceptions and provide means of diagnosis.
4109 { 4122 {
4110 // 4945125 The vm thread comes to a safepoint during exit. 4123 // 4945125 The vm thread comes to a safepoint during exit.
4111 // GC vm_operations can get caught at the safepoint, and the 4124 // GC vm_operations can get caught at the safepoint, and the
4112 // heap is unparseable if they are caught. Grab the Heap_lock 4125 // heap is unparseable if they are caught. Grab the Heap_lock
4113 // to prevent this. The GC vm_operations will not be able to 4126 // to prevent this. The GC vm_operations will not be able to
4114 // queue until after the vm thread is dead. 4127 // queue until after the vm thread is dead. After this point,
4115 // After this point, we'll never emerge out of the safepoint before 4128 // we'll never emerge out of the safepoint before the VM exits.
4116 // the VM exits, so concurrent GC threads do not need to be explicitly
4117 // stopped; they remain inactive until the process exits.
4118 // Note: some concurrent G1 threads may be running during a safepoint,
4119 // but these will not be accessing the heap, just some G1-specific side
4120 // data structures that are not accessed by any other threads but them
4121 // after this point in a terminal safepoint.
4122 4129
4123 MutexLocker ml(Heap_lock); 4130 MutexLocker ml(Heap_lock);
4124 4131
4125 VMThread::wait_for_vm_thread_exit(); 4132 VMThread::wait_for_vm_thread_exit();
4126 assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint"); 4133 assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
4424 } 4431 }
4425 4432
4426 // Threads::print_on() is called at safepoint by VM_PrintThreads operation. 4433 // Threads::print_on() is called at safepoint by VM_PrintThreads operation.
4427 void Threads::print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks) { 4434 void Threads::print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks) {
4428 char buf[32]; 4435 char buf[32];
4429 st->print_cr(os::local_time_string(buf, sizeof(buf))); 4436 st->print_raw_cr(os::local_time_string(buf, sizeof(buf)));
4430 4437
4431 st->print_cr("Full thread dump %s (%s %s):", 4438 st->print_cr("Full thread dump %s (%s %s):",
4432 Abstract_VM_Version::vm_name(), 4439 Abstract_VM_Version::vm_name(),
4433 Abstract_VM_Version::vm_release(), 4440 Abstract_VM_Version::vm_release(),
4434 Abstract_VM_Version::vm_info_string() 4441 Abstract_VM_Version::vm_info_string()
4561 for (;;) { 4568 for (;;) {
4562 while (*adr != 0) { 4569 while (*adr != 0) {
4563 ++ctr ; 4570 ++ctr ;
4564 if ((ctr & 0xFFF) == 0 || !os::is_MP()) { 4571 if ((ctr & 0xFFF) == 0 || !os::is_MP()) {
4565 if (Yields > 5) { 4572 if (Yields > 5) {
4566 // Consider using a simple NakedSleep() instead. 4573 os::naked_short_sleep(1);
4567 // Then SpinAcquire could be called by non-JVM threads
4568 Thread::current()->_ParkEvent->park(1) ;
4569 } else { 4574 } else {
4570 os::NakedYield() ; 4575 os::NakedYield() ;
4571 ++Yields ; 4576 ++Yields ;
4572 } 4577 }
4573 } else { 4578 } else {