comparison src/share/vm/interpreter/rewriter.cpp @ 2142:8012aa3ccede

4926272: methodOopDesc::method_from_bcp is unsafe Reviewed-by: coleenp, jrose, kvn, dcubed
author never
date Thu, 13 Jan 2011 22:15:41 -0800
parents dad31fc330cd
children d25d4ca69222 c5a923563727
comparison
equal deleted inserted replaced
2130:34d64ad817f4 2142:8012aa3ccede
1 /* 1 /*
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
219 // directly. Some more complicated bytecodes will report 219 // directly. Some more complicated bytecodes will report
220 // a length of zero, meaning we need to make another method 220 // a length of zero, meaning we need to make another method
221 // call to calculate the length. 221 // call to calculate the length.
222 bc_length = Bytecodes::length_for(c); 222 bc_length = Bytecodes::length_for(c);
223 if (bc_length == 0) { 223 if (bc_length == 0) {
224 bc_length = Bytecodes::length_at(bcp); 224 bc_length = Bytecodes::length_at(method, bcp);
225 225
226 // length_at will put us at the bytecode after the one modified 226 // length_at will put us at the bytecode after the one modified
227 // by 'wide'. We don't currently examine any of the bytecodes 227 // by 'wide'. We don't currently examine any of the bytecodes
228 // modified by wide, but in case we do in the future... 228 // modified by wide, but in case we do in the future...
229 if (c == Bytecodes::_wide) { 229 if (c == Bytecodes::_wide) {
235 assert(bc_length != 0, "impossible bytecode length"); 235 assert(bc_length != 0, "impossible bytecode length");
236 236
237 switch (c) { 237 switch (c) {
238 case Bytecodes::_lookupswitch : { 238 case Bytecodes::_lookupswitch : {
239 #ifndef CC_INTERP 239 #ifndef CC_INTERP
240 Bytecode_lookupswitch* bc = Bytecode_lookupswitch_at(bcp); 240 Bytecode_lookupswitch bc(method, bcp);
241 (*bcp) = ( 241 (*bcp) = (
242 bc->number_of_pairs() < BinarySwitchThreshold 242 bc.number_of_pairs() < BinarySwitchThreshold
243 ? Bytecodes::_fast_linearswitch 243 ? Bytecodes::_fast_linearswitch
244 : Bytecodes::_fast_binaryswitch 244 : Bytecodes::_fast_binaryswitch
245 ); 245 );
246 #endif 246 #endif
247 break; 247 break;