1 /*
2 * Copyright (c) 1997, 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 *
23 */
24
25 #ifndef SHARE_VM_OOPS_INSTANCEKLASS_HPP
26 #define SHARE_VM_OOPS_INSTANCEKLASS_HPP
27
28 #include "classfile/classLoaderData.hpp"
29 #include "gc/shared/specialized_oop_closures.hpp"
30 #include "memory/referenceType.hpp"
31 #include "oops/annotations.hpp"
32 #include "oops/constMethod.hpp"
33 #include "oops/fieldInfo.hpp"
34 #include "oops/instanceOop.hpp"
35 #include "oops/klassVtable.hpp"
36 #include "runtime/handles.hpp"
37 #include "runtime/os.hpp"
38 #include "trace/traceMacros.hpp"
39 #include "utilities/accessFlags.hpp"
40 #include "utilities/bitMap.inline.hpp"
41 #include "utilities/macros.hpp"
42
43 // An InstanceKlass is the VM level representation of a Java class.
44 // It contains all information needed for at class at execution runtime.
45
46 // InstanceKlass embedded field layout (after declared fields):
47 // [EMBEDDED Java vtable ] size in words = vtable_len
48 // [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
49 // The embedded nonstatic oop-map blocks are short pairs (offset, length)
1240 #ifndef PRODUCT
1241 void print_on(outputStream* st) const;
1242 #endif
1243 void print_value_on(outputStream* st) const;
1244
1245 void oop_print_value_on(oop obj, outputStream* st);
1246
1247 #ifndef PRODUCT
1248 void oop_print_on (oop obj, outputStream* st);
1249
1250 void print_dependent_nmethods(bool verbose = false);
1251 bool is_dependent_nmethod(nmethod* nm);
1252 #endif
1253
1254 const char* internal_name() const;
1255
1256 // Verification
1257 void verify_on(outputStream* st);
1258
1259 void oop_verify_on(oop obj, outputStream* st);
1260 };
1261
1262 inline Method* InstanceKlass::method_at_vtable(int index) {
1263 #ifndef PRODUCT
1264 assert(index >= 0, "valid vtable index");
1265 if (DebugVtables) {
1266 verify_vtable_index(index);
1267 }
1268 #endif
1269 vtableEntry* ve = (vtableEntry*)start_of_vtable();
1270 return ve[index].method();
1271 }
1272
1273 // for adding methods
1274 // UNSET_IDNUM return means no more ids available
1275 inline u2 InstanceKlass::next_method_idnum() {
1276 if (_idnum_allocated_count == ConstMethod::MAX_IDNUM) {
1277 return ConstMethod::UNSET_IDNUM; // no more ids available
1278 } else {
1279 return _idnum_allocated_count++;
|
1 /*
2 * Copyright (c) 1997, 2016, 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 *
23 */
24
25 #ifndef SHARE_VM_OOPS_INSTANCEKLASS_HPP
26 #define SHARE_VM_OOPS_INSTANCEKLASS_HPP
27
28 #include "classfile/classLoaderData.hpp"
29 #include "gc/shared/specialized_oop_closures.hpp"
30 #include "logging/logLevel.hpp"
31 #include "memory/referenceType.hpp"
32 #include "oops/annotations.hpp"
33 #include "oops/constMethod.hpp"
34 #include "oops/fieldInfo.hpp"
35 #include "oops/instanceOop.hpp"
36 #include "oops/klassVtable.hpp"
37 #include "runtime/handles.hpp"
38 #include "runtime/os.hpp"
39 #include "trace/traceMacros.hpp"
40 #include "utilities/accessFlags.hpp"
41 #include "utilities/bitMap.inline.hpp"
42 #include "utilities/macros.hpp"
43
44 // An InstanceKlass is the VM level representation of a Java class.
45 // It contains all information needed for at class at execution runtime.
46
47 // InstanceKlass embedded field layout (after declared fields):
48 // [EMBEDDED Java vtable ] size in words = vtable_len
49 // [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
50 // The embedded nonstatic oop-map blocks are short pairs (offset, length)
1241 #ifndef PRODUCT
1242 void print_on(outputStream* st) const;
1243 #endif
1244 void print_value_on(outputStream* st) const;
1245
1246 void oop_print_value_on(oop obj, outputStream* st);
1247
1248 #ifndef PRODUCT
1249 void oop_print_on (oop obj, outputStream* st);
1250
1251 void print_dependent_nmethods(bool verbose = false);
1252 bool is_dependent_nmethod(nmethod* nm);
1253 #endif
1254
1255 const char* internal_name() const;
1256
1257 // Verification
1258 void verify_on(outputStream* st);
1259
1260 void oop_verify_on(oop obj, outputStream* st);
1261
1262 // Logging
1263 void print_loading_log(LogLevel::type type, ClassLoaderData* loader_data, const ClassFileStream* cfs) const;
1264 };
1265
1266 inline Method* InstanceKlass::method_at_vtable(int index) {
1267 #ifndef PRODUCT
1268 assert(index >= 0, "valid vtable index");
1269 if (DebugVtables) {
1270 verify_vtable_index(index);
1271 }
1272 #endif
1273 vtableEntry* ve = (vtableEntry*)start_of_vtable();
1274 return ve[index].method();
1275 }
1276
1277 // for adding methods
1278 // UNSET_IDNUM return means no more ids available
1279 inline u2 InstanceKlass::next_method_idnum() {
1280 if (_idnum_allocated_count == ConstMethod::MAX_IDNUM) {
1281 return ConstMethod::UNSET_IDNUM; // no more ids available
1282 } else {
1283 return _idnum_allocated_count++;
|