hotspot/src/share/vm/oops/cpCacheKlass.cpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1 489c9b5090e2
child 360 21d113ecbf6a
permissions -rw-r--r--
Initial load
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 1998-2006 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
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_cpCacheKlass.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
int constantPoolCacheKlass::oop_size(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  assert(obj->is_constantPoolCache(), "must be constantPool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  return constantPoolCacheOop(obj)->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
constantPoolCacheOop constantPoolCacheKlass::allocate(int length, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  // allocate memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  int size = constantPoolCacheOopDesc::object_size(length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  KlassHandle klass (THREAD, as_klassOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  constantPoolCacheOop cache = (constantPoolCacheOop)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    CollectedHeap::permanent_array_allocate(klass, size, length, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  cache->set_constant_pool(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  return cache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
klassOop constantPoolCacheKlass::create_klass(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  constantPoolCacheKlass o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  KlassHandle klassklass(THREAD, Universe::arrayKlassKlassObj());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  arrayKlassHandle k = base_create_array_klass(o.vtbl_value(), header_size(), klassklass, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  KlassHandle super (THREAD, k->super());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  complete_create_array_klass(k, super, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  return k();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
void constantPoolCacheKlass::oop_follow_contents(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // know that Universe::constantPoolCacheKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // gc of constant pool cache instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  MarkSweep::mark_and_push((oop*)cache->constant_pool_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // gc of constant pool cache entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  int i = cache->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  while (i-- > 0) cache->entry_at(i)->follow_contents();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
void constantPoolCacheKlass::oop_follow_contents(ParCompactionManager* cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
                                                 oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // know that Universe::constantPoolCacheKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // gc of constant pool cache instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  PSParallelCompact::mark_and_push(cm, (oop*)cache->constant_pool_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // gc of constant pool cache entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  int i = cache->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  while (i-- > 0) cache->entry_at(i)->follow_contents(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
int constantPoolCacheKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  int size = cache->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  // know that Universe::constantPoolCacheKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // iteration over constant pool cache instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  blk->do_oop((oop*)cache->constant_pool_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // iteration over constant pool cache entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate(blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
int constantPoolCacheKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  int size = cache->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // know that Universe::constantPoolCacheKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // iteration over constant pool cache instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  oop* addr = (oop*)cache->constant_pool_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  if (mr.contains(addr)) blk->do_oop(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // iteration over constant pool cache entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate_m(blk, mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
int constantPoolCacheKlass::oop_adjust_pointers(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  int size = cache->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // know that Universe::constantPoolCacheKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // Iteration over constant pool cache instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  MarkSweep::adjust_pointer((oop*)cache->constant_pool_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // iteration over constant pool cache entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  for (int i = 0; i < cache->length(); i++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    cache->entry_at(i)->adjust_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
void constantPoolCacheKlass::oop_copy_contents(PSPromotionManager* pm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
                                               oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  assert(obj->is_constantPoolCache(), "should be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
                                               oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  assert(obj->is_constantPoolCache(), "should be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
int
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // Iteration over constant pool cache instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  PSParallelCompact::adjust_pointer((oop*)cache->constant_pool_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // iteration over constant pool cache entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  for (int i = 0; i < cache->length(); ++i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    cache->entry_at(i)->update_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  return cache->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
int
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
                                            HeapWord* beg_addr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
                                            HeapWord* end_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  // Iteration over constant pool cache instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  oop* p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  p = (oop*)cache->constant_pool_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // Iteration over constant pool cache entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  for (int i = 0; i < cache->length(); ++i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    cache->entry_at(i)->update_pointers(beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  return cache->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // super print
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  arrayKlass::oop_print_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // print constant pool cache entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->print(st, i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
void constantPoolCacheKlass::oop_verify_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  guarantee(obj->is_constantPoolCache(), "obj must be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // super verify
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  arrayKlass::oop_verify_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // print constant pool cache entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->verify(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
const char* constantPoolCacheKlass::internal_name() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  return "{constant pool cache}";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
}