comparison src/share/vm/code/nmethod.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 5a1e52a439fa
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.
1861 // called with a frame corresponding to a Java invoke 1861 // called with a frame corresponding to a Java invoke
1862 void nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { 1862 void nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
1863 #ifndef SHARK 1863 #ifndef SHARK
1864 if (!method()->is_native()) { 1864 if (!method()->is_native()) {
1865 SimpleScopeDesc ssd(this, fr.pc()); 1865 SimpleScopeDesc ssd(this, fr.pc());
1866 Bytecode_invoke* call = Bytecode_invoke_at(ssd.method(), ssd.bci()); 1866 Bytecode_invoke call(ssd.method(), ssd.bci());
1867 bool has_receiver = call->has_receiver(); 1867 bool has_receiver = call.has_receiver();
1868 symbolOop signature = call->signature(); 1868 symbolOop signature = call.signature();
1869 fr.oops_compiled_arguments_do(signature, has_receiver, reg_map, f); 1869 fr.oops_compiled_arguments_do(signature, has_receiver, reg_map, f);
1870 } 1870 }
1871 #endif // !SHARK 1871 #endif // !SHARK
1872 } 1872 }
1873 1873
2696 if (sd->method().is_null()) { 2696 if (sd->method().is_null()) {
2697 st->print("method is NULL"); 2697 st->print("method is NULL");
2698 } else if (sd->method()->is_native()) { 2698 } else if (sd->method()->is_native()) {
2699 st->print("method is native"); 2699 st->print("method is native");
2700 } else { 2700 } else {
2701 address bcp = sd->method()->bcp_from(sd->bci()); 2701 Bytecodes::Code bc = sd->method()->java_code_at(sd->bci());
2702 Bytecodes::Code bc = Bytecodes::java_code_at(bcp);
2703 st->print(";*%s", Bytecodes::name(bc)); 2702 st->print(";*%s", Bytecodes::name(bc));
2704 switch (bc) { 2703 switch (bc) {
2705 case Bytecodes::_invokevirtual: 2704 case Bytecodes::_invokevirtual:
2706 case Bytecodes::_invokespecial: 2705 case Bytecodes::_invokespecial:
2707 case Bytecodes::_invokestatic: 2706 case Bytecodes::_invokestatic:
2708 case Bytecodes::_invokeinterface: 2707 case Bytecodes::_invokeinterface:
2709 { 2708 {
2710 Bytecode_invoke* invoke = Bytecode_invoke_at(sd->method(), sd->bci()); 2709 Bytecode_invoke invoke(sd->method(), sd->bci());
2711 st->print(" "); 2710 st->print(" ");
2712 if (invoke->name() != NULL) 2711 if (invoke.name() != NULL)
2713 invoke->name()->print_symbol_on(st); 2712 invoke.name()->print_symbol_on(st);
2714 else 2713 else
2715 st->print("<UNKNOWN>"); 2714 st->print("<UNKNOWN>");
2716 break; 2715 break;
2717 } 2716 }
2718 case Bytecodes::_getfield: 2717 case Bytecodes::_getfield:
2719 case Bytecodes::_putfield: 2718 case Bytecodes::_putfield:
2720 case Bytecodes::_getstatic: 2719 case Bytecodes::_getstatic:
2721 case Bytecodes::_putstatic: 2720 case Bytecodes::_putstatic:
2722 { 2721 {
2723 Bytecode_field* field = Bytecode_field_at(sd->method(), sd->bci()); 2722 Bytecode_field field(sd->method(), sd->bci());
2724 st->print(" "); 2723 st->print(" ");
2725 if (field->name() != NULL) 2724 if (field.name() != NULL)
2726 field->name()->print_symbol_on(st); 2725 field.name()->print_symbol_on(st);
2727 else 2726 else
2728 st->print("<UNKNOWN>"); 2727 st->print("<UNKNOWN>");
2729 } 2728 }
2730 } 2729 }
2731 } 2730 }