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