Mercurial > hg > truffle
comparison src/share/vm/prims/jvm.cpp @ 14518:d8041d695d19
Merged with jdk9/dev/hotspot changeset 3812c088b945
author | twisti |
---|---|
date | Tue, 11 Mar 2014 18:45:59 -0700 |
parents | 096c224171c4 016b6a289fc4 |
children | b51e29501f30 4ca6dc0799b6 |
comparison
equal
deleted
inserted
replaced
14141:f97c5ec83832 | 14518:d8041d695d19 |
---|---|
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. |
74 # include "jvm_solaris.h" | 74 # include "jvm_solaris.h" |
75 #endif | 75 #endif |
76 #ifdef TARGET_OS_FAMILY_windows | 76 #ifdef TARGET_OS_FAMILY_windows |
77 # include "jvm_windows.h" | 77 # include "jvm_windows.h" |
78 #endif | 78 #endif |
79 #ifdef TARGET_OS_FAMILY_aix | |
80 # include "jvm_aix.h" | |
81 #endif | |
79 #ifdef TARGET_OS_FAMILY_bsd | 82 #ifdef TARGET_OS_FAMILY_bsd |
80 # include "jvm_bsd.h" | 83 # include "jvm_bsd.h" |
81 #endif | 84 #endif |
82 | 85 |
83 #include <errno.h> | 86 #include <errno.h> |
84 | |
85 #ifndef USDT2 | |
86 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__begin, long long); | |
87 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__end, int); | |
88 HS_DTRACE_PROBE_DECL0(hotspot, thread__yield); | |
89 #endif /* !USDT2 */ | |
90 | 87 |
91 /* | 88 /* |
92 NOTE about use of any ctor or function call that can trigger a safepoint/GC: | 89 NOTE about use of any ctor or function call that can trigger a safepoint/GC: |
93 such ctors and calls MUST NOT come between an oop declaration/init and its | 90 such ctors and calls MUST NOT come between an oop declaration/init and its |
94 usage because if objects are move this may cause various memory stomps, bus | 91 usage because if objects are move this may cause various memory stomps, bus |
518 JVMWrapper("JVM_MonitorWait"); | 515 JVMWrapper("JVM_MonitorWait"); |
519 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); | 516 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
520 JavaThreadInObjectWaitState jtiows(thread, ms != 0); | 517 JavaThreadInObjectWaitState jtiows(thread, ms != 0); |
521 if (JvmtiExport::should_post_monitor_wait()) { | 518 if (JvmtiExport::should_post_monitor_wait()) { |
522 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); | 519 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); |
520 | |
521 // The current thread already owns the monitor and it has not yet | |
522 // been added to the wait queue so the current thread cannot be | |
523 // made the successor. This means that the JVMTI_EVENT_MONITOR_WAIT | |
524 // event handler cannot accidentally consume an unpark() meant for | |
525 // the ParkEvent associated with this ObjectMonitor. | |
523 } | 526 } |
524 ObjectSynchronizer::wait(obj, ms, CHECK); | 527 ObjectSynchronizer::wait(obj, ms, CHECK); |
525 JVM_END | 528 JVM_END |
526 | 529 |
527 | 530 |
1249 } | 1252 } |
1250 | 1253 |
1251 if (HAS_PENDING_EXCEPTION) { | 1254 if (HAS_PENDING_EXCEPTION) { |
1252 pending_exception = Handle(THREAD, PENDING_EXCEPTION); | 1255 pending_exception = Handle(THREAD, PENDING_EXCEPTION); |
1253 CLEAR_PENDING_EXCEPTION; | 1256 CLEAR_PENDING_EXCEPTION; |
1254 | 1257 // JVMTI has already reported the pending exception |
1258 // JVMTI internal flag reset is needed in order to report PrivilegedActionException | |
1259 if (THREAD->is_Java_thread()) { | |
1260 JvmtiExport::clear_detected_exception((JavaThread*) THREAD); | |
1261 } | |
1255 if ( pending_exception->is_a(SystemDictionary::Exception_klass()) && | 1262 if ( pending_exception->is_a(SystemDictionary::Exception_klass()) && |
1256 !pending_exception->is_a(SystemDictionary::RuntimeException_klass())) { | 1263 !pending_exception->is_a(SystemDictionary::RuntimeException_klass())) { |
1257 // Throw a java.security.PrivilegedActionException(Exception e) exception | 1264 // Throw a java.security.PrivilegedActionException(Exception e) exception |
1258 JavaCallArguments args(pending_exception); | 1265 JavaCallArguments args(pending_exception); |
1259 THROW_ARG_0(vmSymbols::java_security_PrivilegedActionException(), | 1266 THROW_ARG_0(vmSymbols::java_security_PrivilegedActionException(), |
2886 // No one should hold a reference to the 'native_thread'. | 2893 // No one should hold a reference to the 'native_thread'. |
2887 delete native_thread; | 2894 delete native_thread; |
2888 if (JvmtiExport::should_post_resource_exhausted()) { | 2895 if (JvmtiExport::should_post_resource_exhausted()) { |
2889 JvmtiExport::post_resource_exhausted( | 2896 JvmtiExport::post_resource_exhausted( |
2890 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_THREADS, | 2897 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_THREADS, |
2891 "unable to create new native thread"); | 2898 os::native_thread_creation_failed_msg()); |
2892 } | 2899 } |
2893 THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), | 2900 THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), |
2894 "unable to create new native thread"); | 2901 os::native_thread_creation_failed_msg()); |
2895 } | 2902 } |
2896 | 2903 |
2897 Thread::start(native_thread); | 2904 Thread::start(native_thread); |
2898 | 2905 |
2899 JVM_END | 2906 JVM_END |
3013 | 3020 |
3014 | 3021 |
3015 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) | 3022 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) |
3016 JVMWrapper("JVM_Yield"); | 3023 JVMWrapper("JVM_Yield"); |
3017 if (os::dont_yield()) return; | 3024 if (os::dont_yield()) return; |
3018 #ifndef USDT2 | |
3019 HS_DTRACE_PROBE0(hotspot, thread__yield); | |
3020 #else /* USDT2 */ | |
3021 HOTSPOT_THREAD_YIELD(); | 3025 HOTSPOT_THREAD_YIELD(); |
3022 #endif /* USDT2 */ | 3026 |
3023 // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. | 3027 // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. |
3024 // Critical for similar threading behaviour | 3028 // Critical for similar threading behaviour |
3025 if (ConvertYieldToSleep) { | 3029 if (ConvertYieldToSleep) { |
3026 os::sleep(thread, MinSleepInterval, false); | 3030 os::sleep(thread, MinSleepInterval, false); |
3027 } else { | 3031 } else { |
3043 | 3047 |
3044 // Save current thread state and restore it at the end of this block. | 3048 // Save current thread state and restore it at the end of this block. |
3045 // And set new thread state to SLEEPING. | 3049 // And set new thread state to SLEEPING. |
3046 JavaThreadSleepState jtss(thread); | 3050 JavaThreadSleepState jtss(thread); |
3047 | 3051 |
3048 #ifndef USDT2 | 3052 HOTSPOT_THREAD_SLEEP_BEGIN(millis); |
3049 HS_DTRACE_PROBE1(hotspot, thread__sleep__begin, millis); | |
3050 #else /* USDT2 */ | |
3051 HOTSPOT_THREAD_SLEEP_BEGIN( | |
3052 millis); | |
3053 #endif /* USDT2 */ | |
3054 | 3053 |
3055 EventThreadSleep event; | 3054 EventThreadSleep event; |
3056 | 3055 |
3057 if (millis == 0) { | 3056 if (millis == 0) { |
3058 // When ConvertSleepToYield is on, this matches the classic VM implementation of | 3057 // When ConvertSleepToYield is on, this matches the classic VM implementation of |
3076 if (!HAS_PENDING_EXCEPTION) { | 3075 if (!HAS_PENDING_EXCEPTION) { |
3077 if (event.should_commit()) { | 3076 if (event.should_commit()) { |
3078 event.set_time(millis); | 3077 event.set_time(millis); |
3079 event.commit(); | 3078 event.commit(); |
3080 } | 3079 } |
3081 #ifndef USDT2 | 3080 HOTSPOT_THREAD_SLEEP_END(1); |
3082 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,1); | 3081 |
3083 #else /* USDT2 */ | |
3084 HOTSPOT_THREAD_SLEEP_END( | |
3085 1); | |
3086 #endif /* USDT2 */ | |
3087 // TODO-FIXME: THROW_MSG returns which means we will not call set_state() | 3082 // TODO-FIXME: THROW_MSG returns which means we will not call set_state() |
3088 // to properly restore the thread state. That's likely wrong. | 3083 // to properly restore the thread state. That's likely wrong. |
3089 THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); | 3084 THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); |
3090 } | 3085 } |
3091 } | 3086 } |
3093 } | 3088 } |
3094 if (event.should_commit()) { | 3089 if (event.should_commit()) { |
3095 event.set_time(millis); | 3090 event.set_time(millis); |
3096 event.commit(); | 3091 event.commit(); |
3097 } | 3092 } |
3098 #ifndef USDT2 | 3093 HOTSPOT_THREAD_SLEEP_END(0); |
3099 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,0); | |
3100 #else /* USDT2 */ | |
3101 HOTSPOT_THREAD_SLEEP_END( | |
3102 0); | |
3103 #endif /* USDT2 */ | |
3104 JVM_END | 3094 JVM_END |
3105 | 3095 |
3106 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) | 3096 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) |
3107 JVMWrapper("JVM_CurrentThread"); | 3097 JVMWrapper("JVM_CurrentThread"); |
3108 oop jthread = thread->threadObj(); | 3098 oop jthread = thread->threadObj(); |
3982 } | 3972 } |
3983 return (jclass) JNIHandles::make_local(env, klass_handle->java_mirror()); | 3973 return (jclass) JNIHandles::make_local(env, klass_handle->java_mirror()); |
3984 } | 3974 } |
3985 | 3975 |
3986 | 3976 |
3987 // Internal SQE debugging support /////////////////////////////////////////////////////////// | |
3988 | |
3989 #ifndef PRODUCT | |
3990 | |
3991 extern "C" { | |
3992 JNIEXPORT jboolean JNICALL JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get); | |
3993 JNIEXPORT jboolean JNICALL JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get); | |
3994 JNIEXPORT void JNICALL JVM_VMBreakPoint(JNIEnv *env, jobject obj); | |
3995 } | |
3996 | |
3997 JVM_LEAF(jboolean, JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get)) | |
3998 JVMWrapper("JVM_AccessBoolVMFlag"); | |
3999 return is_get ? CommandLineFlags::boolAt((char*) name, (bool*) value) : CommandLineFlags::boolAtPut((char*) name, (bool*) value, Flag::INTERNAL); | |
4000 JVM_END | |
4001 | |
4002 JVM_LEAF(jboolean, JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get)) | |
4003 JVMWrapper("JVM_AccessVMIntFlag"); | |
4004 intx v; | |
4005 jboolean result = is_get ? CommandLineFlags::intxAt((char*) name, &v) : CommandLineFlags::intxAtPut((char*) name, &v, Flag::INTERNAL); | |
4006 *value = (jint)v; | |
4007 return result; | |
4008 JVM_END | |
4009 | |
4010 | |
4011 JVM_ENTRY(void, JVM_VMBreakPoint(JNIEnv *env, jobject obj)) | |
4012 JVMWrapper("JVM_VMBreakPoint"); | |
4013 oop the_obj = JNIHandles::resolve(obj); | |
4014 BREAKPOINT; | |
4015 JVM_END | |
4016 | |
4017 | |
4018 #endif | |
4019 | |
4020 | |
4021 // Method /////////////////////////////////////////////////////////////////////////////////////////// | 3977 // Method /////////////////////////////////////////////////////////////////////////////////////////// |
4022 | 3978 |
4023 JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)) | 3979 JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)) |
4024 JVMWrapper("JVM_InvokeMethod"); | 3980 JVMWrapper("JVM_InvokeMethod"); |
4025 Handle method_handle; | 3981 Handle method_handle; |