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())) {
183 tty->print("*** get_canonical_holder(%d) on ", offset);
184 this->print();
185 tty->print_cr(" ***");
186 };
187 assert(offset >= 0 && offset < layout_helper(), "offset must be tame");
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 {
203 self = super; // return super->get_canonical_holder(offset)
204 }
205 }
206 }
207
|
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() || (offset == -8 && UseShenandoahGC))) {
183 tty->print("*** get_canonical_holder(%d) on ", offset);
184 this->print();
185 tty->print_cr(" ***");
186 };
187 assert(offset >= 0 && offset < layout_helper() || (offset == -8 && UseShenandoahGC), "offset must be tame");
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 {
203 self = super; // return super->get_canonical_holder(offset)
204 }
205 }
206 }
207
|