hotspot/src/share/vm/classfile/placeholders.hpp
author coleenp
Thu, 19 Jun 2014 11:16:10 -0400
changeset 25325 e3af4e02b0d5
parent 15188 3916ac601e04
child 33589 7cbd1b2c139b
permissions -rw-r--r--
8026977: NPG: Remove ConstantPool::lock Summary: Write klass and resolved_references constant pool fields lock free. Reviewed-by: jrose, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
15188
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
     2
 * Copyright (c) 2003, 2013, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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_PLACEHOLDERS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CLASSFILE_PLACEHOLDERS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
7408
c04a5c989f26 7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents: 7397
diff changeset
    28
#include "runtime/thread.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "utilities/hashtable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class PlaceholderEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// Placeholder objects. These represent classes currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// being loaded, as well as arrays of primitives.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    37
class PlaceholderTable : public TwoOopHashtable<Symbol*, mtClass> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  PlaceholderTable(int table_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    43
  PlaceholderEntry* new_entry(int hash, Symbol* name, ClassLoaderData* loader_data, bool havesupername, Symbol* supername);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
    44
  void free_entry(PlaceholderEntry* entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  PlaceholderEntry* bucket(int i) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    47
    return (PlaceholderEntry*)Hashtable<Symbol*, mtClass>::bucket(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  PlaceholderEntry** bucket_addr(int i) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    51
    return (PlaceholderEntry**)Hashtable<Symbol*, mtClass>::bucket_addr(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  void add_entry(int index, PlaceholderEntry* new_entry) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    55
    Hashtable<Symbol*, mtClass>::add_entry(index, (HashtableEntry<Symbol*, mtClass>*)new_entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
    58
  void add_entry(int index, unsigned int hash, Symbol* name,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    59
                ClassLoaderData* loader_data, bool havesupername, Symbol* supername);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
    61
  // This returns a Symbol* to match type for SystemDictionary
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
    62
  Symbol* find_entry(int index, unsigned int hash,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    63
                       Symbol* name, ClassLoaderData* loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  PlaceholderEntry* get_entry(int index, unsigned int hash,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    66
                       Symbol* name, ClassLoaderData* loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// caller to create a placeholder entry must enumerate an action
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// caller claims ownership of that action
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// For parallel classloading:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// multiple LOAD_INSTANCE threads can proceed in parallel
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// multiple LOAD_SUPER threads can proceed in parallel
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
// LOAD_SUPER needed to check for class circularity
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
// DEFINE_CLASS: ultimately define class must be single threaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
// on a class/classloader basis
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
// so the head of that queue owns the token
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// and the rest of the threads return the result the first thread gets
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 enum classloadAction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    LOAD_INSTANCE = 1,             // calling load_instance_class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    LOAD_SUPER = 2,                // loading superclass for this class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    DEFINE_CLASS = 3               // find_or_define class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
 };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // find_and_add returns probe pointer - old or new
15188
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
    85
  // If no entry exists, add a placeholder entry and push SeenThread for classloadAction
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // If entry exists, reuse entry and push SeenThread for classloadAction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  PlaceholderEntry* find_and_add(int index, unsigned int hash,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    88
                                 Symbol* name, ClassLoaderData* loader_data,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
    89
                                 classloadAction action, Symbol* supername,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
                                 Thread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  void remove_entry(int index, unsigned int hash,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    93
                    Symbol* name, ClassLoaderData* loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
15188
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
    95
  // find_and_remove first removes SeenThread for classloadAction
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
    96
  // If all queues are empty and definer is null, remove the PlacheholderEntry completely
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  void find_and_remove(int index, unsigned int hash,
15188
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
    98
                       Symbol* name, ClassLoaderData* loader_data,
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
    99
                       classloadAction action, Thread* thread);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // GC support.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   102
  void classes_do(KlassClosure* f);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // JVMTI support
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   105
  void entries_do(void f(Symbol*));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
// SeenThread objects represent list of threads that are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// currently performing a load action on a class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
// For class circularity, set before loading a superclass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
// For bootclasssearchpath, set before calling load_instance_class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
// Defining must be single threaded on a class/classloader basis
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
// For DEFINE_CLASS, the head of the queue owns the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// define token and the rest of the threads wait to return the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
// result the first thread gets.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   121
class SeenThread: public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
   Thread *_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
   SeenThread* _stnext;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
   SeenThread* _stprev;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
   SeenThread(Thread *thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
       _thread = thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
       _stnext = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
       _stprev = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
   Thread* thread()                const { return _thread;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
   void set_thread(Thread *thread) { _thread = thread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
   SeenThread* next()              const { return _stnext;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
   void set_next(SeenThread *seen) { _stnext = seen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
   void set_prev(SeenThread *seen) { _stprev = seen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  void printActionQ() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    SeenThread* seen = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    while (seen != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      seen->thread()->print_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      tty->print(", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
      seen = seen->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
// Placeholder objects represent classes currently being loaded.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
// All threads examining the placeholder table must hold the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
// SystemDictionary_lock, so we don't need special precautions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// on store ordering here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
// The system dictionary is the only user of this class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   157
class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
 private:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   162
  ClassLoaderData*  _loader_data;   // initiating loader
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  bool              _havesupername; // distinguish between null supername, and unknown
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
   164
  Symbol*           _supername;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  Thread*           _definer;       // owner of define token
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   166
  Klass*            _instanceKlass; // InstanceKlass from successful define
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  SeenThread*       _superThreadQ;  // doubly-linked queue of Threads loading a superclass for this class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  SeenThread*       _loadInstanceThreadQ;  // loadInstance thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
                                    // can be multiple threads if classloader object lock broken by application
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
                                    // or if classloader supports parallel classloading
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  SeenThread*       _defineThreadQ; // queue of Threads trying to define this class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
                                    // including _definer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
                                    // _definer owns token
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
                                    // queue waits for and returns results from _definer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  // Simple accessors, used only by SystemDictionary
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
   179
  Symbol*            klassname()           const { return literal(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   181
  ClassLoaderData*   loader_data()         const { return _loader_data; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   182
  void               set_loader_data(ClassLoaderData* loader_data) { _loader_data = loader_data; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  bool               havesupername()       const { return _havesupername; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  void               set_havesupername(bool havesupername) { _havesupername = havesupername; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
   187
  Symbol*            supername()           const { return _supername; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
   188
  void               set_supername(Symbol* supername) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
   189
    _supername = supername;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
   190
    if (_supername != NULL) _supername->increment_refcount();
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7408
diff changeset
   191
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  Thread*            definer()             const {return _definer; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  void               set_definer(Thread* definer) { _definer = definer; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13728
diff changeset
   196
  Klass*             instance_klass()      const {return _instanceKlass; }
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13728
diff changeset
   197
  void               set_instance_klass(Klass* ik) { _instanceKlass = ik; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  SeenThread*        superThreadQ()        const { return _superThreadQ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  void               set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  SeenThread*        loadInstanceThreadQ() const { return _loadInstanceThreadQ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  void               set_loadInstanceThreadQ(SeenThread* SeenThread) { _loadInstanceThreadQ = SeenThread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  SeenThread*        defineThreadQ()        const { return _defineThreadQ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  void               set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  PlaceholderEntry* next() const {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   209
    return (PlaceholderEntry*)HashtableEntry<Symbol*, mtClass>::next();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  PlaceholderEntry** next_addr() {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   213
    return (PlaceholderEntry**)HashtableEntry<Symbol*, mtClass>::next_addr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  // Test for equality
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  // Entries are unique for class/classloader name pair
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   218
  bool equals(Symbol* class_name, ClassLoaderData* loader) const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   219
    return (klassname() == class_name && loader_data() == loader);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  SeenThread* actionToQueue(PlaceholderTable::classloadAction action) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    SeenThread* queuehead;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    switch (action) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      case PlaceholderTable::LOAD_INSTANCE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
         queuehead = _loadInstanceThreadQ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      case PlaceholderTable::LOAD_SUPER:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
         queuehead = _superThreadQ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
      case PlaceholderTable::DEFINE_CLASS:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
         queuehead = _defineThreadQ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      default: Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    return queuehead;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  void set_threadQ(SeenThread* seenthread, PlaceholderTable::classloadAction action) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    switch (action) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      case PlaceholderTable::LOAD_INSTANCE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
         _loadInstanceThreadQ = seenthread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
      case PlaceholderTable::LOAD_SUPER:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
         _superThreadQ = seenthread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
      case PlaceholderTable::DEFINE_CLASS:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
         _defineThreadQ = seenthread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
      default: Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  bool super_load_in_progress() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
     return (_superThreadQ != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  bool instance_load_in_progress() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    return (_loadInstanceThreadQ != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  bool define_class_in_progress() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    return (_defineThreadQ != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
// Doubly-linked list of Threads per action for class/classloader pair
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
// Class circularity support: links in thread before loading superclass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
// bootstrapsearchpath support: links in a thread before load_instance_class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
// definers: use as queue of define requestors, including owner of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
// define token. Appends for debugging of requestor order
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  void add_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    assert_lock_strong(SystemDictionary_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    SeenThread* threadEntry = new SeenThread(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    SeenThread* seen = actionToQueue(action);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    if (seen == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
      set_threadQ(threadEntry, action);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    SeenThread* next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    while ((next = seen->next()) != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
      seen = next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    seen->set_next(threadEntry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    threadEntry->set_prev(seen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  bool check_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    assert_lock_strong(SystemDictionary_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    SeenThread* threadQ = actionToQueue(action);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    SeenThread* seen = threadQ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
    while (seen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
      if (thread == seen->thread()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
      seen = seen->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  // returns true if seenthreadQ is now empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  // Note, caller must ensure probe still exists while holding
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  // SystemDictionary_lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  // ignores if cleanup has already been done
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  // if found, deletes SeenThread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  bool remove_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    assert_lock_strong(SystemDictionary_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    SeenThread* threadQ = actionToQueue(action);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    SeenThread* seen = threadQ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    SeenThread* prev = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    while (seen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
      if (thread == seen->thread()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
        if (prev) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
          prev->set_next(seen->next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
          set_threadQ(seen->next(), action);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
        if (seen->next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
          seen->next()->set_prev(prev);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
        delete seen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
      prev = seen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
      seen = seen->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    return (actionToQueue(action) == NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  // GC support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  // Applies "f->do_oop" to all root oops in the placeholder table.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   334
  void classes_do(KlassClosure* closure);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // Print method doesn't append a cr
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  void print() const  PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  void verify() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   340
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   341
#endif // SHARE_VM_CLASSFILE_PLACEHOLDERS_HPP