1 /*
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 *
73 transitiveInterfaces = type.getAddressField("_transitive_interfaces");
74 fields = type.getAddressField("_fields");
75 javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), 0);
76 constants = new MetadataField(type.getAddressField("_constants"), 0);
77 classLoaderData = type.getAddressField("_class_loader_data");
78 sourceDebugExtension = type.getAddressField("_source_debug_extension");
79 innerClasses = type.getAddressField("_inner_classes");
80 sourceFileNameIndex = new CIntField(type.getCIntegerField("_source_file_name_index"), 0);
81 nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), 0);
82 staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), 0);
83 staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), 0);
84 nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), 0);
85 isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), 0);
86 initState = new CIntField(type.getCIntegerField("_init_state"), 0);
87 vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0);
88 itableLen = new CIntField(type.getCIntegerField("_itable_len"), 0);
89 breakpoints = type.getAddressField("_breakpoints");
90 genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"), 0);
91 majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0);
92 minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0);
93 headerSize = Oop.alignObjectOffset(type.getSize());
94
95 // read field offset constants
96 ACCESS_FLAGS_OFFSET = db.lookupIntConstant("FieldInfo::access_flags_offset").intValue();
97 NAME_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::name_index_offset").intValue();
98 SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue();
99 INITVAL_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue();
100 LOW_OFFSET = db.lookupIntConstant("FieldInfo::low_packed_offset").intValue();
101 HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_packed_offset").intValue();
102 FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue();
103 FIELDINFO_TAG_SIZE = db.lookupIntConstant("FIELDINFO_TAG_SIZE").shortValue();
104 FIELDINFO_TAG_MASK = db.lookupIntConstant("FIELDINFO_TAG_MASK").shortValue();
105 FIELDINFO_TAG_OFFSET = db.lookupIntConstant("FIELDINFO_TAG_OFFSET").shortValue();
106
107 // read ClassState constants
108 CLASS_STATE_ALLOCATED = db.lookupIntConstant("InstanceKlass::allocated").intValue();
109 CLASS_STATE_LOADED = db.lookupIntConstant("InstanceKlass::loaded").intValue();
110 CLASS_STATE_LINKED = db.lookupIntConstant("InstanceKlass::linked").intValue();
111 CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("InstanceKlass::being_initialized").intValue();
112 CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("InstanceKlass::fully_initialized").intValue();
113 CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("InstanceKlass::initialization_error").intValue();
225 if (Assert.ASSERTS_ENABLED) {
226 Assert.that(isLinked(), "Class status is not consistent");
227 }
228 result |= JVMDIClassStatus.INITIALIZED;
229 }
230
231 if (isInErrorState()) {
232 result |= JVMDIClassStatus.ERROR;
233 }
234 return result;
235 }
236
237 // Byteside of the header
238 private static long headerSize;
239
240 public long getObjectSize(Oop object) {
241 return getSizeHelper() * VM.getVM().getAddressSize();
242 }
243
244 public long getSize() {
245 return Oop.alignObjectSize(getHeaderSize() + Oop.alignObjectOffset(getVtableLen()) +
246 Oop.alignObjectOffset(getItableLen()) + Oop.alignObjectOffset(getNonstaticOopMapSize()));
247 }
248
249 public static long getHeaderSize() { return headerSize; }
250
251 public short getFieldAccessFlags(int index) {
252 return getFields().at(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET);
253 }
254
255 public short getFieldNameIndex(int index) {
256 if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;");
257 return getFields().at(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
258 }
259
260 public Symbol getFieldName(int index) {
261 int nameIndex = getFields().at(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
262 if (index < getJavaFieldsCount()) {
263 return getConstants().getSymbolAt(nameIndex);
264 } else {
265 return vmSymbols.symbolAt(nameIndex);
266 }
|
1 /*
2 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 *
73 transitiveInterfaces = type.getAddressField("_transitive_interfaces");
74 fields = type.getAddressField("_fields");
75 javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), 0);
76 constants = new MetadataField(type.getAddressField("_constants"), 0);
77 classLoaderData = type.getAddressField("_class_loader_data");
78 sourceDebugExtension = type.getAddressField("_source_debug_extension");
79 innerClasses = type.getAddressField("_inner_classes");
80 sourceFileNameIndex = new CIntField(type.getCIntegerField("_source_file_name_index"), 0);
81 nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), 0);
82 staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), 0);
83 staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), 0);
84 nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), 0);
85 isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), 0);
86 initState = new CIntField(type.getCIntegerField("_init_state"), 0);
87 vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0);
88 itableLen = new CIntField(type.getCIntegerField("_itable_len"), 0);
89 breakpoints = type.getAddressField("_breakpoints");
90 genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"), 0);
91 majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0);
92 minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0);
93 headerSize = type.getSize();
94
95 // read field offset constants
96 ACCESS_FLAGS_OFFSET = db.lookupIntConstant("FieldInfo::access_flags_offset").intValue();
97 NAME_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::name_index_offset").intValue();
98 SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue();
99 INITVAL_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue();
100 LOW_OFFSET = db.lookupIntConstant("FieldInfo::low_packed_offset").intValue();
101 HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_packed_offset").intValue();
102 FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue();
103 FIELDINFO_TAG_SIZE = db.lookupIntConstant("FIELDINFO_TAG_SIZE").shortValue();
104 FIELDINFO_TAG_MASK = db.lookupIntConstant("FIELDINFO_TAG_MASK").shortValue();
105 FIELDINFO_TAG_OFFSET = db.lookupIntConstant("FIELDINFO_TAG_OFFSET").shortValue();
106
107 // read ClassState constants
108 CLASS_STATE_ALLOCATED = db.lookupIntConstant("InstanceKlass::allocated").intValue();
109 CLASS_STATE_LOADED = db.lookupIntConstant("InstanceKlass::loaded").intValue();
110 CLASS_STATE_LINKED = db.lookupIntConstant("InstanceKlass::linked").intValue();
111 CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("InstanceKlass::being_initialized").intValue();
112 CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("InstanceKlass::fully_initialized").intValue();
113 CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("InstanceKlass::initialization_error").intValue();
225 if (Assert.ASSERTS_ENABLED) {
226 Assert.that(isLinked(), "Class status is not consistent");
227 }
228 result |= JVMDIClassStatus.INITIALIZED;
229 }
230
231 if (isInErrorState()) {
232 result |= JVMDIClassStatus.ERROR;
233 }
234 return result;
235 }
236
237 // Byteside of the header
238 private static long headerSize;
239
240 public long getObjectSize(Oop object) {
241 return getSizeHelper() * VM.getVM().getAddressSize();
242 }
243
244 public long getSize() {
245 return Oop.alignObjectSize(getHeaderSize() + getVtableLen() +
246 getItableLen() + getNonstaticOopMapSize());
247 }
248
249 public static long getHeaderSize() { return headerSize; }
250
251 public short getFieldAccessFlags(int index) {
252 return getFields().at(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET);
253 }
254
255 public short getFieldNameIndex(int index) {
256 if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;");
257 return getFields().at(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
258 }
259
260 public Symbol getFieldName(int index) {
261 int nameIndex = getFields().at(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
262 if (index < getJavaFieldsCount()) {
263 return getConstants().getSymbolAt(nameIndex);
264 } else {
265 return vmSymbols.symbolAt(nameIndex);
266 }
|