src/share/vm/oops/cpCacheKlass.cpp

Mon, 25 Jun 2012 21:33:35 -0400

author
coleenp
date
Mon, 25 Jun 2012 21:33:35 -0400
changeset 3875
246d977b51f2
parent 3092
baf763f388e6
permissions
-rw-r--r--

7178670: runtime/7158800/BadUtf8.java fails in SymbolTable::rehash_table
Summary: Cannot delete _buckets and HashtableEntries in shared space (CDS)
Reviewed-by: acorn, kvn, dlong, dcubed, kamg

     1 /*
     2  * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "classfile/javaClasses.hpp"
    27 #include "gc_implementation/shared/markSweep.inline.hpp"
    28 #include "gc_interface/collectedHeap.hpp"
    29 #include "interpreter/bytecodes.hpp"
    30 #include "memory/genOopClosures.inline.hpp"
    31 #include "memory/permGen.hpp"
    32 #include "oops/constantPoolOop.hpp"
    33 #include "oops/cpCacheKlass.hpp"
    34 #include "oops/oop.inline.hpp"
    35 #include "runtime/handles.inline.hpp"
    36 #ifndef SERIALGC
    37 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
    38 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
    39 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
    40 #include "memory/cardTableRS.hpp"
    41 #include "oops/oop.pcgc.inline.hpp"
    42 #endif
    45 int constantPoolCacheKlass::oop_size(oop obj) const {
    46   assert(obj->is_constantPoolCache(), "must be constantPool");
    47   return constantPoolCacheOop(obj)->object_size();
    48 }
    51 constantPoolCacheOop constantPoolCacheKlass::allocate(int length,
    52                                                       TRAPS) {
    53   // allocate memory
    54   int size = constantPoolCacheOopDesc::object_size(length);
    56   KlassHandle klass (THREAD, as_klassOop());
    58   // Commented out below is the original code.  The code from
    59   // permanent_obj_allocate() was in-lined so that we could
    60   // set the _length field, necessary to correctly compute its
    61   // size(), before setting its klass word further below.
    62   // constantPoolCacheOop cache = (constantPoolCacheOop)
    63   //   CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
    65   oop obj = CollectedHeap::permanent_obj_allocate_no_klass_install(klass, size, CHECK_NULL);
    66 #ifndef PRODUCT
    67   const size_t hs = oopDesc::header_size();
    68   Universe::heap()->check_for_bad_heap_word_value(((HeapWord*) obj)+hs, size-hs);
    69 #endif
    70   constantPoolCacheOop cache = (constantPoolCacheOop) obj;
    71   assert(!UseConcMarkSweepGC || obj->klass_or_null() == NULL,
    72          "klass should be NULL here when using CMS");
    73   cache->set_length(length);  // should become visible before klass is set below.
    74   cache->set_constant_pool(NULL);
    76   OrderAccess::storestore();
    77   obj->set_klass(klass());
    78   assert(cache->size() == size, "Incorrect cache->size()");
    79   return cache;
    80 }
    82 klassOop constantPoolCacheKlass::create_klass(TRAPS) {
    83   constantPoolCacheKlass o;
    84   KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
    85   KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL);
    86   // Make sure size calculation is right
    87   assert(k()->size() == align_object_size(header_size()), "wrong size for object");
    88   java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
    89   return k();
    90 }
    93 void constantPoolCacheKlass::oop_follow_contents(oop obj) {
    94   assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
    95   constantPoolCacheOop cache = (constantPoolCacheOop)obj;
    96   // Performance tweak: We skip iterating over the klass pointer since we
    97   // know that Universe::constantPoolCacheKlassObj never moves.
    98   // gc of constant pool cache instance variables
    99   MarkSweep::mark_and_push((oop*)cache->constant_pool_addr());
   100   // gc of constant pool cache entries
   101   int i = cache->length();
   102   while (i-- > 0) cache->entry_at(i)->follow_contents();
   103 }
   105 #ifndef SERIALGC
   106 void constantPoolCacheKlass::oop_follow_contents(ParCompactionManager* cm,
   107                                                  oop obj) {
   108   assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
   109   constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   110   // Performance tweak: We skip iterating over the klass pointer since we
   111   // know that Universe::constantPoolCacheKlassObj never moves.
   112   // gc of constant pool cache instance variables
   113   PSParallelCompact::mark_and_push(cm, (oop*)cache->constant_pool_addr());
   114   // gc of constant pool cache entries
   115   int i = cache->length();
   116   while (i-- > 0) cache->entry_at(i)->follow_contents(cm);
   117 }
   118 #endif // SERIALGC
   121 int constantPoolCacheKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
   122   assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
   123   constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   124   // Get size before changing pointers.
   125   // Don't call size() or oop_size() since that is a virtual call.
   126   int size = cache->object_size();
   127   // Performance tweak: We skip iterating over the klass pointer since we
   128   // know that Universe::constantPoolCacheKlassObj never moves.
   129   // iteration over constant pool cache instance variables
   130   blk->do_oop((oop*)cache->constant_pool_addr());
   131   // iteration over constant pool cache entries
   132   for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate(blk);
   133   return size;
   134 }
   137 int constantPoolCacheKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
   138   assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
   139   constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   140   // Get size before changing pointers.
   141   // Don't call size() or oop_size() since that is a virtual call.
   142   int size = cache->object_size();
   143   // Performance tweak: We skip iterating over the klass pointer since we
   144   // know that Universe::constantPoolCacheKlassObj never moves.
   145   // iteration over constant pool cache instance variables
   146   oop* addr = (oop*)cache->constant_pool_addr();
   147   if (mr.contains(addr)) blk->do_oop(addr);
   148   // iteration over constant pool cache entries
   149   for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate_m(blk, mr);
   150   return size;
   151 }
   153 int constantPoolCacheKlass::oop_adjust_pointers(oop obj) {
   154   assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
   155   constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   156   // Get size before changing pointers.
   157   // Don't call size() or oop_size() since that is a virtual call.
   158   int size = cache->object_size();
   159   // Performance tweak: We skip iterating over the klass pointer since we
   160   // know that Universe::constantPoolCacheKlassObj never moves.
   161   // Iteration over constant pool cache instance variables
   162   MarkSweep::adjust_pointer((oop*)cache->constant_pool_addr());
   163   // iteration over constant pool cache entries
   164   for (int i = 0; i < cache->length(); i++)
   165     cache->entry_at(i)->adjust_pointers();
   166   return size;
   167 }
   169 #ifndef SERIALGC
   170 void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
   171                                                oop obj) {
   172   assert(obj->is_constantPoolCache(), "should be constant pool");
   173   if (ScavengeRootsInCode) {
   174     constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   175     // during a scavenge, it is safe to inspect my pool, since it is perm
   176     constantPoolOop pool = cache->constant_pool();
   177     assert(pool->is_constantPool(), "should be constant pool");
   178     for (int i = 0; i < cache->length(); i++) {
   179       ConstantPoolCacheEntry* e = cache->entry_at(i);
   180       oop* p = (oop*)&e->_f1;
   181       if (PSScavenge::should_scavenge(p))
   182         pm->claim_or_forward_depth(p);
   183       assert(!(e->is_vfinal() && PSScavenge::should_scavenge((oop*)&e->_f2)),
   184              "no live oops here");
   185     }
   186   }
   187 }
   189 int
   190 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
   191   assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
   192   constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   194   // Iteration over constant pool cache instance variables
   195   PSParallelCompact::adjust_pointer((oop*)cache->constant_pool_addr());
   197   // iteration over constant pool cache entries
   198   for (int i = 0; i < cache->length(); ++i) {
   199     cache->entry_at(i)->update_pointers();
   200   }
   202   return cache->object_size();
   203 }
   204 #endif // SERIALGC
   206 void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) {
   207   assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
   208   constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   209   // super print
   210   Klass::oop_print_on(obj, st);
   211   // print constant pool cache entries
   212   for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->print(st, i);
   213 }
   215 void constantPoolCacheKlass::oop_print_value_on(oop obj, outputStream* st) {
   216   assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
   217   constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   218   st->print("cache [%d]", cache->length());
   219   cache->print_address_on(st);
   220   st->print(" for ");
   221   cache->constant_pool()->print_value_on(st);
   222 }
   224 void constantPoolCacheKlass::oop_verify_on(oop obj, outputStream* st) {
   225   guarantee(obj->is_constantPoolCache(), "obj must be constant pool cache");
   226   constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   227   // super verify
   228   Klass::oop_verify_on(obj, st);
   229   // print constant pool cache entries
   230   for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->verify(st);
   231 }
   234 const char* constantPoolCacheKlass::internal_name() const {
   235   return "{constant pool cache}";
   236 }

mercurial