< prev index next >

src/share/vm/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 "memory/universe.inline.hpp"
  30 #include "oops/annotations.hpp"
  31 #include "oops/instanceKlass.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "oops/fieldStreams.hpp"

  34 #include "runtime/fieldDescriptor.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 {


 129   name()->print_value_on(st);
 130   st->print(" ");
 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_on_for(outputStream* st, oop obj) {
 149   print_on(st);
 150   BasicType ft = field_type();



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


 178       st->print_jlong(obj->long_field(offset()));
 179       break;
 180     case T_SHORT:
 181       as_int = obj->short_field(offset());
 182       st->print(" %d", obj->short_field(offset()));
 183       break;
 184     case T_BOOLEAN:
 185       as_int = obj->bool_field(offset());
 186       st->print(" %s", obj->bool_field(offset()) ? "true" : "false");
 187       break;
 188     case T_ARRAY:
 189       st->print(" ");
 190       NOT_LP64(as_int = obj->int_field(offset()));
 191       obj->obj_field(offset())->print_value_on(st);
 192       break;
 193     case T_OBJECT:
 194       st->print(" ");
 195       NOT_LP64(as_int = obj->int_field(offset()));
 196       obj->obj_field(offset())->print_value_on(st);
 197       break;
 198     case T_VALUETYPE:
 199       st->print(" ");
 200       NOT_LP64(as_int = obj->int_field(offset()));
 201       obj->obj_field(offset())->print_value_on(st);
 202       break;










 203     default:
 204       ShouldNotReachHere();
 205       break;
 206   }
 207   // Print a hint as to the underlying integer representation. This can be wrong for
 208   // pointers on an LP64 machine
 209   if (ft == T_LONG || ft == T_DOUBLE LP64_ONLY(|| !is_java_primitive(ft)) ) {
 210     st->print(" (%x %x)", obj->int_field(offset()), obj->int_field(offset()+sizeof(jint)));
 211   } else if (as_int < 0 || as_int > 9) {
 212     st->print(" (%x)", as_int);
 213   }

 214 }
 215 
 216 #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 "memory/universe.inline.hpp"
  30 #include "oops/annotations.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.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 {


 130   name()->print_value_on(st);
 131   st->print(" ");
 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_on_for(outputStream* st, oop obj) {

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


 181       st->print_jlong(obj->long_field(offset()));
 182       break;
 183     case T_SHORT:
 184       as_int = obj->short_field(offset());
 185       st->print(" %d", obj->short_field(offset()));
 186       break;
 187     case T_BOOLEAN:
 188       as_int = obj->bool_field(offset());
 189       st->print(" %s", obj->bool_field(offset()) ? "true" : "false");
 190       break;
 191     case T_ARRAY:
 192       st->print(" ");
 193       NOT_LP64(as_int = obj->int_field(offset()));
 194       obj->obj_field(offset())->print_value_on(st);
 195       break;
 196     case T_OBJECT:
 197       st->print(" ");
 198       NOT_LP64(as_int = obj->int_field(offset()));
 199       obj->obj_field(offset())->print_value_on(st);
 200       break;
 201     case T_VALUETYPE: {
 202       // Resolve klass of flattened value type field
 203       Thread* THREAD = Thread::current();
 204       SignatureStream ss(signature(), false);
 205       Klass* k = ss.as_klass(Handle(field_holder()->class_loader()), Handle(field_holder()->protection_domain()), SignatureStream::ReturnNull, THREAD);
 206       assert(k != NULL && !HAS_PENDING_EXCEPTION, "can resolve klass?");
 207       ValueKlass* vk = ValueKlass::cast(k);
 208       int field_offset = offset() - vk->first_field_offset();
 209       obj = (oop)((uintptr_t)obj + field_offset);
 210       // Print flattened fields of the value type field
 211       st->print_cr("Flattened value type '%s':", vk->name()->as_C_string());
 212       FieldPrinter print_field(st, obj);
 213       vk->do_nonstatic_fields(&print_field);
 214       return; // Do not print underlying representation
 215     }
 216     default:
 217       ShouldNotReachHere();
 218       break;
 219   }
 220   // Print a hint as to the underlying integer representation. This can be wrong for
 221   // pointers on an LP64 machine
 222   if (ft == T_LONG || ft == T_DOUBLE LP64_ONLY(|| !is_java_primitive(ft)) ) {
 223     st->print(" (%x %x)", obj->int_field(offset()), obj->int_field(offset()+sizeof(jint)));
 224   } else if (as_int < 0 || as_int > 9) {
 225     st->print(" (%x)", as_int);
 226   }
 227   st->cr();
 228 }
 229 
 230 #endif /* PRODUCT */
< prev index next >