Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/verifier.cpp @ 2044:06f017f7daa7
Merge.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Fri, 07 Jan 2011 18:18:08 +0100 |
parents | 828eafbd85cc |
children | 3582bf76420e |
comparison
equal
deleted
inserted
replaced
1942:00bc9eaf0e24 | 2044:06f017f7daa7 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 # include "incls/_precompiled.incl" | 25 #include "precompiled.hpp" |
26 # include "incls/_verifier.cpp.incl" | 26 #include "classfile/classFileStream.hpp" |
27 #include "classfile/javaClasses.hpp" | |
28 #include "classfile/stackMapTable.hpp" | |
29 #include "classfile/systemDictionary.hpp" | |
30 #include "classfile/verifier.hpp" | |
31 #include "classfile/vmSymbols.hpp" | |
32 #include "interpreter/bytecodeStream.hpp" | |
33 #include "memory/oopFactory.hpp" | |
34 #include "memory/resourceArea.hpp" | |
35 #include "oops/instanceKlass.hpp" | |
36 #include "oops/oop.inline.hpp" | |
37 #include "oops/typeArrayOop.hpp" | |
38 #include "prims/jvm.h" | |
39 #include "runtime/fieldDescriptor.hpp" | |
40 #include "runtime/handles.inline.hpp" | |
41 #include "runtime/interfaceSupport.hpp" | |
42 #include "runtime/javaCalls.hpp" | |
43 #include "runtime/orderAccess.hpp" | |
44 #include "runtime/os.hpp" | |
45 #ifdef TARGET_ARCH_x86 | |
46 # include "bytes_x86.hpp" | |
47 #endif | |
48 #ifdef TARGET_ARCH_sparc | |
49 # include "bytes_sparc.hpp" | |
50 #endif | |
51 #ifdef TARGET_ARCH_zero | |
52 # include "bytes_zero.hpp" | |
53 #endif | |
27 | 54 |
28 #define NOFAILOVER_MAJOR_VERSION 51 | 55 #define NOFAILOVER_MAJOR_VERSION 51 |
29 | 56 |
30 // Access to external entry for VerifyClassCodes - old byte code verifier | 57 // Access to external entry for VerifyClassCodes - old byte code verifier |
31 | 58 |
39 static volatile jint _is_new_verify_byte_codes_fn = (jint) true; | 66 static volatile jint _is_new_verify_byte_codes_fn = (jint) true; |
40 | 67 |
41 static void* verify_byte_codes_fn() { | 68 static void* verify_byte_codes_fn() { |
42 if (_verify_byte_codes_fn == NULL) { | 69 if (_verify_byte_codes_fn == NULL) { |
43 void *lib_handle = os::native_java_library(); | 70 void *lib_handle = os::native_java_library(); |
44 void *func = hpi::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion"); | 71 void *func = os::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion"); |
45 OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); | 72 OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); |
46 if (func == NULL) { | 73 if (func == NULL) { |
47 OrderAccess::release_store(&_is_new_verify_byte_codes_fn, false); | 74 OrderAccess::release_store(&_is_new_verify_byte_codes_fn, false); |
48 func = hpi::dll_lookup(lib_handle, "VerifyClassCodes"); | 75 func = os::dll_lookup(lib_handle, "VerifyClassCodes"); |
49 OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); | 76 OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); |
50 } | 77 } |
51 } | 78 } |
52 return (void*)_verify_byte_codes_fn; | 79 return (void*)_verify_byte_codes_fn; |
53 } | 80 } |
245 } | 272 } |
246 | 273 |
247 ClassVerifier::~ClassVerifier() { | 274 ClassVerifier::~ClassVerifier() { |
248 } | 275 } |
249 | 276 |
277 VerificationType ClassVerifier::object_type() const { | |
278 return VerificationType::reference_type(vmSymbols::java_lang_Object()); | |
279 } | |
280 | |
250 void ClassVerifier::verify_class(TRAPS) { | 281 void ClassVerifier::verify_class(TRAPS) { |
251 if (_verify_verbose) { | 282 if (_verify_verbose) { |
252 tty->print_cr("Verifying class %s with new format", | 283 tty->print_cr("Verifying class %s with new format", |
253 _klass->external_name()); | 284 _klass->external_name()); |
254 } | 285 } |
724 verify_error(bci, bad_type_msg, "dastore"); | 755 verify_error(bci, bad_type_msg, "dastore"); |
725 return; | 756 return; |
726 } | 757 } |
727 no_control_flow = false; break; | 758 no_control_flow = false; break; |
728 case Bytecodes::_aastore : | 759 case Bytecodes::_aastore : |
729 type = current_frame.pop_stack( | 760 type = current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); |
730 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
731 type2 = current_frame.pop_stack( | 761 type2 = current_frame.pop_stack( |
732 VerificationType::integer_type(), CHECK_VERIFY(this)); | 762 VerificationType::integer_type(), CHECK_VERIFY(this)); |
733 atype = current_frame.pop_stack( | 763 atype = current_frame.pop_stack( |
734 VerificationType::reference_check(), CHECK_VERIFY(this)); | 764 VerificationType::reference_check(), CHECK_VERIFY(this)); |
735 // more type-checking is done at runtime | 765 // more type-checking is done at runtime |
1230 no_control_flow = false; break; | 1260 no_control_flow = false; break; |
1231 case Bytecodes::_checkcast : | 1261 case Bytecodes::_checkcast : |
1232 { | 1262 { |
1233 index = bcs.get_index_u2(); | 1263 index = bcs.get_index_u2(); |
1234 verify_cp_class_type(index, cp, CHECK_VERIFY(this)); | 1264 verify_cp_class_type(index, cp, CHECK_VERIFY(this)); |
1235 current_frame.pop_stack( | 1265 current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); |
1236 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1237 VerificationType klass_type = cp_index_to_type( | 1266 VerificationType klass_type = cp_index_to_type( |
1238 index, cp, CHECK_VERIFY(this)); | 1267 index, cp, CHECK_VERIFY(this)); |
1239 current_frame.push_stack(klass_type, CHECK_VERIFY(this)); | 1268 current_frame.push_stack(klass_type, CHECK_VERIFY(this)); |
1240 no_control_flow = false; break; | 1269 no_control_flow = false; break; |
1241 } | 1270 } |
1242 case Bytecodes::_instanceof : { | 1271 case Bytecodes::_instanceof : { |
1243 index = bcs.get_index_u2(); | 1272 index = bcs.get_index_u2(); |
1244 verify_cp_class_type(index, cp, CHECK_VERIFY(this)); | 1273 verify_cp_class_type(index, cp, CHECK_VERIFY(this)); |
1245 current_frame.pop_stack( | 1274 current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); |
1246 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1247 current_frame.push_stack( | 1275 current_frame.push_stack( |
1248 VerificationType::integer_type(), CHECK_VERIFY(this)); | 1276 VerificationType::integer_type(), CHECK_VERIFY(this)); |
1249 no_control_flow = false; break; | 1277 no_control_flow = false; break; |
1250 } | 1278 } |
1251 case Bytecodes::_monitorenter : | 1279 case Bytecodes::_monitorenter : |
1608 assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w"); | 1636 assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w"); |
1609 types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long); | 1637 types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long); |
1610 verify_cp_type(index, cp, types, CHECK_VERIFY(this)); | 1638 verify_cp_type(index, cp, types, CHECK_VERIFY(this)); |
1611 } | 1639 } |
1612 if (tag.is_string() && cp->is_pseudo_string_at(index)) { | 1640 if (tag.is_string() && cp->is_pseudo_string_at(index)) { |
1613 current_frame->push_stack( | 1641 current_frame->push_stack(object_type(), CHECK_VERIFY(this)); |
1614 VerificationType::reference_type( | |
1615 vmSymbols::java_lang_Object()), CHECK_VERIFY(this)); | |
1616 } else if (tag.is_string() || tag.is_unresolved_string()) { | 1642 } else if (tag.is_string() || tag.is_unresolved_string()) { |
1617 current_frame->push_stack( | 1643 current_frame->push_stack( |
1618 VerificationType::reference_type( | 1644 VerificationType::reference_type( |
1619 vmSymbols::java_lang_String()), CHECK_VERIFY(this)); | 1645 vmSymbols::java_lang_String()), CHECK_VERIFY(this)); |
1620 } else if (tag.is_klass() || tag.is_unresolved_klass()) { | 1646 } else if (tag.is_klass() || tag.is_unresolved_klass()) { |