hotspot/src/share/vm/classfile/classLoader.hpp
author rasbold
Thu, 13 Mar 2008 05:40:44 -0700
changeset 219 ac2d788217ca
parent 1 489c9b5090e2
child 3575 224791e7ecab
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// The VM class loader.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include <sys/stat.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// Meta-index (optional, to be able to skip opening boot classpath jar files)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class MetaIndex: public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  char** _meta_package_names;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  int    _num_meta_package_names;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  MetaIndex(char** meta_package_names, int num_meta_package_names);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  ~MetaIndex();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  bool may_contain(const char* class_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// Class path entry (directory or zip file)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class ClassPathEntry: public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  ClassPathEntry* _next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // Next entry in class path
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  ClassPathEntry* next()              { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  void set_next(ClassPathEntry* next) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    // may have unlocked readers, so write atomically.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    OrderAccess::release_store_ptr(&_next, next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  virtual bool is_jar_file() = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  virtual const char* name() = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  virtual bool is_lazy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  ClassPathEntry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // Attempt to locate file_name through this class path entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Returns a class file parsing stream if successfull.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  virtual ClassFileStream* open_stream(const char* name) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  NOT_PRODUCT(virtual bool is_rt_jar() = 0;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
class ClassPathDirEntry: public ClassPathEntry {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  char* _dir;           // Name of directory
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  bool is_jar_file()  { return false;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  const char* name()  { return _dir; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  ClassPathDirEntry(char* dir);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  ClassFileStream* open_stream(const char* name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  NOT_PRODUCT(bool is_rt_jar();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// Type definitions for zip file and zip file entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
typedef void* jzfile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  char *name;                   /* entry name */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  jlong time;                   /* modification time */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  jlong size;                   /* size of uncompressed data */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  jlong csize;                  /* size of compressed data (zero if uncompressed) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  jint crc;                     /* crc of uncompressed data */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  char *comment;                /* optional zip file comment */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  jbyte *extra;                 /* optional extra data */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  jlong pos;                    /* position of LOC header (if negative) or data */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
} jzentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
class ClassPathZipEntry: public ClassPathEntry {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  jzfile* _zip;        // The zip archive
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  char*   _zip_name;   // Name of zip archive
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  bool is_jar_file()  { return true;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  const char* name()  { return _zip_name; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  ClassPathZipEntry(jzfile* zip, const char* zip_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  ~ClassPathZipEntry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  ClassFileStream* open_stream(const char* name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  void contents_do(void f(const char* name, void* context), void* context);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  NOT_PRODUCT(void compile_the_world12(Handle loader, TRAPS);) // JDK 1.2 version
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  NOT_PRODUCT(void compile_the_world13(Handle loader, TRAPS);) // JDK 1.3 version
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  NOT_PRODUCT(bool is_rt_jar();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  NOT_PRODUCT(bool is_rt_jar12();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  NOT_PRODUCT(bool is_rt_jar13();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
// For lazier loading of boot class path entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
class LazyClassPathEntry: public ClassPathEntry {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  char* _path; // dir or file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  struct stat _st;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  MetaIndex* _meta_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  volatile ClassPathEntry* _resolved_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  ClassPathEntry* resolve_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  bool is_jar_file();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  const char* name()  { return _path; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  LazyClassPathEntry(char* path, struct stat st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  ClassFileStream* open_stream(const char* name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  void set_meta_index(MetaIndex* meta_index) { _meta_index = meta_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  virtual bool is_lazy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  NOT_PRODUCT(bool is_rt_jar();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
class PackageHashtable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
class PackageInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
class HashtableBucket;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
class ClassLoader: AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  enum SomeConstants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    package_hash_table_size = 31  // Number of buckets
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  friend class LazyClassPathEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // Performance counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  static PerfCounter* _perf_accumulated_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  static PerfCounter* _perf_classes_inited;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  static PerfCounter* _perf_class_init_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  static PerfCounter* _perf_class_verify_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  static PerfCounter* _perf_classes_linked;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  static PerfCounter* _perf_class_link_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  static PerfCounter* _sync_systemLoaderLockContentionRate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  static PerfCounter* _sync_nonSystemLoaderLockContentionRate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  static PerfCounter* _sync_JVMFindLoadedClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  static PerfCounter* _sync_JVMDefineClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  static PerfCounter* _sync_JNIDefineClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  static PerfCounter* _unsafe_defineClassCallCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  static PerfCounter* _isUnsyncloadClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  static PerfCounter* _load_instance_class_failCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // First entry in linked list of ClassPathEntry instances
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  static ClassPathEntry* _first_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // Last entry in linked list of ClassPathEntry instances
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  static ClassPathEntry* _last_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  // Hash table used to keep track of loaded packages
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  static PackageHashtable* _package_hash_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  static const char* _shared_archive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  // Hash function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  static unsigned int hash(const char *s, int n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // Returns the package file name corresponding to the specified package
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // or class name, or null if not found.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  static PackageInfo* lookup_package(const char *pkgname);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // Adds a new package entry for the specified class or package name and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // corresponding directory or jar file name.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  static bool add_package(const char *pkgname, int classpath_index, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // Initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  static void setup_meta_index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  static void setup_bootstrap_search_path();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  static void load_zip_library();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  static void create_class_path_entry(char *path, struct stat st, ClassPathEntry **new_entry, bool lazy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // Canonicalizes path names, so strcmp will work properly. This is mainly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // to avoid confusing the zip library
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  static bool get_canonical_path(char* orig, char* out, int len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Used by the kernel jvm.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  static void update_class_path_entry_list(const char *path,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
                                           bool check_for_duplicates);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  static void print_bootclasspath();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // Timing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  static PerfCounter* perf_accumulated_time()  { return _perf_accumulated_time; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  static PerfCounter* perf_classes_inited()    { return _perf_classes_inited; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  static PerfCounter* perf_class_init_time()   { return _perf_class_init_time; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  static PerfCounter* perf_class_verify_time() { return _perf_class_verify_time; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  static PerfCounter* perf_classes_linked()    { return _perf_classes_linked; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  static PerfCounter* perf_class_link_time() { return _perf_class_link_time; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  // Record how often system loader lock object is contended
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  static PerfCounter* sync_systemLoaderLockContentionRate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    return _sync_systemLoaderLockContentionRate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  // Record how often non system loader lock object is contended
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  static PerfCounter* sync_nonSystemLoaderLockContentionRate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    return _sync_nonSystemLoaderLockContentionRate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  // Record how many calls to JVM_FindLoadedClass w/o holding a lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  static PerfCounter* sync_JVMFindLoadedClassLockFreeCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    return _sync_JVMFindLoadedClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // Record how many calls to JVM_DefineClass w/o holding a lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  static PerfCounter* sync_JVMDefineClassLockFreeCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    return _sync_JVMDefineClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  // Record how many calls to jni_DefineClass w/o holding a lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  static PerfCounter* sync_JNIDefineClassLockFreeCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    return _sync_JNIDefineClassLockFreeCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  // Record how many calls to Unsafe_DefineClass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  static PerfCounter* unsafe_defineClassCallCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    return _unsafe_defineClassCallCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  // Record how many times SystemDictionary::load_instance_class call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // fails with linkageError when Unsyncloadclass flag is set.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  static PerfCounter* load_instance_class_failCounter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    return _load_instance_class_failCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // Load individual .class file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  static instanceKlassHandle load_classfile(symbolHandle h_name, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // If the specified package has been loaded by the system, then returns
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // the name of the directory or ZIP file that the package was loaded from.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  // Returns null if the package was not loaded.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  // Note: The specified name can either be the name of a class or package.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  // If a package name is specified, then it must be "/"-separator and also
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  // end with a trailing "/".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  static oop get_system_package(const char* name, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  // Returns an array of Java strings representing all of the currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  // loaded system packages.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  // Note: The package names returned are "/"-separated and end with a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // trailing "/".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  static objArrayOop get_system_packages(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  // Initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  static void create_package_info_table();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  static void create_package_info_table(HashtableBucket *t, int length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
                                        int number_of_entries);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  static int compute_Object_vtable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  static ClassPathEntry* classpath_entry(int n) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    ClassPathEntry* e = ClassLoader::_first_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    while (--n >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
      assert(e != NULL, "Not that many classpath entries.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
      e = e->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    return e;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // Sharing dump and restore
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  static void copy_package_info_buckets(char** top, char* end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  static void copy_package_info_table(char** top, char* end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  // VM monitoring and management support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  static jlong classloader_time_ms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  static jlong class_method_total_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  static jlong class_init_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  static jlong class_init_time_ms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  static jlong class_verify_time_ms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  static jlong class_link_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  static jlong class_link_time_ms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // indicates if class path already contains a entry (exact match by name)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  static bool contains_entry(ClassPathEntry* entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  // adds a class path list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  static void add_to_list(ClassPathEntry* new_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // creates a class path zip entry (returns NULL if JAR file cannot be opened)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  static ClassPathZipEntry* create_class_path_zip_entry(const char *apath);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  static void verify()              PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  // Force compilation of all methods in all classes in bootstrap class path (stress test)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  static int _compile_the_world_counter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  static void compile_the_world();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  static void compile_the_world_in(char* name, Handle loader, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  static int  compile_the_world_counter() { return _compile_the_world_counter; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
#endif //PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
};