src/hotspot/share/jfr/jni/jfrJniMethod.cpp
author mseledtsov
Thu, 12 Sep 2019 11:32:03 -0700
branchJEP-349-branch
changeset 58112 e7754025004b
parent 57360 5d043a159d5c
child 58165 8584c5b96cb6
permissions -rw-r--r--
Copyright update - round 2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     1
/*
58112
e7754025004b Copyright update - round 2
mseledtsov
parents: 57360
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     4
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     8
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    13
 * accompanied this code).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    14
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    18
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    21
 * questions.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    22
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    23
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    24
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    25
#include "precompiled.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    26
#include "jni.h"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    27
#include "jvm.h"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    28
#include "jfr/jfr.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    29
#include "jfr/jfrEvents.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    30
#include "jfr/periodic/sampling/jfrThreadSampler.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    31
#include "jfr/recorder/jfrEventSetting.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    32
#include "jfr/recorder/jfrRecorder.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    33
#include "jfr/recorder/checkpoint/jfrMetadataEvent.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    34
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    35
#include "jfr/recorder/repository/jfrRepository.hpp"
53014
339d2fbe8675 8215284: Reduce noise induced by periodic task getFileSize()
mgronlun
parents: 50163
diff changeset
    36
#include "jfr/recorder/repository/jfrChunkRotation.hpp"
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    37
#include "jfr/recorder/repository/jfrChunkWriter.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    38
#include "jfr/recorder/service/jfrOptionSet.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    39
#include "jfr/recorder/stacktrace/jfrStackTraceRepository.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    40
#include "jfr/recorder/stringpool/jfrStringPool.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    41
#include "jfr/jni/jfrGetAllEventClasses.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    42
#include "jfr/jni/jfrJavaSupport.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    43
#include "jfr/jni/jfrJniMethodRegistration.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    44
#include "jfr/instrumentation/jfrEventClassTransformer.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    45
#include "jfr/instrumentation/jfrJvmtiAgent.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    46
#include "jfr/leakprofiler/leakProfiler.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    47
#include "jfr/utilities/jfrJavaLog.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    48
#include "jfr/utilities/jfrTimeConverter.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    49
#include "jfr/utilities/jfrTime.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    50
#include "jfr/writers/jfrJavaEventWriter.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    51
#include "jfrfiles/jfrPeriodic.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    52
#include "logging/log.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    53
#include "memory/resourceArea.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    54
#include "runtime/interfaceSupport.inline.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    55
#include "runtime/mutexLocker.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    56
#include "runtime/os.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    57
#include "runtime/thread.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    58
#include "utilities/debug.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    59
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    60
#define NO_TRANSITION(result_type, header) extern "C" { result_type JNICALL header {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    61
#define NO_TRANSITION_END } }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    62
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    63
/*
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    64
 * NO_TRANSITION entries
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    65
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    66
 * Thread remains _thread_in_native
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    67
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    68
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    69
NO_TRANSITION(void, jfr_register_natives(JNIEnv* env, jclass jvmclass))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    70
  JfrJniMethodRegistration register_native_methods(env);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    71
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    72
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    73
NO_TRANSITION(jboolean, jfr_is_enabled())
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    74
  return Jfr::is_enabled() ? JNI_TRUE : JNI_FALSE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    75
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    76
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    77
NO_TRANSITION(jboolean, jfr_is_disabled())
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    78
  return Jfr::is_disabled() ? JNI_TRUE : JNI_FALSE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    79
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    80
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    81
NO_TRANSITION(jboolean, jfr_is_started())
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    82
  return JfrRecorder::is_created() ? JNI_TRUE : JNI_FALSE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    83
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    84
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    85
NO_TRANSITION(jstring, jfr_get_pid(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    86
  char pid_buf[32] = { 0 };
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    87
  jio_snprintf(pid_buf, sizeof(pid_buf), "%d", os::current_process_id());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    88
  jstring pid_string = env->NewStringUTF(pid_buf);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    89
  return pid_string; // exception pending if NULL
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    90
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    91
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    92
NO_TRANSITION(jlong, jfr_elapsed_frequency(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    93
  return JfrTime::frequency();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    94
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    95
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    96
NO_TRANSITION(jlong, jfr_elapsed_counter(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    97
  return JfrTicks::now();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    98
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    99
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   100
NO_TRANSITION(void, jfr_retransform_classes(JNIEnv* env, jobject jvm, jobjectArray classes))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   101
  JfrJvmtiAgent::retransform_classes(env, classes, JavaThread::thread_from_jni_environment(env));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   102
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   103
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   104
NO_TRANSITION(void, jfr_set_enabled(JNIEnv* env, jobject jvm, jlong event_type_id, jboolean enabled))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   105
  JfrEventSetting::set_enabled(event_type_id, JNI_TRUE == enabled);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   106
  if (EventOldObjectSample::eventId == event_type_id) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   107
    ThreadInVMfromNative transition(JavaThread::thread_from_jni_environment(env));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   108
    if (JNI_TRUE == enabled) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   109
      LeakProfiler::start(JfrOptionSet::old_object_queue_size());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   110
    } else {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   111
      LeakProfiler::stop();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   112
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   113
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   114
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   115
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   116
NO_TRANSITION(void, jfr_set_file_notification(JNIEnv* env, jobject jvm, jlong threshold))
53897
0abec72a3ac2 8217647: JFR: recordings on 32-bit systems unreadable
bulasevich
parents: 53014
diff changeset
   117
  JfrChunkRotation::set_threshold(threshold);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   118
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   119
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   120
NO_TRANSITION(void, jfr_set_sample_threads(JNIEnv* env, jobject jvm, jboolean sampleThreads))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   121
  JfrOptionSet::set_sample_threads(sampleThreads);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   122
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   123
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   124
NO_TRANSITION(void, jfr_set_stack_depth(JNIEnv* env, jobject jvm, jint depth))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   125
  JfrOptionSet::set_stackdepth((jlong)depth);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   126
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   127
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   128
NO_TRANSITION(void, jfr_set_stacktrace_enabled(JNIEnv* env, jobject jvm, jlong event_type_id, jboolean enabled))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   129
  JfrEventSetting::set_stacktrace(event_type_id, JNI_TRUE == enabled);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   130
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   131
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   132
NO_TRANSITION(void, jfr_set_global_buffer_count(JNIEnv* env, jobject jvm, jlong count))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   133
  JfrOptionSet::set_num_global_buffers(count);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   134
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   135
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   136
NO_TRANSITION(void, jfr_set_global_buffer_size(JNIEnv* env, jobject jvm, jlong size))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   137
JfrOptionSet::set_global_buffer_size(size);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   138
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   139
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   140
NO_TRANSITION(void, jfr_set_thread_buffer_size(JNIEnv* env, jobject jvm, jlong size))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   141
  JfrOptionSet::set_thread_buffer_size(size);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   142
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   143
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   144
NO_TRANSITION(void, jfr_set_memory_size(JNIEnv* env, jobject jvm, jlong size))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   145
  JfrOptionSet::set_memory_size(size);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   146
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   147
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   148
NO_TRANSITION(jboolean, jfr_set_threshold(JNIEnv* env, jobject jvm, jlong event_type_id, jlong thresholdTicks))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   149
  return JfrEventSetting::set_threshold(event_type_id, thresholdTicks) ? JNI_TRUE : JNI_FALSE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   150
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   151
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   152
NO_TRANSITION(jboolean, jfr_allow_event_retransforms(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   153
  return JfrOptionSet::allow_event_retransforms() ? JNI_TRUE : JNI_FALSE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   154
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   155
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   156
NO_TRANSITION(jboolean, jfr_is_available(JNIEnv* env, jclass jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   157
  return !Jfr::is_disabled() ? JNI_TRUE : JNI_FALSE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   158
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   159
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   160
NO_TRANSITION(jlong, jfr_get_epoch_address(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   161
  return JfrTraceIdEpoch::epoch_address();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   162
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   163
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   164
NO_TRANSITION(jlong, jfr_get_unloaded_event_classes_count(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   165
  return JfrEventClasses::unloaded_event_classes_count();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   166
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   167
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   168
NO_TRANSITION(jdouble, jfr_time_conv_factor(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   169
  return (jdouble)JfrTimeConverter::nano_to_counter_multiplier();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   170
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   171
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   172
NO_TRANSITION(jboolean, jfr_set_cutoff(JNIEnv* env, jobject jvm, jlong event_type_id, jlong cutoff_ticks))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   173
  return JfrEventSetting::set_cutoff(event_type_id, cutoff_ticks) ? JNI_TRUE : JNI_FALSE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   174
NO_TRANSITION_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   175
53014
339d2fbe8675 8215284: Reduce noise induced by periodic task getFileSize()
mgronlun
parents: 50163
diff changeset
   176
NO_TRANSITION(jboolean, jfr_should_rotate_disk(JNIEnv* env, jobject jvm))
339d2fbe8675 8215284: Reduce noise induced by periodic task getFileSize()
mgronlun
parents: 50163
diff changeset
   177
  return JfrChunkRotation::should_rotate() ? JNI_TRUE : JNI_FALSE;
339d2fbe8675 8215284: Reduce noise induced by periodic task getFileSize()
mgronlun
parents: 50163
diff changeset
   178
NO_TRANSITION_END
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   179
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   180
/*
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   181
 * JVM_ENTRY_NO_ENV entries
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   182
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   183
 * Transitions:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   184
 *   Entry: _thread_in_native -> _thread_in_vm
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   185
 *   Exit:  _thread_in_vm -> _thread_in_native
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   186
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   187
 * Current JavaThread available as "thread" variable
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   188
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   189
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   190
JVM_ENTRY_NO_ENV(jboolean, jfr_create_jfr(JNIEnv* env, jobject jvm, jboolean simulate_failure))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   191
  if (JfrRecorder::is_created()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   192
    return JNI_TRUE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   193
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   194
  if (!JfrRecorder::create(simulate_failure == JNI_TRUE)) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   195
    JfrJavaSupport::throw_illegal_state_exception("Unable to start Jfr", thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   196
    return JNI_FALSE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   197
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   198
  return JNI_TRUE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   199
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   200
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   201
JVM_ENTRY_NO_ENV(jboolean, jfr_destroy_jfr(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   202
  JfrRecorder::destroy();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   203
  return JNI_TRUE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   204
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   205
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   206
JVM_ENTRY_NO_ENV(void, jfr_begin_recording(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   207
  if (JfrRecorder::is_recording()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   208
    return;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   209
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   210
  JfrRecorder::start_recording();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   211
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   212
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   213
JVM_ENTRY_NO_ENV(void, jfr_end_recording(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   214
  if (!JfrRecorder::is_recording()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   215
    return;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   216
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   217
  JfrRecorder::stop_recording();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   218
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   219
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   220
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   221
JVM_ENTRY_NO_ENV(jboolean, jfr_emit_event(JNIEnv* env, jobject jvm, jlong eventTypeId, jlong timeStamp, jlong when))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   222
  JfrPeriodicEventSet::requestEvent((JfrEventId)eventTypeId);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   223
  return thread->has_pending_exception() ? JNI_FALSE : JNI_TRUE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   224
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   225
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   226
JVM_ENTRY_NO_ENV(jobject, jfr_get_all_event_classes(JNIEnv* env, jobject jvm))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   227
  return JfrEventClasses::get_all_event_classes(thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   228
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   229
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   230
JVM_ENTRY_NO_ENV(jlong, jfr_class_id(JNIEnv* env, jclass jvm, jclass jc))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   231
  return JfrTraceId::use(jc);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   232
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   233
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   234
JVM_ENTRY_NO_ENV(jlong, jfr_stacktrace_id(JNIEnv* env, jobject jvm, jint skip))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   235
  return JfrStackTraceRepository::record(thread, skip);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   236
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   237
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   238
JVM_ENTRY_NO_ENV(void, jfr_log(JNIEnv* env, jobject jvm, jint tag_set, jint level, jstring message))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   239
  JfrJavaLog::log(tag_set, level, message, thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   240
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   241
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   242
JVM_ENTRY_NO_ENV(void, jfr_subscribe_log_level(JNIEnv* env, jobject jvm, jobject log_tag, jint id))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   243
  JfrJavaLog::subscribe_log_level(log_tag, id, thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   244
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   245
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   246
JVM_ENTRY_NO_ENV(void, jfr_set_output(JNIEnv* env, jobject jvm, jstring path))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   247
  JfrRepository::set_chunk_path(path, thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   248
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   249
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   250
JVM_ENTRY_NO_ENV(void, jfr_set_method_sampling_interval(JNIEnv* env, jobject jvm, jlong type, jlong intervalMillis))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   251
  if (intervalMillis < 0) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   252
    intervalMillis = 0;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   253
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   254
  JfrEventId typed_event_id = (JfrEventId)type;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   255
  assert(EventExecutionSample::eventId == typed_event_id || EventNativeMethodSample::eventId == typed_event_id, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   256
  if (intervalMillis > 0) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   257
    JfrEventSetting::set_enabled(typed_event_id, true); // ensure sampling event is enabled
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   258
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   259
  if (EventExecutionSample::eventId == type) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   260
    JfrThreadSampling::set_java_sample_interval(intervalMillis);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   261
  } else {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   262
    JfrThreadSampling::set_native_sample_interval(intervalMillis);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   263
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   264
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   265
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   266
JVM_ENTRY_NO_ENV(void, jfr_store_metadata_descriptor(JNIEnv* env, jobject jvm, jbyteArray descriptor))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   267
  JfrMetadataEvent::update(descriptor);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   268
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   269
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   270
// trace thread id for a thread object
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   271
JVM_ENTRY_NO_ENV(jlong, jfr_id_for_thread(JNIEnv* env, jobject jvm, jobject t))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   272
  return JfrJavaSupport::jfr_thread_id(t);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   273
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   274
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   275
JVM_ENTRY_NO_ENV(jobject, jfr_get_event_writer(JNIEnv* env, jclass cls))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   276
  return JfrJavaEventWriter::event_writer(thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   277
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   278
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   279
JVM_ENTRY_NO_ENV(jobject, jfr_new_event_writer(JNIEnv* env, jclass cls))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   280
  return JfrJavaEventWriter::new_event_writer(thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   281
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   282
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   283
JVM_ENTRY_NO_ENV(jboolean, jfr_event_writer_flush(JNIEnv* env, jclass cls, jobject writer, jint used_size, jint requested_size))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   284
  return JfrJavaEventWriter::flush(writer, used_size, requested_size, thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   285
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   286
57360
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   287
JVM_ENTRY_NO_ENV(void, jfr_flush(JNIEnv* env, jobject jvm, jboolean include_metadata, jshort flush_counter))
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   288
  JfrRepository::flush(include_metadata == JNI_TRUE, thread);
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   289
JVM_END
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   290
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   291
JVM_ENTRY_NO_ENV(void, jfr_set_repository_location(JNIEnv* env, jobject repo, jstring location))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   292
  return JfrRepository::set_path(location, thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   293
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   294
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   295
JVM_ENTRY_NO_ENV(void, jfr_uncaught_exception(JNIEnv* env, jobject jvm, jobject t, jthrowable throwable))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   296
  JfrJavaSupport::uncaught_exception(throwable, thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   297
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   298
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   299
JVM_ENTRY_NO_ENV(void, jfr_abort(JNIEnv* env, jobject jvm, jstring errorMsg))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   300
  JfrJavaSupport::abort(errorMsg, thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   301
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   302
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   303
JVM_ENTRY_NO_ENV(jlong, jfr_type_id(JNIEnv* env, jobject jvm, jclass jc))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   304
  return JfrTraceId::get(jc);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   305
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   306
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   307
JVM_ENTRY_NO_ENV(jboolean, jfr_add_string_constant(JNIEnv* env, jclass jvm, jboolean epoch, jlong id, jstring string))
50163
268ea94772da 8203346: JFR: Inconsistent signature of jfr_add_string_constant
mgronlun
parents: 50113
diff changeset
   308
  return JfrStringPool::add(epoch == JNI_TRUE, id, string, thread) ? JNI_TRUE : JNI_FALSE;
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   309
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   310
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   311
JVM_ENTRY_NO_ENV(void, jfr_set_force_instrumentation(JNIEnv* env, jobject jvm, jboolean force_instrumentation))
50163
268ea94772da 8203346: JFR: Inconsistent signature of jfr_add_string_constant
mgronlun
parents: 50113
diff changeset
   312
  JfrEventClassTransformer::set_force_instrumentation(force_instrumentation == JNI_TRUE);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   313
JVM_END
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   314
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   315
JVM_ENTRY_NO_ENV(void, jfr_emit_old_object_samples(JNIEnv* env, jobject jvm, jlong cutoff_ticks, jboolean emit_all))
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   316
  LeakProfiler::emit_events(cutoff_ticks, emit_all == JNI_TRUE);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   317
JVM_END
57360
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   318
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   319
JVM_ENTRY_NO_ENV(void, jfr_exclude_thread(JNIEnv* env, jobject jvm, jobject t))
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   320
  JfrJavaSupport::exclude(t);
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   321
JVM_END
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   322
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   323
JVM_ENTRY_NO_ENV(void, jfr_include_thread(JNIEnv* env, jobject jvm, jobject t))
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   324
  JfrJavaSupport::include(t);
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   325
JVM_END
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   326
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   327
JVM_ENTRY_NO_ENV(jboolean, jfr_is_thread_excluded(JNIEnv* env, jobject jvm, jobject t))
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   328
  return JfrJavaSupport::is_excluded(t);
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   329
JVM_END
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   330
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   331
JVM_ENTRY_NO_ENV(jlong, jfr_chunk_start_nanos(JNIEnv* env, jobject jvm))
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   332
  return JfrRepository::current_chunk_start_nanos();
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   333
JVM_END
5d043a159d5c Preview
egahlin
parents: 53897
diff changeset
   334