Mercurial > hg > truffle
comparison src/share/vm/runtime/thread.cpp @ 4875:379b22e03c32
Merge
author | jcoomes |
---|---|
date | Fri, 03 Feb 2012 12:08:55 -0800 |
parents | 0382d2b469b2 |
children | f1cb6f9cfe21 |
comparison
equal
deleted
inserted
replaced
4866:527cf36f4a20 | 4875:379b22e03c32 |
---|---|
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. |
31 #include "compiler/compileBroker.hpp" | 31 #include "compiler/compileBroker.hpp" |
32 #include "interpreter/interpreter.hpp" | 32 #include "interpreter/interpreter.hpp" |
33 #include "interpreter/linkResolver.hpp" | 33 #include "interpreter/linkResolver.hpp" |
34 #include "interpreter/oopMapCache.hpp" | 34 #include "interpreter/oopMapCache.hpp" |
35 #include "jvmtifiles/jvmtiEnv.hpp" | 35 #include "jvmtifiles/jvmtiEnv.hpp" |
36 #include "memory/gcLocker.inline.hpp" | |
36 #include "memory/oopFactory.hpp" | 37 #include "memory/oopFactory.hpp" |
37 #include "memory/universe.inline.hpp" | 38 #include "memory/universe.inline.hpp" |
38 #include "oops/instanceKlass.hpp" | 39 #include "oops/instanceKlass.hpp" |
39 #include "oops/objArrayOop.hpp" | 40 #include "oops/objArrayOop.hpp" |
40 #include "oops/oop.inline.hpp" | 41 #include "oops/oop.inline.hpp" |
1598 if (!destroy_vm || JDK_Version::is_jdk12x_version()) { | 1599 if (!destroy_vm || JDK_Version::is_jdk12x_version()) { |
1599 // JSR-166: change call from from ThreadGroup.uncaughtException to | 1600 // JSR-166: change call from from ThreadGroup.uncaughtException to |
1600 // java.lang.Thread.dispatchUncaughtException | 1601 // java.lang.Thread.dispatchUncaughtException |
1601 if (uncaught_exception.not_null()) { | 1602 if (uncaught_exception.not_null()) { |
1602 Handle group(this, java_lang_Thread::threadGroup(threadObj())); | 1603 Handle group(this, java_lang_Thread::threadGroup(threadObj())); |
1603 Events::log("uncaught exception INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT", | |
1604 (address)uncaught_exception(), (address)threadObj(), (address)group()); | |
1605 { | 1604 { |
1606 EXCEPTION_MARK; | 1605 EXCEPTION_MARK; |
1607 // Check if the method Thread.dispatchUncaughtException() exists. If so | 1606 // Check if the method Thread.dispatchUncaughtException() exists. If so |
1608 // call it. Otherwise we have an older library without the JSR-166 changes, | 1607 // call it. Otherwise we have an older library without the JSR-166 changes, |
1609 // so call ThreadGroup.uncaughtException() | 1608 // so call ThreadGroup.uncaughtException() |
2275 | 2274 |
2276 if (thread->has_async_exception()) { | 2275 if (thread->has_async_exception()) { |
2277 // We are in _thread_in_native_trans state, don't handle unsafe | 2276 // We are in _thread_in_native_trans state, don't handle unsafe |
2278 // access error since that may block. | 2277 // access error since that may block. |
2279 thread->check_and_handle_async_exceptions(false); | 2278 thread->check_and_handle_async_exceptions(false); |
2279 } | |
2280 } | |
2281 | |
2282 // This is a variant of the normal | |
2283 // check_special_condition_for_native_trans with slightly different | |
2284 // semantics for use by critical native wrappers. It does all the | |
2285 // normal checks but also performs the transition back into | |
2286 // thread_in_Java state. This is required so that critical natives | |
2287 // can potentially block and perform a GC if they are the last thread | |
2288 // exiting the GC_locker. | |
2289 void JavaThread::check_special_condition_for_native_trans_and_transition(JavaThread *thread) { | |
2290 check_special_condition_for_native_trans(thread); | |
2291 | |
2292 // Finish the transition | |
2293 thread->set_thread_state(_thread_in_Java); | |
2294 | |
2295 if (thread->do_critical_native_unlock()) { | |
2296 ThreadInVMfromJavaNoAsyncException tiv(thread); | |
2297 GC_locker::unlock_critical(thread); | |
2298 thread->clear_critical_native_unlock(); | |
2280 } | 2299 } |
2281 } | 2300 } |
2282 | 2301 |
2283 // We need to guarantee the Threads_lock here, since resumes are not | 2302 // We need to guarantee the Threads_lock here, since resumes are not |
2284 // allowed during safepoint synchronization | 2303 // allowed during safepoint synchronization |
3883 } | 3902 } |
3884 | 3903 |
3885 ThreadService::add_thread(p, daemon); | 3904 ThreadService::add_thread(p, daemon); |
3886 | 3905 |
3887 // Possible GC point. | 3906 // Possible GC point. |
3888 Events::log("Thread added: " INTPTR_FORMAT, p); | 3907 Events::log(p, "Thread added: " INTPTR_FORMAT, p); |
3889 } | 3908 } |
3890 | 3909 |
3891 void Threads::remove(JavaThread* p) { | 3910 void Threads::remove(JavaThread* p) { |
3892 // Extra scope needed for Thread_lock, so we can check | 3911 // Extra scope needed for Thread_lock, so we can check |
3893 // that we do not remove thread without safepoint code notice | 3912 // that we do not remove thread without safepoint code notice |
3928 // of this thread since it is removed from the queue. | 3947 // of this thread since it is removed from the queue. |
3929 p->set_terminated_value(); | 3948 p->set_terminated_value(); |
3930 } // unlock Threads_lock | 3949 } // unlock Threads_lock |
3931 | 3950 |
3932 // Since Events::log uses a lock, we grab it outside the Threads_lock | 3951 // Since Events::log uses a lock, we grab it outside the Threads_lock |
3933 Events::log("Thread exited: " INTPTR_FORMAT, p); | 3952 Events::log(p, "Thread exited: " INTPTR_FORMAT, p); |
3934 } | 3953 } |
3935 | 3954 |
3936 // Threads_lock must be held when this is called (or must be called during a safepoint) | 3955 // Threads_lock must be held when this is called (or must be called during a safepoint) |
3937 bool Threads::includes(JavaThread* p) { | 3956 bool Threads::includes(JavaThread* p) { |
3938 assert(Threads_lock->is_locked(), "sanity check"); | 3957 assert(Threads_lock->is_locked(), "sanity check"); |