src/share/vm/ci/ciInstanceKlass.cpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6680
78bbf4d43a14
parent 0
f90c822e73f8
child 8856
ac27a9c85bea
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1999, 2014, 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 "ci/ciField.hpp"
    27 #include "ci/ciInstance.hpp"
    28 #include "ci/ciInstanceKlass.hpp"
    29 #include "ci/ciUtilities.hpp"
    30 #include "classfile/systemDictionary.hpp"
    31 #include "memory/allocation.hpp"
    32 #include "memory/allocation.inline.hpp"
    33 #include "oops/oop.inline.hpp"
    34 #include "oops/fieldStreams.hpp"
    35 #include "runtime/fieldDescriptor.hpp"
    37 // ciInstanceKlass
    38 //
    39 // This class represents a Klass* in the HotSpot virtual machine
    40 // whose Klass part in an InstanceKlass.
    42 // ------------------------------------------------------------------
    43 // ciInstanceKlass::ciInstanceKlass
    44 //
    45 // Loaded instance klass.
    46 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
    47   ciKlass(h_k), _non_static_fields(NULL)
    48 {
    49   assert(get_Klass()->oop_is_instance(), "wrong type");
    50   assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
    51   InstanceKlass* ik = get_instanceKlass();
    53   AccessFlags access_flags = ik->access_flags();
    54   _flags = ciFlags(access_flags);
    55   _has_finalizer = access_flags.has_finalizer();
    56   _has_subklass = ik->subklass() != NULL;
    57   _init_state = ik->init_state();
    58   _nonstatic_field_size = ik->nonstatic_field_size();
    59   _has_nonstatic_fields = ik->has_nonstatic_fields();
    60   _has_default_methods = ik->has_default_methods();
    61   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
    63   _implementor = NULL; // we will fill these lazily
    65   Thread *thread = Thread::current();
    66   if (ciObjectFactory::is_initialized()) {
    67     _loader = JNIHandles::make_local(thread, ik->class_loader());
    68     _protection_domain = JNIHandles::make_local(thread,
    69                                                 ik->protection_domain());
    70     _is_shared = false;
    71   } else {
    72     Handle h_loader(thread, ik->class_loader());
    73     Handle h_protection_domain(thread, ik->protection_domain());
    74     _loader = JNIHandles::make_global(h_loader);
    75     _protection_domain = JNIHandles::make_global(h_protection_domain);
    76     _is_shared = true;
    77   }
    79   // Lazy fields get filled in only upon request.
    80   _super  = NULL;
    81   _java_mirror = NULL;
    83   if (is_shared()) {
    84     if (h_k() != SystemDictionary::Object_klass()) {
    85       super();
    86     }
    87     //compute_nonstatic_fields();  // done outside of constructor
    88   }
    90   _field_cache = NULL;
    91 }
    93 // Version for unloaded classes:
    94 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
    95                                  jobject loader, jobject protection_domain)
    96   : ciKlass(name, T_OBJECT)
    97 {
    98   assert(name->byte_at(0) != '[', "not an instance klass");
    99   _init_state = (InstanceKlass::ClassState)0;
   100   _nonstatic_field_size = -1;
   101   _has_nonstatic_fields = false;
   102   _nonstatic_fields = NULL;
   103   _loader = loader;
   104   _protection_domain = protection_domain;
   105   _is_shared = false;
   106   _super = NULL;
   107   _java_mirror = NULL;
   108   _field_cache = NULL;
   109 }
   113 // ------------------------------------------------------------------
   114 // ciInstanceKlass::compute_shared_is_initialized
   115 void ciInstanceKlass::compute_shared_init_state() {
   116   GUARDED_VM_ENTRY(
   117     InstanceKlass* ik = get_instanceKlass();
   118     _init_state = ik->init_state();
   119   )
   120 }
   122 // ------------------------------------------------------------------
   123 // ciInstanceKlass::compute_shared_has_subklass
   124 bool ciInstanceKlass::compute_shared_has_subklass() {
   125   GUARDED_VM_ENTRY(
   126     InstanceKlass* ik = get_instanceKlass();
   127     _has_subklass = ik->subklass() != NULL;
   128     return _has_subklass;
   129   )
   130 }
   132 // ------------------------------------------------------------------
   133 // ciInstanceKlass::loader
   134 oop ciInstanceKlass::loader() {
   135   ASSERT_IN_VM;
   136   return JNIHandles::resolve(_loader);
   137 }
   139 // ------------------------------------------------------------------
   140 // ciInstanceKlass::loader_handle
   141 jobject ciInstanceKlass::loader_handle() {
   142   return _loader;
   143 }
   145 // ------------------------------------------------------------------
   146 // ciInstanceKlass::protection_domain
   147 oop ciInstanceKlass::protection_domain() {
   148   ASSERT_IN_VM;
   149   return JNIHandles::resolve(_protection_domain);
   150 }
   152 // ------------------------------------------------------------------
   153 // ciInstanceKlass::protection_domain_handle
   154 jobject ciInstanceKlass::protection_domain_handle() {
   155   return _protection_domain;
   156 }
   158 // ------------------------------------------------------------------
   159 // ciInstanceKlass::field_cache
   160 //
   161 // Get the field cache associated with this klass.
   162 ciConstantPoolCache* ciInstanceKlass::field_cache() {
   163   if (is_shared()) {
   164     return NULL;
   165   }
   166   if (_field_cache == NULL) {
   167     assert(!is_java_lang_Object(), "Object has no fields");
   168     Arena* arena = CURRENT_ENV->arena();
   169     _field_cache = new (arena) ciConstantPoolCache(arena, 5);
   170   }
   171   return _field_cache;
   172 }
   174 // ------------------------------------------------------------------
   175 // ciInstanceKlass::get_canonical_holder
   176 //
   177 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
   178   #ifdef ASSERT
   179   if (!(offset >= 0 && offset < layout_helper())) {
   180     tty->print("*** get_canonical_holder(%d) on ", offset);
   181     this->print();
   182     tty->print_cr(" ***");
   183   };
   184   assert(offset >= 0 && offset < layout_helper(), "offset must be tame");
   185   #endif
   187   if (offset < instanceOopDesc::base_offset_in_bytes()) {
   188     // All header offsets belong properly to java/lang/Object.
   189     return CURRENT_ENV->Object_klass();
   190   }
   192   ciInstanceKlass* self = this;
   193   for (;;) {
   194     assert(self->is_loaded(), "must be loaded to have size");
   195     ciInstanceKlass* super = self->super();
   196     if (super == NULL || super->nof_nonstatic_fields() == 0 ||
   197         !super->contains_field_offset(offset)) {
   198       return self;
   199     } else {
   200       self = super;  // return super->get_canonical_holder(offset)
   201     }
   202   }
   203 }
   205 // ------------------------------------------------------------------
   206 // ciInstanceKlass::is_java_lang_Object
   207 //
   208 // Is this klass java.lang.Object?
   209 bool ciInstanceKlass::is_java_lang_Object() const {
   210   return equals(CURRENT_ENV->Object_klass());
   211 }
   213 // ------------------------------------------------------------------
   214 // ciInstanceKlass::uses_default_loader
   215 bool ciInstanceKlass::uses_default_loader() const {
   216   // Note:  We do not need to resolve the handle or enter the VM
   217   // in order to test null-ness.
   218   return _loader == NULL;
   219 }
   221 // ------------------------------------------------------------------
   223 /**
   224  * Return basic type of boxed value for box klass or T_OBJECT if not.
   225  */
   226 BasicType ciInstanceKlass::box_klass_type() const {
   227   if (uses_default_loader() && is_loaded()) {
   228     return SystemDictionary::box_klass_type(get_Klass());
   229   } else {
   230     return T_OBJECT;
   231   }
   232 }
   234 /**
   235  * Is this boxing klass?
   236  */
   237 bool ciInstanceKlass::is_box_klass() const {
   238   return is_java_primitive(box_klass_type());
   239 }
   241 /**
   242  *  Is this boxed value offset?
   243  */
   244 bool ciInstanceKlass::is_boxed_value_offset(int offset) const {
   245   BasicType bt = box_klass_type();
   246   return is_java_primitive(bt) &&
   247          (offset == java_lang_boxing_object::value_offset_in_bytes(bt));
   248 }
   250 // ------------------------------------------------------------------
   251 // ciInstanceKlass::is_in_package
   252 //
   253 // Is this klass in the given package?
   254 bool ciInstanceKlass::is_in_package(const char* packagename, int len) {
   255   // To avoid class loader mischief, this test always rejects application classes.
   256   if (!uses_default_loader())
   257     return false;
   258   GUARDED_VM_ENTRY(
   259     return is_in_package_impl(packagename, len);
   260   )
   261 }
   263 bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) {
   264   ASSERT_IN_VM;
   266   // If packagename contains trailing '/' exclude it from the
   267   // prefix-test since we test for it explicitly.
   268   if (packagename[len - 1] == '/')
   269     len--;
   271   if (!name()->starts_with(packagename, len))
   272     return false;
   274   // Test if the class name is something like "java/lang".
   275   if ((len + 1) > name()->utf8_length())
   276     return false;
   278   // Test for trailing '/'
   279   if ((char) name()->byte_at(len) != '/')
   280     return false;
   282   // Make sure it's not actually in a subpackage:
   283   if (name()->index_of_at(len+1, "/", 1) >= 0)
   284     return false;
   286   return true;
   287 }
   289 // ------------------------------------------------------------------
   290 // ciInstanceKlass::print_impl
   291 //
   292 // Implementation of the print method.
   293 void ciInstanceKlass::print_impl(outputStream* st) {
   294   ciKlass::print_impl(st);
   295   GUARDED_VM_ENTRY(st->print(" loader=" INTPTR_FORMAT, p2i((address)loader()));)
   296   if (is_loaded()) {
   297     st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=",
   298               bool_to_str(is_initialized()),
   299               bool_to_str(has_finalizer()),
   300               bool_to_str(has_subklass()),
   301               layout_helper());
   303     _flags.print_klass_flags();
   305     if (_super) {
   306       st->print(" super=");
   307       _super->print_name();
   308     }
   309     if (_java_mirror) {
   310       st->print(" mirror=PRESENT");
   311     }
   312   } else {
   313     st->print(" loaded=false");
   314   }
   315 }
   317 // ------------------------------------------------------------------
   318 // ciInstanceKlass::super
   319 //
   320 // Get the superklass of this klass.
   321 ciInstanceKlass* ciInstanceKlass::super() {
   322   assert(is_loaded(), "must be loaded");
   323   if (_super == NULL && !is_java_lang_Object()) {
   324     GUARDED_VM_ENTRY(
   325       Klass* super_klass = get_instanceKlass()->super();
   326       _super = CURRENT_ENV->get_instance_klass(super_klass);
   327     )
   328   }
   329   return _super;
   330 }
   332 // ------------------------------------------------------------------
   333 // ciInstanceKlass::java_mirror
   334 //
   335 // Get the instance of java.lang.Class corresponding to this klass.
   336 // Cache it on this->_java_mirror.
   337 ciInstance* ciInstanceKlass::java_mirror() {
   338   if (is_shared()) {
   339     return ciKlass::java_mirror();
   340   }
   341   if (_java_mirror == NULL) {
   342     _java_mirror = ciKlass::java_mirror();
   343   }
   344   return _java_mirror;
   345 }
   347 // ------------------------------------------------------------------
   348 // ciInstanceKlass::unique_concrete_subklass
   349 ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() {
   350   if (!is_loaded())     return NULL; // No change if class is not loaded
   351   if (!is_abstract())   return NULL; // Only applies to abstract classes.
   352   if (!has_subklass())  return NULL; // Must have at least one subklass.
   353   VM_ENTRY_MARK;
   354   InstanceKlass* ik = get_instanceKlass();
   355   Klass* up = ik->up_cast_abstract();
   356   assert(up->oop_is_instance(), "must be InstanceKlass");
   357   if (ik == up) {
   358     return NULL;
   359   }
   360   return CURRENT_THREAD_ENV->get_instance_klass(up);
   361 }
   363 // ------------------------------------------------------------------
   364 // ciInstanceKlass::has_finalizable_subclass
   365 bool ciInstanceKlass::has_finalizable_subclass() {
   366   if (!is_loaded())     return true;
   367   VM_ENTRY_MARK;
   368   return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL;
   369 }
   371 // ------------------------------------------------------------------
   372 // ciInstanceKlass::get_field_by_offset
   373 ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) {
   374   if (!is_static) {
   375     for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) {
   376       ciField* field = _nonstatic_fields->at(i);
   377       int  field_off = field->offset_in_bytes();
   378       if (field_off == field_offset)
   379         return field;
   380       if (field_off > field_offset)
   381         break;
   382       // could do binary search or check bins, but probably not worth it
   383     }
   384     return NULL;
   385   }
   386   VM_ENTRY_MARK;
   387   InstanceKlass* k = get_instanceKlass();
   388   fieldDescriptor fd;
   389   if (!k->find_field_from_offset(field_offset, is_static, &fd)) {
   390     return NULL;
   391   }
   392   ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd);
   393   return field;
   394 }
   396 // ------------------------------------------------------------------
   397 // ciInstanceKlass::get_field_by_name
   398 ciField* ciInstanceKlass::get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static) {
   399   VM_ENTRY_MARK;
   400   InstanceKlass* k = get_instanceKlass();
   401   fieldDescriptor fd;
   402   Klass* def = k->find_field(name->get_symbol(), signature->get_symbol(), is_static, &fd);
   403   if (def == NULL) {
   404     return NULL;
   405   }
   406   ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd);
   407   return field;
   408 }
   410 // ------------------------------------------------------------------
   411 // ciInstanceKlass::non_static_fields.
   413 class NonStaticFieldFiller: public FieldClosure {
   414   GrowableArray<ciField*>* _arr;
   415   ciEnv* _curEnv;
   416 public:
   417   NonStaticFieldFiller(ciEnv* curEnv, GrowableArray<ciField*>* arr) :
   418     _curEnv(curEnv), _arr(arr)
   419   {}
   420   void do_field(fieldDescriptor* fd) {
   421     ciField* field = new (_curEnv->arena()) ciField(fd);
   422     _arr->append(field);
   423   }
   424 };
   426 GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() {
   427   if (_non_static_fields == NULL) {
   428     VM_ENTRY_MARK;
   429     ciEnv* curEnv = ciEnv::current();
   430     InstanceKlass* ik = get_instanceKlass();
   431     int max_n_fields = ik->java_fields_count();
   433     Arena* arena = curEnv->arena();
   434     _non_static_fields =
   435       new (arena) GrowableArray<ciField*>(arena, max_n_fields, 0, NULL);
   436     NonStaticFieldFiller filler(curEnv, _non_static_fields);
   437     ik->do_nonstatic_fields(&filler);
   438   }
   439   return _non_static_fields;
   440 }
   442 static int sort_field_by_offset(ciField** a, ciField** b) {
   443   return (*a)->offset_in_bytes() - (*b)->offset_in_bytes();
   444   // (no worries about 32-bit overflow...)
   445 }
   447 // ------------------------------------------------------------------
   448 // ciInstanceKlass::compute_nonstatic_fields
   449 int ciInstanceKlass::compute_nonstatic_fields() {
   450   assert(is_loaded(), "must be loaded");
   452   if (_nonstatic_fields != NULL)
   453     return _nonstatic_fields->length();
   455   if (!has_nonstatic_fields()) {
   456     Arena* arena = CURRENT_ENV->arena();
   457     _nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL);
   458     return 0;
   459   }
   460   assert(!is_java_lang_Object(), "bootstrap OK");
   462   // Size in bytes of my fields, including inherited fields.
   463   int fsize = nonstatic_field_size() * heapOopSize;
   465   ciInstanceKlass* super = this->super();
   466   GrowableArray<ciField*>* super_fields = NULL;
   467   if (super != NULL && super->has_nonstatic_fields()) {
   468     int super_fsize  = super->nonstatic_field_size() * heapOopSize;
   469     int super_flen   = super->nof_nonstatic_fields();
   470     super_fields = super->_nonstatic_fields;
   471     assert(super_flen == 0 || super_fields != NULL, "first get nof_fields");
   472     // See if I am no larger than my super; if so, I can use his fields.
   473     if (fsize == super_fsize) {
   474       _nonstatic_fields = super_fields;
   475       return super_fields->length();
   476     }
   477   }
   479   GrowableArray<ciField*>* fields = NULL;
   480   GUARDED_VM_ENTRY({
   481       fields = compute_nonstatic_fields_impl(super_fields);
   482     });
   484   if (fields == NULL) {
   485     // This can happen if this class (java.lang.Class) has invisible fields.
   486     _nonstatic_fields = super_fields;
   487     return super_fields->length();
   488   }
   490   int flen = fields->length();
   492   // Now sort them by offset, ascending.
   493   // (In principle, they could mix with superclass fields.)
   494   fields->sort(sort_field_by_offset);
   495   _nonstatic_fields = fields;
   496   return flen;
   497 }
   499 GrowableArray<ciField*>*
   500 ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>*
   501                                                super_fields) {
   502   ASSERT_IN_VM;
   503   Arena* arena = CURRENT_ENV->arena();
   504   int flen = 0;
   505   GrowableArray<ciField*>* fields = NULL;
   506   InstanceKlass* k = get_instanceKlass();
   507   for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
   508     if (fs.access_flags().is_static())  continue;
   509     flen += 1;
   510   }
   512   // allocate the array:
   513   if (flen == 0) {
   514     return NULL;  // return nothing if none are locally declared
   515   }
   516   if (super_fields != NULL) {
   517     flen += super_fields->length();
   518   }
   519   fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
   520   if (super_fields != NULL) {
   521     fields->appendAll(super_fields);
   522   }
   524   for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
   525     if (fs.access_flags().is_static())  continue;
   526     fieldDescriptor& fd = fs.field_descriptor();
   527     ciField* field = new (arena) ciField(&fd);
   528     fields->append(field);
   529   }
   530   assert(fields->length() == flen, "sanity");
   531   return fields;
   532 }
   534 // ------------------------------------------------------------------
   535 // ciInstanceKlass::find_method
   536 //
   537 // Find a method in this klass.
   538 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
   539   VM_ENTRY_MARK;
   540   InstanceKlass* k = get_instanceKlass();
   541   Symbol* name_sym = name->get_symbol();
   542   Symbol* sig_sym= signature->get_symbol();
   544   Method* m = k->find_method(name_sym, sig_sym);
   545   if (m == NULL)  return NULL;
   547   return CURRENT_THREAD_ENV->get_method(m);
   548 }
   550 // ------------------------------------------------------------------
   551 // ciInstanceKlass::is_leaf_type
   552 bool ciInstanceKlass::is_leaf_type() {
   553   assert(is_loaded(), "must be loaded");
   554   if (is_shared()) {
   555     return is_final();  // approximately correct
   556   } else {
   557     return !_has_subklass && (nof_implementors() == 0);
   558   }
   559 }
   561 // ------------------------------------------------------------------
   562 // ciInstanceKlass::implementor
   563 //
   564 // Report an implementor of this interface.
   565 // Note that there are various races here, since my copy
   566 // of _nof_implementors might be out of date with respect
   567 // to results returned by InstanceKlass::implementor.
   568 // This is OK, since any dependencies we decide to assert
   569 // will be checked later under the Compile_lock.
   570 ciInstanceKlass* ciInstanceKlass::implementor() {
   571   ciInstanceKlass* impl = _implementor;
   572   if (impl == NULL) {
   573     // Go into the VM to fetch the implementor.
   574     {
   575       VM_ENTRY_MARK;
   576       Klass* k = get_instanceKlass()->implementor();
   577       if (k != NULL) {
   578         if (k == get_instanceKlass()) {
   579           // More than one implementors. Use 'this' in this case.
   580           impl = this;
   581         } else {
   582           impl = CURRENT_THREAD_ENV->get_instance_klass(k);
   583         }
   584       }
   585     }
   586     // Memoize this result.
   587     if (!is_shared()) {
   588       _implementor = impl;
   589     }
   590   }
   591   return impl;
   592 }
   594 // Utility class for printing of the contents of the static fields for
   595 // use by compilation replay.  It only prints out the information that
   596 // could be consumed by the compiler, so for primitive types it prints
   597 // out the actual value.  For Strings it's the actual string value.
   598 // For array types it it's first level array size since that's the
   599 // only value which statically unchangeable.  For all other reference
   600 // types it simply prints out the dynamic type.
   602 class StaticFinalFieldPrinter : public FieldClosure {
   603   outputStream* _out;
   604   const char*   _holder;
   605  public:
   606   StaticFinalFieldPrinter(outputStream* out, const char* holder) :
   607     _out(out),
   608     _holder(holder) {
   609   }
   610   void do_field(fieldDescriptor* fd) {
   611     if (fd->is_final() && !fd->has_initial_value()) {
   612       ResourceMark rm;
   613       oop mirror = fd->field_holder()->java_mirror();
   614       _out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii());
   615       switch (fd->field_type()) {
   616         case T_BYTE:    _out->print_cr("%d", mirror->byte_field(fd->offset()));   break;
   617         case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset()));   break;
   618         case T_SHORT:   _out->print_cr("%d", mirror->short_field(fd->offset()));  break;
   619         case T_CHAR:    _out->print_cr("%d", mirror->char_field(fd->offset()));   break;
   620         case T_INT:     _out->print_cr("%d", mirror->int_field(fd->offset()));    break;
   621         case T_LONG:    _out->print_cr(INT64_FORMAT, (int64_t)(mirror->long_field(fd->offset())));   break;
   622         case T_FLOAT: {
   623           float f = mirror->float_field(fd->offset());
   624           _out->print_cr("%d", *(int*)&f);
   625           break;
   626         }
   627         case T_DOUBLE: {
   628           double d = mirror->double_field(fd->offset());
   629           _out->print_cr(INT64_FORMAT, *(int64_t*)&d);
   630           break;
   631         }
   632         case T_ARRAY: {
   633           oop value =  mirror->obj_field_acquire(fd->offset());
   634           if (value == NULL) {
   635             _out->print_cr("null");
   636           } else {
   637             typeArrayOop ta = (typeArrayOop)value;
   638             _out->print("%d", ta->length());
   639             if (value->is_objArray()) {
   640               objArrayOop oa = (objArrayOop)value;
   641               const char* klass_name  = value->klass()->name()->as_quoted_ascii();
   642               _out->print(" %s", klass_name);
   643             }
   644             _out->cr();
   645           }
   646           break;
   647         }
   648         case T_OBJECT: {
   649           oop value =  mirror->obj_field_acquire(fd->offset());
   650           if (value == NULL) {
   651             _out->print_cr("null");
   652           } else if (value->is_instance()) {
   653             if (value->is_a(SystemDictionary::String_klass())) {
   654               _out->print("\"");
   655               _out->print_raw(java_lang_String::as_quoted_ascii(value));
   656               _out->print_cr("\"");
   657             } else {
   658               const char* klass_name  = value->klass()->name()->as_quoted_ascii();
   659               _out->print_cr("%s", klass_name);
   660             }
   661           } else {
   662             ShouldNotReachHere();
   663           }
   664           break;
   665         }
   666         default:
   667           ShouldNotReachHere();
   668         }
   669     }
   670   }
   671 };
   674 void ciInstanceKlass::dump_replay_data(outputStream* out) {
   675   ResourceMark rm;
   677   InstanceKlass* ik = get_instanceKlass();
   678   ConstantPool*  cp = ik->constants();
   680   // Try to record related loaded classes
   681   Klass* sub = ik->subklass();
   682   while (sub != NULL) {
   683     if (sub->oop_is_instance()) {
   684       out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii());
   685     }
   686     sub = sub->next_sibling();
   687   }
   689   // Dump out the state of the constant pool tags.  During replay the
   690   // tags will be validated for things which shouldn't change and
   691   // classes will be resolved if the tags indicate that they were
   692   // resolved at compile time.
   693   out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(),
   694              is_linked(), is_initialized(), cp->length());
   695   for (int index = 1; index < cp->length(); index++) {
   696     out->print(" %d", cp->tags()->at(index));
   697   }
   698   out->cr();
   699   if (is_initialized()) {
   700     //  Dump out the static final fields in case the compilation relies
   701     //  on their value for correct replay.
   702     StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii());
   703     ik->do_local_static_fields(&sffp);
   704   }
   705 }

mercurial