hotspot/src/share/vm/oops/constantPoolKlass.cpp
author ysr
Thu, 03 Dec 2009 15:01:57 -0800
changeset 4461 c17c526d36ef
parent 2570 ecc7862946d4
child 4584 e2a449e8cc6f
permissions -rw-r--r--
6906727: UseCompressedOops: some card-marking fixes related to object arrays Summary: Introduced a new write_ref_array(HeapWords* start, size_t count) method that does the requisite MemRegion range calculation so (some of the) clients of the erstwhile write_ref_array(MemRegion mr) do not need to worry. This removed all external uses of array_size(), which was also simplified and made private. Asserts were added to catch other possible issues. Further, less essential, fixes stemming from this investigation are deferred to CR 6904516 (to follow shortly in hs17). Reviewed-by: kvn, coleenp, jmasa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
2105
347008ce7984 6814575: Update copyright year
xdono
parents: 1894
diff changeset
     2
 * Copyright 1997-2009 Sun Microsystems, Inc.  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
 *
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/_constantPoolKlass.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
1894
5c343868d071 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 1550
diff changeset
    28
constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  int size = constantPoolOopDesc::object_size(length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  KlassHandle klass (THREAD, as_klassOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  constantPoolOop c =
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    32
    (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    34
  c->set_length(length);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  c->set_tags(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  c->set_cache(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  c->set_pool_holder(NULL);
1550
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
    38
  c->set_flags(0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  // only set to non-zero if constant pool is merged by RedefineClasses
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  c->set_orig_length(0);
1894
5c343868d071 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 1550
diff changeset
    41
  // if constant pool may change during RedefineClasses, it is created
5c343868d071 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 1550
diff changeset
    42
  // unsafe for GC concurrent processing.
5c343868d071 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 1550
diff changeset
    43
  c->set_is_conc_safe(is_conc_safe);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // all fields are initialized; needed for GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // initialize tag array
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // Note: cannot introduce constant pool handle before since it is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  //       completely initialized (no class) -> would cause assertion failure
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  constantPoolHandle pool (THREAD, c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  typeArrayHandle tags (THREAD, t_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  for (int index = 0; index < length; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    tags()->byte_at_put(index, JVM_CONSTANT_Invalid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  pool->set_tags(tags());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  return pool();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
klassOop constantPoolKlass::create_klass(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  constantPoolKlass o;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    62
  KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    63
  KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    64
  // Make sure size calculation is right
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    65
  assert(k()->size() == align_object_size(header_size()), "wrong size for object");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    66
  java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  return k();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
int constantPoolKlass::oop_size(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  assert(obj->is_constantPool(), "must be constantPool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  return constantPoolOop(obj)->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
void constantPoolKlass::oop_follow_contents(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  assert (obj->is_constantPool(), "obj must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  constantPoolOop cp = (constantPoolOop) obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // know that Universe::constantPoolKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // If the tags array is null we are in the middle of allocating this constant pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  if (cp->tags() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    // gc of constant pool contents
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    oop* base = (oop*)cp->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    for (int i = 0; i < cp->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      if (cp->is_pointer_entry(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
        if (*base != NULL) MarkSweep::mark_and_push(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      base++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    // gc of constant pool instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    MarkSweep::mark_and_push(cp->tags_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    MarkSweep::mark_and_push(cp->cache_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    MarkSweep::mark_and_push(cp->pool_holder_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
void constantPoolKlass::oop_follow_contents(ParCompactionManager* cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
                                            oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  assert (obj->is_constantPool(), "obj must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  constantPoolOop cp = (constantPoolOop) obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // know that Universe::constantPoolKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // If the tags array is null we are in the middle of allocating this constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // pool.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  if (cp->tags() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    // gc of constant pool contents
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    oop* base = (oop*)cp->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    for (int i = 0; i < cp->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      if (cp->is_pointer_entry(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
        if (*base != NULL) PSParallelCompact::mark_and_push(cm, base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
      base++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    // gc of constant pool instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    PSParallelCompact::mark_and_push(cm, cp->tags_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    PSParallelCompact::mark_and_push(cm, cp->cache_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    PSParallelCompact::mark_and_push(cm, cp->pool_holder_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
int constantPoolKlass::oop_adjust_pointers(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  assert (obj->is_constantPool(), "obj must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  constantPoolOop cp = (constantPoolOop) obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  int size = cp->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // know that Universe::constantPoolKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // If the tags array is null we are in the middle of allocating this constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // pool.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  if (cp->tags() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    oop* base = (oop*)cp->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    for (int i = 0; i< cp->length();  i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
      if (cp->is_pointer_entry(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
        MarkSweep::adjust_pointer(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      base++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  MarkSweep::adjust_pointer(cp->tags_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  MarkSweep::adjust_pointer(cp->cache_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  MarkSweep::adjust_pointer(cp->pool_holder_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
int constantPoolKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  assert (obj->is_constantPool(), "obj must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  // know that Universe::constantPoolKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  constantPoolOop cp = (constantPoolOop) obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  int size = cp->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // If the tags array is null we are in the middle of allocating this constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  // pool.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  if (cp->tags() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    oop* base = (oop*)cp->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    for (int i = 0; i < cp->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
      if (cp->is_pointer_entry(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        blk->do_oop(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
      base++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  blk->do_oop(cp->tags_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  blk->do_oop(cp->cache_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  blk->do_oop(cp->pool_holder_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
int constantPoolKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  assert (obj->is_constantPool(), "obj must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  // know that Universe::constantPoolKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  constantPoolOop cp = (constantPoolOop) obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  int size = cp->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // If the tags array is null we are in the middle of allocating this constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // pool.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  if (cp->tags() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    oop* base = (oop*)cp->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    for (int i = 0; i < cp->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      if (mr.contains(base)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
        if (cp->is_pointer_entry(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
          blk->do_oop(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      base++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  oop* addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  addr = cp->tags_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  blk->do_oop(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  addr = cp->cache_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  blk->do_oop(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  addr = cp->pool_holder_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  blk->do_oop(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
1894
5c343868d071 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 1550
diff changeset
   213
bool constantPoolKlass::oop_is_conc_safe(oop obj) const {
5c343868d071 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 1550
diff changeset
   214
  assert(obj->is_constantPool(), "must be constantPool");
5c343868d071 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 1550
diff changeset
   215
  return constantPoolOop(obj)->is_conc_safe();
5c343868d071 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 1550
diff changeset
   216
}
5c343868d071 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 1550
diff changeset
   217
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
int constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  assert (obj->is_constantPool(), "obj must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  constantPoolOop cp = (constantPoolOop) obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // If the tags array is null we are in the middle of allocating this constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  // pool.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  if (cp->tags() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    oop* base = (oop*)cp->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    for (int i = 0; i < cp->length(); ++i, ++base) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      if (cp->is_pointer_entry(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
        PSParallelCompact::adjust_pointer(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  PSParallelCompact::adjust_pointer(cp->tags_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  PSParallelCompact::adjust_pointer(cp->cache_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  PSParallelCompact::adjust_pointer(cp->pool_holder_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  return cp->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
int
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
                                       HeapWord* beg_addr, HeapWord* end_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  assert (obj->is_constantPool(), "obj must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  constantPoolOop cp = (constantPoolOop) obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // If the tags array is null we are in the middle of allocating this constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // pool.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  if (cp->tags() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    oop* base = (oop*)cp->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    oop* const beg_oop = MAX2((oop*)beg_addr, base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    oop* const end_oop = MIN2((oop*)end_addr, base + cp->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    const size_t beg_idx = pointer_delta(beg_oop, base, sizeof(oop*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    const size_t end_idx = pointer_delta(end_oop, base, sizeof(oop*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    for (size_t cur_idx = beg_idx; cur_idx < end_idx; ++cur_idx, ++base) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
      if (cp->is_pointer_entry(int(cur_idx))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
        PSParallelCompact::adjust_pointer(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  oop* p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  p = cp->tags_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  p = cp->cache_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  p = cp->pool_holder_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  return cp->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
void constantPoolKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  assert(obj->is_constantPool(), "should be constant pool");
1550
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   273
  constantPoolOop cp = (constantPoolOop) obj;
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   274
  if (AnonymousClasses && cp->has_pseudo_string() && cp->tags() != NULL) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   275
    oop* base = (oop*)cp->base();
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   276
    for (int i = 0; i < cp->length(); ++i, ++base) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   277
      if (cp->tag_at(i).is_string()) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   278
        if (PSScavenge::should_scavenge(base)) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   279
          pm->claim_or_forward_breadth(base);
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   280
        }
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   281
      }
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   282
    }
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   283
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  assert(obj->is_constantPool(), "should be constant pool");
1550
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   288
  constantPoolOop cp = (constantPoolOop) obj;
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   289
  if (AnonymousClasses && cp->has_pseudo_string() && cp->tags() != NULL) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   290
    oop* base = (oop*)cp->base();
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   291
    for (int i = 0; i < cp->length(); ++i, ++base) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   292
      if (cp->tag_at(i).is_string()) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   293
        if (PSScavenge::should_scavenge(base)) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   294
          pm->claim_or_forward_depth(base);
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   295
        }
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   296
      }
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   297
    }
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   298
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
// Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
void constantPoolKlass::oop_print_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  EXCEPTION_MARK;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  oop anObj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  assert(obj->is_constantPool(), "must be constantPool");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   310
  Klass::oop_print_on(obj, st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  constantPoolOop cp = constantPoolOop(obj);
1550
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   312
  if (cp->flags() != 0) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   313
    st->print(" - flags : 0x%x", cp->flags());
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   314
    if (cp->has_pseudo_string()) st->print(" has_pseudo_string");
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 2105
diff changeset
   315
    if (cp->has_invokedynamic()) st->print(" has_invokedynamic");
1550
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   316
    st->cr();
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   317
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  // Temp. remove cache so we can do lookups with original indicies.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  constantPoolCacheHandle cache (THREAD, cp->cache());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  cp->set_cache(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  for (int index = 1; index < cp->length(); index++) {      // Index 0 is unused
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    st->print(" - %3d : ", index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    cp->tag_at(index).print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    st->print(" : ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    switch (cp->tag_at(index).value()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
      case JVM_CONSTANT_Class :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
        { anObj = cp->klass_at(index, CATCH);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
          anObj->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
          st->print(" {0x%lx}", (address)anObj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      case JVM_CONSTANT_Fieldref :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
      case JVM_CONSTANT_Methodref :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
      case JVM_CONSTANT_InterfaceMethodref :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
        st->print("klass_index=%d", cp->klass_ref_index_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
        st->print(" name_and_type_index=%d", cp->name_and_type_ref_index_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
      case JVM_CONSTANT_UnresolvedString :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
      case JVM_CONSTANT_String :
1550
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   342
        if (cp->is_pseudo_string_at(index)) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   343
          anObj = cp->pseudo_string_at(index);
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   344
        } else {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   345
          anObj = cp->string_at(index, CATCH);
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   346
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
        anObj->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
        st->print(" {0x%lx}", (address)anObj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
      case JVM_CONSTANT_Integer :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
        st->print("%d", cp->int_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
      case JVM_CONSTANT_Float :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
        st->print("%f", cp->float_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
      case JVM_CONSTANT_Long :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
        st->print_jlong(cp->long_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
        index++;   // Skip entry following eigth-byte constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
      case JVM_CONSTANT_Double :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
        st->print("%lf", cp->double_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
        index++;   // Skip entry following eigth-byte constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
      case JVM_CONSTANT_NameAndType :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
        st->print("name_index=%d", cp->name_ref_index_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
        st->print(" signature_index=%d", cp->signature_ref_index_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
      case JVM_CONSTANT_Utf8 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
        cp->symbol_at(index)->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
      case JVM_CONSTANT_UnresolvedClass :               // fall-through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
      case JVM_CONSTANT_UnresolvedClassInError: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
        // unresolved_klass_at requires lock or safe world.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
        oop entry = *cp->obj_at_addr(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
        entry->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  // Restore cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  cp->set_cache(cache());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
const char* constantPoolKlass::internal_name() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  return "{constant pool}";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
void constantPoolKlass::oop_verify_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  Klass::oop_verify_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  guarantee(obj->is_constantPool(), "object must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  constantPoolOop cp = constantPoolOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  guarantee(cp->is_perm(), "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  if (!cp->partially_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    oop* base = (oop*)cp->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    for (int i = 0; i< cp->length();  i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
      if (cp->tag_at(i).is_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
        guarantee((*base)->is_perm(),     "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
        guarantee((*base)->is_klass(),    "should be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
      if (cp->tag_at(i).is_unresolved_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
        guarantee((*base)->is_perm(),     "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
        guarantee((*base)->is_symbol() || (*base)->is_klass(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
                  "should be symbol or klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
      if (cp->tag_at(i).is_symbol()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
        guarantee((*base)->is_perm(),     "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
        guarantee((*base)->is_symbol(),   "should be symbol");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
      if (cp->tag_at(i).is_unresolved_string()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
        guarantee((*base)->is_perm(),     "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
        guarantee((*base)->is_symbol() || (*base)->is_instance(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
                  "should be symbol or instance");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
      if (cp->tag_at(i).is_string()) {
1550
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   426
        if (!cp->has_pseudo_string()) {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   427
          guarantee((*base)->is_perm(),   "should be in permspace");
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   428
          guarantee((*base)->is_instance(), "should be instance");
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   429
        } else {
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   430
          // can be non-perm, can be non-instance (array)
be2fc37a817f 6653858: dynamic languages need to be able to load anonymous classes
jrose
parents: 670
diff changeset
   431
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
      base++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    guarantee(cp->tags()->is_perm(),         "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
    guarantee(cp->tags()->is_typeArray(),    "should be type array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    if (cp->cache() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
      // Note: cache() can be NULL before a class is completely setup or
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
      // in temporary constant pools used during constant pool merging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      guarantee(cp->cache()->is_perm(),              "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
      guarantee(cp->cache()->is_constantPoolCache(), "should be constant pool cache");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    if (cp->pool_holder() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
      // Note: pool_holder() can be NULL in temporary constant pools
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
      // used during constant pool merging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
      guarantee(cp->pool_holder()->is_perm(),  "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
      guarantee(cp->pool_holder()->is_klass(), "should be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
bool constantPoolKlass::oop_partially_loaded(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  assert(obj->is_constantPool(), "object must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  constantPoolOop cp = constantPoolOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  return cp->tags() == NULL || cp->pool_holder() == (klassOop) cp;   // Check whether pool holder points to self
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
void constantPoolKlass::oop_set_partially_loaded(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  assert(obj->is_constantPool(), "object must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  constantPoolOop cp = constantPoolOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  assert(cp->pool_holder() == NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  cp->set_pool_holder((klassOop) cp);   // Temporarily set pool holder to point to self
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
// CompileTheWorld support. Preload all classes loaded references in the passed in constantpool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
void constantPoolKlass::preload_and_initialize_all_classes(oop obj, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  guarantee(obj->is_constantPool(), "object must be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  constantPoolHandle cp(THREAD, (constantPoolOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  guarantee(!cp->partially_loaded(), "must be fully loaded");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  for (int i = 0; i< cp->length();  i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    if (cp->tag_at(i).is_unresolved_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
      // This will force loading of the class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
      klassOop klass = cp->klass_at(i, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
      if (klass->is_instance()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
        // Force initialization of class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
        instanceKlass::cast(klass)->initialize(CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
#endif