src/share/vm/oops/instanceKlass.cpp

changeset 2658
c7f3d0b4570f
parent 2639
8033953d67ff
child 2690
2cd0180da6e1
     1.1 --- a/src/share/vm/oops/instanceKlass.cpp	Fri Mar 18 15:52:42 2011 -0700
     1.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Fri Mar 18 16:00:34 2011 -0700
     1.3 @@ -37,6 +37,7 @@
     1.4  #include "memory/oopFactory.hpp"
     1.5  #include "memory/permGen.hpp"
     1.6  #include "oops/instanceKlass.hpp"
     1.7 +#include "oops/instanceMirrorKlass.hpp"
     1.8  #include "oops/instanceOop.hpp"
     1.9  #include "oops/methodOop.hpp"
    1.10  #include "oops/objArrayKlassKlass.hpp"
    1.11 @@ -649,6 +650,7 @@
    1.12  }
    1.13  
    1.14  instanceOop instanceKlass::allocate_instance(TRAPS) {
    1.15 +  assert(!oop_is_instanceMirror(), "wrong allocation path");
    1.16    bool has_finalizer_flag = has_finalizer(); // Query before possible GC
    1.17    int size = size_helper();  // Query before forming handle.
    1.18  
    1.19 @@ -669,6 +671,7 @@
    1.20    // instances so simply disallow finalizable perm objects.  This can
    1.21    // be relaxed if a need for it is found.
    1.22    assert(!has_finalizer(), "perm objects not allowed to have finalizers");
    1.23 +  assert(!oop_is_instanceMirror(), "wrong allocation path");
    1.24    int size = size_helper();  // Query before forming handle.
    1.25    KlassHandle h_k(THREAD, as_klassOop());
    1.26    instanceOop i = (instanceOop)
    1.27 @@ -898,6 +901,7 @@
    1.28    }
    1.29  }
    1.30  
    1.31 +
    1.32  void instanceKlass::do_local_static_fields(FieldClosure* cl) {
    1.33    fieldDescriptor fd;
    1.34    int length = fields()->length();
    1.35 @@ -1609,36 +1613,6 @@
    1.36  // The following macros call specialized macros, passing either oop or
    1.37  // narrowOop as the specialization type.  These test the UseCompressedOops
    1.38  // flag.
    1.39 -#define InstanceKlass_OOP_ITERATE(start_p, count,    \
    1.40 -                                  do_oop, assert_fn) \
    1.41 -{                                                    \
    1.42 -  if (UseCompressedOops) {                           \
    1.43 -    InstanceKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
    1.44 -      start_p, count,                                \
    1.45 -      do_oop, assert_fn)                             \
    1.46 -  } else {                                           \
    1.47 -    InstanceKlass_SPECIALIZED_OOP_ITERATE(oop,       \
    1.48 -      start_p, count,                                \
    1.49 -      do_oop, assert_fn)                             \
    1.50 -  }                                                  \
    1.51 -}
    1.52 -
    1.53 -#define InstanceKlass_BOUNDED_OOP_ITERATE(start_p, count, low, high,    \
    1.54 -                                          do_oop, assert_fn) \
    1.55 -{                                                            \
    1.56 -  if (UseCompressedOops) {                                   \
    1.57 -    InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop, \
    1.58 -      start_p, count,                                        \
    1.59 -      low, high,                                             \
    1.60 -      do_oop, assert_fn)                                     \
    1.61 -  } else {                                                   \
    1.62 -    InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop,       \
    1.63 -      start_p, count,                                        \
    1.64 -      low, high,                                             \
    1.65 -      do_oop, assert_fn)                                     \
    1.66 -  }                                                          \
    1.67 -}
    1.68 -
    1.69  #define InstanceKlass_OOP_MAP_ITERATE(obj, do_oop, assert_fn)            \
    1.70  {                                                                        \
    1.71    /* Compute oopmap block range. The common case                         \
    1.72 @@ -1711,38 +1685,6 @@
    1.73    }                                                                      \
    1.74  }
    1.75  
    1.76 -void instanceKlass::follow_static_fields() {
    1.77 -  InstanceKlass_OOP_ITERATE( \
    1.78 -    start_of_static_fields(), static_oop_field_size(), \
    1.79 -    MarkSweep::mark_and_push(p), \
    1.80 -    assert_is_in_closed_subset)
    1.81 -}
    1.82 -
    1.83 -#ifndef SERIALGC
    1.84 -void instanceKlass::follow_static_fields(ParCompactionManager* cm) {
    1.85 -  InstanceKlass_OOP_ITERATE( \
    1.86 -    start_of_static_fields(), static_oop_field_size(), \
    1.87 -    PSParallelCompact::mark_and_push(cm, p), \
    1.88 -    assert_is_in)
    1.89 -}
    1.90 -#endif // SERIALGC
    1.91 -
    1.92 -void instanceKlass::adjust_static_fields() {
    1.93 -  InstanceKlass_OOP_ITERATE( \
    1.94 -    start_of_static_fields(), static_oop_field_size(), \
    1.95 -    MarkSweep::adjust_pointer(p), \
    1.96 -    assert_nothing)
    1.97 -}
    1.98 -
    1.99 -#ifndef SERIALGC
   1.100 -void instanceKlass::update_static_fields() {
   1.101 -  InstanceKlass_OOP_ITERATE( \
   1.102 -    start_of_static_fields(), static_oop_field_size(), \
   1.103 -    PSParallelCompact::adjust_pointer(p), \
   1.104 -    assert_nothing)
   1.105 -}
   1.106 -#endif // SERIALGC
   1.107 -
   1.108  void instanceKlass::oop_follow_contents(oop obj) {
   1.109    assert(obj != NULL, "can't follow the content of NULL object");
   1.110    obj->follow_header();
   1.111 @@ -1829,22 +1771,6 @@
   1.112  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
   1.113  #endif // !SERIALGC
   1.114  
   1.115 -void instanceKlass::iterate_static_fields(OopClosure* closure) {
   1.116 -    InstanceKlass_OOP_ITERATE( \
   1.117 -      start_of_static_fields(), static_oop_field_size(), \
   1.118 -      closure->do_oop(p), \
   1.119 -      assert_is_in_reserved)
   1.120 -}
   1.121 -
   1.122 -void instanceKlass::iterate_static_fields(OopClosure* closure,
   1.123 -                                          MemRegion mr) {
   1.124 -  InstanceKlass_BOUNDED_OOP_ITERATE( \
   1.125 -    start_of_static_fields(), static_oop_field_size(), \
   1.126 -    mr.start(), mr.end(), \
   1.127 -    (closure)->do_oop_v(p), \
   1.128 -    assert_is_in_closed_subset)
   1.129 -}
   1.130 -
   1.131  int instanceKlass::oop_adjust_pointers(oop obj) {
   1.132    int size = size_helper();
   1.133    InstanceKlass_OOP_MAP_ITERATE( \
   1.134 @@ -1873,21 +1799,6 @@
   1.135    return size_helper();
   1.136  }
   1.137  
   1.138 -void instanceKlass::push_static_fields(PSPromotionManager* pm) {
   1.139 -  InstanceKlass_OOP_ITERATE( \
   1.140 -    start_of_static_fields(), static_oop_field_size(), \
   1.141 -    if (PSScavenge::should_scavenge(p)) { \
   1.142 -      pm->claim_or_forward_depth(p); \
   1.143 -    }, \
   1.144 -    assert_nothing )
   1.145 -}
   1.146 -
   1.147 -void instanceKlass::copy_static_fields(ParCompactionManager* cm) {
   1.148 -  InstanceKlass_OOP_ITERATE( \
   1.149 -    start_of_static_fields(), static_oop_field_size(), \
   1.150 -    PSParallelCompact::adjust_pointer(p), \
   1.151 -    assert_is_in)
   1.152 -}
   1.153  #endif // SERIALGC
   1.154  
   1.155  // This klass is alive but the implementor link is not followed/updated.
   1.156 @@ -2002,6 +1913,11 @@
   1.157    if (_source_debug_extension != NULL) _source_debug_extension->increment_refcount();
   1.158  }
   1.159  
   1.160 +address instanceKlass::static_field_addr(int offset) {
   1.161 +  return (address)(offset + instanceMirrorKlass::offset_of_static_fields() + (intptr_t)java_mirror());
   1.162 +}
   1.163 +
   1.164 +
   1.165  const char* instanceKlass::signature_name() const {
   1.166    const char* src = (const char*) (name()->as_C_string());
   1.167    const int src_length = (int)strlen(src);
   1.168 @@ -2369,7 +2285,7 @@
   1.169  
   1.170  void FieldPrinter::do_field(fieldDescriptor* fd) {
   1.171    _st->print(BULLET);
   1.172 -   if (fd->is_static() || (_obj == NULL)) {
   1.173 +   if (_obj == NULL) {
   1.174       fd->print_on(_st);
   1.175       _st->cr();
   1.176     } else {
   1.177 @@ -2399,8 +2315,8 @@
   1.178    }
   1.179  
   1.180    st->print_cr(BULLET"---- fields (total size %d words):", oop_size(obj));
   1.181 -  FieldPrinter print_nonstatic_field(st, obj);
   1.182 -  do_nonstatic_fields(&print_nonstatic_field);
   1.183 +  FieldPrinter print_field(st, obj);
   1.184 +  do_nonstatic_fields(&print_field);
   1.185  
   1.186    if (as_klassOop() == SystemDictionary::Class_klass()) {
   1.187      st->print(BULLET"signature: ");
   1.188 @@ -2418,6 +2334,12 @@
   1.189      st->print(BULLET"fake entry for array: ");
   1.190      array_klass->print_value_on(st);
   1.191      st->cr();
   1.192 +    st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj));
   1.193 +    st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj));
   1.194 +    klassOop real_klass = java_lang_Class::as_klassOop(obj);
   1.195 +    if (real_klass && real_klass->klass_part()->oop_is_instance()) {
   1.196 +      instanceKlass::cast(real_klass)->do_local_static_fields(&print_field);
   1.197 +    }
   1.198    } else if (as_klassOop() == SystemDictionary::MethodType_klass()) {
   1.199      st->print(BULLET"signature: ");
   1.200      java_lang_invoke_MethodType::print_signature(obj, st);
   1.201 @@ -2560,7 +2482,7 @@
   1.202  
   1.203  
   1.204  void JNIid::verify(klassOop holder) {
   1.205 -  int first_field_offset  = instanceKlass::cast(holder)->offset_of_static_fields();
   1.206 +  int first_field_offset  = instanceMirrorKlass::offset_of_static_fields();
   1.207    int end_field_offset;
   1.208    end_field_offset = first_field_offset + (instanceKlass::cast(holder)->static_field_size() * wordSize);
   1.209  

mercurial