src/hotspot/share/jfr/jfr.cpp
author mgronlun
Thu, 28 Jun 2018 11:37:02 +0200
changeset 50873 ce53844224b6
parent 50113 caf115bb98ad
child 51004 162867fa0f8d
permissions -rw-r--r--
8205906: jdk.jfr.jcmd.TestJcmdDumpLimited fails due to erronous processing of -XX:FlightRecorderOptions Reviewed-by: egahlin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     1
/*
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
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 "jfr/jfr.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    27
#include "jfr/leakprofiler/leakProfiler.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    28
#include "jfr/periodic/sampling/jfrThreadSampler.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    29
#include "jfr/recorder/service/jfrOptionSet.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    30
#include "jfr/recorder/jfrRecorder.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    31
#include "jfr/recorder/checkpoint/jfrCheckpointManager.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    32
#include "jfr/recorder/repository/jfrEmergencyDump.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    33
#include "jfr/support/jfrThreadLocal.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    34
#include "runtime/java.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    35
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    36
bool Jfr::is_enabled() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    37
  return JfrRecorder::is_enabled();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    38
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    39
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    40
bool Jfr::is_disabled() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    41
  return JfrRecorder::is_disabled();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    42
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    43
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    44
bool Jfr::is_recording() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    45
  return JfrRecorder::is_recording();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    46
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    47
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    48
void Jfr::on_vm_init() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    49
  if (!JfrRecorder::on_vm_init()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    50
    vm_exit_during_initialization("Failure when starting JFR on_vm_init");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    51
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    52
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    53
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    54
void Jfr::on_vm_start() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    55
  if (!JfrRecorder::on_vm_start()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    56
    vm_exit_during_initialization("Failure when starting JFR on_vm_start");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    57
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    58
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    59
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    60
void Jfr::on_unloading_classes() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    61
  if (JfrRecorder::is_created()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    62
    JfrCheckpointManager::write_type_set_for_unloaded_classes();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    63
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    64
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    65
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    66
void Jfr::on_thread_exit(JavaThread* thread) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    67
  if (JfrRecorder::is_recording()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    68
    JfrThreadLocal::on_exit(thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    69
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    70
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    71
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    72
void Jfr::on_thread_destruct(Thread* thread) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    73
  if (JfrRecorder::is_created()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    74
    JfrThreadLocal::on_destruct(thread);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    75
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    76
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    77
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    78
void Jfr::on_vm_shutdown(bool exception_handler) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    79
  if (JfrRecorder::is_recording()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    80
    JfrEmergencyDump::on_vm_shutdown(exception_handler);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    81
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    82
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    83
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    84
void Jfr::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    85
  LeakProfiler::oops_do(is_alive, f);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    86
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    87
50873
ce53844224b6 8205906: jdk.jfr.jcmd.TestJcmdDumpLimited fails due to erronous processing of -XX:FlightRecorderOptions
mgronlun
parents: 50113
diff changeset
    88
bool Jfr::on_flight_recorder_option(const JavaVMOption** option, char* delimiter) {
ce53844224b6 8205906: jdk.jfr.jcmd.TestJcmdDumpLimited fails due to erronous processing of -XX:FlightRecorderOptions
mgronlun
parents: 50113
diff changeset
    89
  return JfrOptionSet::parse_flight_recorder_option(option, delimiter);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    90
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    91
50873
ce53844224b6 8205906: jdk.jfr.jcmd.TestJcmdDumpLimited fails due to erronous processing of -XX:FlightRecorderOptions
mgronlun
parents: 50113
diff changeset
    92
bool Jfr::on_start_flight_recording_option(const JavaVMOption** option, char* delimiter) {
ce53844224b6 8205906: jdk.jfr.jcmd.TestJcmdDumpLimited fails due to erronous processing of -XX:FlightRecorderOptions
mgronlun
parents: 50113
diff changeset
    93
  return JfrOptionSet::parse_start_flight_recording_option(option, delimiter);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    94
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    95
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    96
Thread* Jfr::sampler_thread() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    97
  return JfrThreadSampling::sampler_thread();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    98
}