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