128 } _saved;
129
130 void set_tags(Array<u1>* tags) { _tags = tags; }
131 void tag_at_put(int which, jbyte t) { tags()->at_put(which, t); }
132 void release_tag_at_put(int which, jbyte t) { tags()->release_at_put(which, t); }
133
134 u1* tag_addr_at(int which) const { return tags()->adr_at(which); }
135
136 void set_operands(Array<u2>* operands) { _operands = operands; }
137
138 int flags() const { return _flags; }
139 void set_flags(int f) { _flags = f; }
140
141 private:
142 intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(ConstantPool)); }
143
144 CPSlot slot_at(int which) const {
145 assert(is_within_bounds(which), "index out of bounds");
146 assert(!tag_at(which).is_unresolved_klass() && !tag_at(which).is_unresolved_klass_in_error(), "Corrupted constant pool");
147 // Uses volatile because the klass slot changes without a lock.
148 volatile intptr_t adr = (intptr_t)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which));
149 assert(adr != 0 || which == 0, "cp entry for klass should not be zero");
150 return CPSlot(adr);
151 }
152
153 void slot_at_put(int which, CPSlot s) const {
154 assert(is_within_bounds(which), "index out of bounds");
155 assert(s.value() != 0, "Caught something");
156 *(intptr_t*)&base()[which] = s.value();
157 }
158 intptr_t* obj_at_addr_raw(int which) const {
159 assert(is_within_bounds(which), "index out of bounds");
160 return (intptr_t*) &base()[which];
161 }
162
163 jint* int_at_addr(int which) const {
164 assert(is_within_bounds(which), "index out of bounds");
165 return (jint*) &base()[which];
166 }
167
168 jlong* long_at_addr(int which) const {
390 "Corrupted constant pool");
391 int value = *int_at_addr(which);
392 int name_index = extract_high_short_from_int(value);
393 int resolved_klass_index = extract_low_short_from_int(value);
394 return CPKlassSlot(name_index, resolved_klass_index);
395 }
396
397 Symbol* klass_name_at(int which) const; // Returns the name, w/o resolving.
398 int klass_name_index_at(int which) const {
399 return klass_slot_at(which).name_index();
400 }
401
402 Klass* resolved_klass_at(int which) const { // Used by Compiler
403 guarantee(tag_at(which).is_klass(), "Corrupted constant pool");
404 // Must do an acquire here in case another thread resolved the klass
405 // behind our back, lest we later load stale values thru the oop.
406 CPKlassSlot kslot = klass_slot_at(which);
407 assert(tag_at(kslot.name_index()).is_symbol(), "sanity");
408
409 Klass** adr = resolved_klasses()->adr_at(kslot.resolved_klass_index());
410 return (Klass*)OrderAccess::load_ptr_acquire(adr);
411 }
412
413 // RedefineClasses() API support:
414 Symbol* klass_at_noresolve(int which) { return klass_name_at(which); }
415 void temp_unresolved_klass_at_put(int which, int name_index) {
416 // Used only during constant pool merging for class redefinition. The resolved klass index
417 // will be initialized later by a call to initialize_unresolved_klasses().
418 unresolved_klass_at_put(which, name_index, CPKlassSlot::_temp_resolved_klass_index);
419 }
420
421 jint int_at(int which) {
422 assert(tag_at(which).is_int(), "Corrupted constant pool");
423 return *int_at_addr(which);
424 }
425
426 jlong long_at(int which) {
427 assert(tag_at(which).is_long(), "Corrupted constant pool");
428 // return *long_at_addr(which);
429 u8 tmp = Bytes::get_native_u8((address)&base()[which]);
430 return *((jlong*)&tmp);
|
128 } _saved;
129
130 void set_tags(Array<u1>* tags) { _tags = tags; }
131 void tag_at_put(int which, jbyte t) { tags()->at_put(which, t); }
132 void release_tag_at_put(int which, jbyte t) { tags()->release_at_put(which, t); }
133
134 u1* tag_addr_at(int which) const { return tags()->adr_at(which); }
135
136 void set_operands(Array<u2>* operands) { _operands = operands; }
137
138 int flags() const { return _flags; }
139 void set_flags(int f) { _flags = f; }
140
141 private:
142 intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(ConstantPool)); }
143
144 CPSlot slot_at(int which) const {
145 assert(is_within_bounds(which), "index out of bounds");
146 assert(!tag_at(which).is_unresolved_klass() && !tag_at(which).is_unresolved_klass_in_error(), "Corrupted constant pool");
147 // Uses volatile because the klass slot changes without a lock.
148 volatile intptr_t adr = OrderAccess::load_acquire(obj_at_addr_raw(which));
149 assert(adr != 0 || which == 0, "cp entry for klass should not be zero");
150 return CPSlot(adr);
151 }
152
153 void slot_at_put(int which, CPSlot s) const {
154 assert(is_within_bounds(which), "index out of bounds");
155 assert(s.value() != 0, "Caught something");
156 *(intptr_t*)&base()[which] = s.value();
157 }
158 intptr_t* obj_at_addr_raw(int which) const {
159 assert(is_within_bounds(which), "index out of bounds");
160 return (intptr_t*) &base()[which];
161 }
162
163 jint* int_at_addr(int which) const {
164 assert(is_within_bounds(which), "index out of bounds");
165 return (jint*) &base()[which];
166 }
167
168 jlong* long_at_addr(int which) const {
390 "Corrupted constant pool");
391 int value = *int_at_addr(which);
392 int name_index = extract_high_short_from_int(value);
393 int resolved_klass_index = extract_low_short_from_int(value);
394 return CPKlassSlot(name_index, resolved_klass_index);
395 }
396
397 Symbol* klass_name_at(int which) const; // Returns the name, w/o resolving.
398 int klass_name_index_at(int which) const {
399 return klass_slot_at(which).name_index();
400 }
401
402 Klass* resolved_klass_at(int which) const { // Used by Compiler
403 guarantee(tag_at(which).is_klass(), "Corrupted constant pool");
404 // Must do an acquire here in case another thread resolved the klass
405 // behind our back, lest we later load stale values thru the oop.
406 CPKlassSlot kslot = klass_slot_at(which);
407 assert(tag_at(kslot.name_index()).is_symbol(), "sanity");
408
409 Klass** adr = resolved_klasses()->adr_at(kslot.resolved_klass_index());
410 return OrderAccess::load_acquire(adr);
411 }
412
413 // RedefineClasses() API support:
414 Symbol* klass_at_noresolve(int which) { return klass_name_at(which); }
415 void temp_unresolved_klass_at_put(int which, int name_index) {
416 // Used only during constant pool merging for class redefinition. The resolved klass index
417 // will be initialized later by a call to initialize_unresolved_klasses().
418 unresolved_klass_at_put(which, name_index, CPKlassSlot::_temp_resolved_klass_index);
419 }
420
421 jint int_at(int which) {
422 assert(tag_at(which).is_int(), "Corrupted constant pool");
423 return *int_at_addr(which);
424 }
425
426 jlong long_at(int which) {
427 assert(tag_at(which).is_long(), "Corrupted constant pool");
428 // return *long_at_addr(which);
429 u8 tmp = Bytes::get_native_u8((address)&base()[which]);
430 return *((jlong*)&tmp);
|