1 /*
2 * Copyright (c) 2000, 2024, 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 *
32 import sun.jvm.hotspot.types.*;
33 import sun.jvm.hotspot.utilities.Observable;
34 import sun.jvm.hotspot.utilities.Observer;
35
36 public class Klass extends Metadata implements ClassConstants {
37 static {
38 VM.registerVMInitializedObserver(new Observer() {
39 public void update(Observable o, Object data) {
40 initialize(VM.getVM().getTypeDataBase());
41 }
42 });
43 }
44
45 // anon-enum constants for _layout_helper.
46 public static int LH_INSTANCE_SLOW_PATH_BIT;
47 public static int LH_LOG2_ELEMENT_SIZE_SHIFT;
48 public static int LH_ELEMENT_TYPE_SHIFT;
49 public static int LH_HEADER_SIZE_SHIFT;
50 public static int LH_ARRAY_TAG_SHIFT;
51 public static int LH_ARRAY_TAG_TYPE_VALUE;
52 public static int LH_ARRAY_TAG_OBJ_VALUE;
53
54 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
55 Type type = db.lookupType("Klass");
56 javaMirrorFieldOffset = type.getField("_java_mirror").getOffset();
57 superField = new MetadataField(type.getAddressField("_super"), 0);
58 layoutHelper = new IntField(type.getJIntField("_layout_helper"), 0);
59 name = type.getAddressField("_name");
60 accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
61 try {
62 traceIDField = type.getField("_trace_id");
63 } catch(Exception e) {
64 }
65 subklass = new MetadataField(type.getAddressField("_subklass"), 0);
66 nextSibling = new MetadataField(type.getAddressField("_next_sibling"), 0);
67 nextLink = new MetadataField(type.getAddressField("_next_link"), 0);
68 vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0);
69 classLoaderData = type.getAddressField("_class_loader_data");
70
71 LH_INSTANCE_SLOW_PATH_BIT = db.lookupIntConstant("Klass::_lh_instance_slow_path_bit").intValue();
72 LH_LOG2_ELEMENT_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_log2_element_size_shift").intValue();
73 LH_ELEMENT_TYPE_SHIFT = db.lookupIntConstant("Klass::_lh_element_type_shift").intValue();
74 LH_HEADER_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_header_size_shift").intValue();
75 LH_ARRAY_TAG_SHIFT = db.lookupIntConstant("Klass::_lh_array_tag_shift").intValue();
76 LH_ARRAY_TAG_TYPE_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_type_value").intValue();
77 LH_ARRAY_TAG_OBJ_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_obj_value").intValue();
78 }
79
80
81 public Klass(Address addr) {
82 super(addr);
83 }
84
85 // jvmdi support - see also class_status in VM code
86 public int getClassStatus() {
87 return 0; // overridden in derived classes
88 }
89
90 public boolean isKlass() { return true; }
91 public boolean isArrayKlass() { return false; }
92
93 // Fields
94 private static long javaMirrorFieldOffset;
95 private static MetadataField superField;
96 private static IntField layoutHelper;
97 private static AddressField name;
|
1 /*
2 * Copyright (c) 2000, 2025, 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 *
32 import sun.jvm.hotspot.types.*;
33 import sun.jvm.hotspot.utilities.Observable;
34 import sun.jvm.hotspot.utilities.Observer;
35
36 public class Klass extends Metadata implements ClassConstants {
37 static {
38 VM.registerVMInitializedObserver(new Observer() {
39 public void update(Observable o, Object data) {
40 initialize(VM.getVM().getTypeDataBase());
41 }
42 });
43 }
44
45 // anon-enum constants for _layout_helper.
46 public static int LH_INSTANCE_SLOW_PATH_BIT;
47 public static int LH_LOG2_ELEMENT_SIZE_SHIFT;
48 public static int LH_ELEMENT_TYPE_SHIFT;
49 public static int LH_HEADER_SIZE_SHIFT;
50 public static int LH_ARRAY_TAG_SHIFT;
51 public static int LH_ARRAY_TAG_TYPE_VALUE;
52
53
54 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
55 Type type = db.lookupType("Klass");
56 javaMirrorFieldOffset = type.getField("_java_mirror").getOffset();
57 superField = new MetadataField(type.getAddressField("_super"), 0);
58 layoutHelper = new IntField(type.getJIntField("_layout_helper"), 0);
59 name = type.getAddressField("_name");
60 accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
61 try {
62 traceIDField = type.getField("_trace_id");
63 } catch(Exception e) {
64 }
65 subklass = new MetadataField(type.getAddressField("_subklass"), 0);
66 nextSibling = new MetadataField(type.getAddressField("_next_sibling"), 0);
67 nextLink = new MetadataField(type.getAddressField("_next_link"), 0);
68 vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0);
69 classLoaderData = type.getAddressField("_class_loader_data");
70
71 LH_INSTANCE_SLOW_PATH_BIT = db.lookupIntConstant("Klass::_lh_instance_slow_path_bit").intValue();
72 LH_LOG2_ELEMENT_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_log2_element_size_shift").intValue();
73 LH_ELEMENT_TYPE_SHIFT = db.lookupIntConstant("Klass::_lh_element_type_shift").intValue();
74 LH_HEADER_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_header_size_shift").intValue();
75 LH_ARRAY_TAG_SHIFT = db.lookupIntConstant("Klass::_lh_array_tag_shift").intValue();
76 LH_ARRAY_TAG_TYPE_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_type_value").intValue();
77 }
78
79
80 public Klass(Address addr) {
81 super(addr);
82 }
83
84 // jvmdi support - see also class_status in VM code
85 public int getClassStatus() {
86 return 0; // overridden in derived classes
87 }
88
89 public boolean isKlass() { return true; }
90 public boolean isArrayKlass() { return false; }
91
92 // Fields
93 private static long javaMirrorFieldOffset;
94 private static MetadataField superField;
95 private static IntField layoutHelper;
96 private static AddressField name;
|