src/share/vm/ci/ciInstanceKlass.cpp

Fri, 13 Sep 2013 22:38:02 -0400

author
drchase
date
Fri, 13 Sep 2013 22:38:02 -0400
changeset 5732
b2e698d2276c
parent 5110
6f3fd5150b67
child 5904
5cc2d82aa82a
permissions
-rw-r--r--

8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
Summary: Enhance method resolution and resulting data structures, plus some refactoring.
Reviewed-by: twisti, acorn, jrose

     1 /*
     2  * Copyright (c) 1999, 2013, 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   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
    62   _implementor = NULL; // we will fill these lazily
    64   Thread *thread = Thread::current();
    65   if (ciObjectFactory::is_initialized()) {
    66     _loader = JNIHandles::make_local(thread, ik->class_loader());
    67     _protection_domain = JNIHandles::make_local(thread,
    68                                                 ik->protection_domain());
    69     _is_shared = false;
    70   } else {
    71     Handle h_loader(thread, ik->class_loader());
    72     Handle h_protection_domain(thread, ik->protection_domain());
    73     _loader = JNIHandles::make_global(h_loader);
    74     _protection_domain = JNIHandles::make_global(h_protection_domain);
    75     _is_shared = true;
    76   }
    78   // Lazy fields get filled in only upon request.
    79   _super  = NULL;
    80   _java_mirror = NULL;
    82   if (is_shared()) {
    83     if (h_k() != SystemDictionary::Object_klass()) {
    84       super();
    85     }
    86     //compute_nonstatic_fields();  // done outside of constructor
    87   }
    89   _field_cache = NULL;
    90 }
    92 // Version for unloaded classes:
    93 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
    94                                  jobject loader, jobject protection_domain)
    95   : ciKlass(name, T_OBJECT)
    96 {
    97   assert(name->byte_at(0) != '[', "not an instance klass");
    98   _init_state = (InstanceKlass::ClassState)0;
    99   _nonstatic_field_size = -1;
   100   _has_nonstatic_fields = false;
   101   _nonstatic_fields = NULL;
   102   _loader = loader;
   103   _protection_domain = protection_domain;
   104   _is_shared = false;
   105   _super = NULL;
   106   _java_mirror = NULL;
   107   _field_cache = NULL;
   108 }
   112 // ------------------------------------------------------------------
   113 // ciInstanceKlass::compute_shared_is_initialized
   114 void ciInstanceKlass::compute_shared_init_state() {
   115   GUARDED_VM_ENTRY(
   116     InstanceKlass* ik = get_instanceKlass();
   117     _init_state = ik->init_state();
   118   )
   119 }
   121 // ------------------------------------------------------------------
   122 // ciInstanceKlass::compute_shared_has_subklass
   123 bool ciInstanceKlass::compute_shared_has_subklass() {
   124   GUARDED_VM_ENTRY(
   125     InstanceKlass* ik = get_instanceKlass();
   126     _has_subklass = ik->subklass() != NULL;
   127     return _has_subklass;
   128   )
   129 }
   131 // ------------------------------------------------------------------
   132 // ciInstanceKlass::loader
   133 oop ciInstanceKlass::loader() {
   134   ASSERT_IN_VM;
   135   return JNIHandles::resolve(_loader);
   136 }
   138 // ------------------------------------------------------------------
   139 // ciInstanceKlass::loader_handle
   140 jobject ciInstanceKlass::loader_handle() {
   141   return _loader;
   142 }
   144 // ------------------------------------------------------------------
   145 // ciInstanceKlass::protection_domain
   146 oop ciInstanceKlass::protection_domain() {
   147   ASSERT_IN_VM;
   148   return JNIHandles::resolve(_protection_domain);
   149 }
   151 // ------------------------------------------------------------------
   152 // ciInstanceKlass::protection_domain_handle
   153 jobject ciInstanceKlass::protection_domain_handle() {
   154   return _protection_domain;
   155 }
   157 // ------------------------------------------------------------------
   158 // ciInstanceKlass::field_cache
   159 //
   160 // Get the field cache associated with this klass.
   161 ciConstantPoolCache* ciInstanceKlass::field_cache() {
   162   if (is_shared()) {
   163     return NULL;
   164   }
   165   if (_field_cache == NULL) {
   166     assert(!is_java_lang_Object(), "Object has no fields");
   167     Arena* arena = CURRENT_ENV->arena();
   168     _field_cache = new (arena) ciConstantPoolCache(arena, 5);
   169   }
   170   return _field_cache;
   171 }
   173 // ------------------------------------------------------------------
   174 // ciInstanceKlass::get_canonical_holder
   175 //
   176 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
   177   #ifdef ASSERT
   178   if (!(offset >= 0 && offset < layout_helper())) {
   179     tty->print("*** get_canonical_holder(%d) on ", offset);
   180     this->print();
   181     tty->print_cr(" ***");
   182   };
   183   assert(offset >= 0 && offset < layout_helper(), "offset must be tame");
   184   #endif
   186   if (offset < instanceOopDesc::base_offset_in_bytes()) {
   187     // All header offsets belong properly to java/lang/Object.
   188     return CURRENT_ENV->Object_klass();
   189   }
   191   ciInstanceKlass* self = this;
   192   for (;;) {
   193     assert(self->is_loaded(), "must be loaded to have size");
   194     ciInstanceKlass* super = self->super();
   195     if (super == NULL || super->nof_nonstatic_fields() == 0 ||
   196         !super->contains_field_offset(offset)) {
   197       return self;
   198     } else {
   199       self = super;  // return super->get_canonical_holder(offset)
   200     }
   201   }
   202 }
   204 // ------------------------------------------------------------------
   205 // ciInstanceKlass::is_java_lang_Object
   206 //
   207 // Is this klass java.lang.Object?
   208 bool ciInstanceKlass::is_java_lang_Object() const {
   209   return equals(CURRENT_ENV->Object_klass());
   210 }
   212 // ------------------------------------------------------------------
   213 // ciInstanceKlass::uses_default_loader
   214 bool ciInstanceKlass::uses_default_loader() const {
   215   // Note:  We do not need to resolve the handle or enter the VM
   216   // in order to test null-ness.
   217   return _loader == NULL;
   218 }
   220 // ------------------------------------------------------------------
   222 /**
   223  * Return basic type of boxed value for box klass or T_OBJECT if not.
   224  */
   225 BasicType ciInstanceKlass::box_klass_type() const {
   226   if (uses_default_loader() && is_loaded()) {
   227     return SystemDictionary::box_klass_type(get_Klass());
   228   } else {
   229     return T_OBJECT;
   230   }
   231 }
   233 /**
   234  * Is this boxing klass?
   235  */
   236 bool ciInstanceKlass::is_box_klass() const {
   237   return is_java_primitive(box_klass_type());
   238 }
   240 /**
   241  *  Is this boxed value offset?
   242  */
   243 bool ciInstanceKlass::is_boxed_value_offset(int offset) const {
   244   BasicType bt = box_klass_type();
   245   return is_java_primitive(bt) &&
   246          (offset == java_lang_boxing_object::value_offset_in_bytes(bt));
   247 }
   249 // ------------------------------------------------------------------
   250 // ciInstanceKlass::is_in_package
   251 //
   252 // Is this klass in the given package?
   253 bool ciInstanceKlass::is_in_package(const char* packagename, int len) {
   254   // To avoid class loader mischief, this test always rejects application classes.
   255   if (!uses_default_loader())
   256     return false;
   257   GUARDED_VM_ENTRY(
   258     return is_in_package_impl(packagename, len);
   259   )
   260 }
   262 bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) {
   263   ASSERT_IN_VM;
   265   // If packagename contains trailing '/' exclude it from the
   266   // prefix-test since we test for it explicitly.
   267   if (packagename[len - 1] == '/')
   268     len--;
   270   if (!name()->starts_with(packagename, len))
   271     return false;
   273   // Test if the class name is something like "java/lang".
   274   if ((len + 1) > name()->utf8_length())
   275     return false;
   277   // Test for trailing '/'
   278   if ((char) name()->byte_at(len) != '/')
   279     return false;
   281   // Make sure it's not actually in a subpackage:
   282   if (name()->index_of_at(len+1, "/", 1) >= 0)
   283     return false;
   285   return true;
   286 }
   288 // ------------------------------------------------------------------
   289 // ciInstanceKlass::print_impl
   290 //
   291 // Implementation of the print method.
   292 void ciInstanceKlass::print_impl(outputStream* st) {
   293   ciKlass::print_impl(st);
   294   GUARDED_VM_ENTRY(st->print(" loader=0x%x", (address)loader());)
   295   if (is_loaded()) {
   296     st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=",
   297               bool_to_str(is_initialized()),
   298               bool_to_str(has_finalizer()),
   299               bool_to_str(has_subklass()),
   300               layout_helper());
   302     _flags.print_klass_flags();
   304     if (_super) {
   305       st->print(" super=");
   306       _super->print_name();
   307     }
   308     if (_java_mirror) {
   309       st->print(" mirror=PRESENT");
   310     }
   311   } else {
   312     st->print(" loaded=false");
   313   }
   314 }
   316 // ------------------------------------------------------------------
   317 // ciInstanceKlass::super
   318 //
   319 // Get the superklass of this klass.
   320 ciInstanceKlass* ciInstanceKlass::super() {
   321   assert(is_loaded(), "must be loaded");
   322   if (_super == NULL && !is_java_lang_Object()) {
   323     GUARDED_VM_ENTRY(
   324       Klass* super_klass = get_instanceKlass()->super();
   325       _super = CURRENT_ENV->get_instance_klass(super_klass);
   326     )
   327   }
   328   return _super;
   329 }
   331 // ------------------------------------------------------------------
   332 // ciInstanceKlass::java_mirror
   333 //
   334 // Get the instance of java.lang.Class corresponding to this klass.
   335 // Cache it on this->_java_mirror.
   336 ciInstance* ciInstanceKlass::java_mirror() {
   337   if (is_shared()) {
   338     return ciKlass::java_mirror();
   339   }
   340   if (_java_mirror == NULL) {
   341     _java_mirror = ciKlass::java_mirror();
   342   }
   343   return _java_mirror;
   344 }
   346 // ------------------------------------------------------------------
   347 // ciInstanceKlass::unique_concrete_subklass
   348 ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() {
   349   if (!is_loaded())     return NULL; // No change if class is not loaded
   350   if (!is_abstract())   return NULL; // Only applies to abstract classes.
   351   if (!has_subklass())  return NULL; // Must have at least one subklass.
   352   VM_ENTRY_MARK;
   353   InstanceKlass* ik = get_instanceKlass();
   354   Klass* up = ik->up_cast_abstract();
   355   assert(up->oop_is_instance(), "must be InstanceKlass");
   356   if (ik == up) {
   357     return NULL;
   358   }
   359   return CURRENT_THREAD_ENV->get_instance_klass(up);
   360 }
   362 // ------------------------------------------------------------------
   363 // ciInstanceKlass::has_finalizable_subclass
   364 bool ciInstanceKlass::has_finalizable_subclass() {
   365   if (!is_loaded())     return true;
   366   VM_ENTRY_MARK;
   367   return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL;
   368 }
   370 // ------------------------------------------------------------------
   371 // ciInstanceKlass::get_field_by_offset
   372 ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) {
   373   if (!is_static) {
   374     for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) {
   375       ciField* field = _nonstatic_fields->at(i);
   376       int  field_off = field->offset_in_bytes();
   377       if (field_off == field_offset)
   378         return field;
   379       if (field_off > field_offset)
   380         break;
   381       // could do binary search or check bins, but probably not worth it
   382     }
   383     return NULL;
   384   }
   385   VM_ENTRY_MARK;
   386   InstanceKlass* k = get_instanceKlass();
   387   fieldDescriptor fd;
   388   if (!k->find_field_from_offset(field_offset, is_static, &fd)) {
   389     return NULL;
   390   }
   391   ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd);
   392   return field;
   393 }
   395 // ------------------------------------------------------------------
   396 // ciInstanceKlass::get_field_by_name
   397 ciField* ciInstanceKlass::get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static) {
   398   VM_ENTRY_MARK;
   399   InstanceKlass* k = get_instanceKlass();
   400   fieldDescriptor fd;
   401   Klass* def = k->find_field(name->get_symbol(), signature->get_symbol(), is_static, &fd);
   402   if (def == NULL) {
   403     return NULL;
   404   }
   405   ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd);
   406   return field;
   407 }
   409 // ------------------------------------------------------------------
   410 // ciInstanceKlass::non_static_fields.
   412 class NonStaticFieldFiller: public FieldClosure {
   413   GrowableArray<ciField*>* _arr;
   414   ciEnv* _curEnv;
   415 public:
   416   NonStaticFieldFiller(ciEnv* curEnv, GrowableArray<ciField*>* arr) :
   417     _curEnv(curEnv), _arr(arr)
   418   {}
   419   void do_field(fieldDescriptor* fd) {
   420     ciField* field = new (_curEnv->arena()) ciField(fd);
   421     _arr->append(field);
   422   }
   423 };
   425 GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() {
   426   if (_non_static_fields == NULL) {
   427     VM_ENTRY_MARK;
   428     ciEnv* curEnv = ciEnv::current();
   429     InstanceKlass* ik = get_instanceKlass();
   430     int max_n_fields = ik->java_fields_count();
   432     Arena* arena = curEnv->arena();
   433     _non_static_fields =
   434       new (arena) GrowableArray<ciField*>(arena, max_n_fields, 0, NULL);
   435     NonStaticFieldFiller filler(curEnv, _non_static_fields);
   436     ik->do_nonstatic_fields(&filler);
   437   }
   438   return _non_static_fields;
   439 }
   441 static int sort_field_by_offset(ciField** a, ciField** b) {
   442   return (*a)->offset_in_bytes() - (*b)->offset_in_bytes();
   443   // (no worries about 32-bit overflow...)
   444 }
   446 // ------------------------------------------------------------------
   447 // ciInstanceKlass::compute_nonstatic_fields
   448 int ciInstanceKlass::compute_nonstatic_fields() {
   449   assert(is_loaded(), "must be loaded");
   451   if (_nonstatic_fields != NULL)
   452     return _nonstatic_fields->length();
   454   if (!has_nonstatic_fields()) {
   455     Arena* arena = CURRENT_ENV->arena();
   456     _nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL);
   457     return 0;
   458   }
   459   assert(!is_java_lang_Object(), "bootstrap OK");
   461   // Size in bytes of my fields, including inherited fields.
   462   int fsize = nonstatic_field_size() * heapOopSize;
   464   ciInstanceKlass* super = this->super();
   465   GrowableArray<ciField*>* super_fields = NULL;
   466   if (super != NULL && super->has_nonstatic_fields()) {
   467     int super_fsize  = super->nonstatic_field_size() * heapOopSize;
   468     int super_flen   = super->nof_nonstatic_fields();
   469     super_fields = super->_nonstatic_fields;
   470     assert(super_flen == 0 || super_fields != NULL, "first get nof_fields");
   471     // See if I am no larger than my super; if so, I can use his fields.
   472     if (fsize == super_fsize) {
   473       _nonstatic_fields = super_fields;
   474       return super_fields->length();
   475     }
   476   }
   478   GrowableArray<ciField*>* fields = NULL;
   479   GUARDED_VM_ENTRY({
   480       fields = compute_nonstatic_fields_impl(super_fields);
   481     });
   483   if (fields == NULL) {
   484     // This can happen if this class (java.lang.Class) has invisible fields.
   485     _nonstatic_fields = super_fields;
   486     return super_fields->length();
   487   }
   489   int flen = fields->length();
   491   // Now sort them by offset, ascending.
   492   // (In principle, they could mix with superclass fields.)
   493   fields->sort(sort_field_by_offset);
   494   _nonstatic_fields = fields;
   495   return flen;
   496 }
   498 GrowableArray<ciField*>*
   499 ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>*
   500                                                super_fields) {
   501   ASSERT_IN_VM;
   502   Arena* arena = CURRENT_ENV->arena();
   503   int flen = 0;
   504   GrowableArray<ciField*>* fields = NULL;
   505   InstanceKlass* k = get_instanceKlass();
   506   for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
   507     if (fs.access_flags().is_static())  continue;
   508     flen += 1;
   509   }
   511   // allocate the array:
   512   if (flen == 0) {
   513     return NULL;  // return nothing if none are locally declared
   514   }
   515   if (super_fields != NULL) {
   516     flen += super_fields->length();
   517   }
   518   fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
   519   if (super_fields != NULL) {
   520     fields->appendAll(super_fields);
   521   }
   523   for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
   524     if (fs.access_flags().is_static())  continue;
   525     fieldDescriptor& fd = fs.field_descriptor();
   526     ciField* field = new (arena) ciField(&fd);
   527     fields->append(field);
   528   }
   529   assert(fields->length() == flen, "sanity");
   530   return fields;
   531 }
   533 // ------------------------------------------------------------------
   534 // ciInstanceKlass::find_method
   535 //
   536 // Find a method in this klass.
   537 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
   538   VM_ENTRY_MARK;
   539   InstanceKlass* k = get_instanceKlass();
   540   Symbol* name_sym = name->get_symbol();
   541   Symbol* sig_sym= signature->get_symbol();
   543   Method* m = k->find_method(name_sym, sig_sym);
   544   if (m == NULL)  return NULL;
   546   return CURRENT_THREAD_ENV->get_method(m);
   547 }
   549 // ------------------------------------------------------------------
   550 // ciInstanceKlass::is_leaf_type
   551 bool ciInstanceKlass::is_leaf_type() {
   552   assert(is_loaded(), "must be loaded");
   553   if (is_shared()) {
   554     return is_final();  // approximately correct
   555   } else {
   556     return !_has_subklass && (nof_implementors() == 0);
   557   }
   558 }
   560 // ------------------------------------------------------------------
   561 // ciInstanceKlass::implementor
   562 //
   563 // Report an implementor of this interface.
   564 // Note that there are various races here, since my copy
   565 // of _nof_implementors might be out of date with respect
   566 // to results returned by InstanceKlass::implementor.
   567 // This is OK, since any dependencies we decide to assert
   568 // will be checked later under the Compile_lock.
   569 ciInstanceKlass* ciInstanceKlass::implementor() {
   570   ciInstanceKlass* impl = _implementor;
   571   if (impl == NULL) {
   572     // Go into the VM to fetch the implementor.
   573     {
   574       VM_ENTRY_MARK;
   575       Klass* k = get_instanceKlass()->implementor();
   576       if (k != NULL) {
   577         if (k == get_instanceKlass()) {
   578           // More than one implementors. Use 'this' in this case.
   579           impl = this;
   580         } else {
   581           impl = CURRENT_THREAD_ENV->get_instance_klass(k);
   582         }
   583       }
   584     }
   585     // Memoize this result.
   586     if (!is_shared()) {
   587       _implementor = impl;
   588     }
   589   }
   590   return impl;
   591 }
   593 // Utility class for printing of the contents of the static fields for
   594 // use by compilation replay.  It only prints out the information that
   595 // could be consumed by the compiler, so for primitive types it prints
   596 // out the actual value.  For Strings it's the actual string value.
   597 // For array types it it's first level array size since that's the
   598 // only value which statically unchangeable.  For all other reference
   599 // types it simply prints out the dynamic type.
   601 class StaticFinalFieldPrinter : public FieldClosure {
   602   outputStream* _out;
   603   const char*   _holder;
   604  public:
   605   StaticFinalFieldPrinter(outputStream* out, const char* holder) :
   606     _out(out),
   607     _holder(holder) {
   608   }
   609   void do_field(fieldDescriptor* fd) {
   610     if (fd->is_final() && !fd->has_initial_value()) {
   611       ResourceMark rm;
   612       oop mirror = fd->field_holder()->java_mirror();
   613       _out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii());
   614       switch (fd->field_type()) {
   615         case T_BYTE:    _out->print_cr("%d", mirror->byte_field(fd->offset()));   break;
   616         case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset()));   break;
   617         case T_SHORT:   _out->print_cr("%d", mirror->short_field(fd->offset()));  break;
   618         case T_CHAR:    _out->print_cr("%d", mirror->char_field(fd->offset()));   break;
   619         case T_INT:     _out->print_cr("%d", mirror->int_field(fd->offset()));    break;
   620         case T_LONG:    _out->print_cr(INT64_FORMAT, mirror->long_field(fd->offset()));   break;
   621         case T_FLOAT: {
   622           float f = mirror->float_field(fd->offset());
   623           _out->print_cr("%d", *(int*)&f);
   624           break;
   625         }
   626         case T_DOUBLE: {
   627           double d = mirror->double_field(fd->offset());
   628           _out->print_cr(INT64_FORMAT, *(jlong*)&d);
   629           break;
   630         }
   631         case T_ARRAY: {
   632           oop value =  mirror->obj_field_acquire(fd->offset());
   633           if (value == NULL) {
   634             _out->print_cr("null");
   635           } else {
   636             typeArrayOop ta = (typeArrayOop)value;
   637             _out->print("%d", ta->length());
   638             if (value->is_objArray()) {
   639               objArrayOop oa = (objArrayOop)value;
   640               const char* klass_name  = value->klass()->name()->as_quoted_ascii();
   641               _out->print(" %s", klass_name);
   642             }
   643             _out->cr();
   644           }
   645           break;
   646         }
   647         case T_OBJECT: {
   648           oop value =  mirror->obj_field_acquire(fd->offset());
   649           if (value == NULL) {
   650             _out->print_cr("null");
   651           } else if (value->is_instance()) {
   652             if (value->is_a(SystemDictionary::String_klass())) {
   653               _out->print("\"");
   654               _out->print_raw(java_lang_String::as_quoted_ascii(value));
   655               _out->print_cr("\"");
   656             } else {
   657               const char* klass_name  = value->klass()->name()->as_quoted_ascii();
   658               _out->print_cr(klass_name);
   659             }
   660           } else {
   661             ShouldNotReachHere();
   662           }
   663           break;
   664         }
   665         default:
   666           ShouldNotReachHere();
   667         }
   668     }
   669   }
   670 };
   673 void ciInstanceKlass::dump_replay_data(outputStream* out) {
   674   ASSERT_IN_VM;
   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