comparison src/share/vm/interpreter/interpreterRuntime.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 9bc798875b2a
children 633a44a9fc45
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.
130 IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) { 130 IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) {
131 assert(bytecode == Bytecodes::_fast_aldc || 131 assert(bytecode == Bytecodes::_fast_aldc ||
132 bytecode == Bytecodes::_fast_aldc_w, "wrong bc"); 132 bytecode == Bytecodes::_fast_aldc_w, "wrong bc");
133 ResourceMark rm(thread); 133 ResourceMark rm(thread);
134 methodHandle m (thread, method(thread)); 134 methodHandle m (thread, method(thread));
135 Bytecode_loadconstant* ldc = Bytecode_loadconstant_at(m, bci(thread)); 135 Bytecode_loadconstant ldc(m, bci(thread));
136 oop result = ldc->resolve_constant(THREAD); 136 oop result = ldc.resolve_constant(THREAD);
137 DEBUG_ONLY(ConstantPoolCacheEntry* cpce = m->constants()->cache()->entry_at(ldc->cache_index())); 137 DEBUG_ONLY(ConstantPoolCacheEntry* cpce = m->constants()->cache()->entry_at(ldc.cache_index()));
138 assert(result == cpce->f1(), "expected result for assembly code"); 138 assert(result == cpce->f1(), "expected result for assembly code");
139 } 139 }
140 IRT_END 140 IRT_END
141 141
142 142
670 // extract receiver from the outgoing argument list if necessary 670 // extract receiver from the outgoing argument list if necessary
671 Handle receiver(thread, NULL); 671 Handle receiver(thread, NULL);
672 if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface) { 672 if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface) {
673 ResourceMark rm(thread); 673 ResourceMark rm(thread);
674 methodHandle m (thread, method(thread)); 674 methodHandle m (thread, method(thread));
675 Bytecode_invoke* call = Bytecode_invoke_at(m, bci(thread)); 675 Bytecode_invoke call(m, bci(thread));
676 symbolHandle signature (thread, call->signature()); 676 symbolHandle signature (thread, call.signature());
677 receiver = Handle(thread, 677 receiver = Handle(thread,
678 thread->last_frame().interpreter_callee_receiver(signature)); 678 thread->last_frame().interpreter_callee_receiver(signature));
679 assert(Universe::heap()->is_in_reserved_or_null(receiver()), 679 assert(Universe::heap()->is_in_reserved_or_null(receiver()),
680 "sanity check"); 680 "sanity check");
681 assert(receiver.is_null() || 681 assert(receiver.is_null() ||
754 int site_index = 0; 754 int site_index = 0;
755 { address caller_bcp = bcp(thread); 755 { address caller_bcp = bcp(thread);
756 caller_bci = caller_method->bci_from(caller_bcp); 756 caller_bci = caller_method->bci_from(caller_bcp);
757 site_index = Bytes::get_native_u4(caller_bcp+1); 757 site_index = Bytes::get_native_u4(caller_bcp+1);
758 } 758 }
759 assert(site_index == InterpreterRuntime::bytecode(thread)->get_index_u4(bytecode), ""); 759 assert(site_index == InterpreterRuntime::bytecode(thread).get_index_u4(bytecode), "");
760 assert(constantPoolCacheOopDesc::is_secondary_index(site_index), "proper format"); 760 assert(constantPoolCacheOopDesc::is_secondary_index(site_index), "proper format");
761 // there is a second CPC entries that is of interest; it caches signature info: 761 // there is a second CPC entries that is of interest; it caches signature info:
762 int main_index = pool->cache()->secondary_entry_at(site_index)->main_entry_index(); 762 int main_index = pool->cache()->secondary_entry_at(site_index)->main_entry_index();
763 int pool_index = pool->cache()->entry_at(main_index)->constant_pool_index(); 763 int pool_index = pool->cache()->entry_at(main_index)->constant_pool_index();
764 764
1243 ResourceMark rm; 1243 ResourceMark rm;
1244 frame fr = thread->last_frame(); 1244 frame fr = thread->last_frame();
1245 assert(fr.is_interpreted_frame(), ""); 1245 assert(fr.is_interpreted_frame(), "");
1246 jint bci = fr.interpreter_frame_bci(); 1246 jint bci = fr.interpreter_frame_bci();
1247 methodHandle mh(thread, fr.interpreter_frame_method()); 1247 methodHandle mh(thread, fr.interpreter_frame_method());
1248 Bytecode_invoke* invoke = Bytecode_invoke_at(mh, bci); 1248 Bytecode_invoke invoke(mh, bci);
1249 ArgumentSizeComputer asc(invoke->signature()); 1249 ArgumentSizeComputer asc(invoke.signature());
1250 int size_of_arguments = (asc.size() + (invoke->has_receiver() ? 1 : 0)); // receiver 1250 int size_of_arguments = (asc.size() + (invoke.has_receiver() ? 1 : 0)); // receiver
1251 Copy::conjoint_jbytes(src_address, dest_address, 1251 Copy::conjoint_jbytes(src_address, dest_address,
1252 size_of_arguments * Interpreter::stackElementSize); 1252 size_of_arguments * Interpreter::stackElementSize);
1253 IRT_END 1253 IRT_END
1254 #endif 1254 #endif