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