1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_CLASSLOADER_HPP
  26 #define SHARE_VM_CLASSFILE_CLASSLOADER_HPP
  27 
  28 #include "jimage.hpp"
  29 #include "runtime/handles.hpp"
  30 #include "runtime/perfData.hpp"
  31 #include "utilities/exceptions.hpp"
  32 #include "utilities/macros.hpp"
  33 
  34 // The VM class loader.
  35 #include <sys/stat.h>
  36 
  37 // Name of boot "modules" image
  38 #define  MODULES_IMAGE_NAME "modules"
  39 
  40 // Class path entry (directory or zip file)
  41 
  42 class JImageFile;
  43 class ClassFileStream;
  44 class PackageEntry;
  45 template <typename T> class GrowableArray;
  46 
  47 class ClassPathEntry : public CHeapObj<mtClass> {
  48 private:
  49   ClassPathEntry* volatile _next;
  50 public:
  51   ClassPathEntry* next() const;
  52   virtual ~ClassPathEntry() {}
  53   void set_next(ClassPathEntry* next);
  54   virtual bool is_modules_image() const = 0;
  55   virtual bool is_jar_file() const = 0;
  56   virtual const char* name() const = 0;
  57   virtual JImageFile* jimage() const = 0;
  58   // Constructor
  59   ClassPathEntry() : _next(NULL) {}
  60   // Attempt to locate file_name through this class path entry.
  61   // Returns a class file parsing stream if successfull.
  62   virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0;
  63   // Debugging
  64   NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;)
  65 };
  66 
  67 class ClassPathDirEntry: public ClassPathEntry {
  68  private:
  69   const char* _dir;           // Name of directory
  70  public:
  71   bool is_modules_image() const { return false; }
  72   bool is_jar_file() const { return false;  }
  73   const char* name() const { return _dir; }
  74   JImageFile* jimage() const { return NULL; }
  75   ClassPathDirEntry(const char* dir);
  76   virtual ~ClassPathDirEntry() {}
  77   ClassFileStream* open_stream(const char* name, TRAPS);
  78   // Debugging
  79   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
  80 };
  81 
  82 
  83 // Type definitions for zip file and zip file entry
  84 typedef void* jzfile;
  85 typedef struct {
  86   char *name;                   /* entry name */
  87   jlong time;                   /* modification time */
  88   jlong size;                   /* size of uncompressed data */
  89   jlong csize;                  /* size of compressed data (zero if uncompressed) */
  90   jint crc;                     /* crc of uncompressed data */
  91   char *comment;                /* optional zip file comment */
  92   jbyte *extra;                 /* optional extra data */
  93   jlong pos;                    /* position of LOC header (if negative) or data */
  94 } jzentry;
  95 
  96 class ClassPathZipEntry: public ClassPathEntry {
  97  enum {
  98    _unknown = 0,
  99    _yes     = 1,
 100    _no      = 2
 101  };
 102  private:
 103   jzfile* _zip;              // The zip archive
 104   const char*   _zip_name;   // Name of zip archive
 105   bool _is_boot_append;      // entry coming from -Xbootclasspath/a
 106   u1 _multi_versioned;       // indicates if the jar file has multi-versioned entries.
 107                              // It can have value of "_unknown", "_yes", or "_no"
 108  public:
 109   bool is_modules_image() const { return false; }
 110   bool is_jar_file() const { return true;  }
 111   const char* name() const { return _zip_name; }
 112   JImageFile* jimage() const { return NULL; }
 113   ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append);
 114   virtual ~ClassPathZipEntry();
 115   u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS);
 116   u1* open_versioned_entry(const char* name, jint* filesize, TRAPS) NOT_CDS_RETURN_(NULL);
 117   ClassFileStream* open_stream(const char* name, TRAPS);
 118   void contents_do(void f(const char* name, void* context), void* context);
 119   bool is_multiple_versioned(TRAPS) NOT_CDS_RETURN_(false);
 120   // Debugging
 121   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
 122 };
 123 
 124 
 125 // For java image files
 126 class ClassPathImageEntry: public ClassPathEntry {
 127 private:
 128   JImageFile* _jimage;
 129   const char* _name;
 130 public:
 131   bool is_modules_image() const;
 132   bool is_jar_file() const { return false; }
 133   bool is_open() const { return _jimage != NULL; }
 134   const char* name() const { return _name == NULL ? "" : _name; }
 135   JImageFile* jimage() const { return _jimage; }
 136   ClassPathImageEntry(JImageFile* jimage, const char* name);
 137   virtual ~ClassPathImageEntry();
 138   ClassFileStream* open_stream(const char* name, TRAPS);
 139 
 140   // Debugging
 141   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
 142 };
 143 
 144 // ModuleClassPathList contains a linked list of ClassPathEntry's
 145 // that have been specified for a specific module.  Currently,
 146 // the only way to specify a module/path pair is via the --patch-module
 147 // command line option.
 148 class ModuleClassPathList : public CHeapObj<mtClass> {
 149 private:
 150   Symbol* _module_name;
 151   // First and last entries of class path entries for a specific module
 152   ClassPathEntry* _module_first_entry;
 153   ClassPathEntry* _module_last_entry;
 154 public:
 155   Symbol* module_name() const { return _module_name; }
 156   ClassPathEntry* module_first_entry() const { return _module_first_entry; }
 157   ModuleClassPathList(Symbol* module_name);
 158   ~ModuleClassPathList();
 159   void add_to_list(ClassPathEntry* new_entry);
 160 };
 161 
 162 class SharedPathsMiscInfo;
 163 
 164 class ClassLoader: AllStatic {
 165  public:
 166   enum ClassLoaderType {
 167     BOOT_LOADER = 1,      /* boot loader */
 168     PLATFORM_LOADER  = 2, /* PlatformClassLoader */
 169     APP_LOADER  = 3       /* AppClassLoader */
 170   };
 171  protected:
 172 
 173   // Performance counters
 174   static PerfCounter* _perf_accumulated_time;
 175   static PerfCounter* _perf_classes_inited;
 176   static PerfCounter* _perf_class_init_time;
 177   static PerfCounter* _perf_class_init_selftime;
 178   static PerfCounter* _perf_classes_verified;
 179   static PerfCounter* _perf_class_verify_time;
 180   static PerfCounter* _perf_class_verify_selftime;
 181   static PerfCounter* _perf_classes_linked;
 182   static PerfCounter* _perf_class_link_time;
 183   static PerfCounter* _perf_class_link_selftime;
 184   static PerfCounter* _perf_class_parse_time;
 185   static PerfCounter* _perf_class_parse_selftime;
 186   static PerfCounter* _perf_sys_class_lookup_time;
 187   static PerfCounter* _perf_shared_classload_time;
 188   static PerfCounter* _perf_sys_classload_time;
 189   static PerfCounter* _perf_app_classload_time;
 190   static PerfCounter* _perf_app_classload_selftime;
 191   static PerfCounter* _perf_app_classload_count;
 192   static PerfCounter* _perf_define_appclasses;
 193   static PerfCounter* _perf_define_appclass_time;
 194   static PerfCounter* _perf_define_appclass_selftime;
 195   static PerfCounter* _perf_app_classfile_bytes_read;
 196   static PerfCounter* _perf_sys_classfile_bytes_read;
 197 
 198   static PerfCounter* _sync_systemLoaderLockContentionRate;
 199   static PerfCounter* _sync_nonSystemLoaderLockContentionRate;
 200   static PerfCounter* _sync_JVMFindLoadedClassLockFreeCounter;
 201   static PerfCounter* _sync_JVMDefineClassLockFreeCounter;
 202   static PerfCounter* _sync_JNIDefineClassLockFreeCounter;
 203 
 204   static PerfCounter* _unsafe_defineClassCallCounter;
 205   static PerfCounter* _load_instance_class_failCounter;
 206 
 207   // The boot class path consists of 3 ordered pieces:
 208   //  1. the module/path pairs specified to --patch-module
 209   //    --patch-module=<module>=<file>(<pathsep><file>)*
 210   //  2. the base piece
 211   //    [jimage | build with exploded modules]
 212   //  3. boot loader append path
 213   //    [-Xbootclasspath/a]; [jvmti appended entries]
 214   //
 215   // The boot loader must obey this order when attempting
 216   // to load a class.
 217 
 218   // 1. Contains the module/path pairs specified to --patch-module
 219   static GrowableArray<ModuleClassPathList*>* _patch_mod_entries;
 220 
 221   // 2. the base piece
 222   //    Contains the ClassPathEntry of the modular java runtime image.
 223   //    If no java runtime image is present, this indicates a
 224   //    build with exploded modules is being used instead.
 225   static ClassPathEntry* _jrt_entry;
 226   static GrowableArray<ModuleClassPathList*>* _exploded_entries;
 227   enum { EXPLODED_ENTRY_SIZE = 80 }; // Initial number of exploded modules
 228 
 229   // 3. the boot loader's append path
 230   //    [-Xbootclasspath/a]; [jvmti appended entries]
 231   //    Note: boot loader append path does not support named modules.
 232   static ClassPathEntry* _first_append_entry;
 233   // Last entry in linked list of appended ClassPathEntry instances
 234   static ClassPathEntry* _last_append_entry;
 235 
 236   // Info used by CDS
 237   CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;)
 238 
 239   CDS_ONLY(static ClassPathEntry* _app_classpath_entries;)
 240   CDS_ONLY(static ClassPathEntry* _last_app_classpath_entry;)
 241   CDS_ONLY(static ClassPathEntry* _module_path_entries;)
 242   CDS_ONLY(static ClassPathEntry* _last_module_path_entry;)
 243   CDS_ONLY(static void setup_app_search_path(const char* class_path);)
 244   CDS_ONLY(static void setup_module_search_path(const char* path, TRAPS);)
 245   static void add_to_app_classpath_entries(const char* path,
 246                                            ClassPathEntry* entry,
 247                                            bool check_for_duplicates);
 248   CDS_ONLY(static void add_to_module_path_entries(const char* path,
 249                                            ClassPathEntry* entry);)
 250  public:
 251   CDS_ONLY(static ClassPathEntry* app_classpath_entries() {return _app_classpath_entries;})
 252   CDS_ONLY(static ClassPathEntry* module_path_entries() {return _module_path_entries;})
 253 
 254  protected:
 255   // Initialization:
 256   //   - setup the boot loader's system class path
 257   //   - setup the boot loader's patch mod entries, if present
 258   //   - create the ModuleEntry for java.base
 259   static void setup_bootstrap_search_path();
 260   static void setup_boot_search_path(const char *class_path);
 261   static void setup_patch_mod_entries();
 262   static void create_javabase();
 263 
 264   static void load_zip_library();
 265   static void load_jimage_library();
 266   static ClassPathEntry* create_class_path_entry(const char *path, const struct stat* st,
 267                                                  bool throw_exception,
 268                                                  bool is_boot_append, TRAPS);
 269 
 270  public:
 271 
 272   // If the package for the fully qualified class name is in the boot
 273   // loader's package entry table then add_package() sets the classpath_index
 274   // field so that get_system_package() will know to return a non-null value
 275   // for the package's location.  And, so that the package will be added to
 276   // the list of packages returned by get_system_packages().
 277   // For packages whose classes are loaded from the boot loader class path, the
 278   // classpath_index indicates which entry on the boot loader class path.
 279   static bool add_package(const char *fullq_class_name, s2 classpath_index, TRAPS);
 280 
 281   // Canonicalizes path names, so strcmp will work properly. This is mainly
 282   // to avoid confusing the zip library
 283   static bool get_canonical_path(const char* orig, char* out, int len);
 284   static const char* file_name_for_class_name(const char* class_name,
 285                                               int class_name_len);
 286   static PackageEntry* get_package_entry(const char* class_name, ClassLoaderData* loader_data, TRAPS);
 287 
 288  public:
 289   static jboolean decompress(void *in, u8 inSize, void *out, u8 outSize, char **pmsg);
 290   static int crc32(int crc, const char* buf, int len);
 291   static bool update_class_path_entry_list(const char *path,
 292                                            bool check_for_duplicates,
 293                                            bool is_boot_append,
 294                                            bool throw_exception=true);
 295   CDS_ONLY(static void update_module_path_entry_list(const char *path, TRAPS);)
 296   static void print_bootclasspath();
 297 
 298   // Timing
 299   static PerfCounter* perf_accumulated_time()         { return _perf_accumulated_time; }
 300   static PerfCounter* perf_classes_inited()           { return _perf_classes_inited; }
 301   static PerfCounter* perf_class_init_time()          { return _perf_class_init_time; }
 302   static PerfCounter* perf_class_init_selftime()      { return _perf_class_init_selftime; }
 303   static PerfCounter* perf_classes_verified()         { return _perf_classes_verified; }
 304   static PerfCounter* perf_class_verify_time()        { return _perf_class_verify_time; }
 305   static PerfCounter* perf_class_verify_selftime()    { return _perf_class_verify_selftime; }
 306   static PerfCounter* perf_classes_linked()           { return _perf_classes_linked; }
 307   static PerfCounter* perf_class_link_time()          { return _perf_class_link_time; }
 308   static PerfCounter* perf_class_link_selftime()      { return _perf_class_link_selftime; }
 309   static PerfCounter* perf_class_parse_time()         { return _perf_class_parse_time; }
 310   static PerfCounter* perf_class_parse_selftime()     { return _perf_class_parse_selftime; }
 311   static PerfCounter* perf_sys_class_lookup_time()    { return _perf_sys_class_lookup_time; }
 312   static PerfCounter* perf_shared_classload_time()    { return _perf_shared_classload_time; }
 313   static PerfCounter* perf_sys_classload_time()       { return _perf_sys_classload_time; }
 314   static PerfCounter* perf_app_classload_time()       { return _perf_app_classload_time; }
 315   static PerfCounter* perf_app_classload_selftime()   { return _perf_app_classload_selftime; }
 316   static PerfCounter* perf_app_classload_count()      { return _perf_app_classload_count; }
 317   static PerfCounter* perf_define_appclasses()        { return _perf_define_appclasses; }
 318   static PerfCounter* perf_define_appclass_time()     { return _perf_define_appclass_time; }
 319   static PerfCounter* perf_define_appclass_selftime() { return _perf_define_appclass_selftime; }
 320   static PerfCounter* perf_app_classfile_bytes_read() { return _perf_app_classfile_bytes_read; }
 321   static PerfCounter* perf_sys_classfile_bytes_read() { return _perf_sys_classfile_bytes_read; }
 322 
 323   // Record how often system loader lock object is contended
 324   static PerfCounter* sync_systemLoaderLockContentionRate() {
 325     return _sync_systemLoaderLockContentionRate;
 326   }
 327 
 328   // Record how often non system loader lock object is contended
 329   static PerfCounter* sync_nonSystemLoaderLockContentionRate() {
 330     return _sync_nonSystemLoaderLockContentionRate;
 331   }
 332 
 333   // Record how many calls to JVM_FindLoadedClass w/o holding a lock
 334   static PerfCounter* sync_JVMFindLoadedClassLockFreeCounter() {
 335     return _sync_JVMFindLoadedClassLockFreeCounter;
 336   }
 337 
 338   // Record how many calls to JVM_DefineClass w/o holding a lock
 339   static PerfCounter* sync_JVMDefineClassLockFreeCounter() {
 340     return _sync_JVMDefineClassLockFreeCounter;
 341   }
 342 
 343   // Record how many calls to jni_DefineClass w/o holding a lock
 344   static PerfCounter* sync_JNIDefineClassLockFreeCounter() {
 345     return _sync_JNIDefineClassLockFreeCounter;
 346   }
 347 
 348   // Record how many calls to Unsafe_DefineClass
 349   static PerfCounter* unsafe_defineClassCallCounter() {
 350     return _unsafe_defineClassCallCounter;
 351   }
 352 
 353   // Record how many times SystemDictionary::load_instance_class call
 354   // fails with linkageError when Unsyncloadclass flag is set.
 355   static PerfCounter* load_instance_class_failCounter() {
 356     return _load_instance_class_failCounter;
 357   }
 358 
 359   // Modular java runtime image is present vs. a build with exploded modules
 360   static bool has_jrt_entry() { return (_jrt_entry != NULL); }
 361   static ClassPathEntry* get_jrt_entry() { return _jrt_entry; }
 362 
 363   // Add a module's exploded directory to the boot loader's exploded module build list
 364   static void add_to_exploded_build_list(Symbol* module_name, TRAPS);
 365 
 366   // Attempt load of individual class from either the patched or exploded modules build lists
 367   static ClassFileStream* search_module_entries(const GrowableArray<ModuleClassPathList*>* const module_list,
 368                                                 const char* const class_name,
 369                                                 const char* const file_name, TRAPS);
 370 
 371   // Load individual .class file
 372   static InstanceKlass* load_class(Symbol* class_name, bool search_append_only, TRAPS);
 373 
 374   // If the specified package has been loaded by the system, then returns
 375   // the name of the directory or ZIP file that the package was loaded from.
 376   // Returns null if the package was not loaded.
 377   // Note: The specified name can either be the name of a class or package.
 378   // If a package name is specified, then it must be "/"-separator and also
 379   // end with a trailing "/".
 380   static oop get_system_package(const char* name, TRAPS);
 381 
 382   // Returns an array of Java strings representing all of the currently
 383   // loaded system packages.
 384   // Note: The package names returned are "/"-separated and end with a
 385   // trailing "/".
 386   static objArrayOop get_system_packages(TRAPS);
 387 
 388   // Initialization
 389   static void initialize();
 390   static void classLoader_init2(TRAPS);
 391   CDS_ONLY(static void initialize_shared_path();)
 392   CDS_ONLY(static void initialize_module_path(TRAPS);)
 393 
 394   static int compute_Object_vtable();
 395 
 396   static ClassPathEntry* classpath_entry(int n);
 397 
 398   static bool is_in_patch_mod_entries(Symbol* module_name);
 399 
 400 #if INCLUDE_CDS
 401   // Sharing dump and restore
 402 
 403   // Helper function used by CDS code to get the number of boot classpath
 404   // entries during shared classpath setup time.
 405   static int num_boot_classpath_entries();
 406 
 407   static ClassPathEntry* get_next_boot_classpath_entry(ClassPathEntry* e);
 408 
 409   // Helper function used by CDS code to get the number of app classpath
 410   // entries during shared classpath setup time.
 411   static int num_app_classpath_entries();
 412 
 413   // Helper function used by CDS code to get the number of module path
 414   // entries during shared classpath setup time.
 415   static int num_module_path_entries() {
 416     assert(DumpSharedSpaces, "Should only be called at CDS dump time");
 417     int num_entries = 0;
 418     ClassPathEntry* e= ClassLoader::_module_path_entries;
 419     while (e != NULL) {
 420       num_entries ++;
 421       e = e->next();
 422     }
 423     return num_entries;
 424   }
 425   static void  finalize_shared_paths_misc_info();
 426   static int   get_shared_paths_misc_info_size();
 427   static void* get_shared_paths_misc_info();
 428   static bool  check_shared_paths_misc_info(void* info, int size);
 429   static int   get_module_paths_misc_info_size();
 430   static void* get_module_paths_misc_info();
 431   static void  exit_with_path_failure(const char* error, const char* message);
 432   static char* skip_uri_protocol(char* source);
 433   static void  record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS);
 434 #endif
 435   static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name,
 436                                                 const char* file_name, jlong &size);
 437 
 438   static void  trace_class_path(const char* msg, const char* name = NULL);
 439 
 440   // VM monitoring and management support
 441   static jlong classloader_time_ms();
 442   static jlong class_method_total_size();
 443   static jlong class_init_count();
 444   static jlong class_init_time_ms();
 445   static jlong class_verify_time_ms();
 446   static jlong class_link_count();
 447   static jlong class_link_time_ms();
 448 
 449   // indicates if class path already contains a entry (exact match by name)
 450   static bool contains_append_entry(const char* name);
 451 
 452   // adds a class path to the boot append entries
 453   static void add_to_boot_append_entries(ClassPathEntry* new_entry);
 454 
 455   // creates a class path zip entry (returns NULL if JAR file cannot be opened)
 456   static ClassPathZipEntry* create_class_path_zip_entry(const char *apath, bool is_boot_append);
 457 
 458   static bool string_ends_with(const char* str, const char* str_to_find);
 459 
 460   // obtain package name from a fully qualified class name
 461   // *bad_class_name is set to true if there's a problem with parsing class_name, to
 462   // distinguish from a class_name with no package name, as both cases have a NULL return value
 463   static const char* package_from_name(const char* const class_name, bool* bad_class_name = NULL);
 464 
 465   static bool is_modules_image(const char* name) { return string_ends_with(name, MODULES_IMAGE_NAME); }
 466 
 467   // Debugging
 468   static void verify()              PRODUCT_RETURN;
 469 
 470   // Force compilation of all methods in all classes in bootstrap class path (stress test)
 471 #ifndef PRODUCT
 472  protected:
 473   static int _compile_the_world_class_counter;
 474   static int _compile_the_world_method_counter;
 475  public:
 476   static void compile_the_world();
 477   static void compile_the_world_in(char* name, Handle loader, TRAPS);
 478   static int  compile_the_world_counter() { return _compile_the_world_class_counter; }
 479 #endif //PRODUCT
 480 };
 481 
 482 // PerfClassTraceTime is used to measure time for class loading related events.
 483 // This class tracks cumulative time and exclusive time for specific event types.
 484 // During the execution of one event, other event types (e.g. class loading and
 485 // resolution) as well as recursive calls of the same event type could happen.
 486 // Only one elapsed timer (cumulative) and one thread-local self timer (exclusive)
 487 // (i.e. only one event type) are active at a time even multiple PerfClassTraceTime
 488 // instances have been created as multiple events are happening.
 489 class PerfClassTraceTime {
 490  public:
 491   enum {
 492     CLASS_LOAD   = 0,
 493     PARSE_CLASS  = 1,
 494     CLASS_LINK   = 2,
 495     CLASS_VERIFY = 3,
 496     CLASS_CLINIT = 4,
 497     DEFINE_CLASS = 5,
 498     EVENT_TYPE_COUNT = 6
 499   };
 500  protected:
 501   // _t tracks time from initialization to destruction of this timer instance
 502   // including time for all other event types, and recursive calls of this type.
 503   // When a timer is called recursively, the elapsedTimer _t would not be used.
 504   elapsedTimer     _t;
 505   PerfLongCounter* _timep;
 506   PerfLongCounter* _selftimep;
 507   PerfLongCounter* _eventp;
 508   // pointer to thread-local recursion counter and timer array
 509   // The thread_local timers track cumulative time for specific event types
 510   // exclusive of time for other event types, but including recursive calls
 511   // of the same type.
 512   int*             _recursion_counters;
 513   elapsedTimer*    _timers;
 514   int              _event_type;
 515   int              _prev_active_event;
 516 
 517  public:
 518 
 519   inline PerfClassTraceTime(PerfLongCounter* timep,     /* counter incremented with inclusive time */
 520                             PerfLongCounter* selftimep, /* counter incremented with exclusive time */
 521                             PerfLongCounter* eventp,    /* event counter */
 522                             int* recursion_counters,    /* thread-local recursion counter array */
 523                             elapsedTimer* timers,       /* thread-local timer array */
 524                             int type                    /* event type */ ) :
 525       _timep(timep), _selftimep(selftimep), _eventp(eventp), _recursion_counters(recursion_counters), _timers(timers), _event_type(type) {
 526     initialize();
 527   }
 528 
 529   inline PerfClassTraceTime(PerfLongCounter* timep,     /* counter incremented with inclusive time */
 530                             elapsedTimer* timers,       /* thread-local timer array */
 531                             int type                    /* event type */ ) :
 532       _timep(timep), _selftimep(NULL), _eventp(NULL), _recursion_counters(NULL), _timers(timers), _event_type(type) {
 533     initialize();
 534   }
 535 
 536   inline void suspend() { _t.stop(); _timers[_event_type].stop(); }
 537   inline void resume()  { _t.start(); _timers[_event_type].start(); }
 538 
 539   ~PerfClassTraceTime();
 540   void initialize();
 541 };
 542 
 543 #endif // SHARE_VM_CLASSFILE_CLASSLOADER_HPP