src/share/vm/runtime/fieldDescriptor.cpp

Wed, 17 Aug 2011 10:32:53 -0700

author
jcoomes
date
Wed, 17 Aug 2011 10:32:53 -0700
changeset 3057
24cee90e9453
parent 2314
f95d63e2154a
child 3137
e6b1331a51d2
permissions
-rw-r--r--

6791672: enable 1G and larger pages on solaris
Reviewed-by: ysr, iveresov, johnc

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "classfile/systemDictionary.hpp"
stefank@2314 27 #include "classfile/vmSymbols.hpp"
stefank@2314 28 #include "memory/resourceArea.hpp"
stefank@2314 29 #include "memory/universe.inline.hpp"
stefank@2314 30 #include "oops/instanceKlass.hpp"
stefank@2314 31 #include "runtime/fieldDescriptor.hpp"
stefank@2314 32 #include "runtime/handles.inline.hpp"
stefank@2314 33 #include "runtime/signature.hpp"
duke@435 34
duke@435 35
duke@435 36 oop fieldDescriptor::loader() const {
duke@435 37 return instanceKlass::cast(_cp->pool_holder())->class_loader();
duke@435 38 }
duke@435 39
duke@435 40 typeArrayOop fieldDescriptor::annotations() const {
duke@435 41 instanceKlass* ik = instanceKlass::cast(field_holder());
duke@435 42 objArrayOop md = ik->fields_annotations();
duke@435 43 if (md == NULL)
duke@435 44 return NULL;
duke@435 45 assert((index() % instanceKlass::next_offset) == 0, "");
duke@435 46 return typeArrayOop(md->obj_at(index() / instanceKlass::next_offset));
duke@435 47 }
duke@435 48
duke@435 49 constantTag fieldDescriptor::initial_value_tag() const {
duke@435 50 return constants()->tag_at(_initial_value_index);
duke@435 51 }
duke@435 52
duke@435 53 jint fieldDescriptor::int_initial_value() const {
duke@435 54 return constants()->int_at(_initial_value_index);
duke@435 55 }
duke@435 56
duke@435 57 jlong fieldDescriptor::long_initial_value() const {
duke@435 58 return constants()->long_at(_initial_value_index);
duke@435 59 }
duke@435 60
duke@435 61 jfloat fieldDescriptor::float_initial_value() const {
duke@435 62 return constants()->float_at(_initial_value_index);
duke@435 63 }
duke@435 64
duke@435 65 jdouble fieldDescriptor::double_initial_value() const {
duke@435 66 return constants()->double_at(_initial_value_index);
duke@435 67 }
duke@435 68
duke@435 69 oop fieldDescriptor::string_initial_value(TRAPS) const {
duke@435 70 return constants()->string_at(_initial_value_index, CHECK_0);
duke@435 71 }
duke@435 72
duke@435 73 void fieldDescriptor::initialize(klassOop k, int index) {
duke@435 74 instanceKlass* ik = instanceKlass::cast(k);
duke@435 75 _cp = ik->constants();
duke@435 76 typeArrayOop fields = ik->fields();
duke@435 77
duke@435 78 assert(fields->length() % instanceKlass::next_offset == 0, "Illegal size of field array");
duke@435 79 assert(fields->length() >= index + instanceKlass::next_offset, "Illegal size of field array");
duke@435 80
duke@435 81 _access_flags.set_field_flags(fields->ushort_at(index + instanceKlass::access_flags_offset));
duke@435 82 _name_index = fields->ushort_at(index + instanceKlass::name_index_offset);
duke@435 83 _signature_index = fields->ushort_at(index + instanceKlass::signature_index_offset);
duke@435 84 _initial_value_index = fields->ushort_at(index + instanceKlass::initval_index_offset);
duke@435 85 guarantee(_name_index != 0 && _signature_index != 0, "bad constant pool index for fieldDescriptor");
duke@435 86 _offset = ik->offset_from_fields( index );
duke@435 87 _generic_signature_index = fields->ushort_at(index + instanceKlass::generic_signature_offset);
duke@435 88 _index = index;
duke@435 89 }
duke@435 90
duke@435 91 #ifndef PRODUCT
duke@435 92
duke@435 93 void fieldDescriptor::print_on(outputStream* st) const {
duke@435 94 _access_flags.print_on(st);
duke@435 95 constants()->symbol_at(_name_index)->print_value_on(st);
duke@435 96 st->print(" ");
duke@435 97 constants()->symbol_at(_signature_index)->print_value_on(st);
duke@435 98 st->print(" @%d ", offset());
duke@435 99 if (WizardMode && has_initial_value()) {
duke@435 100 st->print("(initval ");
duke@435 101 constantTag t = initial_value_tag();
duke@435 102 if (t.is_int()) {
duke@435 103 st->print("int %d)", int_initial_value());
duke@435 104 } else if (t.is_long()){
duke@435 105 st->print_jlong(long_initial_value());
duke@435 106 } else if (t.is_float()){
duke@435 107 st->print("float %f)", float_initial_value());
duke@435 108 } else if (t.is_double()){
duke@435 109 st->print("double %lf)", double_initial_value());
duke@435 110 }
duke@435 111 }
duke@435 112 }
duke@435 113
duke@435 114 void fieldDescriptor::print_on_for(outputStream* st, oop obj) {
duke@435 115 print_on(st);
duke@435 116 BasicType ft = field_type();
jrose@1100 117 jint as_int = 0;
duke@435 118 switch (ft) {
duke@435 119 case T_BYTE:
duke@435 120 as_int = (jint)obj->byte_field(offset());
duke@435 121 st->print(" %d", obj->byte_field(offset()));
duke@435 122 break;
duke@435 123 case T_CHAR:
jrose@1100 124 as_int = (jint)obj->char_field(offset());
duke@435 125 {
duke@435 126 jchar c = obj->char_field(offset());
duke@435 127 as_int = c;
duke@435 128 st->print(" %c %d", isprint(c) ? c : ' ', c);
duke@435 129 }
duke@435 130 break;
duke@435 131 case T_DOUBLE:
duke@435 132 st->print(" %lf", obj->double_field(offset()));
duke@435 133 break;
duke@435 134 case T_FLOAT:
duke@435 135 as_int = obj->int_field(offset());
duke@435 136 st->print(" %f", obj->float_field(offset()));
duke@435 137 break;
duke@435 138 case T_INT:
jrose@1100 139 as_int = obj->int_field(offset());
duke@435 140 st->print(" %d", obj->int_field(offset()));
duke@435 141 break;
duke@435 142 case T_LONG:
duke@435 143 st->print(" ");
duke@435 144 st->print_jlong(obj->long_field(offset()));
duke@435 145 break;
duke@435 146 case T_SHORT:
duke@435 147 as_int = obj->short_field(offset());
duke@435 148 st->print(" %d", obj->short_field(offset()));
duke@435 149 break;
duke@435 150 case T_BOOLEAN:
duke@435 151 as_int = obj->bool_field(offset());
duke@435 152 st->print(" %s", obj->bool_field(offset()) ? "true" : "false");
duke@435 153 break;
duke@435 154 case T_ARRAY:
duke@435 155 st->print(" ");
jrose@1100 156 NOT_LP64(as_int = obj->int_field(offset()));
duke@435 157 obj->obj_field(offset())->print_value_on(st);
duke@435 158 break;
duke@435 159 case T_OBJECT:
duke@435 160 st->print(" ");
jrose@1100 161 NOT_LP64(as_int = obj->int_field(offset()));
duke@435 162 obj->obj_field(offset())->print_value_on(st);
duke@435 163 break;
duke@435 164 default:
duke@435 165 ShouldNotReachHere();
duke@435 166 break;
duke@435 167 }
duke@435 168 // Print a hint as to the underlying integer representation. This can be wrong for
duke@435 169 // pointers on an LP64 machine
jrose@1100 170 if (ft == T_LONG || ft == T_DOUBLE LP64_ONLY(|| !is_java_primitive(ft)) ) {
duke@435 171 st->print(" (%x %x)", obj->int_field(offset()), obj->int_field(offset()+sizeof(jint)));
jrose@1100 172 } else if (as_int < 0 || as_int > 9) {
duke@435 173 st->print(" (%x)", as_int);
duke@435 174 }
duke@435 175 }
duke@435 176
duke@435 177 #endif /* PRODUCT */

mercurial