src/share/vm/jfr/jni/jfrJavaSupport.hpp

Fri, 12 Jun 2020 02:59:56 +0100

author
jbachorik
date
Fri, 12 Jun 2020 02:59:56 +0100
changeset 9925
30fb8c8cceb9
parent 9858
b985cbb00e68
child 9986
85e682d8ab91
permissions
-rw-r--r--

8233197: Invert JvmtiExport::post_vm_initialized() and Jfr:on_vm_start() start-up order for correct option parsing
8246703: [TESTBUG] Add test for JDK-8233197
Reviewed-by: aph, adinn, neugens

apetushkov@9858 1 /*
apetushkov@9858 2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
apetushkov@9858 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
apetushkov@9858 4 *
apetushkov@9858 5 * This code is free software; you can redistribute it and/or modify it
apetushkov@9858 6 * under the terms of the GNU General Public License version 2 only, as
apetushkov@9858 7 * published by the Free Software Foundation.
apetushkov@9858 8 *
apetushkov@9858 9 * This code is distributed in the hope that it will be useful, but WITHOUT
apetushkov@9858 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
apetushkov@9858 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
apetushkov@9858 12 * version 2 for more details (a copy is included in the LICENSE file that
apetushkov@9858 13 * accompanied this code).
apetushkov@9858 14 *
apetushkov@9858 15 * You should have received a copy of the GNU General Public License version
apetushkov@9858 16 * 2 along with this work; if not, write to the Free Software Foundation,
apetushkov@9858 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
apetushkov@9858 18 *
apetushkov@9858 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
apetushkov@9858 20 * or visit www.oracle.com if you need additional information or have any
apetushkov@9858 21 * questions.
apetushkov@9858 22 *
apetushkov@9858 23 */
apetushkov@9858 24
apetushkov@9858 25 #ifndef SHARE_VM_JFR_JNI_JFRJAVASUPPORT_HPP
apetushkov@9858 26 #define SHARE_VM_JFR_JNI_JFRJAVASUPPORT_HPP
apetushkov@9858 27
apetushkov@9858 28 #include "jfr/jni/jfrJavaCall.hpp"
apetushkov@9858 29 #include "utilities/exceptions.hpp"
apetushkov@9858 30
apetushkov@9858 31 class Klass;
apetushkov@9858 32 class JavaThread;
apetushkov@9858 33 class outputStream;
apetushkov@9858 34
apetushkov@9858 35 class JfrJavaSupport : public AllStatic {
apetushkov@9858 36 public:
apetushkov@9858 37 static jobject local_jni_handle(const oop obj, Thread* t);
apetushkov@9858 38 static jobject local_jni_handle(const jobject handle, Thread* t);
apetushkov@9858 39 static void destroy_local_jni_handle(const jobject handle);
apetushkov@9858 40
apetushkov@9858 41 static jobject global_jni_handle(const oop obj, Thread* t);
apetushkov@9858 42 static jobject global_jni_handle(const jobject handle, Thread* t);
apetushkov@9858 43 static void destroy_global_jni_handle(const jobject handle);
apetushkov@9858 44
apetushkov@9858 45 static oop resolve_non_null(jobject obj);
apetushkov@9858 46 static void notify_all(jobject obj, TRAPS);
apetushkov@9858 47 static void set_array_element(jobjectArray arr, jobject element, int index, Thread* t);
apetushkov@9858 48
apetushkov@9858 49 // naked oop result
apetushkov@9858 50 static void call_static(JfrJavaArguments* args, TRAPS);
apetushkov@9858 51 static void call_special(JfrJavaArguments* args, TRAPS);
apetushkov@9858 52 static void call_virtual(JfrJavaArguments* args, TRAPS);
apetushkov@9858 53
apetushkov@9858 54 static void set_field(JfrJavaArguments* args, TRAPS);
apetushkov@9858 55 static void get_field(JfrJavaArguments* args, TRAPS);
apetushkov@9858 56 static void new_object(JfrJavaArguments* args, TRAPS);
apetushkov@9858 57
apetushkov@9858 58 // global jni handle result
apetushkov@9858 59 static void new_object_global_ref(JfrJavaArguments* args, TRAPS);
apetushkov@9858 60 static void get_field_global_ref(JfrJavaArguments* args, TRAPS);
apetushkov@9858 61
apetushkov@9858 62 // local jni handle result
apetushkov@9858 63 static void new_object_local_ref(JfrJavaArguments* args, TRAPS);
apetushkov@9858 64 static void get_field_local_ref(JfrJavaArguments* args, TRAPS);
apetushkov@9858 65
apetushkov@9858 66 static jstring new_string(const char* c_str, TRAPS);
apetushkov@9858 67 static jobjectArray new_string_array(int length, TRAPS);
apetushkov@9858 68
apetushkov@9858 69 static jobject new_java_lang_Boolean(bool value, TRAPS);
apetushkov@9858 70 static jobject new_java_lang_Integer(jint value, TRAPS);
apetushkov@9858 71 static jobject new_java_lang_Long(jlong value, TRAPS);
apetushkov@9858 72
apetushkov@9858 73 // misc
apetushkov@9858 74 static Klass* klass(const jobject handle);
apetushkov@9858 75 // caller needs ResourceMark
apetushkov@9858 76 static const char* c_str(jstring string, Thread* jt);
apetushkov@9858 77
apetushkov@9858 78 // exceptions
apetushkov@9858 79 static void throw_illegal_state_exception(const char* message, TRAPS);
apetushkov@9858 80 static void throw_illegal_argument_exception(const char* message, TRAPS);
apetushkov@9858 81 static void throw_internal_error(const char* message, TRAPS);
apetushkov@9858 82 static void throw_out_of_memory_error(const char* message, TRAPS);
apetushkov@9858 83 static void throw_class_format_error(const char* message, TRAPS);
jbachorik@9925 84 static void throw_runtime_exception(const char* message, TRAPS);
apetushkov@9858 85
apetushkov@9858 86 static jlong jfr_thread_id(jobject target_thread);
apetushkov@9858 87
apetushkov@9858 88 // critical
apetushkov@9858 89 static void abort(jstring errorMsg, TRAPS);
apetushkov@9858 90 static void uncaught_exception(jthrowable throwable, Thread* t);
apetushkov@9858 91
apetushkov@9858 92 // asserts
apetushkov@9858 93 DEBUG_ONLY(static void check_java_thread_in_vm(Thread* t);)
apetushkov@9858 94 DEBUG_ONLY(static void check_java_thread_in_native(Thread* t);)
apetushkov@9858 95
apetushkov@9858 96 enum CAUSE {
apetushkov@9858 97 VM_ERROR,
apetushkov@9858 98 OUT_OF_MEMORY,
apetushkov@9858 99 STACK_OVERFLOW,
apetushkov@9858 100 RUNTIME_EXCEPTION,
apetushkov@9858 101 UNKNOWN,
apetushkov@9858 102 NOF_CAUSES
apetushkov@9858 103 };
apetushkov@9858 104
apetushkov@9858 105 static CAUSE cause();
apetushkov@9858 106
apetushkov@9858 107 private:
apetushkov@9858 108 static CAUSE _cause;
apetushkov@9858 109 static void set_cause(jthrowable throwable, Thread* t);
apetushkov@9858 110 };
apetushkov@9858 111
apetushkov@9858 112 #endif // SHARE_VM_JFR_JNI_JFRJAVASUPPORT_HPP

mercurial