8216995: Clean up JFR command line processing

Tue, 15 Jan 2019 21:17:35 +0100

author
redestad
date
Tue, 15 Jan 2019 21:17:35 +0100
changeset 9879
d2b51a10084d
parent 9878
8689c69d5c19
child 9880
3549c2f110d2

8216995: Clean up JFR command line processing
Reviewed-by: gziemski, mgronlun

src/share/vm/jfr/recorder/jfrRecorder.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/globals_extension.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/jfr/recorder/jfrRecorder.cpp	Wed Jan 16 13:38:19 2019 -0500
     1.2 +++ b/src/share/vm/jfr/recorder/jfrRecorder.cpp	Tue Jan 15 21:17:35 2019 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -42,32 +42,24 @@
    1.11  #include "jfr/writers/jfrJavaEventWriter.hpp"
    1.12  #include "memory/resourceArea.hpp"
    1.13  #include "runtime/handles.inline.hpp"
    1.14 -#include "runtime/globals.hpp"
    1.15 +#include "runtime/globals_extension.hpp"
    1.16  #include "utilities/growableArray.hpp"
    1.17  
    1.18  bool JfrRecorder::_shutting_down = false;
    1.19  
    1.20 -static bool is_disabled_on_command_line() {
    1.21 -  static const size_t length = strlen("FlightRecorder");
    1.22 -  static Flag* const flight_recorder_flag = Flag::find_flag("FlightRecorder", length);
    1.23 -  assert(flight_recorder_flag != NULL, "invariant");
    1.24 -  return flight_recorder_flag->is_command_line() ? !FlightRecorder : false;
    1.25 -}
    1.26 -
    1.27  bool JfrRecorder::is_disabled() {
    1.28 -  return is_disabled_on_command_line();
    1.29 -}
    1.30 -
    1.31 -static bool set_flight_recorder_flag(bool flag_value) {
    1.32 -  CommandLineFlags::boolAtPut((char*)"FlightRecorder", &flag_value, Flag::MANAGEMENT);
    1.33 -  return FlightRecorder;
    1.34 +  // True if -XX:-FlightRecorder has been explicitly set on the
    1.35 +  // command line
    1.36 +  return FLAG_IS_CMDLINE(FlightRecorder) ? !FlightRecorder : false;
    1.37  }
    1.38  
    1.39  static bool _enabled = false;
    1.40  
    1.41  static bool enable() {
    1.42    assert(!_enabled, "invariant");
    1.43 -  _enabled = set_flight_recorder_flag(true);
    1.44 +  FLAG_SET_MGMT(bool, FlightRecorder, true);
    1.45 +  _enabled = FlightRecorder;
    1.46 +  assert(_enabled, "invariant");
    1.47    return _enabled;
    1.48  }
    1.49  
     2.1 --- a/src/share/vm/runtime/globals_extension.hpp	Wed Jan 16 13:38:19 2019 -0500
     2.2 +++ b/src/share/vm/runtime/globals_extension.hpp	Tue Jan 15 21:17:35 2019 +0100
     2.3 @@ -191,6 +191,7 @@
     2.4  
     2.5  #define FLAG_SET_CMDLINE(type, name, value) (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), Flag::COMMAND_LINE))
     2.6  #define FLAG_SET_ERGO(type, name, value)    (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), Flag::ERGONOMIC))
     2.7 +#define FLAG_SET_MGMT(type, name, value)    (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name, type), (type)(value), Flag::MANAGEMENT))
     2.8  
     2.9  // Can't put the following in CommandLineFlags because
    2.10  // of a circular dependency on the enum definition.

mercurial