src/hotspot/share/jfr/periodic/jfrPeriodic.cpp
changeset 50113 caf115bb98ad
child 50879 d90c3cbf13df
equal deleted inserted replaced
50112:7a2a740815b7 50113:caf115bb98ad
       
     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 #include "precompiled.hpp"
       
    26 #include "jvm.h"
       
    27 #include "classfile/classLoaderStats.hpp"
       
    28 #include "classfile/javaClasses.hpp"
       
    29 #include "code/codeCache.hpp"
       
    30 #include "compiler/compileBroker.hpp"
       
    31 #include "gc/g1/g1HeapRegionEventSender.hpp"
       
    32 #include "gc/shared/gcConfiguration.hpp"
       
    33 #include "gc/shared/gcTrace.hpp"
       
    34 #include "gc/shared/objectCountEventSender.hpp"
       
    35 #include "gc/shared/vmGCOperations.hpp"
       
    36 #include "jfr/jfrEvents.hpp"
       
    37 #include "jfr/periodic/jfrModuleEvent.hpp"
       
    38 #include "jfr/periodic/jfrOSInterface.hpp"
       
    39 #include "jfr/periodic/jfrThreadCPULoadEvent.hpp"
       
    40 #include "jfr/periodic/jfrThreadDumpEvent.hpp"
       
    41 #include "jfr/recorder/jfrRecorder.hpp"
       
    42 #include "jfr/support/jfrThreadId.hpp"
       
    43 #include "jfr/utilities/jfrTime.hpp"
       
    44 #include "jfrfiles/jfrPeriodic.hpp"
       
    45 #include "logging/log.hpp"
       
    46 #include "memory/heapInspection.hpp"
       
    47 #include "memory/resourceArea.hpp"
       
    48 #include "oops/oop.inline.hpp"
       
    49 #include "runtime/arguments.hpp"
       
    50 #include "runtime/flags/jvmFlag.hpp"
       
    51 #include "runtime/globals.hpp"
       
    52 #include "runtime/os.hpp"
       
    53 #include "runtime/os_perf.hpp"
       
    54 #include "runtime/thread.inline.hpp"
       
    55 #include "runtime/threadSMR.hpp"
       
    56 #include "runtime/sweeper.hpp"
       
    57 #include "runtime/vmThread.hpp"
       
    58 #include "services/classLoadingService.hpp"
       
    59 #include "services/management.hpp"
       
    60 #include "services/threadService.hpp"
       
    61 #include "utilities/exceptions.hpp"
       
    62 #include "utilities/globalDefinitions.hpp"
       
    63 
       
    64 /**
       
    65  *  JfrPeriodic class
       
    66  *  Implementation of declarations in
       
    67  *  xsl generated traceRequestables.hpp
       
    68  */
       
    69 #define TRACE_REQUEST_FUNC(id)    void JfrPeriodicEventSet::request##id(void)
       
    70 
       
    71 TRACE_REQUEST_FUNC(JVMInformation) {
       
    72   ResourceMark rm;
       
    73   EventJVMInformation event;
       
    74   event.set_jvmName(VM_Version::vm_name());
       
    75   event.set_jvmVersion(VM_Version::internal_vm_info_string());
       
    76   event.set_javaArguments(Arguments::java_command());
       
    77   event.set_jvmArguments(Arguments::jvm_args());
       
    78   event.set_jvmFlags(Arguments::jvm_flags());
       
    79   event.set_jvmStartTime(Management::vm_init_done_time());
       
    80   event.commit();
       
    81  }
       
    82 
       
    83 TRACE_REQUEST_FUNC(OSInformation) {
       
    84   ResourceMark rm;
       
    85   char* os_name = NEW_RESOURCE_ARRAY(char, 2048);
       
    86   JfrOSInterface::os_version(&os_name);
       
    87   EventOSInformation event;
       
    88   event.set_osVersion(os_name);
       
    89   event.commit();
       
    90 }
       
    91 
       
    92 TRACE_REQUEST_FUNC(ModuleRequire) {
       
    93   JfrModuleEvent::generate_module_dependency_events();
       
    94 }
       
    95 
       
    96 TRACE_REQUEST_FUNC(ModuleExport) {
       
    97   JfrModuleEvent::generate_module_export_events();
       
    98 }
       
    99 
       
   100 /*
       
   101  * This is left empty on purpose, having ExecutionSample as a requestable
       
   102  * is a way of getting the period. The period is passed to ThreadSampling::update_period.
       
   103  * Implementation in jfrSamples.cpp
       
   104  */
       
   105 TRACE_REQUEST_FUNC(ExecutionSample) {
       
   106 }
       
   107 TRACE_REQUEST_FUNC(NativeMethodSample) {
       
   108 }
       
   109 
       
   110 TRACE_REQUEST_FUNC(ThreadDump) {
       
   111   ResourceMark rm;
       
   112   EventThreadDump event;
       
   113   event.set_result(JfrDcmdEvent::thread_dump());
       
   114   event.commit();
       
   115 }
       
   116 
       
   117 static int _native_library_callback(const char* name, address base, address top, void *param) {
       
   118   EventNativeLibrary event(UNTIMED);
       
   119   event.set_name(name);
       
   120   event.set_baseAddress((u8)base);
       
   121   event.set_topAddress((u8)top);
       
   122   event.set_endtime(*(JfrTicks*) param);
       
   123   event.commit();
       
   124   return 0;
       
   125 }
       
   126 
       
   127 TRACE_REQUEST_FUNC(NativeLibrary) {
       
   128   JfrTicks ts= JfrTicks::now();
       
   129   os::get_loaded_modules_info(&_native_library_callback, (void *)&ts);
       
   130 }
       
   131 
       
   132 TRACE_REQUEST_FUNC(InitialEnvironmentVariable) {
       
   133   JfrOSInterface::generate_initial_environment_variable_events();
       
   134 }
       
   135 
       
   136 TRACE_REQUEST_FUNC(CPUInformation) {
       
   137   CPUInformation cpu_info;
       
   138   int ret_val = JfrOSInterface::cpu_information(cpu_info);
       
   139   if (ret_val == OS_ERR) {
       
   140     log_debug(jfr, system)( "Unable to generate requestable event CPUInformation");
       
   141     return;
       
   142   }
       
   143   if (ret_val == FUNCTIONALITY_NOT_IMPLEMENTED) {
       
   144      return;
       
   145   }
       
   146   if (ret_val == OS_OK) {
       
   147     EventCPUInformation event;
       
   148     event.set_cpu(cpu_info.cpu_name());
       
   149     event.set_description(cpu_info.cpu_description());
       
   150     event.set_sockets(cpu_info.number_of_sockets());
       
   151     event.set_cores(cpu_info.number_of_cores());
       
   152     event.set_hwThreads(cpu_info.number_of_hardware_threads());
       
   153     event.commit();
       
   154   }
       
   155 }
       
   156 
       
   157 TRACE_REQUEST_FUNC(CPULoad) {
       
   158   double u = 0; // user time
       
   159   double s = 0; // kernel time
       
   160   double t = 0; // total time
       
   161   int ret_val = JfrOSInterface::cpu_loads_process(&u, &s, &t);
       
   162   if (ret_val == OS_ERR) {
       
   163     log_debug(jfr, system)( "Unable to generate requestable event CPULoad");
       
   164     return;
       
   165   }
       
   166   if (ret_val == OS_OK) {
       
   167     EventCPULoad event;
       
   168     event.set_jvmUser((float)u);
       
   169     event.set_jvmSystem((float)s);
       
   170     event.set_machineTotal((float)t);
       
   171     event.commit();
       
   172   }
       
   173 }
       
   174 
       
   175 TRACE_REQUEST_FUNC(ThreadCPULoad) {
       
   176   JfrThreadCPULoadEvent::send_events();
       
   177 }
       
   178 
       
   179 TRACE_REQUEST_FUNC(CPUTimeStampCounter) {
       
   180   EventCPUTimeStampCounter event;
       
   181   event.set_fastTimeEnabled(JfrTime::is_ft_enabled());
       
   182   event.set_fastTimeAutoEnabled(JfrTime::is_ft_supported());
       
   183   event.set_osFrequency(os::elapsed_frequency());
       
   184   event.set_fastTimeFrequency(JfrTime::frequency());
       
   185   event.commit();
       
   186 }
       
   187 
       
   188 TRACE_REQUEST_FUNC(SystemProcess) {
       
   189   char pid_buf[16];
       
   190   SystemProcess* processes = NULL;
       
   191   int num_of_processes = 0;
       
   192   JfrTicks start_time = JfrTicks::now();
       
   193   int ret_val = JfrOSInterface::system_processes(&processes, &num_of_processes);
       
   194   if (ret_val == OS_ERR) {
       
   195     log_debug(jfr, system)( "Unable to generate requestable event SystemProcesses");
       
   196     return;
       
   197   }
       
   198   JfrTicks end_time = JfrTicks::now();
       
   199   if (ret_val == FUNCTIONALITY_NOT_IMPLEMENTED) {
       
   200     return;
       
   201   }
       
   202   if (ret_val == OS_OK) {
       
   203     // feature is implemented, write real event
       
   204     while (processes != NULL) {
       
   205       SystemProcess* tmp = processes;
       
   206       const char* info = processes->command_line();
       
   207       if (info == NULL) {
       
   208          info = processes->path();
       
   209       }
       
   210       if (info == NULL) {
       
   211          info = processes->name();
       
   212       }
       
   213       if (info == NULL) {
       
   214          info = "?";
       
   215       }
       
   216       jio_snprintf(pid_buf, sizeof(pid_buf), "%d", processes->pid());
       
   217       EventSystemProcess event(UNTIMED);
       
   218       event.set_pid(pid_buf);
       
   219       event.set_commandLine(info);
       
   220       event.set_starttime(start_time);
       
   221       event.set_endtime(end_time);
       
   222       event.commit();
       
   223       processes = processes->next();
       
   224       delete tmp;
       
   225     }
       
   226   }
       
   227 }
       
   228 
       
   229 TRACE_REQUEST_FUNC(ThreadContextSwitchRate) {
       
   230   double rate = 0.0;
       
   231   int ret_val = JfrOSInterface::context_switch_rate(&rate);
       
   232   if (ret_val == OS_ERR) {
       
   233     log_debug(jfr, system)( "Unable to generate requestable event ThreadContextSwitchRate");
       
   234     return;
       
   235   }
       
   236   if (ret_val == FUNCTIONALITY_NOT_IMPLEMENTED) {
       
   237     return;
       
   238   }
       
   239   if (ret_val == OS_OK) {
       
   240     EventThreadContextSwitchRate event;
       
   241     event.set_switchRate((float)rate + 0.0f);
       
   242     event.commit();
       
   243   }
       
   244 }
       
   245 
       
   246 #define SEND_FLAGS_OF_TYPE(eventType, flagType)                   \
       
   247   do {                                                            \
       
   248     JVMFlag *flag = JVMFlag::flags;                               \
       
   249     while (flag->_name != NULL) {                                 \
       
   250       if (flag->is_ ## flagType()) {                              \
       
   251         if (flag->is_unlocked()) {                                \
       
   252           Event ## eventType event;                               \
       
   253           event.set_name(flag->_name);                            \
       
   254           event.set_value(flag->get_ ## flagType());              \
       
   255           event.set_origin(flag->get_origin());                   \
       
   256           event.commit();                                         \
       
   257         }                                                         \
       
   258       }                                                           \
       
   259       ++flag;                                                     \
       
   260     }                                                             \
       
   261   } while (0)
       
   262 
       
   263 TRACE_REQUEST_FUNC(IntFlag) {
       
   264   SEND_FLAGS_OF_TYPE(IntFlag, int);
       
   265 }
       
   266 
       
   267 TRACE_REQUEST_FUNC(UnsignedIntFlag) {
       
   268   SEND_FLAGS_OF_TYPE(UnsignedIntFlag, uint);
       
   269 }
       
   270 
       
   271 TRACE_REQUEST_FUNC(LongFlag) {
       
   272   SEND_FLAGS_OF_TYPE(LongFlag, intx);
       
   273 }
       
   274 
       
   275 TRACE_REQUEST_FUNC(UnsignedLongFlag) {
       
   276   SEND_FLAGS_OF_TYPE(UnsignedLongFlag, uintx);
       
   277   SEND_FLAGS_OF_TYPE(UnsignedLongFlag, uint64_t);
       
   278   SEND_FLAGS_OF_TYPE(UnsignedLongFlag, size_t);
       
   279 }
       
   280 
       
   281 TRACE_REQUEST_FUNC(DoubleFlag) {
       
   282   SEND_FLAGS_OF_TYPE(DoubleFlag, double);
       
   283 }
       
   284 
       
   285 TRACE_REQUEST_FUNC(BooleanFlag) {
       
   286   SEND_FLAGS_OF_TYPE(BooleanFlag, bool);
       
   287 }
       
   288 
       
   289 TRACE_REQUEST_FUNC(StringFlag) {
       
   290   SEND_FLAGS_OF_TYPE(StringFlag, ccstr);
       
   291 }
       
   292 
       
   293 class VM_GC_SendObjectCountEvent : public VM_GC_HeapInspection {
       
   294  public:
       
   295   VM_GC_SendObjectCountEvent() : VM_GC_HeapInspection(NULL, true) {}
       
   296   virtual void doit() {
       
   297     ObjectCountEventSender::enable_requestable_event();
       
   298     collect();
       
   299     ObjectCountEventSender::disable_requestable_event();
       
   300   }
       
   301 };
       
   302 
       
   303 TRACE_REQUEST_FUNC(ObjectCount) {
       
   304   VM_GC_SendObjectCountEvent op;
       
   305   VMThread::execute(&op);
       
   306 }
       
   307 
       
   308 class VM_G1SendHeapRegionInfoEvents : public VM_Operation {
       
   309   virtual void doit() {
       
   310     G1HeapRegionEventSender::send_events();
       
   311   }
       
   312   virtual VMOp_Type type() const { return VMOp_HeapIterateOperation; }
       
   313 };
       
   314 
       
   315 TRACE_REQUEST_FUNC(G1HeapRegionInformation) {
       
   316   if (UseG1GC) {
       
   317     VM_G1SendHeapRegionInfoEvents op;
       
   318     VMThread::execute(&op);
       
   319   }
       
   320 }
       
   321 
       
   322 // Java Mission Control (JMC) uses (Java) Long.MIN_VALUE to describe that a
       
   323 // long value is undefined.
       
   324 static jlong jmc_undefined_long = min_jlong;
       
   325 
       
   326 TRACE_REQUEST_FUNC(GCConfiguration) {
       
   327   GCConfiguration conf;
       
   328   jlong pause_target = conf.has_pause_target_default_value() ? jmc_undefined_long : conf.pause_target();
       
   329   EventGCConfiguration event;
       
   330   event.set_youngCollector(conf.young_collector());
       
   331   event.set_oldCollector(conf.old_collector());
       
   332   event.set_parallelGCThreads(conf.num_parallel_gc_threads());
       
   333   event.set_concurrentGCThreads(conf.num_concurrent_gc_threads());
       
   334   event.set_usesDynamicGCThreads(conf.uses_dynamic_gc_threads());
       
   335   event.set_isExplicitGCConcurrent(conf.is_explicit_gc_concurrent());
       
   336   event.set_isExplicitGCDisabled(conf.is_explicit_gc_disabled());
       
   337   event.set_gcTimeRatio(conf.gc_time_ratio());
       
   338   event.set_pauseTarget((s8)pause_target);
       
   339   event.commit();
       
   340 }
       
   341 
       
   342 TRACE_REQUEST_FUNC(GCTLABConfiguration) {
       
   343   GCTLABConfiguration conf;
       
   344   EventGCTLABConfiguration event;
       
   345   event.set_usesTLABs(conf.uses_tlabs());
       
   346   event.set_minTLABSize(conf.min_tlab_size());
       
   347   event.set_tlabRefillWasteLimit(conf.tlab_refill_waste_limit());
       
   348   event.commit();
       
   349 }
       
   350 
       
   351 TRACE_REQUEST_FUNC(GCSurvivorConfiguration) {
       
   352   GCSurvivorConfiguration conf;
       
   353   EventGCSurvivorConfiguration event;
       
   354   event.set_maxTenuringThreshold(conf.max_tenuring_threshold());
       
   355   event.set_initialTenuringThreshold(conf.initial_tenuring_threshold());
       
   356   event.commit();
       
   357 }
       
   358 
       
   359 TRACE_REQUEST_FUNC(GCHeapConfiguration) {
       
   360   GCHeapConfiguration conf;
       
   361   EventGCHeapConfiguration event;
       
   362   event.set_minSize(conf.min_size());
       
   363   event.set_maxSize(conf.max_size());
       
   364   event.set_initialSize(conf.initial_size());
       
   365   event.set_usesCompressedOops(conf.uses_compressed_oops());
       
   366   event.set_compressedOopsMode(conf.narrow_oop_mode());
       
   367   event.set_objectAlignment(conf.object_alignment_in_bytes());
       
   368   event.set_heapAddressBits(conf.heap_address_size_in_bits());
       
   369   event.commit();
       
   370 }
       
   371 
       
   372 TRACE_REQUEST_FUNC(YoungGenerationConfiguration) {
       
   373   GCYoungGenerationConfiguration conf;
       
   374   jlong max_size = conf.has_max_size_default_value() ? jmc_undefined_long : conf.max_size();
       
   375   EventYoungGenerationConfiguration event;
       
   376   event.set_maxSize((u8)max_size);
       
   377   event.set_minSize(conf.min_size());
       
   378   event.set_newRatio(conf.new_ratio());
       
   379   event.commit();
       
   380 }
       
   381 
       
   382 TRACE_REQUEST_FUNC(InitialSystemProperty) {
       
   383   SystemProperty* p = Arguments::system_properties();
       
   384   JfrTicks time_stamp = JfrTicks::now();
       
   385   while (p !=  NULL) {
       
   386     if (!p->internal()) {
       
   387       EventInitialSystemProperty event(UNTIMED);
       
   388       event.set_key(p->key());
       
   389       event.set_value(p->value());
       
   390       event.set_endtime(time_stamp);
       
   391       event.commit();
       
   392     }
       
   393     p = p->next();
       
   394   }
       
   395 }
       
   396 
       
   397 TRACE_REQUEST_FUNC(ThreadAllocationStatistics) {
       
   398   ResourceMark rm;
       
   399   int initial_size = Threads::number_of_threads();
       
   400   GrowableArray<jlong> allocated(initial_size);
       
   401   GrowableArray<traceid> thread_ids(initial_size);
       
   402   JfrTicks time_stamp = JfrTicks::now();
       
   403   {
       
   404     // Collect allocation statistics while holding threads lock
       
   405     MutexLockerEx ml(Threads_lock);
       
   406     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
       
   407       allocated.append(jt->cooked_allocated_bytes());
       
   408       thread_ids.append(JFR_THREAD_ID(jt));
       
   409     }
       
   410   }
       
   411 
       
   412   // Write allocation statistics to buffer.
       
   413   for(int i = 0; i < thread_ids.length(); i++) {
       
   414     EventThreadAllocationStatistics event(UNTIMED);
       
   415     event.set_allocated(allocated.at(i));
       
   416     event.set_thread(thread_ids.at(i));
       
   417     event.set_endtime(time_stamp);
       
   418     event.commit();
       
   419   }
       
   420 }
       
   421 
       
   422 /**
       
   423  *  PhysicalMemory event represents:
       
   424  *
       
   425  *  @totalSize == The amount of physical memory (hw) installed and reported by the OS, in bytes.
       
   426  *  @usedSize  == The amount of physical memory currently in use in the system (reserved/committed), in bytes.
       
   427  *
       
   428  *  Both fields are systemwide, i.e. represents the entire OS/HW environment.
       
   429  *  These fields do not include virtual memory.
       
   430  *
       
   431  *  If running inside a guest OS on top of a hypervisor in a virtualized environment,
       
   432  *  the total memory reported is the amount of memory configured for the guest OS by the hypervisor.
       
   433  */
       
   434 TRACE_REQUEST_FUNC(PhysicalMemory) {
       
   435   u8 totalPhysicalMemory = os::physical_memory();
       
   436   EventPhysicalMemory event;
       
   437   event.set_totalSize(totalPhysicalMemory);
       
   438   event.set_usedSize(totalPhysicalMemory - os::available_memory());
       
   439   event.commit();
       
   440 }
       
   441 
       
   442 TRACE_REQUEST_FUNC(JavaThreadStatistics) {
       
   443   EventJavaThreadStatistics event;
       
   444   event.set_activeCount(ThreadService::get_live_thread_count());
       
   445   event.set_daemonCount(ThreadService::get_daemon_thread_count());
       
   446   event.set_accumulatedCount(ThreadService::get_total_thread_count());
       
   447   event.set_peakCount(ThreadService::get_peak_thread_count());
       
   448   event.commit();
       
   449 }
       
   450 
       
   451 TRACE_REQUEST_FUNC(ClassLoadingStatistics) {
       
   452   EventClassLoadingStatistics event;
       
   453   event.set_loadedClassCount(ClassLoadingService::loaded_class_count());
       
   454   event.set_unloadedClassCount(ClassLoadingService::unloaded_class_count());
       
   455   event.commit();
       
   456 }
       
   457 
       
   458 class JfrClassLoaderStatsClosure : public ClassLoaderStatsClosure {
       
   459 public:
       
   460   JfrClassLoaderStatsClosure() : ClassLoaderStatsClosure(NULL) {}
       
   461 
       
   462   bool do_entry(oop const& key, ClassLoaderStats* const& cls) {
       
   463     const ClassLoaderData* this_cld = cls->_class_loader != NULL ?
       
   464       java_lang_ClassLoader::loader_data(cls->_class_loader) : (ClassLoaderData*)NULL;
       
   465     const ClassLoaderData* parent_cld = cls->_parent != NULL ?
       
   466       java_lang_ClassLoader::loader_data(cls->_parent) : (ClassLoaderData*)NULL;
       
   467     EventClassLoaderStatistics event;
       
   468     event.set_classLoader(this_cld);
       
   469     event.set_parentClassLoader(parent_cld);
       
   470     event.set_classLoaderData((intptr_t)cls->_cld);
       
   471     event.set_classCount(cls->_classes_count);
       
   472     event.set_chunkSize(cls->_chunk_sz);
       
   473     event.set_blockSize(cls->_block_sz);
       
   474     event.set_anonymousClassCount(cls->_anon_classes_count);
       
   475     event.set_anonymousChunkSize(cls->_anon_chunk_sz);
       
   476     event.set_anonymousBlockSize(cls->_anon_block_sz);
       
   477     event.commit();
       
   478     return true;
       
   479   }
       
   480 
       
   481   void createEvents(void) {
       
   482     _stats->iterate(this);
       
   483   }
       
   484 };
       
   485 
       
   486 class JfrClassLoaderStatsVMOperation : public ClassLoaderStatsVMOperation {
       
   487  public:
       
   488   JfrClassLoaderStatsVMOperation() : ClassLoaderStatsVMOperation(NULL) { }
       
   489 
       
   490   void doit() {
       
   491     JfrClassLoaderStatsClosure clsc;
       
   492     ClassLoaderDataGraph::cld_do(&clsc);
       
   493     clsc.createEvents();
       
   494   }
       
   495 };
       
   496 
       
   497 TRACE_REQUEST_FUNC(ClassLoaderStatistics) {
       
   498   JfrClassLoaderStatsVMOperation op;
       
   499   VMThread::execute(&op);
       
   500 }
       
   501 
       
   502 TRACE_REQUEST_FUNC(CompilerStatistics) {
       
   503   EventCompilerStatistics event;
       
   504   event.set_compileCount(CompileBroker::get_total_compile_count());
       
   505   event.set_bailoutCount(CompileBroker::get_total_bailout_count());
       
   506   event.set_invalidatedCount(CompileBroker::get_total_invalidated_count());
       
   507   event.set_osrCompileCount(CompileBroker::get_total_osr_compile_count());
       
   508   event.set_standardCompileCount(CompileBroker::get_total_standard_compile_count());
       
   509   event.set_osrBytesCompiled(CompileBroker::get_sum_osr_bytes_compiled());
       
   510   event.set_standardBytesCompiled(CompileBroker::get_sum_standard_bytes_compiled());
       
   511   event.set_nmetodsSize(CompileBroker::get_sum_nmethod_size());
       
   512   event.set_nmetodCodeSize(CompileBroker::get_sum_nmethod_code_size());
       
   513   event.set_peakTimeSpent(CompileBroker::get_peak_compilation_time());
       
   514   event.set_totalTimeSpent(CompileBroker::get_total_compilation_time());
       
   515   event.commit();
       
   516 }
       
   517 
       
   518 TRACE_REQUEST_FUNC(CompilerConfiguration) {
       
   519   EventCompilerConfiguration event;
       
   520   event.set_threadCount(CICompilerCount);
       
   521   event.set_tieredCompilation(TieredCompilation);
       
   522   event.commit();
       
   523 }
       
   524 
       
   525 TRACE_REQUEST_FUNC(CodeCacheStatistics) {
       
   526   // Emit stats for all available code heaps
       
   527   for (int bt = 0; bt < CodeBlobType::NumTypes; ++bt) {
       
   528     if (CodeCache::heap_available(bt)) {
       
   529       EventCodeCacheStatistics event;
       
   530       event.set_codeBlobType((u1)bt);
       
   531       event.set_startAddress((u8)CodeCache::low_bound(bt));
       
   532       event.set_reservedTopAddress((u8)CodeCache::high_bound(bt));
       
   533       event.set_entryCount(CodeCache::blob_count(bt));
       
   534       event.set_methodCount(CodeCache::nmethod_count(bt));
       
   535       event.set_adaptorCount(CodeCache::adapter_count(bt));
       
   536       event.set_unallocatedCapacity(CodeCache::unallocated_capacity(bt));
       
   537       event.set_fullCount(CodeCache::get_codemem_full_count(bt));
       
   538       event.commit();
       
   539     }
       
   540   }
       
   541 }
       
   542 
       
   543 TRACE_REQUEST_FUNC(CodeCacheConfiguration) {
       
   544   EventCodeCacheConfiguration event;
       
   545   event.set_initialSize(InitialCodeCacheSize);
       
   546   event.set_reservedSize(ReservedCodeCacheSize);
       
   547   event.set_nonNMethodSize(NonNMethodCodeHeapSize);
       
   548   event.set_profiledSize(ProfiledCodeHeapSize);
       
   549   event.set_nonProfiledSize(NonProfiledCodeHeapSize);
       
   550   event.set_expansionSize(CodeCacheExpansionSize);
       
   551   event.set_minBlockLength(CodeCacheMinBlockLength);
       
   552   event.set_startAddress((u8)CodeCache::low_bound());
       
   553   event.set_reservedTopAddress((u8)CodeCache::high_bound());
       
   554   event.commit();
       
   555 }
       
   556 
       
   557 TRACE_REQUEST_FUNC(CodeSweeperStatistics) {
       
   558   EventCodeSweeperStatistics event;
       
   559   event.set_sweepCount(NMethodSweeper::traversal_count());
       
   560   event.set_methodReclaimedCount(NMethodSweeper::total_nof_methods_reclaimed());
       
   561   event.set_totalSweepTime(NMethodSweeper::total_time_sweeping());
       
   562   event.set_peakFractionTime(NMethodSweeper::peak_sweep_fraction_time());
       
   563   event.set_peakSweepTime(NMethodSweeper::peak_sweep_time());
       
   564   event.commit();
       
   565 }
       
   566 
       
   567 TRACE_REQUEST_FUNC(CodeSweeperConfiguration) {
       
   568   EventCodeSweeperConfiguration event;
       
   569   event.set_sweeperEnabled(MethodFlushing);
       
   570   event.set_flushingEnabled(UseCodeCacheFlushing);
       
   571   event.commit();
       
   572 }