< prev index next >

src/hotspot/share/runtime/fieldDescriptor.cpp

Print this page
*** 29,10 ***
--- 29,11 ---
  #include "oops/constantPool.hpp"
  #include "oops/instanceKlass.hpp"
  #include "oops/klass.inline.hpp"
  #include "oops/oop.inline.hpp"
  #include "oops/fieldStreams.inline.hpp"
+ #include "oops/inlineKlass.inline.hpp"
  #include "runtime/fieldDescriptor.inline.hpp"
  #include "runtime/handles.inline.hpp"
  #include "runtime/signature.hpp"
  
  Symbol* fieldDescriptor::generic_signature() const {

*** 42,11 ***
    return _cp->symbol_at(_fieldinfo.generic_signature_index());
  }
  
  bool fieldDescriptor::is_trusted_final() const {
    InstanceKlass* ik = field_holder();
!   return is_final() && (is_static() || ik->is_hidden() || ik->is_record());
  }
  
  AnnotationArray* fieldDescriptor::annotations() const {
    InstanceKlass* ik = field_holder();
    Array<AnnotationArray*>* md = ik->fields_annotations();
--- 43,12 ---
    return _cp->symbol_at(_fieldinfo.generic_signature_index());
  }
  
  bool fieldDescriptor::is_trusted_final() const {
    InstanceKlass* ik = field_holder();
!   return is_final() && (is_static() || ik->is_hidden() || ik->is_record() || ik->is_inline_klass()
+                         || (ik->is_abstract() && !ik->is_identity_class() && !ik->is_interface()));
  }
  
  AnnotationArray* fieldDescriptor::annotations() const {
    InstanceKlass* ik = field_holder();
    Array<AnnotationArray*>* md = ik->fields_annotations();

*** 98,17 ***
    _fieldinfo= ik->field(index);
    assert((int)_fieldinfo.index() == index, "just checking");
    guarantee(_fieldinfo.name_index() != 0 && _fieldinfo.signature_index() != 0, "bad constant pool index for fieldDescriptor");
  }
  
! void fieldDescriptor::print_on(outputStream* st) const {
    access_flags().print_on(st);
    if (field_flags().is_injected()) st->print("injected ");
    name()->print_value_on(st);
    st->print(" ");
    signature()->print_value_on(st);
!   st->print(" @%d ", offset());
    if (WizardMode && has_initial_value()) {
      st->print("(initval ");
      constantTag t = initial_value_tag();
      if (t.is_int()) {
        st->print("int %d)", int_initial_value());
--- 100,17 ---
    _fieldinfo= ik->field(index);
    assert((int)_fieldinfo.index() == index, "just checking");
    guarantee(_fieldinfo.name_index() != 0 && _fieldinfo.signature_index() != 0, "bad constant pool index for fieldDescriptor");
  }
  
! void fieldDescriptor::print_on(outputStream* st, int base_offset) const {
    access_flags().print_on(st);
    if (field_flags().is_injected()) st->print("injected ");
    name()->print_value_on(st);
    st->print(" ");
    signature()->print_value_on(st);
!   st->print(" @%d ", offset() + base_offset);
    if (WizardMode && has_initial_value()) {
      st->print("(initval ");
      constantTag t = initial_value_tag();
      if (t.is_int()) {
        st->print("int %d)", int_initial_value());

*** 122,15 ***
    }
  }
  
  void fieldDescriptor::print() const { print_on(tty); }
  
! void fieldDescriptor::print_on_for(outputStream* st, oop obj) {
-   print_on(st);
-   st->print(" ");
- 
    BasicType ft = field_type();
    switch (ft) {
      case T_BYTE:
        st->print("%d", obj->byte_field(offset()));
        break;
      case T_CHAR:
--- 124,15 ---
    }
  }
  
  void fieldDescriptor::print() const { print_on(tty); }
  
! void fieldDescriptor::print_on_for(outputStream* st, oop obj, int indent, int base_offset) {
    BasicType ft = field_type();
+   print_on(st, base_offset);
+   st->print(" ");
+   jint as_int = 0;
    switch (ft) {
      case T_BYTE:
        st->print("%d", obj->byte_field(offset()));
        break;
      case T_CHAR:

*** 156,17 ***
        break;
      case T_BOOLEAN:
        st->print("%s", obj->bool_field(offset()) ? "true" : "false");
        break;
      case T_ARRAY:
-       if (obj->obj_field(offset()) != nullptr) {
-         obj->obj_field(offset())->print_value_on(st);
-       } else {
-         st->print("null");
-       }
-       break;
      case T_OBJECT:
        if (obj->obj_field(offset()) != nullptr) {
          obj->obj_field(offset())->print_value_on(st);
        } else {
          st->print("null");
        }
--- 158,28 ---
        break;
      case T_BOOLEAN:
        st->print("%s", obj->bool_field(offset()) ? "true" : "false");
        break;
      case T_ARRAY:
      case T_OBJECT:
+       if (is_flat()) { // only some inline types can be flat
+         // Print fields of flat fields (recursively)
+         InlineKlass* vk = InlineKlass::cast(field_holder()->get_inline_type_field_klass(index()));
+         int field_offset = offset() - vk->first_field_offset();
+         obj = cast_to_oop(cast_from_oop<address>(obj) + field_offset);
+         st->print_cr("Flat inline type field:");
+         FieldPrinter print_field(st, obj, indent + 1, base_offset + field_offset );
+         vk->do_nonstatic_fields(&print_field);
+         if (this->field_flags().has_null_marker()) {
+           for (int i = 0; i < indent + 1; i++) st->print("  ");
+           st->print_cr(" - [null_marker] @%d %s",
+                     vk->null_marker_offset() - base_offset + field_offset,
+                     obj->bool_field(vk->null_marker_offset()) ? "Field marked as non-null" : "Field marked as null");
+         }
+         return; // Do not print underlying representation
+       }
+       // Not flat inline type field, fall through
        if (obj->obj_field(offset()) != nullptr) {
          obj->obj_field(offset())->print_value_on(st);
        } else {
          st->print("null");
        }
< prev index next >