Mercurial > hg > truffle
comparison src/share/vm/prims/jvm.cpp @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | d8041d695d19 |
children | 53a0a0b8c234 |
comparison
equal
deleted
inserted
replaced
14908:8db6e76cb658 | 14909:4ca6dc0799b6 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2013, 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 | |
82 #ifdef TARGET_OS_FAMILY_bsd | 79 #ifdef TARGET_OS_FAMILY_bsd |
83 # include "jvm_bsd.h" | 80 # include "jvm_bsd.h" |
84 #endif | 81 #endif |
85 | 82 |
86 #include <errno.h> | 83 #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 */ | |
87 | 90 |
88 /* | 91 /* |
89 NOTE about use of any ctor or function call that can trigger a safepoint/GC: | 92 NOTE about use of any ctor or function call that can trigger a safepoint/GC: |
90 such ctors and calls MUST NOT come between an oop declaration/init and its | 93 such ctors and calls MUST NOT come between an oop declaration/init and its |
91 usage because if objects are move this may cause various memory stomps, bus | 94 usage because if objects are move this may cause various memory stomps, bus |
515 JVMWrapper("JVM_MonitorWait"); | 518 JVMWrapper("JVM_MonitorWait"); |
516 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); | 519 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
517 JavaThreadInObjectWaitState jtiows(thread, ms != 0); | 520 JavaThreadInObjectWaitState jtiows(thread, ms != 0); |
518 if (JvmtiExport::should_post_monitor_wait()) { | 521 if (JvmtiExport::should_post_monitor_wait()) { |
519 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); | 522 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. | |
526 } | 523 } |
527 ObjectSynchronizer::wait(obj, ms, CHECK); | 524 ObjectSynchronizer::wait(obj, ms, CHECK); |
528 JVM_END | 525 JVM_END |
529 | 526 |
530 | 527 |
1252 } | 1249 } |
1253 | 1250 |
1254 if (HAS_PENDING_EXCEPTION) { | 1251 if (HAS_PENDING_EXCEPTION) { |
1255 pending_exception = Handle(THREAD, PENDING_EXCEPTION); | 1252 pending_exception = Handle(THREAD, PENDING_EXCEPTION); |
1256 CLEAR_PENDING_EXCEPTION; | 1253 CLEAR_PENDING_EXCEPTION; |
1257 // JVMTI has already reported the pending exception | 1254 |
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 } | |
1262 if ( pending_exception->is_a(SystemDictionary::Exception_klass()) && | 1255 if ( pending_exception->is_a(SystemDictionary::Exception_klass()) && |
1263 !pending_exception->is_a(SystemDictionary::RuntimeException_klass())) { | 1256 !pending_exception->is_a(SystemDictionary::RuntimeException_klass())) { |
1264 // Throw a java.security.PrivilegedActionException(Exception e) exception | 1257 // Throw a java.security.PrivilegedActionException(Exception e) exception |
1265 JavaCallArguments args(pending_exception); | 1258 JavaCallArguments args(pending_exception); |
1266 THROW_ARG_0(vmSymbols::java_security_PrivilegedActionException(), | 1259 THROW_ARG_0(vmSymbols::java_security_PrivilegedActionException(), |
2893 // No one should hold a reference to the 'native_thread'. | 2886 // No one should hold a reference to the 'native_thread'. |
2894 delete native_thread; | 2887 delete native_thread; |
2895 if (JvmtiExport::should_post_resource_exhausted()) { | 2888 if (JvmtiExport::should_post_resource_exhausted()) { |
2896 JvmtiExport::post_resource_exhausted( | 2889 JvmtiExport::post_resource_exhausted( |
2897 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_THREADS, | 2890 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_THREADS, |
2898 os::native_thread_creation_failed_msg()); | 2891 "unable to create new native thread"); |
2899 } | 2892 } |
2900 THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), | 2893 THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), |
2901 os::native_thread_creation_failed_msg()); | 2894 "unable to create new native thread"); |
2902 } | 2895 } |
2903 | 2896 |
2904 Thread::start(native_thread); | 2897 Thread::start(native_thread); |
2905 | 2898 |
2906 JVM_END | 2899 JVM_END |
3020 | 3013 |
3021 | 3014 |
3022 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) | 3015 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) |
3023 JVMWrapper("JVM_Yield"); | 3016 JVMWrapper("JVM_Yield"); |
3024 if (os::dont_yield()) return; | 3017 if (os::dont_yield()) return; |
3018 #ifndef USDT2 | |
3019 HS_DTRACE_PROBE0(hotspot, thread__yield); | |
3020 #else /* USDT2 */ | |
3025 HOTSPOT_THREAD_YIELD(); | 3021 HOTSPOT_THREAD_YIELD(); |
3026 | 3022 #endif /* USDT2 */ |
3027 // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. | 3023 // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. |
3028 // Critical for similar threading behaviour | 3024 // Critical for similar threading behaviour |
3029 if (ConvertYieldToSleep) { | 3025 if (ConvertYieldToSleep) { |
3030 os::sleep(thread, MinSleepInterval, false); | 3026 os::sleep(thread, MinSleepInterval, false); |
3031 } else { | 3027 } else { |
3047 | 3043 |
3048 // Save current thread state and restore it at the end of this block. | 3044 // Save current thread state and restore it at the end of this block. |
3049 // And set new thread state to SLEEPING. | 3045 // And set new thread state to SLEEPING. |
3050 JavaThreadSleepState jtss(thread); | 3046 JavaThreadSleepState jtss(thread); |
3051 | 3047 |
3052 HOTSPOT_THREAD_SLEEP_BEGIN(millis); | 3048 #ifndef USDT2 |
3049 HS_DTRACE_PROBE1(hotspot, thread__sleep__begin, millis); | |
3050 #else /* USDT2 */ | |
3051 HOTSPOT_THREAD_SLEEP_BEGIN( | |
3052 millis); | |
3053 #endif /* USDT2 */ | |
3053 | 3054 |
3054 EventThreadSleep event; | 3055 EventThreadSleep event; |
3055 | 3056 |
3056 if (millis == 0) { | 3057 if (millis == 0) { |
3057 // When ConvertSleepToYield is on, this matches the classic VM implementation of | 3058 // When ConvertSleepToYield is on, this matches the classic VM implementation of |
3075 if (!HAS_PENDING_EXCEPTION) { | 3076 if (!HAS_PENDING_EXCEPTION) { |
3076 if (event.should_commit()) { | 3077 if (event.should_commit()) { |
3077 event.set_time(millis); | 3078 event.set_time(millis); |
3078 event.commit(); | 3079 event.commit(); |
3079 } | 3080 } |
3080 HOTSPOT_THREAD_SLEEP_END(1); | 3081 #ifndef USDT2 |
3081 | 3082 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,1); |
3083 #else /* USDT2 */ | |
3084 HOTSPOT_THREAD_SLEEP_END( | |
3085 1); | |
3086 #endif /* USDT2 */ | |
3082 // TODO-FIXME: THROW_MSG returns which means we will not call set_state() | 3087 // TODO-FIXME: THROW_MSG returns which means we will not call set_state() |
3083 // to properly restore the thread state. That's likely wrong. | 3088 // to properly restore the thread state. That's likely wrong. |
3084 THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); | 3089 THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); |
3085 } | 3090 } |
3086 } | 3091 } |
3088 } | 3093 } |
3089 if (event.should_commit()) { | 3094 if (event.should_commit()) { |
3090 event.set_time(millis); | 3095 event.set_time(millis); |
3091 event.commit(); | 3096 event.commit(); |
3092 } | 3097 } |
3093 HOTSPOT_THREAD_SLEEP_END(0); | 3098 #ifndef USDT2 |
3099 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,0); | |
3100 #else /* USDT2 */ | |
3101 HOTSPOT_THREAD_SLEEP_END( | |
3102 0); | |
3103 #endif /* USDT2 */ | |
3094 JVM_END | 3104 JVM_END |
3095 | 3105 |
3096 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) | 3106 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) |
3097 JVMWrapper("JVM_CurrentThread"); | 3107 JVMWrapper("JVM_CurrentThread"); |
3098 oop jthread = thread->threadObj(); | 3108 oop jthread = thread->threadObj(); |
3972 } | 3982 } |
3973 return (jclass) JNIHandles::make_local(env, klass_handle->java_mirror()); | 3983 return (jclass) JNIHandles::make_local(env, klass_handle->java_mirror()); |
3974 } | 3984 } |
3975 | 3985 |
3976 | 3986 |
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 | |
3977 // Method /////////////////////////////////////////////////////////////////////////////////////////// | 4021 // Method /////////////////////////////////////////////////////////////////////////////////////////// |
3978 | 4022 |
3979 JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)) | 4023 JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)) |
3980 JVMWrapper("JVM_InvokeMethod"); | 4024 JVMWrapper("JVM_InvokeMethod"); |
3981 Handle method_handle; | 4025 Handle method_handle; |