hotspot/src/share/vm/classfile/classLoader.hpp
author ikrylov
Wed, 01 Dec 2010 18:26:32 -0500
changeset 7405 e6fc8d3926f8
parent 7397 5b173b4ca846
child 7910 135031ddb2bb
permissions -rw-r--r--
6348631: remove the use of the HPI library from Hotspot Summary: move functions from hpi library to hotspot, communicate with licensees and open source community, check jdk for dependency, file CCC request Reviewed-by: coleenp, acorn, dsamersoff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3795
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3795
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3795
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_CLASSLOADER_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CLASSFILE_CLASSLOADER_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "classfile/classFileParser.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/perfData.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// The VM class loader.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
#include <sys/stat.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// Meta-index (optional, to be able to skip opening boot classpath jar files)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class MetaIndex: public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  char** _meta_package_names;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  int    _num_meta_package_names;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  MetaIndex(char** meta_package_names, int num_meta_package_names);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  ~MetaIndex();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  bool may_contain(const char* class_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// Class path entry (directory or zip file)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class ClassPathEntry: public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  ClassPathEntry* _next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // Next entry in class path
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  ClassPathEntry* next()              { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  void set_next(ClassPathEntry* next) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    // may have unlocked readers, so write atomically.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    OrderAccess::release_store_ptr(&_next, next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  virtual bool is_jar_file() = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  virtual const char* name() = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  virtual bool is_lazy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  ClassPathEntry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // Attempt to locate file_name through this class path entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // Returns a class file parsing stream if successfull.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  virtual ClassFileStream* open_stream(const char* name) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  NOT_PRODUCT(virtual bool is_rt_jar() = 0;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
class ClassPathDirEntry: public ClassPathEntry {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  char* _dir;           // Name of directory
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  bool is_jar_file()  { return false;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  const char* name()  { return _dir; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  ClassPathDirEntry(char* dir);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  ClassFileStream* open_stream(const char* name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  NOT_PRODUCT(bool is_rt_jar();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
// Type definitions for zip file and zip file entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
typedef void* jzfile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  char *name;                   /* entry name */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  jlong time;                   /* modification time */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  jlong size;                   /* size of uncompressed data */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  jlong csize;                  /* size of compressed data (zero if uncompressed) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  jint crc;                     /* crc of uncompressed data */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  char *comment;                /* optional zip file comment */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  jbyte *extra;                 /* optional extra data */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  jlong pos;                    /* position of LOC header (if negative) or data */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
} jzentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
class ClassPathZipEntry: public ClassPathEntry {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  jzfile* _zip;        // The zip archive
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  char*   _zip_name;   // Name of zip archive
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  bool is_jar_file()  { return true;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  const char* name()  { return _zip_name; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  ClassPathZipEntry(jzfile* zip, const char* zip_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  ~ClassPathZipEntry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  ClassFileStream* open_stream(const char* name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  void contents_do(void f(const char* name, void* context), void* context);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  NOT_PRODUCT(void compile_the_world12(Handle loader, TRAPS);) // JDK 1.2 version
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  NOT_PRODUCT(void compile_the_world13(Handle loader, TRAPS);) // JDK 1.3 version
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  NOT_PRODUCT(bool is_rt_jar();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  NOT_PRODUCT(bool is_rt_jar12();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  NOT_PRODUCT(bool is_rt_jar13();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
// For lazier loading of boot class path entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
class LazyClassPathEntry: public ClassPathEntry {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  char* _path; // dir or file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  struct stat _st;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  MetaIndex* _meta_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  volatile ClassPathEntry* _resolved_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  ClassPathEntry* resolve_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  bool is_jar_file();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  const char* name()  { return _path; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  LazyClassPathEntry(char* path, struct stat st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  ClassFileStream* open_stream(const char* name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  void set_meta_index(MetaIndex* meta_index) { _meta_index = meta_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  virtual bool is_lazy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  NOT_PRODUCT(bool is_rt_jar();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
class PackageHashtable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
class PackageInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
class HashtableBucket;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
class ClassLoader: AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  enum SomeConstants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    package_hash_table_size = 31  // Number of buckets
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  friend class LazyClassPathEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // Performance counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  static PerfCounter* _perf_accumulated_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  static PerfCounter* _perf_classes_inited;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  static PerfCounter* _perf_class_init_time;
3575
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   158
  static PerfCounter* _perf_class_init_selftime;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   159
  static PerfCounter* _perf_classes_verified;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  static PerfCounter* _perf_class_verify_time;
3575
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   161
  static PerfCounter* _perf_class_verify_selftime;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  static PerfCounter* _perf_classes_linked;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  static PerfCounter* _perf_class_link_time;
3575
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   164
  static PerfCounter* _perf_class_link_selftime;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   165
  static PerfCounter* _perf_class_parse_time;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   166
  static PerfCounter* _perf_class_parse_selftime;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   167
  static PerfCounter* _perf_sys_class_lookup_time;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   168
  static PerfCounter* _perf_shared_classload_time;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   169
  static PerfCounter* _perf_sys_classload_time;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   170
  static PerfCounter* _perf_app_classload_time;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   171
  static PerfCounter* _perf_app_classload_selftime;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   172
  static PerfCounter* _perf_app_classload_count;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   173
  static PerfCounter* _perf_define_appclasses;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   174
  static PerfCounter* _perf_define_appclass_time;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   175
  static PerfCounter* _perf_define_appclass_selftime;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   176
  static PerfCounter* _perf_app_classfile_bytes_read;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   177
  static PerfCounter* _perf_sys_classfile_bytes_read;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  static PerfCounter* _sync_systemLoaderLockContentionRate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  static PerfCounter* _sync_nonSystemLoaderLockContentionRate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  static PerfCounter* _sync_JVMFindLoadedClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  static PerfCounter* _sync_JVMDefineClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  static PerfCounter* _sync_JNIDefineClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  static PerfCounter* _unsafe_defineClassCallCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  static PerfCounter* _isUnsyncloadClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  static PerfCounter* _load_instance_class_failCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // First entry in linked list of ClassPathEntry instances
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  static ClassPathEntry* _first_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // Last entry in linked list of ClassPathEntry instances
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  static ClassPathEntry* _last_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Hash table used to keep track of loaded packages
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  static PackageHashtable* _package_hash_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  static const char* _shared_archive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  // Hash function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  static unsigned int hash(const char *s, int n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // Returns the package file name corresponding to the specified package
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  // or class name, or null if not found.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  static PackageInfo* lookup_package(const char *pkgname);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  // Adds a new package entry for the specified class or package name and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  // corresponding directory or jar file name.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  static bool add_package(const char *pkgname, int classpath_index, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  // Initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  static void setup_meta_index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  static void setup_bootstrap_search_path();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  static void load_zip_library();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  static void create_class_path_entry(char *path, struct stat st, ClassPathEntry **new_entry, bool lazy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // Canonicalizes path names, so strcmp will work properly. This is mainly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // to avoid confusing the zip library
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  static bool get_canonical_path(char* orig, char* out, int len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  // Used by the kernel jvm.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  static void update_class_path_entry_list(const char *path,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
                                           bool check_for_duplicates);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  static void print_bootclasspath();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // Timing
3575
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   222
  static PerfCounter* perf_accumulated_time()         { return _perf_accumulated_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   223
  static PerfCounter* perf_classes_inited()           { return _perf_classes_inited; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   224
  static PerfCounter* perf_class_init_time()          { return _perf_class_init_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   225
  static PerfCounter* perf_class_init_selftime()      { return _perf_class_init_selftime; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   226
  static PerfCounter* perf_classes_verified()         { return _perf_classes_verified; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   227
  static PerfCounter* perf_class_verify_time()        { return _perf_class_verify_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   228
  static PerfCounter* perf_class_verify_selftime()    { return _perf_class_verify_selftime; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   229
  static PerfCounter* perf_classes_linked()           { return _perf_classes_linked; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   230
  static PerfCounter* perf_class_link_time()          { return _perf_class_link_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   231
  static PerfCounter* perf_class_link_selftime()      { return _perf_class_link_selftime; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   232
  static PerfCounter* perf_class_parse_time()         { return _perf_class_parse_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   233
  static PerfCounter* perf_class_parse_selftime()     { return _perf_class_parse_selftime; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   234
  static PerfCounter* perf_sys_class_lookup_time()    { return _perf_sys_class_lookup_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   235
  static PerfCounter* perf_shared_classload_time()    { return _perf_shared_classload_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   236
  static PerfCounter* perf_sys_classload_time()       { return _perf_sys_classload_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   237
  static PerfCounter* perf_app_classload_time()       { return _perf_app_classload_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   238
  static PerfCounter* perf_app_classload_selftime()   { return _perf_app_classload_selftime; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   239
  static PerfCounter* perf_app_classload_count()      { return _perf_app_classload_count; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   240
  static PerfCounter* perf_define_appclasses()        { return _perf_define_appclasses; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   241
  static PerfCounter* perf_define_appclass_time()     { return _perf_define_appclass_time; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   242
  static PerfCounter* perf_define_appclass_selftime() { return _perf_define_appclass_selftime; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   243
  static PerfCounter* perf_app_classfile_bytes_read() { return _perf_app_classfile_bytes_read; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   244
  static PerfCounter* perf_sys_classfile_bytes_read() { return _perf_sys_classfile_bytes_read; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // Record how often system loader lock object is contended
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  static PerfCounter* sync_systemLoaderLockContentionRate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    return _sync_systemLoaderLockContentionRate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // Record how often non system loader lock object is contended
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  static PerfCounter* sync_nonSystemLoaderLockContentionRate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    return _sync_nonSystemLoaderLockContentionRate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // Record how many calls to JVM_FindLoadedClass w/o holding a lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  static PerfCounter* sync_JVMFindLoadedClassLockFreeCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    return _sync_JVMFindLoadedClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // Record how many calls to JVM_DefineClass w/o holding a lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  static PerfCounter* sync_JVMDefineClassLockFreeCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    return _sync_JVMDefineClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  // Record how many calls to jni_DefineClass w/o holding a lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  static PerfCounter* sync_JNIDefineClassLockFreeCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    return _sync_JNIDefineClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  // Record how many calls to Unsafe_DefineClass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  static PerfCounter* unsafe_defineClassCallCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    return _unsafe_defineClassCallCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // Record how many times SystemDictionary::load_instance_class call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  // fails with linkageError when Unsyncloadclass flag is set.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  static PerfCounter* load_instance_class_failCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    return _load_instance_class_failCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // Load individual .class file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  static instanceKlassHandle load_classfile(symbolHandle h_name, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  // If the specified package has been loaded by the system, then returns
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  // the name of the directory or ZIP file that the package was loaded from.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // Returns null if the package was not loaded.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // Note: The specified name can either be the name of a class or package.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // If a package name is specified, then it must be "/"-separator and also
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // end with a trailing "/".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  static oop get_system_package(const char* name, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  // Returns an array of Java strings representing all of the currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // loaded system packages.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // Note: The package names returned are "/"-separated and end with a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // trailing "/".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  static objArrayOop get_system_packages(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // Initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  static void create_package_info_table();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  static void create_package_info_table(HashtableBucket *t, int length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
                                        int number_of_entries);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  static int compute_Object_vtable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  static ClassPathEntry* classpath_entry(int n) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    ClassPathEntry* e = ClassLoader::_first_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    while (--n >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
      assert(e != NULL, "Not that many classpath entries.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      e = e->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    return e;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  // Sharing dump and restore
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  static void copy_package_info_buckets(char** top, char* end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  static void copy_package_info_table(char** top, char* end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  // VM monitoring and management support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  static jlong classloader_time_ms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  static jlong class_method_total_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  static jlong class_init_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  static jlong class_init_time_ms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  static jlong class_verify_time_ms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  static jlong class_link_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  static jlong class_link_time_ms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  // indicates if class path already contains a entry (exact match by name)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  static bool contains_entry(ClassPathEntry* entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  // adds a class path list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  static void add_to_list(ClassPathEntry* new_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // creates a class path zip entry (returns NULL if JAR file cannot be opened)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  static ClassPathZipEntry* create_class_path_zip_entry(const char *apath);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  static void verify()              PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  // Force compilation of all methods in all classes in bootstrap class path (stress test)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  static int _compile_the_world_counter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  static void compile_the_world();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  static void compile_the_world_in(char* name, Handle loader, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  static int  compile_the_world_counter() { return _compile_the_world_counter; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
#endif //PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
};
3575
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   350
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   351
// PerfClassTraceTime is used to measure time for class loading related events.
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   352
// This class tracks cumulative time and exclusive time for specific event types.
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   353
// During the execution of one event, other event types (e.g. class loading and
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   354
// resolution) as well as recursive calls of the same event type could happen.
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   355
// Only one elapsed timer (cumulative) and one thread-local self timer (exclusive)
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   356
// (i.e. only one event type) are active at a time even multiple PerfClassTraceTime
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   357
// instances have been created as multiple events are happening.
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   358
class PerfClassTraceTime {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   359
  public:
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   360
    enum {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   361
       CLASS_LOAD   = 0,
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   362
       PARSE_CLASS  = 1,
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   363
       CLASS_LINK   = 2,
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   364
       CLASS_VERIFY = 3,
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   365
       CLASS_CLINIT = 4,
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   366
       DEFINE_CLASS = 5,
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   367
       EVENT_TYPE_COUNT = 6
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   368
    };
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   369
  protected:
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   370
    // _t tracks time from initialization to destruction of this timer instance
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   371
    // including time for all other event types, and recursive calls of this type.
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   372
    // When a timer is called recursively, the elapsedTimer _t would not be used.
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   373
    elapsedTimer     _t;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   374
    PerfLongCounter* _timep;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   375
    PerfLongCounter* _selftimep;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   376
    PerfLongCounter* _eventp;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   377
    // pointer to thread-local recursion counter and timer array
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   378
    // The thread_local timers track cumulative time for specific event types
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   379
    // exclusive of time for other event types, but including recursive calls
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   380
    // of the same type.
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   381
    int*             _recursion_counters;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   382
    elapsedTimer*    _timers;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   383
    int              _event_type;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   384
    int              _prev_active_event;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   385
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   386
  public:
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   387
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   388
    inline PerfClassTraceTime(PerfLongCounter* timep,     /* counter incremented with inclusive time */
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   389
                              PerfLongCounter* selftimep, /* counter incremented with exclusive time */
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   390
                              PerfLongCounter* eventp,    /* event counter */
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   391
                              int* recursion_counters,    /* thread-local recursion counter array */
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   392
                              elapsedTimer* timers,       /* thread-local timer array */
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   393
                              int type                    /* event type */ ) :
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   394
        _timep(timep), _selftimep(selftimep), _eventp(eventp), _recursion_counters(recursion_counters), _timers(timers), _event_type(type) {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   395
      initialize();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   396
    }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   397
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   398
    inline PerfClassTraceTime(PerfLongCounter* timep,     /* counter incremented with inclusive time */
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   399
                              elapsedTimer* timers,       /* thread-local timer array */
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   400
                              int type                    /* event type */ ) :
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   401
        _timep(timep), _selftimep(NULL), _eventp(NULL), _recursion_counters(NULL), _timers(timers), _event_type(type) {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   402
      initialize();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   403
    }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   404
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   405
    void initialize() {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   406
      if (!UsePerfData) return;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   407
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   408
      if (_eventp != NULL) {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   409
        // increment the event counter
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   410
        _eventp->inc();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   411
      }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   412
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   413
      // stop the current active thread-local timer to measure inclusive time
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   414
      _prev_active_event = -1;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   415
      for (int i=0; i < EVENT_TYPE_COUNT; i++) {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   416
         if (_timers[i].is_active()) {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   417
           assert(_prev_active_event == -1, "should have only one active timer");
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   418
           _prev_active_event = i;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   419
           _timers[i].stop();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   420
         }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   421
      }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   422
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   423
      if (_recursion_counters == NULL || (_recursion_counters[_event_type])++ == 0) {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   424
        // start the inclusive timer if not recursively called
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   425
        _t.start();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   426
      }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   427
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   428
      // start thread-local timer of the given event type
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   429
      if (!_timers[_event_type].is_active()) {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   430
        _timers[_event_type].start();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   431
      }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   432
    }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   433
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   434
    inline void suspend() { _t.stop(); _timers[_event_type].stop(); }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   435
    inline void resume()  { _t.start(); _timers[_event_type].start(); }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   436
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   437
    ~PerfClassTraceTime() {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   438
      if (!UsePerfData) return;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   439
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   440
      // stop the thread-local timer as the event completes
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   441
      // and resume the thread-local timer of the event next on the stack
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   442
      _timers[_event_type].stop();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   443
      jlong selftime = _timers[_event_type].ticks();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   444
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   445
      if (_prev_active_event >= 0) {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   446
        _timers[_prev_active_event].start();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   447
      }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   448
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   449
      if (_recursion_counters != NULL && --(_recursion_counters[_event_type]) > 0) return;
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   450
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   451
      // increment the counters only on the leaf call
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   452
      _t.stop();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   453
      _timep->inc(_t.ticks());
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   454
      if (_selftimep != NULL) {
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   455
        _selftimep->inc(selftime);
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   456
      }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   457
      // add all class loading related event selftime to the accumulated time counter
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   458
      ClassLoader::perf_accumulated_time()->inc(selftime);
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   459
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   460
      // reset the timer
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   461
      _timers[_event_type].reset();
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   462
    }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   463
};
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1
diff changeset
   464
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   465
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   466
#endif // SHARE_VM_CLASSFILE_CLASSLOADER_HPP