Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/jfr/jni/jfrJniMethodRegistration.cpp
38920 views
/*1* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "jfr/jni/jfrJniMethod.hpp"26#include "jfr/jni/jfrJniMethodRegistration.hpp"27#include "jfr/utilities/jfrJavaLog.hpp"28#include "runtime/interfaceSupport.hpp"29#include "runtime/thread.hpp"30#include "utilities/exceptions.hpp"3132JfrJniMethodRegistration::JfrJniMethodRegistration(JNIEnv* env) {33assert(env != NULL, "invariant");34jclass jfr_clz = env->FindClass("jdk/jfr/internal/JVM");35if (jfr_clz != NULL) {36JNINativeMethod method[] = {37(char*)"beginRecording", (char*)"()V", (void*)jfr_begin_recording,38(char*)"endRecording", (char*)"()V", (void*)jfr_end_recording,39(char*)"counterTime", (char*)"()J", (void*)jfr_elapsed_counter,40(char*)"createJFR", (char*)"(Z)Z", (void*)jfr_create_jfr,41(char*)"destroyJFR", (char*)"()Z", (void*)jfr_destroy_jfr,42(char*)"emitEvent", (char*)"(JJJ)Z", (void*)jfr_emit_event,43(char*)"getAllEventClasses", (char*)"()Ljava/util/List;", (void*)jfr_get_all_event_classes,44(char*)"getClassIdNonIntrinsic", (char*)"(Ljava/lang/Class;)J", (void*)jfr_class_id,45(char*)"getPid", (char*)"()Ljava/lang/String;", (void*)jfr_get_pid,46(char*)"getStackTraceId", (char*)"(I)J", (void*)jfr_stacktrace_id,47(char*)"getThreadId", (char*)"(Ljava/lang/Thread;)J", (void*)jfr_id_for_thread,48(char*)"getTicksFrequency", (char*)"()J", (void*)jfr_elapsed_frequency,49(char*)"subscribeLogLevel", (char*)"(Ljdk/jfr/internal/LogTag;I)V", (void*)jfr_subscribe_log_level,50(char*)"log", (char*)"(IILjava/lang/String;)V", (void*)jfr_log,51(char*)"retransformClasses", (char*)"([Ljava/lang/Class;)V", (void*)jfr_retransform_classes,52(char*)"setEnabled", (char*)"(JZ)V", (void*)jfr_set_enabled,53(char*)"setFileNotification", (char*)"(J)V", (void*)jfr_set_file_notification,54(char*)"setGlobalBufferCount", (char*)"(J)V", (void*)jfr_set_global_buffer_count,55(char*)"setGlobalBufferSize", (char*)"(J)V", (void*)jfr_set_global_buffer_size,56(char*)"setMethodSamplingInterval", (char*)"(JJ)V", (void*)jfr_set_method_sampling_interval,57(char*)"setOutput", (char*)"(Ljava/lang/String;)V", (void*)jfr_set_output,58(char*)"setSampleThreads", (char*)"(Z)V", (void*)jfr_set_sample_threads,59(char*)"setStackDepth", (char*)"(I)V", (void*)jfr_set_stack_depth,60(char*)"setStackTraceEnabled", (char*)"(JZ)V", (void*)jfr_set_stacktrace_enabled,61(char*)"setThreadBufferSize", (char*)"(J)V", (void*)jfr_set_thread_buffer_size,62(char*)"setMemorySize", (char*)"(J)V", (void*)jfr_set_memory_size,63(char*)"setThreshold", (char*)"(JJ)Z", (void*)jfr_set_threshold,64(char*)"storeMetadataDescriptor", (char*)"([B)V", (void*)jfr_store_metadata_descriptor,65(char*)"getAllowedToDoEventRetransforms", (char*)"()Z", (void*)jfr_allow_event_retransforms,66(char*)"isAvailable", (char*)"()Z", (void*)jfr_is_available,67(char*)"getTimeConversionFactor", (char*)"()D", (void*)jfr_time_conv_factor,68(char*)"getTypeId", (char*)"(Ljava/lang/Class;)J", (void*)jfr_type_id,69(char*)"getEventWriter", (char*)"()Ljava/lang/Object;", (void*)jfr_get_event_writer,70(char*)"newEventWriter", (char*)"()Ljdk/jfr/internal/EventWriter;", (void*)jfr_new_event_writer,71(char*)"flush", (char*)"(Ljdk/jfr/internal/EventWriter;II)Z", (void*)jfr_event_writer_flush,72(char*)"setRepositoryLocation", (char*)"(Ljava/lang/String;)V", (void*)jfr_set_repository_location,73(char*)"abort", (char*)"(Ljava/lang/String;)V", (void*)jfr_abort,74(char*)"getEpochAddress", (char*)"()J",(void*)jfr_get_epoch_address,75(char*)"addStringConstant", (char*)"(ZJLjava/lang/String;)Z", (void*)jfr_add_string_constant,76(char*)"uncaughtException", (char*)"(Ljava/lang/Thread;Ljava/lang/Throwable;)V", (void*)jfr_uncaught_exception,77(char*)"setForceInstrumentation", (char*)"(Z)V", (void*)jfr_set_force_instrumentation,78(char*)"getUnloadedEventClassCount", (char*)"()J", (void*)jfr_get_unloaded_event_classes_count,79(char*)"setCutoff", (char*)"(JJ)Z", (void*)jfr_set_cutoff,80(char*)"emitOldObjectSamples", (char*)"(JZ)V", (void*)jfr_emit_old_object_samples,81(char*)"shouldRotateDisk", (char*)"()Z", (void*)jfr_should_rotate_disk82};8384const size_t method_array_length = sizeof(method) / sizeof(JNINativeMethod);85if (env->RegisterNatives(jfr_clz, method, (jint)method_array_length) != JNI_OK) {86JavaThread* jt = JavaThread::thread_from_jni_environment(env);87assert(jt != NULL, "invariant");88assert(jt->thread_state() == _thread_in_native, "invariant");89ThreadInVMfromNative transition(jt);90if (true) tty->print_cr("RegisterNatives for JVM class failed!");91}92env->DeleteLocalRef(jfr_clz);93}94}959697