90 // Current value of an element.
91 // Returns T_ILLEGAL if there is no element at the given index.
92 ciConstant ciArray::element_value(int index) {
93 BasicType elembt = element_basic_type();
94 GUARDED_VM_ENTRY(
95 return element_value_impl(elembt, get_arrayOop(), index);
96 )
97 }
98
99 // ------------------------------------------------------------------
100 // ciArray::element_value_by_offset
101 //
102 // Current value of an element at the specified offset.
103 // Returns T_ILLEGAL if there is no element at the given offset.
104 ciConstant ciArray::element_value_by_offset(intptr_t element_offset) {
105 BasicType elembt = element_basic_type();
106 intptr_t shift = exact_log2(type2aelembytes(elembt));
107 intptr_t header = arrayOopDesc::base_offset_in_bytes(elembt);
108 intptr_t index = (element_offset - header) >> shift;
109 intptr_t offset = header + ((intptr_t)index << shift);
110 if (offset != element_offset || index != (jint)index)
111 return ciConstant();
112 return element_value((jint) index);
113 }
114
115 // ------------------------------------------------------------------
116 // ciArray::print_impl
117 //
118 // Implementation of the print method.
119 void ciArray::print_impl(outputStream* st) {
120 st->print(" length=%d type=", length());
121 klass()->print(st);
122 }
|
90 // Current value of an element.
91 // Returns T_ILLEGAL if there is no element at the given index.
92 ciConstant ciArray::element_value(int index) {
93 BasicType elembt = element_basic_type();
94 GUARDED_VM_ENTRY(
95 return element_value_impl(elembt, get_arrayOop(), index);
96 )
97 }
98
99 // ------------------------------------------------------------------
100 // ciArray::element_value_by_offset
101 //
102 // Current value of an element at the specified offset.
103 // Returns T_ILLEGAL if there is no element at the given offset.
104 ciConstant ciArray::element_value_by_offset(intptr_t element_offset) {
105 BasicType elembt = element_basic_type();
106 intptr_t shift = exact_log2(type2aelembytes(elembt));
107 intptr_t header = arrayOopDesc::base_offset_in_bytes(elembt);
108 intptr_t index = (element_offset - header) >> shift;
109 intptr_t offset = header + ((intptr_t)index << shift);
110 if (offset != element_offset || index != (jint)index || index < 0 || index >= length()) {
111 return ciConstant();
112 }
113 return element_value((jint) index);
114 }
115
116 // ------------------------------------------------------------------
117 // ciArray::print_impl
118 //
119 // Implementation of the print method.
120 void ciArray::print_impl(outputStream* st) {
121 st->print(" length=%d type=", length());
122 klass()->print(st);
123 }
|