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 #include "precompiled.hpp"
26 #include "ci/ciField.hpp"
27 #include "ci/ciInstance.hpp"
28 #include "ci/ciInstanceKlass.hpp"
29 #include "ci/ciUtilities.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "gc_implementation/shenandoah/brooksPointer.hpp"
32 #include "memory/allocation.hpp"
33 #include "memory/allocation.inline.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "oops/fieldStreams.hpp"
36 #include "runtime/fieldDescriptor.hpp"
37
38 // ciInstanceKlass
39 //
40 // This class represents a Klass* in the HotSpot virtual machine
41 // whose Klass part in an InstanceKlass.
42
43 // ------------------------------------------------------------------
44 // ciInstanceKlass::ciInstanceKlass
45 //
46 // Loaded instance klass.
47 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
48 ciKlass(h_k), _non_static_fields(NULL)
49 {
50 assert(get_Klass()->oop_is_instance(), "wrong type");
51 assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
162 // ciInstanceKlass::field_cache
163 //
164 // Get the field cache associated with this klass.
165 ciConstantPoolCache* ciInstanceKlass::field_cache() {
166 if (is_shared()) {
167 return NULL;
168 }
169 if (_field_cache == NULL) {
170 assert(!is_java_lang_Object(), "Object has no fields");
171 Arena* arena = CURRENT_ENV->arena();
172 _field_cache = new (arena) ciConstantPoolCache(arena, 5);
173 }
174 return _field_cache;
175 }
176
177 // ------------------------------------------------------------------
178 // ciInstanceKlass::get_canonical_holder
179 //
180 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
181 #ifdef ASSERT
182 if (!((offset >= 0 && offset < layout_helper()) || (UseShenandoahGC && offset == BrooksPointer::byte_offset()))) {
183 tty->print("*** get_canonical_holder(%d) on ", offset);
184 this->print();
185 tty->print_cr(" ***");
186 fatal("offset must be tame");
187 }
188 #endif
189
190 if (offset < instanceOopDesc::base_offset_in_bytes()) {
191 // All header offsets belong properly to java/lang/Object.
192 return CURRENT_ENV->Object_klass();
193 }
194
195 ciInstanceKlass* self = this;
196 for (;;) {
197 assert(self->is_loaded(), "must be loaded to have size");
198 ciInstanceKlass* super = self->super();
199 if (super == NULL || super->nof_nonstatic_fields() == 0 ||
200 !super->contains_field_offset(offset)) {
201 return self;
202 } else {
|
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 #include "precompiled.hpp"
26 #include "ci/ciField.hpp"
27 #include "ci/ciInstance.hpp"
28 #include "ci/ciInstanceKlass.hpp"
29 #include "ci/ciUtilities.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "gc_implementation/shenandoah/shenandoahBrooksPointer.hpp"
32 #include "memory/allocation.hpp"
33 #include "memory/allocation.inline.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "oops/fieldStreams.hpp"
36 #include "runtime/fieldDescriptor.hpp"
37
38 // ciInstanceKlass
39 //
40 // This class represents a Klass* in the HotSpot virtual machine
41 // whose Klass part in an InstanceKlass.
42
43 // ------------------------------------------------------------------
44 // ciInstanceKlass::ciInstanceKlass
45 //
46 // Loaded instance klass.
47 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
48 ciKlass(h_k), _non_static_fields(NULL)
49 {
50 assert(get_Klass()->oop_is_instance(), "wrong type");
51 assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
162 // ciInstanceKlass::field_cache
163 //
164 // Get the field cache associated with this klass.
165 ciConstantPoolCache* ciInstanceKlass::field_cache() {
166 if (is_shared()) {
167 return NULL;
168 }
169 if (_field_cache == NULL) {
170 assert(!is_java_lang_Object(), "Object has no fields");
171 Arena* arena = CURRENT_ENV->arena();
172 _field_cache = new (arena) ciConstantPoolCache(arena, 5);
173 }
174 return _field_cache;
175 }
176
177 // ------------------------------------------------------------------
178 // ciInstanceKlass::get_canonical_holder
179 //
180 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
181 #ifdef ASSERT
182 if (!((offset >= 0 && offset < layout_helper()) || (UseShenandoahGC && offset == ShenandoahBrooksPointer::byte_offset()))) {
183 tty->print("*** get_canonical_holder(%d) on ", offset);
184 this->print();
185 tty->print_cr(" ***");
186 fatal("offset must be tame");
187 }
188 #endif
189
190 if (offset < instanceOopDesc::base_offset_in_bytes()) {
191 // All header offsets belong properly to java/lang/Object.
192 return CURRENT_ENV->Object_klass();
193 }
194
195 ciInstanceKlass* self = this;
196 for (;;) {
197 assert(self->is_loaded(), "must be loaded to have size");
198 ciInstanceKlass* super = self->super();
199 if (super == NULL || super->nof_nonstatic_fields() == 0 ||
200 !super->contains_field_offset(offset)) {
201 return self;
202 } else {
|