149 |
149 |
150 // Does this instruction contain an index which refes into the CP cache? |
150 // Does this instruction contain an index which refes into the CP cache? |
151 bool has_cache_index() const { return Bytecodes::uses_cp_cache(cur_bc_raw()); } |
151 bool has_cache_index() const { return Bytecodes::uses_cp_cache(cur_bc_raw()); } |
152 |
152 |
153 int get_index_u1() const { |
153 int get_index_u1() const { |
154 return bytecode()->get_index_u1(cur_bc_raw()); |
154 return bytecode().get_index_u1(cur_bc_raw()); |
155 } |
155 } |
156 |
156 |
157 int get_index_u1_cpcache() const { |
157 int get_index_u1_cpcache() const { |
158 return bytecode()->get_index_u1_cpcache(cur_bc_raw()); |
158 return bytecode().get_index_u1_cpcache(cur_bc_raw()); |
159 } |
159 } |
160 |
160 |
161 // Get a byte index following this bytecode. |
161 // Get a byte index following this bytecode. |
162 // If prefixed with a wide bytecode, get a wide index. |
162 // If prefixed with a wide bytecode, get a wide index. |
163 int get_index() const { |
163 int get_index() const { |
167 : get_index_u1(); // no, return narrow index |
167 : get_index_u1(); // no, return narrow index |
168 } |
168 } |
169 |
169 |
170 // Get 2-byte index (byte swapping depending on which bytecode) |
170 // Get 2-byte index (byte swapping depending on which bytecode) |
171 int get_index_u2(bool is_wide = false) const { |
171 int get_index_u2(bool is_wide = false) const { |
172 return bytecode()->get_index_u2(cur_bc_raw(), is_wide); |
172 return bytecode().get_index_u2(cur_bc_raw(), is_wide); |
173 } |
173 } |
174 |
174 |
175 // Get 2-byte index in native byte order. (Rewriter::rewrite makes these.) |
175 // Get 2-byte index in native byte order. (Rewriter::rewrite makes these.) |
176 int get_index_u2_cpcache() const { |
176 int get_index_u2_cpcache() const { |
177 return bytecode()->get_index_u2_cpcache(cur_bc_raw()); |
177 return bytecode().get_index_u2_cpcache(cur_bc_raw()); |
178 } |
178 } |
179 |
179 |
180 // Get 4-byte index, for invokedynamic. |
180 // Get 4-byte index, for invokedynamic. |
181 int get_index_u4() const { |
181 int get_index_u4() const { |
182 return bytecode()->get_index_u4(cur_bc_raw()); |
182 return bytecode().get_index_u4(cur_bc_raw()); |
183 } |
183 } |
184 |
184 |
185 bool has_index_u4() const { |
185 bool has_index_u4() const { |
186 return bytecode()->has_index_u4(cur_bc_raw()); |
186 return bytecode().has_index_u4(cur_bc_raw()); |
187 } |
187 } |
188 |
188 |
189 // Get dimensions byte (multinewarray) |
189 // Get dimensions byte (multinewarray) |
190 int get_dimensions() const { return *(unsigned char*)(_pc-1); } |
190 int get_dimensions() const { return *(unsigned char*)(_pc-1); } |
191 |
191 |
192 // Sign-extended index byte/short, no widening |
192 // Sign-extended index byte/short, no widening |
193 int get_constant_u1() const { return bytecode()->get_constant_u1(instruction_size()-1, cur_bc_raw()); } |
193 int get_constant_u1() const { return bytecode().get_constant_u1(instruction_size()-1, cur_bc_raw()); } |
194 int get_constant_u2(bool is_wide = false) const { return bytecode()->get_constant_u2(instruction_size()-2, cur_bc_raw(), is_wide); } |
194 int get_constant_u2(bool is_wide = false) const { return bytecode().get_constant_u2(instruction_size()-2, cur_bc_raw(), is_wide); } |
195 |
195 |
196 // Get a byte signed constant for "iinc". Invalid for other bytecodes. |
196 // Get a byte signed constant for "iinc". Invalid for other bytecodes. |
197 // If prefixed with a wide bytecode, get a wide constant |
197 // If prefixed with a wide bytecode, get a wide constant |
198 int get_iinc_con() const {return (_pc==_was_wide) ? (jshort) get_constant_u2(true) : (jbyte) get_constant_u1();} |
198 int get_iinc_con() const {return (_pc==_was_wide) ? (jshort) get_constant_u2(true) : (jbyte) get_constant_u1();} |
199 |
199 |
200 // 2-byte branch offset from current pc |
200 // 2-byte branch offset from current pc |
201 int get_dest() const { |
201 int get_dest() const { |
202 return cur_bci() + bytecode()->get_offset_s2(cur_bc_raw()); |
202 return cur_bci() + bytecode().get_offset_s2(cur_bc_raw()); |
203 } |
203 } |
204 |
204 |
205 // 2-byte branch offset from next pc |
205 // 2-byte branch offset from next pc |
206 int next_get_dest() const { |
206 int next_get_dest() const { |
207 assert(_pc < _end, ""); |
207 assert(_pc < _end, ""); |
208 return next_bci() + next_bytecode()->get_offset_s2(Bytecodes::_ifeq); |
208 return next_bci() + next_bytecode().get_offset_s2(Bytecodes::_ifeq); |
209 } |
209 } |
210 |
210 |
211 // 4-byte branch offset from current pc |
211 // 4-byte branch offset from current pc |
212 int get_far_dest() const { |
212 int get_far_dest() const { |
213 return cur_bci() + bytecode()->get_offset_s4(cur_bc_raw()); |
213 return cur_bci() + bytecode().get_offset_s4(cur_bc_raw()); |
214 } |
214 } |
215 |
215 |
216 // For a lookup or switch table, return target destination |
216 // For a lookup or switch table, return target destination |
217 int get_int_table( int index ) const { |
217 int get_int_table( int index ) const { |
218 return Bytes::get_Java_u4((address)&_table_base[index]); } |
218 return Bytes::get_Java_u4((address)&_table_base[index]); } |