comparison src/share/vm/ci/ciKlass.cpp @ 6948:e522a00b91aa

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author Doug Simon <doug.simon@oracle.com>
date Mon, 12 Nov 2012 23:14:12 +0100
parents 532be189cf09 da91efe96a93
children ce248dc0a656
comparison
equal deleted inserted replaced
6711:ae13cc658b80 6948:e522a00b91aa
1 /* 1 /*
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
28 #include "ci/ciUtilities.hpp" 28 #include "ci/ciUtilities.hpp"
29 #include "oops/oop.inline.hpp" 29 #include "oops/oop.inline.hpp"
30 30
31 // ciKlass 31 // ciKlass
32 // 32 //
33 // This class represents a klassOop in the HotSpot virtual 33 // This class represents a Klass* in the HotSpot virtual
34 // machine. 34 // machine.
35 35
36 // ------------------------------------------------------------------ 36 // ------------------------------------------------------------------
37 // ciKlass::ciKlass 37 // ciKlass::ciKlass
38 ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) { 38 ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) {
39 assert(get_oop()->is_klass(), "wrong type"); 39 assert(get_Klass()->is_klass(), "wrong type");
40 Klass* k = get_Klass(); 40 Klass* k = get_Klass();
41 _layout_helper = k->layout_helper(); 41 _layout_helper = k->layout_helper();
42 Symbol* klass_name = k->name(); 42 Symbol* klass_name = k->name();
43 assert(klass_name != NULL, "wrong ciKlass constructor"); 43 assert(klass_name != NULL, "wrong ciKlass constructor");
44 _name = CURRENT_ENV->get_symbol(klass_name); 44 _name = CURRENT_ENV->get_symbol(klass_name);
47 // ------------------------------------------------------------------ 47 // ------------------------------------------------------------------
48 // ciKlass::ciKlass 48 // ciKlass::ciKlass
49 // 49 //
50 // Nameless klass variant. 50 // Nameless klass variant.
51 ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) { 51 ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) {
52 assert(get_oop()->is_klass(), "wrong type"); 52 assert(get_Klass()->is_klass(), "wrong type");
53 _name = name; 53 _name = name;
54 _layout_helper = Klass::_lh_neutral_value; 54 _layout_helper = Klass::_lh_neutral_value;
55 } 55 }
56 56
57 // ------------------------------------------------------------------ 57 // ------------------------------------------------------------------
58 // ciKlass::ciKlass 58 // ciKlass::ciKlass
59 // 59 //
60 // Unloaded klass variant. 60 // Unloaded klass variant.
61 ciKlass::ciKlass(ciSymbol* name, ciKlass* klass) : ciType(klass) { 61 ciKlass::ciKlass(ciSymbol* name, BasicType bt) : ciType(bt) {
62 _name = name; 62 _name = name;
63 _layout_helper = Klass::_lh_neutral_value; 63 _layout_helper = Klass::_lh_neutral_value;
64 } 64 }
65 65
66 // ------------------------------------------------------------------ 66 // ------------------------------------------------------------------
67 // ciKlass::is_subtype_of 67 // ciKlass::is_subtype_of
68 bool ciKlass::is_subtype_of(ciKlass* that) { 68 bool ciKlass::is_subtype_of(ciKlass* that) {
69 assert(is_loaded() && that->is_loaded(), "must be loaded"); 69 assert(is_loaded() && that->is_loaded(), "must be loaded");
70 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
71 // Check to see if the klasses are identical. 70 // Check to see if the klasses are identical.
72 if (this == that) { 71 if (this == that) {
73 return true; 72 return true;
74 } 73 }
75 #ifndef GRAAL 74 #ifndef GRAAL
76 VM_ENTRY_MARK; 75 VM_ENTRY_MARK;
77 #endif 76 #endif
78 Klass* this_klass = get_Klass(); 77 Klass* this_klass = get_Klass();
79 klassOop that_klass = that->get_klassOop(); 78 Klass* that_klass = that->get_Klass();
80 bool result = this_klass->is_subtype_of(that_klass); 79 bool result = this_klass->is_subtype_of(that_klass);
81 80
82 return result; 81 return result;
83 } 82 }
84 83
85 // ------------------------------------------------------------------ 84 // ------------------------------------------------------------------
86 // ciKlass::is_subclass_of 85 // ciKlass::is_subclass_of
87 bool ciKlass::is_subclass_of(ciKlass* that) { 86 bool ciKlass::is_subclass_of(ciKlass* that) {
88 assert(is_loaded() && that->is_loaded(), "must be loaded"); 87 assert(is_loaded() && that->is_loaded(), "must be loaded");
89 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
90 // Check to see if the klasses are identical. 88 // Check to see if the klasses are identical.
91 89
92 VM_ENTRY_MARK; 90 VM_ENTRY_MARK;
93 Klass* this_klass = get_Klass(); 91 Klass* this_klass = get_Klass();
94 klassOop that_klass = that->get_klassOop(); 92 Klass* that_klass = that->get_Klass();
95 bool result = this_klass->is_subclass_of(that_klass); 93 bool result = this_klass->is_subclass_of(that_klass);
96 94
97 return result; 95 return result;
98 } 96 }
99 97
100 // ------------------------------------------------------------------ 98 // ------------------------------------------------------------------
101 // ciKlass::super_depth 99 // ciKlass::super_depth
102 juint ciKlass::super_depth() { 100 juint ciKlass::super_depth() {
103 assert(is_loaded(), "must be loaded"); 101 assert(is_loaded(), "must be loaded");
104 assert(is_java_klass(), "must be java klasses");
105 102
106 VM_ENTRY_MARK; 103 VM_ENTRY_MARK;
107 Klass* this_klass = get_Klass(); 104 Klass* this_klass = get_Klass();
108 return this_klass->super_depth(); 105 return this_klass->super_depth();
109 } 106 }
110 107
111 // ------------------------------------------------------------------ 108 // ------------------------------------------------------------------
112 // ciKlass::super_check_offset 109 // ciKlass::super_check_offset
113 juint ciKlass::super_check_offset() { 110 juint ciKlass::super_check_offset() {
114 assert(is_loaded(), "must be loaded"); 111 assert(is_loaded(), "must be loaded");
115 assert(is_java_klass(), "must be java klasses");
116 112
117 VM_ENTRY_MARK; 113 VM_ENTRY_MARK;
118 Klass* this_klass = get_Klass(); 114 Klass* this_klass = get_Klass();
119 return this_klass->super_check_offset(); 115 return this_klass->super_check_offset();
120 } 116 }
121 117
122 // ------------------------------------------------------------------ 118 // ------------------------------------------------------------------
123 // ciKlass::super_of_depth 119 // ciKlass::super_of_depth
124 ciKlass* ciKlass::super_of_depth(juint i) { 120 ciKlass* ciKlass::super_of_depth(juint i) {
125 assert(is_loaded(), "must be loaded"); 121 assert(is_loaded(), "must be loaded");
126 assert(is_java_klass(), "must be java klasses"); 122
127 123 VM_ENTRY_MARK;
128 VM_ENTRY_MARK; 124 Klass* this_klass = get_Klass();
129 Klass* this_klass = get_Klass(); 125 Klass* super = this_klass->primary_super_of_depth(i);
130 klassOop super = this_klass->primary_super_of_depth(i); 126 return (super != NULL) ? CURRENT_THREAD_ENV->get_klass(super) : NULL;
131 return (super != NULL) ? CURRENT_THREAD_ENV->get_object(super)->as_klass() : NULL;
132 } 127 }
133 128
134 // ------------------------------------------------------------------ 129 // ------------------------------------------------------------------
135 // ciKlass::can_be_primary_super 130 // ciKlass::can_be_primary_super
136 bool ciKlass::can_be_primary_super() { 131 bool ciKlass::can_be_primary_super() {
137 assert(is_loaded(), "must be loaded"); 132 assert(is_loaded(), "must be loaded");
138 assert(is_java_klass(), "must be java klasses");
139 133
140 VM_ENTRY_MARK; 134 VM_ENTRY_MARK;
141 Klass* this_klass = get_Klass(); 135 Klass* this_klass = get_Klass();
142 return this_klass->can_be_primary_super(); 136 return this_klass->can_be_primary_super();
143 } 137 }
155 // computation or possibly if most of the superklasses have already 149 // computation or possibly if most of the superklasses have already
156 // been created as ciObjects anyway. Something to think about... 150 // been created as ciObjects anyway. Something to think about...
157 ciKlass* 151 ciKlass*
158 ciKlass::least_common_ancestor(ciKlass* that) { 152 ciKlass::least_common_ancestor(ciKlass* that) {
159 assert(is_loaded() && that->is_loaded(), "must be loaded"); 153 assert(is_loaded() && that->is_loaded(), "must be loaded");
160 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
161 // Check to see if the klasses are identical. 154 // Check to see if the klasses are identical.
162 if (this == that) { 155 if (this == that) {
163 return this; 156 return this;
164 } 157 }
165 158
177 return this; 170 return this;
178 } 171 }
179 172
180 // Create the ciInstanceKlass for the lca. 173 // Create the ciInstanceKlass for the lca.
181 ciKlass* result = 174 ciKlass* result =
182 CURRENT_THREAD_ENV->get_object(lca->as_klassOop())->as_klass(); 175 CURRENT_THREAD_ENV->get_klass(lca);
183 176
184 return result; 177 return result;
185 } 178 }
186 179
187 // ------------------------------------------------------------------ 180 // ------------------------------------------------------------------
203 ciInstance* ciKlass::java_mirror() { 196 ciInstance* ciKlass::java_mirror() {
204 GUARDED_VM_ENTRY( 197 GUARDED_VM_ENTRY(
205 if (!is_loaded()) 198 if (!is_loaded())
206 return ciEnv::current()->get_unloaded_klass_mirror(this); 199 return ciEnv::current()->get_unloaded_klass_mirror(this);
207 oop java_mirror = get_Klass()->java_mirror(); 200 oop java_mirror = get_Klass()->java_mirror();
208 return CURRENT_ENV->get_object(java_mirror)->as_instance(); 201 return CURRENT_ENV->get_instance(java_mirror);
209 ) 202 )
210 } 203 }
211 204
212 // ------------------------------------------------------------------ 205 // ------------------------------------------------------------------
213 // ciKlass::modifier_flags 206 // ciKlass::modifier_flags