< prev index next >

src/share/vm/ci/ciInstanceKlass.cpp

Print this page




  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  */
  24 
  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"
  36 
  37 // ciInstanceKlass
  38 //
  39 // This class represents a Klass* in the HotSpot virtual machine
  40 // whose Klass part in an InstanceKlass.
  41 
  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");


 161 // ciInstanceKlass::field_cache
 162 //
 163 // Get the field cache associated with this klass.
 164 ciConstantPoolCache* ciInstanceKlass::field_cache() {
 165   if (is_shared()) {
 166     return NULL;
 167   }
 168   if (_field_cache == NULL) {
 169     assert(!is_java_lang_Object(), "Object has no fields");
 170     Arena* arena = CURRENT_ENV->arena();
 171     _field_cache = new (arena) ciConstantPoolCache(arena, 5);
 172   }
 173   return _field_cache;
 174 }
 175 
 176 // ------------------------------------------------------------------
 177 // ciInstanceKlass::get_canonical_holder
 178 //
 179 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
 180   #ifdef ASSERT
 181   if (!(offset >= 0 && offset < layout_helper())) {
 182     tty->print("*** get_canonical_holder(%d) on ", offset);
 183     this->print();
 184     tty->print_cr(" ***");
 185   };
 186   assert(offset >= 0 && offset < layout_helper(), "offset must be tame");
 187   #endif
 188 
 189   if (offset < instanceOopDesc::base_offset_in_bytes()) {
 190     // All header offsets belong properly to java/lang/Object.
 191     return CURRENT_ENV->Object_klass();
 192   }
 193 
 194   ciInstanceKlass* self = this;
 195   for (;;) {
 196     assert(self->is_loaded(), "must be loaded to have size");
 197     ciInstanceKlass* super = self->super();
 198     if (super == NULL || super->nof_nonstatic_fields() == 0 ||
 199         !super->contains_field_offset(offset)) {
 200       return self;
 201     } else {
 202       self = super;  // return super->get_canonical_holder(offset)
 203     }
 204   }
 205 }
 206 


 698     sub = sub->next_sibling();
 699   }
 700 
 701   // Dump out the state of the constant pool tags.  During replay the
 702   // tags will be validated for things which shouldn't change and
 703   // classes will be resolved if the tags indicate that they were
 704   // resolved at compile time.
 705   out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(),
 706              is_linked(), is_initialized(), cp->length());
 707   for (int index = 1; index < cp->length(); index++) {
 708     out->print(" %d", cp->tags()->at(index));
 709   }
 710   out->cr();
 711   if (is_initialized()) {
 712     //  Dump out the static final fields in case the compilation relies
 713     //  on their value for correct replay.
 714     StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii());
 715     ik->do_local_static_fields(&sffp);
 716   }
 717 }


























  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  */
  24 
  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 "gc_implementation/shenandoah/shenandoahBrooksPointer.hpp"
  32 #include "memory/allocation.hpp"
  33 #include "memory/allocation.inline.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "oops/fieldStreams.hpp"
  36 #include "runtime/fieldDescriptor.hpp"
  37 
  38 // ciInstanceKlass
  39 //
  40 // This class represents a Klass* in the HotSpot virtual machine
  41 // whose Klass part in an InstanceKlass.
  42 
  43 // ------------------------------------------------------------------
  44 // ciInstanceKlass::ciInstanceKlass
  45 //
  46 // Loaded instance klass.
  47 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
  48   ciKlass(h_k), _non_static_fields(NULL)
  49 {
  50   assert(get_Klass()->oop_is_instance(), "wrong type");
  51   assert(get_instanceKlass()->is_loaded(), "must be at least loaded");


 162 // ciInstanceKlass::field_cache
 163 //
 164 // Get the field cache associated with this klass.
 165 ciConstantPoolCache* ciInstanceKlass::field_cache() {
 166   if (is_shared()) {
 167     return NULL;
 168   }
 169   if (_field_cache == NULL) {
 170     assert(!is_java_lang_Object(), "Object has no fields");
 171     Arena* arena = CURRENT_ENV->arena();
 172     _field_cache = new (arena) ciConstantPoolCache(arena, 5);
 173   }
 174   return _field_cache;
 175 }
 176 
 177 // ------------------------------------------------------------------
 178 // ciInstanceKlass::get_canonical_holder
 179 //
 180 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
 181   #ifdef ASSERT
 182   if (!((offset >= 0 && offset < layout_helper()) || (UseShenandoahGC && offset == ShenandoahBrooksPointer::byte_offset()))) {
 183     tty->print("*** get_canonical_holder(%d) on ", offset);
 184     this->print();
 185     tty->print_cr(" ***");
 186     fatal("offset must be tame");
 187   }
 188   #endif
 189 
 190   if (offset < instanceOopDesc::base_offset_in_bytes()) {
 191     // All header offsets belong properly to java/lang/Object.
 192     return CURRENT_ENV->Object_klass();
 193   }
 194 
 195   ciInstanceKlass* self = this;
 196   for (;;) {
 197     assert(self->is_loaded(), "must be loaded to have size");
 198     ciInstanceKlass* super = self->super();
 199     if (super == NULL || super->nof_nonstatic_fields() == 0 ||
 200         !super->contains_field_offset(offset)) {
 201       return self;
 202     } else {
 203       self = super;  // return super->get_canonical_holder(offset)
 204     }
 205   }
 206 }
 207 


 699     sub = sub->next_sibling();
 700   }
 701 
 702   // Dump out the state of the constant pool tags.  During replay the
 703   // tags will be validated for things which shouldn't change and
 704   // classes will be resolved if the tags indicate that they were
 705   // resolved at compile time.
 706   out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(),
 707              is_linked(), is_initialized(), cp->length());
 708   for (int index = 1; index < cp->length(); index++) {
 709     out->print(" %d", cp->tags()->at(index));
 710   }
 711   out->cr();
 712   if (is_initialized()) {
 713     //  Dump out the static final fields in case the compilation relies
 714     //  on their value for correct replay.
 715     StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii());
 716     ik->do_local_static_fields(&sffp);
 717   }
 718 }
 719 
 720 #ifdef ASSERT
 721 bool ciInstanceKlass::debug_final_field_at(int offset) {
 722   GUARDED_VM_ENTRY(
 723     InstanceKlass* ik = get_instanceKlass();
 724     fieldDescriptor fd;
 725     if (ik->find_field_from_offset(offset, false, &fd)) {
 726       return fd.is_final();
 727     }
 728   );
 729   return false;
 730 }
 731 
 732 bool ciInstanceKlass::debug_stable_field_at(int offset) {
 733   GUARDED_VM_ENTRY(
 734     InstanceKlass* ik = get_instanceKlass();
 735     fieldDescriptor fd;
 736     if (ik->find_field_from_offset(offset, false, &fd)) {
 737       return fd.is_stable();
 738     }
 739   );
 740   return false;
 741 }
 742 #endif
< prev index next >