Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/verifier.cpp @ 17937:78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
8043029: Change 8037816 breaks HS build with older GCC versions which don't support diagnostic pragmas
8043164: Format warning in traceStream.hpp
Summary: Backport of main fix + two corrections, enables clang compilation, turns on format attributes, corrects/mutes warnings
Reviewed-by: kvn, coleenp, iveresov, twisti
author | drchase |
---|---|
date | Thu, 22 May 2014 15:52:41 -0400 |
parents | 386dd1c71858 |
children | f73af4455d7d ce8f6bb717c9 |
comparison
equal
deleted
inserted
replaced
17935:7384f6a12fc1 | 17937:78bbf4d43a14 |
---|---|
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 |
1673 verify_error(ErrorContext::bad_code(code_length), | 1674 verify_error(ErrorContext::bad_code(code_length), |
1674 "Control flow falls through code end"); | 1675 "Control flow falls through code end"); |
1675 return; | 1676 return; |
1676 } | 1677 } |
1677 } | 1678 } |
1679 | |
1680 #undef bad_type_message | |
1678 | 1681 |
1679 char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) { | 1682 char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) { |
1680 char* code_data = NEW_RESOURCE_ARRAY(char, code_length); | 1683 char* code_data = NEW_RESOURCE_ARRAY(char, code_length); |
1681 memset(code_data, 0, sizeof(char) * code_length); | 1684 memset(code_data, 0, sizeof(char) * code_length); |
1682 RawBytecodeStream bcs(m); | 1685 RawBytecodeStream bcs(m); |
2361 // Get referenced class type | 2364 // Get referenced class type |
2362 VerificationType ref_class_type; | 2365 VerificationType ref_class_type; |
2363 if (opcode == Bytecodes::_invokedynamic) { | 2366 if (opcode == Bytecodes::_invokedynamic) { |
2364 if (!EnableInvokeDynamic || | 2367 if (!EnableInvokeDynamic || |
2365 _klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { | 2368 _klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { |
2366 class_format_error( | 2369 if (!EnableInvokeDynamic) { |
2367 (!EnableInvokeDynamic ? | 2370 class_format_error("invokedynamic instructions not enabled in this JVM"); |
2368 "invokedynamic instructions not enabled in this JVM" : | 2371 } else { |
2369 "invokedynamic instructions not supported by this class file version"), | 2372 class_format_error("invokedynamic instructions not supported by this class file version (%d), class %s", |
2370 _klass->external_name()); | 2373 _klass->major_version(), _klass->external_name()); |
2374 } | |
2371 return; | 2375 return; |
2372 } | 2376 } |
2373 } else { | 2377 } else { |
2374 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this)); | 2378 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this)); |
2375 } | 2379 } |