Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/verifier.cpp @ 18058:54bc75c144b0
Merge
author | asaha |
---|---|
date | Thu, 29 May 2014 13:14:25 -0700 |
parents | 1fa005fb28f5 f73af4455d7d |
children | ec8878dc470d |
comparison
equal
deleted
inserted
replaced
18055:1fa005fb28f5 | 18058:54bc75c144b0 |
---|---|
362 } | 362 } |
363 #endif | 363 #endif |
364 | 364 |
365 void ErrorContext::details(outputStream* ss, const Method* method) const { | 365 void ErrorContext::details(outputStream* ss, const Method* method) const { |
366 if (is_valid()) { | 366 if (is_valid()) { |
367 ss->print_cr(""); | 367 ss->cr(); |
368 ss->print_cr("Exception Details:"); | 368 ss->print_cr("Exception Details:"); |
369 location_details(ss, method); | 369 location_details(ss, method); |
370 reason_details(ss); | 370 reason_details(ss); |
371 frame_details(ss); | 371 frame_details(ss); |
372 bytecode_details(ss, method); | 372 bytecode_details(ss, method); |
377 | 377 |
378 void ErrorContext::reason_details(outputStream* ss) const { | 378 void ErrorContext::reason_details(outputStream* ss) const { |
379 streamIndentor si(ss); | 379 streamIndentor si(ss); |
380 ss->indent().print_cr("Reason:"); | 380 ss->indent().print_cr("Reason:"); |
381 streamIndentor si2(ss); | 381 streamIndentor si2(ss); |
382 ss->indent().print(""); | 382 ss->indent().print("%s", ""); |
383 switch (_fault) { | 383 switch (_fault) { |
384 case INVALID_BYTECODE: | 384 case INVALID_BYTECODE: |
385 ss->print("Error exists in the bytecode"); | 385 ss->print("Error exists in the bytecode"); |
386 break; | 386 break; |
387 case WRONG_TYPE: | 387 case WRONG_TYPE: |
430 case UNKNOWN: | 430 case UNKNOWN: |
431 default: | 431 default: |
432 ShouldNotReachHere(); | 432 ShouldNotReachHere(); |
433 ss->print_cr("Unknown"); | 433 ss->print_cr("Unknown"); |
434 } | 434 } |
435 ss->print_cr(""); | 435 ss->cr(); |
436 } | 436 } |
437 | 437 |
438 void ErrorContext::location_details(outputStream* ss, const Method* method) const { | 438 void ErrorContext::location_details(outputStream* ss, const Method* method) const { |
439 if (_bci != -1 && method != NULL) { | 439 if (_bci != -1 && method != NULL) { |
440 streamIndentor si(ss); | 440 streamIndentor si(ss); |
505 streamIndentor si2(ss); | 505 streamIndentor si2(ss); |
506 int current_offset = -1; | 506 int current_offset = -1; |
507 for (u2 i = 0; i < sm_table->number_of_entries(); ++i) { | 507 for (u2 i = 0; i < sm_table->number_of_entries(); ++i) { |
508 ss->indent(); | 508 ss->indent(); |
509 sm_frame->print_on(ss, current_offset); | 509 sm_frame->print_on(ss, current_offset); |
510 ss->print_cr(""); | 510 ss->cr(); |
511 current_offset += sm_frame->offset_delta(); | 511 current_offset += sm_frame->offset_delta(); |
512 sm_frame = sm_frame->next(); | 512 sm_frame = sm_frame->next(); |
513 } | 513 } |
514 } | 514 } |
515 } | 515 } |
577 _method = m; // initialize _method | 577 _method = m; // initialize _method |
578 if (VerboseVerification) { | 578 if (VerboseVerification) { |
579 tty->print_cr("Verifying method %s", m->name_and_sig_as_C_string()); | 579 tty->print_cr("Verifying method %s", m->name_and_sig_as_C_string()); |
580 } | 580 } |
581 | 581 |
582 const char* bad_type_msg = "Bad type on operand stack in %s"; | 582 // For clang, the only good constant format string is a literal constant format string. |
583 #define bad_type_msg "Bad type on operand stack in %s" | |
583 | 584 |
584 int32_t max_stack = m->verifier_max_stack(); | 585 int32_t max_stack = m->verifier_max_stack(); |
585 int32_t max_locals = m->max_locals(); | 586 int32_t max_locals = m->max_locals(); |
586 constantPoolHandle cp(THREAD, m->constants()); | 587 constantPoolHandle cp(THREAD, m->constants()); |
587 | 588 |
1677 "Control flow falls through code end"); | 1678 "Control flow falls through code end"); |
1678 return; | 1679 return; |
1679 } | 1680 } |
1680 } | 1681 } |
1681 | 1682 |
1683 #undef bad_type_message | |
1684 | |
1682 char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) { | 1685 char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) { |
1683 char* code_data = NEW_RESOURCE_ARRAY(char, code_length); | 1686 char* code_data = NEW_RESOURCE_ARRAY(char, code_length); |
1684 memset(code_data, 0, sizeof(char) * code_length); | 1687 memset(code_data, 0, sizeof(char) * code_length); |
1685 RawBytecodeStream bcs(m); | 1688 RawBytecodeStream bcs(m); |
1686 | 1689 |
1944 } | 1947 } |
1945 // Check if the specified method or field is protected | 1948 // Check if the specified method or field is protected |
1946 InstanceKlass* target_instance = InstanceKlass::cast(target_class); | 1949 InstanceKlass* target_instance = InstanceKlass::cast(target_class); |
1947 fieldDescriptor fd; | 1950 fieldDescriptor fd; |
1948 if (is_method) { | 1951 if (is_method) { |
1949 Method* m = target_instance->uncached_lookup_method(field_name, field_sig); | 1952 Method* m = target_instance->uncached_lookup_method(field_name, field_sig, Klass::normal); |
1950 if (m != NULL && m->is_protected()) { | 1953 if (m != NULL && m->is_protected()) { |
1951 if (!this_class->is_same_class_package(m->method_holder())) { | 1954 if (!this_class->is_same_class_package(m->method_holder())) { |
1952 return true; | 1955 return true; |
1953 } | 1956 } |
1954 } | 1957 } |
2304 if (name_in_supers(ref_class_type.name(), current_class())) { | 2307 if (name_in_supers(ref_class_type.name(), current_class())) { |
2305 Klass* ref_klass = load_class( | 2308 Klass* ref_klass = load_class( |
2306 ref_class_type.name(), CHECK_VERIFY(this)); | 2309 ref_class_type.name(), CHECK_VERIFY(this)); |
2307 Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method( | 2310 Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method( |
2308 vmSymbols::object_initializer_name(), | 2311 vmSymbols::object_initializer_name(), |
2309 cp->signature_ref_at(bcs->get_index_u2())); | 2312 cp->signature_ref_at(bcs->get_index_u2()), Klass::normal); |
2310 // Do nothing if method is not found. Let resolution detect the error. | 2313 // Do nothing if method is not found. Let resolution detect the error. |
2311 if (m != NULL) { | 2314 if (m != NULL) { |
2312 instanceKlassHandle mh(THREAD, m->method_holder()); | 2315 instanceKlassHandle mh(THREAD, m->method_holder()); |
2313 if (m->is_protected() && !mh->is_same_class_package(_klass())) { | 2316 if (m->is_protected() && !mh->is_same_class_package(_klass())) { |
2314 bool assignable = current_type().is_assignable_from( | 2317 bool assignable = current_type().is_assignable_from( |
2389 // Get referenced class type | 2392 // Get referenced class type |
2390 VerificationType ref_class_type; | 2393 VerificationType ref_class_type; |
2391 if (opcode == Bytecodes::_invokedynamic) { | 2394 if (opcode == Bytecodes::_invokedynamic) { |
2392 if (!EnableInvokeDynamic || | 2395 if (!EnableInvokeDynamic || |
2393 _klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { | 2396 _klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { |
2394 class_format_error( | 2397 if (!EnableInvokeDynamic) { |
2395 (!EnableInvokeDynamic ? | 2398 class_format_error("invokedynamic instructions not enabled in this JVM"); |
2396 "invokedynamic instructions not enabled in this JVM" : | 2399 } else { |
2397 "invokedynamic instructions not supported by this class file version"), | 2400 class_format_error("invokedynamic instructions not supported by this class file version (%d), class %s", |
2398 _klass->external_name()); | 2401 _klass->major_version(), _klass->external_name()); |
2402 } | |
2399 return; | 2403 return; |
2400 } | 2404 } |
2401 } else { | 2405 } else { |
2402 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this)); | 2406 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this)); |
2403 } | 2407 } |