1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 *
230 return instruction_length_at(bci);
231 }
232 // Otherwise, depends on the switch type.
233 switch (bc) {
234 case Bytecodes::_tableswitch: {
235 int lo = int_at(bci + 1 + pad + 4 * 1);
236 int hi = int_at(bci + 1 + pad + 4 * 2);
237 int n = hi - lo + 1;
238 return 1 + pad + 4*(3 + n);
239 }
240 case Bytecodes::_lookupswitch:
241 case Bytecodes::_fast_linearswitch:
242 case Bytecodes::_fast_binaryswitch: {
243 int npairs = int_at(bci + 1 + pad + 4 * 1);
244 return 1 + pad + 4*(2 + 2*npairs);
245 }
246 default:
247 ShouldNotReachHere();
248 }
249 }
250 }
251 return instruction_length_at(bci);
252 }
253
254 // If a change item is recorded for "pc", with type "ct", returns the
255 // associated padding, else -1.
256 int Relocator::get_orig_switch_pad(int bci, bool is_lookup_switch) {
257 for (int k = 0; k < _changes->length(); k++) {
258 ChangeItem* ci = _changes->at(k);
259 if (ci->is_switch_pad()) {
260 ChangeSwitchPad* csp = (ChangeSwitchPad*)ci;
261 if (csp->is_lookup_switch() == is_lookup_switch && csp->bci() == bci) {
262 return csp->padding();
263 }
264 }
265 }
266 return -1;
267 }
268
269
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 *
230 return instruction_length_at(bci);
231 }
232 // Otherwise, depends on the switch type.
233 switch (bc) {
234 case Bytecodes::_tableswitch: {
235 int lo = int_at(bci + 1 + pad + 4 * 1);
236 int hi = int_at(bci + 1 + pad + 4 * 2);
237 int n = hi - lo + 1;
238 return 1 + pad + 4*(3 + n);
239 }
240 case Bytecodes::_lookupswitch:
241 case Bytecodes::_fast_linearswitch:
242 case Bytecodes::_fast_binaryswitch: {
243 int npairs = int_at(bci + 1 + pad + 4 * 1);
244 return 1 + pad + 4*(2 + 2*npairs);
245 }
246 default:
247 ShouldNotReachHere();
248 }
249 }
250 default:
251 break;
252 }
253 return instruction_length_at(bci);
254 }
255
256 // If a change item is recorded for "pc", with type "ct", returns the
257 // associated padding, else -1.
258 int Relocator::get_orig_switch_pad(int bci, bool is_lookup_switch) {
259 for (int k = 0; k < _changes->length(); k++) {
260 ChangeItem* ci = _changes->at(k);
261 if (ci->is_switch_pad()) {
262 ChangeSwitchPad* csp = (ChangeSwitchPad*)ci;
263 if (csp->is_lookup_switch() == is_lookup_switch && csp->bci() == bci) {
264 return csp->padding();
265 }
266 }
267 }
268 return -1;
269 }
270
271
|