src/share/vm/oops/cpCacheKlass.cpp

changeset 2533
c5a923563727
parent 2314
f95d63e2154a
child 2534
e5383553fd4e
     1.1 --- a/src/share/vm/oops/cpCacheKlass.cpp	Thu Feb 03 20:49:09 2011 -0800
     1.2 +++ b/src/share/vm/oops/cpCacheKlass.cpp	Mon Feb 07 22:19:57 2011 -0800
     1.3 @@ -49,43 +49,31 @@
     1.4  
     1.5  
     1.6  constantPoolCacheOop constantPoolCacheKlass::allocate(int length,
     1.7 -                                                      bool is_conc_safe,
     1.8                                                        TRAPS) {
     1.9    // allocate memory
    1.10    int size = constantPoolCacheOopDesc::object_size(length);
    1.11  
    1.12    KlassHandle klass (THREAD, as_klassOop());
    1.13  
    1.14 -  // This is the original code.  The code from permanent_obj_allocate()
    1.15 -  // was in-lined to allow the setting of is_conc_safe before the klass
    1.16 -  // is installed.
    1.17 +  // Commented out below is the original code.  The code from
    1.18 +  // permanent_obj_allocate() was in-lined so that we could
    1.19 +  // set the _length field, necessary to correctly compute its
    1.20 +  // size(), before setting its klass word further below.
    1.21    // constantPoolCacheOop cache = (constantPoolCacheOop)
    1.22    //   CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
    1.23  
    1.24    oop obj = CollectedHeap::permanent_obj_allocate_no_klass_install(klass, size, CHECK_NULL);
    1.25 -  constantPoolCacheOop cache = (constantPoolCacheOop) obj;
    1.26 -  cache->set_is_conc_safe(is_conc_safe);
    1.27 -  // The store to is_conc_safe must be visible before the klass
    1.28 -  // is set.  This should be done safely because _is_conc_safe has
    1.29 -  // been declared volatile.  If there are any problems, consider adding
    1.30 -  // OrderAccess::storestore();
    1.31 -  CollectedHeap::post_allocation_install_obj_klass(klass, obj, size);
    1.32    NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value((HeapWord*) obj,
    1.33                                                                size));
    1.34 +  constantPoolCacheOop cache = (constantPoolCacheOop) obj;
    1.35 +  assert(!UseConcMarkSweepGC || obj->klass_or_null() == NULL,
    1.36 +         "klass should be NULL here when using CMS");
    1.37 +  cache->set_length(length);  // should become visible before klass is set below.
    1.38 +  cache->set_constant_pool(NULL);
    1.39  
    1.40 -  // The length field affects the size of the object.  The allocation
    1.41 -  // above allocates the correct size (see calculation of "size") but
    1.42 -  // the size() method of the constant pool cache oop will not reflect
    1.43 -  // that size until the correct length is set.
    1.44 -  cache->set_length(length);
    1.45 -
    1.46 -  // The store of the length must be visible before is_conc_safe is
    1.47 -  // set to a safe state.
    1.48 -  // This should be done safely because _is_conc_safe has
    1.49 -  // been declared volatile.  If there are any problems, consider adding
    1.50 -  // OrderAccess::storestore();
    1.51 -  cache->set_is_conc_safe(methodOopDesc::IsSafeConc);
    1.52 -  cache->set_constant_pool(NULL);
    1.53 +  OrderAccess::storestore();
    1.54 +  obj->set_klass(klass());
    1.55 +  assert(cache->size() == size, "Incorrect cache->size()");
    1.56    return cache;
    1.57  }
    1.58  
    1.59 @@ -176,11 +164,6 @@
    1.60    return size;
    1.61  }
    1.62  
    1.63 -bool constantPoolCacheKlass::oop_is_conc_safe(oop obj) const {
    1.64 -  assert(obj->is_constantPoolCache(), "should be constant pool");
    1.65 -  return constantPoolCacheOop(obj)->is_conc_safe();
    1.66 -}
    1.67 -
    1.68  #ifndef SERIALGC
    1.69  void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
    1.70                                                 oop obj) {

mercurial