comparison src/share/vm/runtime/thread.hpp @ 4970:33df1aeaebbf

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 27 Feb 2012 13:10:13 +0100
parents 723df37192d6 0382d2b469b2
children 897b7d18bebc
comparison
equal deleted inserted replaced
4703:2cfb7fb2dce7 4970:33df1aeaebbf
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, 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.
39 #include "runtime/park.hpp" 39 #include "runtime/park.hpp"
40 #include "runtime/safepoint.hpp" 40 #include "runtime/safepoint.hpp"
41 #include "runtime/stubRoutines.hpp" 41 #include "runtime/stubRoutines.hpp"
42 #include "runtime/threadLocalStorage.hpp" 42 #include "runtime/threadLocalStorage.hpp"
43 #include "runtime/unhandledOops.hpp" 43 #include "runtime/unhandledOops.hpp"
44 #include "trace/tracing.hpp"
44 #include "utilities/exceptions.hpp" 45 #include "utilities/exceptions.hpp"
45 #include "utilities/top.hpp" 46 #include "utilities/top.hpp"
46 #ifndef SERIALGC 47 #ifndef SERIALGC
47 #include "gc_implementation/g1/dirtyCardQueue.hpp" 48 #include "gc_implementation/g1/dirtyCardQueue.hpp"
48 #include "gc_implementation/g1/satbQueue.hpp" 49 #include "gc_implementation/g1/satbQueue.hpp"
179 180
180 _external_suspend = 0x20000000U, // thread is asked to self suspend 181 _external_suspend = 0x20000000U, // thread is asked to self suspend
181 _ext_suspended = 0x40000000U, // thread has self-suspended 182 _ext_suspended = 0x40000000U, // thread has self-suspended
182 _deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt 183 _deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt
183 184
184 _has_async_exception = 0x00000001U // there is a pending async exception 185 _has_async_exception = 0x00000001U, // there is a pending async exception
186 _critical_native_unlock = 0x00000002U // Must call back to unlock JNI critical lock
185 }; 187 };
186 188
187 // various suspension related flags - atomically updated 189 // various suspension related flags - atomically updated
188 // overloaded for async exception checking in check_special_condition_for_native_trans. 190 // overloaded for async exception checking in check_special_condition_for_native_trans.
189 volatile uint32_t _suspend_flags; 191 volatile uint32_t _suspend_flags;
243 friend class GC_locker; 245 friend class GC_locker;
244 246
245 ThreadLocalAllocBuffer _tlab; // Thread-local eden 247 ThreadLocalAllocBuffer _tlab; // Thread-local eden
246 jlong _allocated_bytes; // Cumulative number of bytes allocated on 248 jlong _allocated_bytes; // Cumulative number of bytes allocated on
247 // the Java heap 249 // the Java heap
250
251 TRACE_BUFFER _trace_buffer; // Thread-local buffer for tracing
248 252
249 int _vm_operation_started_count; // VM_Operation support 253 int _vm_operation_started_count; // VM_Operation support
250 int _vm_operation_completed_count; // VM_Operation support 254 int _vm_operation_completed_count; // VM_Operation support
251 255
252 ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread 256 ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread
345 } 349 }
346 void clear_has_async_exception() { 350 void clear_has_async_exception() {
347 clear_suspend_flag(_has_async_exception); 351 clear_suspend_flag(_has_async_exception);
348 } 352 }
349 353
354 bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
355
356 void set_critical_native_unlock() {
357 set_suspend_flag(_critical_native_unlock);
358 }
359 void clear_critical_native_unlock() {
360 clear_suspend_flag(_critical_native_unlock);
361 }
362
350 // Support for Unhandled Oop detection 363 // Support for Unhandled Oop detection
351 #ifdef CHECK_UNHANDLED_OOPS 364 #ifdef CHECK_UNHANDLED_OOPS
352 private: 365 private:
353 UnhandledOops* _unhandled_oops; 366 UnhandledOops* _unhandled_oops;
354 public: 367 public:
411 return allocated_bytes + used_bytes; 424 return allocated_bytes + used_bytes;
412 } 425 }
413 } 426 }
414 return allocated_bytes; 427 return allocated_bytes;
415 } 428 }
429
430 TRACE_BUFFER trace_buffer() { return _trace_buffer; }
431 void set_trace_buffer(TRACE_BUFFER buf) { _trace_buffer = buf; }
416 432
417 // VM operation support 433 // VM operation support
418 int vm_operation_ticket() { return ++_vm_operation_started_count; } 434 int vm_operation_ticket() { return ++_vm_operation_started_count; }
419 int vm_operation_completed_count() { return _vm_operation_completed_count; } 435 int vm_operation_completed_count() { return _vm_operation_completed_count; }
420 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; } 436 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; }
1051 } 1067 }
1052 static void check_safepoint_and_suspend_for_native_trans(JavaThread *thread); 1068 static void check_safepoint_and_suspend_for_native_trans(JavaThread *thread);
1053 // Check for async exception in addition to safepoint and suspend request. 1069 // Check for async exception in addition to safepoint and suspend request.
1054 static void check_special_condition_for_native_trans(JavaThread *thread); 1070 static void check_special_condition_for_native_trans(JavaThread *thread);
1055 1071
1072 // Same as check_special_condition_for_native_trans but finishes the
1073 // transition into thread_in_Java mode so that it can potentially
1074 // block.
1075 static void check_special_condition_for_native_trans_and_transition(JavaThread *thread);
1076
1056 bool is_ext_suspend_completed(bool called_by_wait, int delay, uint32_t *bits); 1077 bool is_ext_suspend_completed(bool called_by_wait, int delay, uint32_t *bits);
1057 bool is_ext_suspend_completed_with_lock(uint32_t *bits) { 1078 bool is_ext_suspend_completed_with_lock(uint32_t *bits) {
1058 MutexLockerEx ml(SR_lock(), Mutex::_no_safepoint_check_flag); 1079 MutexLockerEx ml(SR_lock(), Mutex::_no_safepoint_check_flag);
1059 // Warning: is_ext_suspend_completed() may temporarily drop the 1080 // Warning: is_ext_suspend_completed() may temporarily drop the
1060 // SR_lock to allow the thread to reach a stable thread state if 1081 // SR_lock to allow the thread to reach a stable thread state if
1328 } 1349 }
1329 } 1350 }
1330 1351
1331 // JNI critical regions. These can nest. 1352 // JNI critical regions. These can nest.
1332 bool in_critical() { return _jni_active_critical > 0; } 1353 bool in_critical() { return _jni_active_critical > 0; }
1333 void enter_critical() { assert(Thread::current() == this, 1354 bool in_last_critical() { return _jni_active_critical == 1; }
1334 "this must be current thread"); 1355 void enter_critical() { assert(Thread::current() == this ||
1356 Thread::current()->is_VM_thread() && SafepointSynchronize::is_synchronizing(),
1357 "this must be current thread or synchronizing");
1335 _jni_active_critical++; } 1358 _jni_active_critical++; }
1336 void exit_critical() { assert(Thread::current() == this, 1359 void exit_critical() { assert(Thread::current() == this,
1337 "this must be current thread"); 1360 "this must be current thread");
1338 _jni_active_critical--; 1361 _jni_active_critical--;
1339 assert(_jni_active_critical >= 0, 1362 assert(_jni_active_critical >= 0,