Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/methodOop.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 | 7cf1a74771e8 |
children | 3582bf76420e |
comparison
equal
deleted
inserted
replaced
2130:34d64ad817f4 | 2142:8012aa3ccede |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 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. |
148 } | 148 } |
149 | 149 |
150 return -1; | 150 return -1; |
151 } | 151 } |
152 | 152 |
153 methodOop methodOopDesc::method_from_bcp(address bcp) { | |
154 debug_only(static int count = 0; count++); | |
155 assert(Universe::heap()->is_in_permanent(bcp), "bcp not in perm_gen"); | |
156 // TO DO: this may be unsafe in some configurations | |
157 HeapWord* p = Universe::heap()->block_start(bcp); | |
158 assert(Universe::heap()->block_is_obj(p), "must be obj"); | |
159 assert(oop(p)->is_constMethod(), "not a method"); | |
160 return constMethodOop(p)->method(); | |
161 } | |
162 | |
163 | |
164 void methodOopDesc::mask_for(int bci, InterpreterOopMap* mask) { | 153 void methodOopDesc::mask_for(int bci, InterpreterOopMap* mask) { |
165 | 154 |
166 Thread* myThread = Thread::current(); | 155 Thread* myThread = Thread::current(); |
167 methodHandle h_this(myThread, this); | 156 methodHandle h_this(myThread, this); |
168 #ifdef ASSERT | 157 #ifdef ASSERT |
467 | 456 |
468 | 457 |
469 bool methodOopDesc::is_accessor() const { | 458 bool methodOopDesc::is_accessor() const { |
470 if (code_size() != 5) return false; | 459 if (code_size() != 5) return false; |
471 if (size_of_parameters() != 1) return false; | 460 if (size_of_parameters() != 1) return false; |
472 methodOop m = (methodOop)this; // pass to code_at() to avoid method_from_bcp | 461 if (java_code_at(0) != Bytecodes::_aload_0 ) return false; |
473 if (Bytecodes::java_code_at(code_base()+0, m) != Bytecodes::_aload_0 ) return false; | 462 if (java_code_at(1) != Bytecodes::_getfield) return false; |
474 if (Bytecodes::java_code_at(code_base()+1, m) != Bytecodes::_getfield) return false; | 463 if (java_code_at(4) != Bytecodes::_areturn && |
475 if (Bytecodes::java_code_at(code_base()+4, m) != Bytecodes::_areturn && | 464 java_code_at(4) != Bytecodes::_ireturn ) return false; |
476 Bytecodes::java_code_at(code_base()+4, m) != Bytecodes::_ireturn ) return false; | |
477 return true; | 465 return true; |
478 } | 466 } |
479 | 467 |
480 | 468 |
481 bool methodOopDesc::is_initializer() const { | 469 bool methodOopDesc::is_initializer() const { |
1412 } | 1400 } |
1413 return true; | 1401 return true; |
1414 } | 1402 } |
1415 | 1403 |
1416 | 1404 |
1417 Bytecodes::Code methodOopDesc::orig_bytecode_at(int bci) { | 1405 Bytecodes::Code methodOopDesc::orig_bytecode_at(int bci) const { |
1418 BreakpointInfo* bp = instanceKlass::cast(method_holder())->breakpoints(); | 1406 BreakpointInfo* bp = instanceKlass::cast(method_holder())->breakpoints(); |
1419 for (; bp != NULL; bp = bp->next()) { | 1407 for (; bp != NULL; bp = bp->next()) { |
1420 if (bp->match(this, bci)) { | 1408 if (bp->match(this, bci)) { |
1421 return bp->orig_bytecode(); | 1409 return bp->orig_bytecode(); |
1422 } | 1410 } |