1 /*
   2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_JFR_RECORDER_SERVICE_JFROPTIONSET_HPP
  26 #define SHARE_VM_JFR_RECORDER_SERVICE_JFROPTIONSET_HPP
  27 
  28 #include "jni.h"
  29 #include "memory/allocation.hpp"
  30 #include "utilities/exceptions.hpp"
  31 
  32 template <typename>
  33 class GrowableArray;
  34 
  35 //
  36 // Command-line options and defaults
  37 //
  38 class JfrOptionSet : public AllStatic {
  39   friend class JfrRecorder;
  40  private:
  41   static jlong _max_chunk_size;
  42   static jlong _global_buffer_size;
  43   static jlong _thread_buffer_size;
  44   static jlong _memory_size;
  45   static jlong _num_global_buffers;
  46   static jlong _old_object_queue_size;
  47   static u4 _stack_depth;
  48   static jboolean _sample_threads;
  49   static jboolean _retransform;
  50   static jboolean _sample_protection;
  51 
  52   static bool initialize(Thread* thread);
  53   static bool configure(TRAPS);
  54   static bool adjust_memory_options();
  55 
  56  public:
  57   static jlong max_chunk_size();
  58   static void set_max_chunk_size(jlong value);
  59   static jlong global_buffer_size();
  60   static void set_global_buffer_size(jlong value);
  61   static jlong thread_buffer_size();
  62   static void set_thread_buffer_size(jlong value);
  63   static jlong memory_size();
  64   static void set_memory_size(jlong value);
  65   static jlong num_global_buffers();
  66   static void set_num_global_buffers(jlong value);
  67   static jint old_object_queue_size();
  68   static void set_old_object_queue_size(jlong value);
  69   static u4 stackdepth();
  70   static void set_stackdepth(u4 depth);
  71   static bool sample_threads();
  72   static void set_sample_threads(jboolean sample);
  73   static bool can_retransform();
  74   static void set_retransform(jboolean value);
  75   static bool compressed_integers();
  76   static bool allow_retransforms();
  77   static bool allow_event_retransforms();
  78   static bool sample_protection();
  79   DEBUG_ONLY(static void set_sample_protection(jboolean protection);)
  80 
  81   static bool parse_flight_recorder_option(const JavaVMOption** option, char* delimiter);
  82   static bool parse_start_flight_recording_option(const JavaVMOption** option, char* delimiter);
  83   static const GrowableArray<const char*>* startup_recording_options();
  84   static void release_startup_recording_options();
  85 };
  86 
  87 #endif // SHARE_VM_JFR_RECORDER_SERVICE_JFROPTIONSET_HPP