< prev index next >

src/hotspot/share/runtime/fieldDescriptor.cpp

Print this page




  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 "classfile/systemDictionary.hpp"
  27 #include "classfile/vmSymbols.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/annotations.hpp"
  30 #include "oops/constantPool.hpp"
  31 #include "oops/instanceKlass.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "oops/fieldStreams.hpp"

  34 #include "runtime/fieldDescriptor.inline.hpp"
  35 #include "runtime/handles.inline.hpp"
  36 #include "runtime/signature.hpp"
  37 
  38 
  39 oop fieldDescriptor::loader() const {
  40   return _cp->pool_holder()->class_loader();
  41 }
  42 
  43 Symbol* fieldDescriptor::generic_signature() const {
  44   if (!has_generic_signature()) {
  45     return NULL;
  46   }
  47 
  48   int idx = 0;
  49   InstanceKlass* ik = field_holder();
  50   for (AllFieldStream fs(ik); !fs.done(); fs.next()) {
  51     if (idx == _index) {
  52       return fs.generic_signature();
  53     } else {


 131   signature()->print_value_on(st);
 132   st->print(" @%d ", offset());
 133   if (WizardMode && has_initial_value()) {
 134     st->print("(initval ");
 135     constantTag t = initial_value_tag();
 136     if (t.is_int()) {
 137       st->print("int %d)", int_initial_value());
 138     } else if (t.is_long()){
 139       st->print_jlong(long_initial_value());
 140     } else if (t.is_float()){
 141       st->print("float %f)", float_initial_value());
 142     } else if (t.is_double()){
 143       st->print("double %lf)", double_initial_value());
 144     }
 145   }
 146 }
 147 
 148 void fieldDescriptor::print() const { print_on(tty); }
 149 
 150 void fieldDescriptor::print_on_for(outputStream* st, oop obj) {
 151   print_on(st);
 152   BasicType ft = field_type();



 153   jint as_int = 0;
 154   switch (ft) {
 155     case T_BYTE:
 156       as_int = (jint)obj->byte_field(offset());
 157       st->print(" %d", obj->byte_field(offset()));
 158       break;
 159     case T_CHAR:
 160       as_int = (jint)obj->char_field(offset());
 161       {
 162         jchar c = obj->char_field(offset());
 163         as_int = c;
 164         st->print(" %c %d", isprint(c) ? c : ' ', c);
 165       }
 166       break;
 167     case T_DOUBLE:
 168       st->print(" %lf", obj->double_field(offset()));
 169       break;
 170     case T_FLOAT:
 171       as_int = obj->int_field(offset());
 172       st->print(" %f", obj->float_field(offset()));


 188       st->print(" %s", obj->bool_field(offset()) ? "true" : "false");
 189       break;
 190     case T_ARRAY:
 191       st->print(" ");
 192       NOT_LP64(as_int = obj->int_field(offset()));
 193       if (obj->obj_field(offset()) != NULL) {
 194         obj->obj_field(offset())->print_value_on(st);
 195       } else {
 196         st->print_cr("NULL");
 197       }
 198       break;
 199     case T_OBJECT:
 200       st->print(" ");
 201       NOT_LP64(as_int = obj->int_field(offset()));
 202       if (obj->obj_field(offset()) != NULL) {
 203         obj->obj_field(offset())->print_value_on(st);
 204       } else {
 205         st->print_cr("NULL");
 206       }
 207       break;



















 208     default:
 209       ShouldNotReachHere();
 210       break;
 211   }
 212   // Print a hint as to the underlying integer representation. This can be wrong for
 213   // pointers on an LP64 machine
 214 #ifdef _LP64
 215   if ((ft == T_OBJECT || ft == T_ARRAY) && UseCompressedOops) {
 216     st->print(" (%x)", obj->int_field(offset()));
 217   }
 218   else // <- intended
 219 #endif
 220   if (ft == T_LONG || ft == T_DOUBLE LP64_ONLY(|| !is_java_primitive(ft)) ) {
 221     st->print(" (%x %x)", obj->int_field(offset()), obj->int_field(offset()+sizeof(jint)));
 222   } else if (as_int < 0 || as_int > 9) {
 223     st->print(" (%x)", as_int);
 224   }

 225 }
 226 
 227 #endif /* PRODUCT */


  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 "classfile/systemDictionary.hpp"
  27 #include "classfile/vmSymbols.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/annotations.hpp"
  30 #include "oops/constantPool.hpp"
  31 #include "oops/instanceKlass.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "oops/fieldStreams.hpp"
  34 #include "oops/valueKlass.hpp"
  35 #include "runtime/fieldDescriptor.inline.hpp"
  36 #include "runtime/handles.inline.hpp"
  37 #include "runtime/signature.hpp"
  38 
  39 
  40 oop fieldDescriptor::loader() const {
  41   return _cp->pool_holder()->class_loader();
  42 }
  43 
  44 Symbol* fieldDescriptor::generic_signature() const {
  45   if (!has_generic_signature()) {
  46     return NULL;
  47   }
  48 
  49   int idx = 0;
  50   InstanceKlass* ik = field_holder();
  51   for (AllFieldStream fs(ik); !fs.done(); fs.next()) {
  52     if (idx == _index) {
  53       return fs.generic_signature();
  54     } else {


 132   signature()->print_value_on(st);
 133   st->print(" @%d ", offset());
 134   if (WizardMode && has_initial_value()) {
 135     st->print("(initval ");
 136     constantTag t = initial_value_tag();
 137     if (t.is_int()) {
 138       st->print("int %d)", int_initial_value());
 139     } else if (t.is_long()){
 140       st->print_jlong(long_initial_value());
 141     } else if (t.is_float()){
 142       st->print("float %f)", float_initial_value());
 143     } else if (t.is_double()){
 144       st->print("double %lf)", double_initial_value());
 145     }
 146   }
 147 }
 148 
 149 void fieldDescriptor::print() const { print_on(tty); }
 150 
 151 void fieldDescriptor::print_on_for(outputStream* st, oop obj) {

 152   BasicType ft = field_type();
 153   if (ft != T_VALUETYPE) {
 154     print_on(st);
 155   }
 156   jint as_int = 0;
 157   switch (ft) {
 158     case T_BYTE:
 159       as_int = (jint)obj->byte_field(offset());
 160       st->print(" %d", obj->byte_field(offset()));
 161       break;
 162     case T_CHAR:
 163       as_int = (jint)obj->char_field(offset());
 164       {
 165         jchar c = obj->char_field(offset());
 166         as_int = c;
 167         st->print(" %c %d", isprint(c) ? c : ' ', c);
 168       }
 169       break;
 170     case T_DOUBLE:
 171       st->print(" %lf", obj->double_field(offset()));
 172       break;
 173     case T_FLOAT:
 174       as_int = obj->int_field(offset());
 175       st->print(" %f", obj->float_field(offset()));


 191       st->print(" %s", obj->bool_field(offset()) ? "true" : "false");
 192       break;
 193     case T_ARRAY:
 194       st->print(" ");
 195       NOT_LP64(as_int = obj->int_field(offset()));
 196       if (obj->obj_field(offset()) != NULL) {
 197         obj->obj_field(offset())->print_value_on(st);
 198       } else {
 199         st->print_cr("NULL");
 200       }
 201       break;
 202     case T_OBJECT:
 203       st->print(" ");
 204       NOT_LP64(as_int = obj->int_field(offset()));
 205       if (obj->obj_field(offset()) != NULL) {
 206         obj->obj_field(offset())->print_value_on(st);
 207       } else {
 208         st->print_cr("NULL");
 209       }
 210       break;
 211     case T_VALUETYPE:
 212       if (is_flattened()) {
 213         // Resolve klass of flattened value type field
 214         ResourceMark rm(Thread::current());
 215         SignatureStream ss(signature(), false);
 216         ValueKlass* vk = ss.as_value_klass(field_holder());
 217         int field_offset = offset() - vk->first_field_offset();
 218         obj = (oop)((address)obj + field_offset);
 219         // Print flattened fields of the value type field
 220         st->print_cr("Flattened value type '%s':", vk->name()->as_C_string());
 221         FieldPrinter print_field(st, obj);
 222         vk->do_nonstatic_fields(&print_field);
 223         return; // Do not print underlying representation
 224       } else {
 225         st->print(" ");
 226         NOT_LP64(as_int = obj->int_field(offset()));
 227         obj->obj_field(offset())->print_value_on(st);
 228       }
 229       break;
 230     default:
 231       ShouldNotReachHere();
 232       break;
 233   }
 234   // Print a hint as to the underlying integer representation. This can be wrong for
 235   // pointers on an LP64 machine
 236 #ifdef _LP64
 237   if ((ft == T_OBJECT || ft == T_ARRAY || ft == T_VALUETYPE) && UseCompressedOops) {
 238     st->print(" (%x)", obj->int_field(offset()));
 239   }
 240   else // <- intended
 241 #endif
 242   if (ft == T_LONG || ft == T_DOUBLE LP64_ONLY(|| !is_java_primitive(ft)) ) {
 243     st->print(" (%x %x)", obj->int_field(offset()), obj->int_field(offset()+sizeof(jint)));
 244   } else if (as_int < 0 || as_int > 9) {
 245     st->print(" (%x)", as_int);
 246   }
 247   st->cr();
 248 }
 249 
 250 #endif /* PRODUCT */
< prev index next >