comparison src/share/vm/opto/library_call.cpp @ 12295:1b64d46620a3

8022585: VM crashes when ran with -XX:+PrintInlining Summary: use adr_at() to access inline info structures in growableArray. Add ability to specify print inlining per method. Reviewed-by: twisti
author kvn
date Tue, 24 Sep 2013 16:08:00 -0700
parents da051ce490eb
children c9ccd7b85f20
comparison
equal deleted inserted replaced
12294:891687731b59 12295:1b64d46620a3
541 JVMState* LibraryIntrinsic::generate(JVMState* jvms) { 541 JVMState* LibraryIntrinsic::generate(JVMState* jvms) {
542 LibraryCallKit kit(jvms, this); 542 LibraryCallKit kit(jvms, this);
543 Compile* C = kit.C; 543 Compile* C = kit.C;
544 int nodes = C->unique(); 544 int nodes = C->unique();
545 #ifndef PRODUCT 545 #ifndef PRODUCT
546 if ((PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) && Verbose) { 546 if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
547 char buf[1000]; 547 char buf[1000];
548 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); 548 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf));
549 tty->print_cr("Intrinsic %s", str); 549 tty->print_cr("Intrinsic %s", str);
550 } 550 }
551 #endif 551 #endif
552 ciMethod* callee = kit.callee(); 552 ciMethod* callee = kit.callee();
553 const int bci = kit.bci(); 553 const int bci = kit.bci();
554 554
555 // Try to inline the intrinsic. 555 // Try to inline the intrinsic.
556 if (kit.try_to_inline()) { 556 if (kit.try_to_inline()) {
557 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { 557 if (C->print_intrinsics() || C->print_inlining()) {
558 C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); 558 C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
559 } 559 }
560 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); 560 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
561 if (C->log()) { 561 if (C->log()) {
562 C->log()->elem("intrinsic id='%s'%s nodes='%d'", 562 C->log()->elem("intrinsic id='%s'%s nodes='%d'",
568 kit.push_result(); 568 kit.push_result();
569 return kit.transfer_exceptions_into_jvms(); 569 return kit.transfer_exceptions_into_jvms();
570 } 570 }
571 571
572 // The intrinsic bailed out 572 // The intrinsic bailed out
573 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { 573 if (C->print_intrinsics() || C->print_inlining()) {
574 if (jvms->has_method()) { 574 if (jvms->has_method()) {
575 // Not a root compile. 575 // Not a root compile.
576 const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)"; 576 const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)";
577 C->print_inlining(callee, jvms->depth() - 1, bci, msg); 577 C->print_inlining(callee, jvms->depth() - 1, bci, msg);
578 } else { 578 } else {
590 LibraryCallKit kit(jvms, this); 590 LibraryCallKit kit(jvms, this);
591 Compile* C = kit.C; 591 Compile* C = kit.C;
592 int nodes = C->unique(); 592 int nodes = C->unique();
593 #ifndef PRODUCT 593 #ifndef PRODUCT
594 assert(is_predicted(), "sanity"); 594 assert(is_predicted(), "sanity");
595 if ((PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) && Verbose) { 595 if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
596 char buf[1000]; 596 char buf[1000];
597 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); 597 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf));
598 tty->print_cr("Predicate for intrinsic %s", str); 598 tty->print_cr("Predicate for intrinsic %s", str);
599 } 599 }
600 #endif 600 #endif
601 ciMethod* callee = kit.callee(); 601 ciMethod* callee = kit.callee();
602 const int bci = kit.bci(); 602 const int bci = kit.bci();
603 603
604 Node* slow_ctl = kit.try_to_predicate(); 604 Node* slow_ctl = kit.try_to_predicate();
605 if (!kit.failing()) { 605 if (!kit.failing()) {
606 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { 606 if (C->print_intrinsics() || C->print_inlining()) {
607 C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); 607 C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
608 } 608 }
609 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); 609 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
610 if (C->log()) { 610 if (C->log()) {
611 C->log()->elem("predicate_intrinsic id='%s'%s nodes='%d'", 611 C->log()->elem("predicate_intrinsic id='%s'%s nodes='%d'",
615 } 615 }
616 return slow_ctl; // Could be NULL if the check folds. 616 return slow_ctl; // Could be NULL if the check folds.
617 } 617 }
618 618
619 // The intrinsic bailed out 619 // The intrinsic bailed out
620 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { 620 if (C->print_intrinsics() || C->print_inlining()) {
621 if (jvms->has_method()) { 621 if (jvms->has_method()) {
622 // Not a root compile. 622 // Not a root compile.
623 const char* msg = "failed to generate predicate for intrinsic"; 623 const char* msg = "failed to generate predicate for intrinsic";
624 C->print_inlining(kit.callee(), jvms->depth() - 1, bci, msg); 624 C->print_inlining(kit.callee(), jvms->depth() - 1, bci, msg);
625 } else { 625 } else {
2297 // contraint in place. 2297 // contraint in place.
2298 if (sharpened_klass != NULL && sharpened_klass->is_loaded()) { 2298 if (sharpened_klass != NULL && sharpened_klass->is_loaded()) {
2299 const TypeOopPtr* tjp = TypeOopPtr::make_from_klass(sharpened_klass); 2299 const TypeOopPtr* tjp = TypeOopPtr::make_from_klass(sharpened_klass);
2300 2300
2301 #ifndef PRODUCT 2301 #ifndef PRODUCT
2302 if (PrintIntrinsics || PrintInlining || PrintOptoInlining) { 2302 if (C->print_intrinsics() || C->print_inlining()) {
2303 tty->print(" from base type: "); adr_type->dump(); 2303 tty->print(" from base type: "); adr_type->dump();
2304 tty->print(" sharpened value: "); tjp->dump(); 2304 tty->print(" sharpened value: "); tjp->dump();
2305 } 2305 }
2306 #endif 2306 #endif
2307 // Sharpen the value type. 2307 // Sharpen the value type.
3258 3258
3259 const TypeInstPtr* mirror_con = _gvn.type(mirror)->isa_instptr(); 3259 const TypeInstPtr* mirror_con = _gvn.type(mirror)->isa_instptr();
3260 if (mirror_con == NULL) return false; // cannot happen? 3260 if (mirror_con == NULL) return false; // cannot happen?
3261 3261
3262 #ifndef PRODUCT 3262 #ifndef PRODUCT
3263 if (PrintIntrinsics || PrintInlining || PrintOptoInlining) { 3263 if (C->print_intrinsics() || C->print_inlining()) {
3264 ciType* k = mirror_con->java_mirror_type(); 3264 ciType* k = mirror_con->java_mirror_type();
3265 if (k) { 3265 if (k) {
3266 tty->print("Inlining %s on constant Class ", vmIntrinsics::name_at(intrinsic_id())); 3266 tty->print("Inlining %s on constant Class ", vmIntrinsics::name_at(intrinsic_id()));
3267 k->print_name(); 3267 k->print_name();
3268 tty->cr(); 3268 tty->cr();
3950 // NOTE: This code must perform the same logic as JVM_GetCallerClass 3950 // NOTE: This code must perform the same logic as JVM_GetCallerClass
3951 // in that it must skip particular security frames and checks for 3951 // in that it must skip particular security frames and checks for
3952 // caller sensitive methods. 3952 // caller sensitive methods.
3953 bool LibraryCallKit::inline_native_Reflection_getCallerClass() { 3953 bool LibraryCallKit::inline_native_Reflection_getCallerClass() {
3954 #ifndef PRODUCT 3954 #ifndef PRODUCT
3955 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { 3955 if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
3956 tty->print_cr("Attempting to inline sun.reflect.Reflection.getCallerClass"); 3956 tty->print_cr("Attempting to inline sun.reflect.Reflection.getCallerClass");
3957 } 3957 }
3958 #endif 3958 #endif
3959 3959
3960 if (!jvms()->has_method()) { 3960 if (!jvms()->has_method()) {
3961 #ifndef PRODUCT 3961 #ifndef PRODUCT
3962 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { 3962 if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
3963 tty->print_cr(" Bailing out because intrinsic was inlined at top level"); 3963 tty->print_cr(" Bailing out because intrinsic was inlined at top level");
3964 } 3964 }
3965 #endif 3965 #endif
3966 return false; 3966 return false;
3967 } 3967 }
3981 break; 3981 break;
3982 case 1: 3982 case 1:
3983 // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass). 3983 // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass).
3984 if (!m->caller_sensitive()) { 3984 if (!m->caller_sensitive()) {
3985 #ifndef PRODUCT 3985 #ifndef PRODUCT
3986 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { 3986 if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
3987 tty->print_cr(" Bailing out: CallerSensitive annotation expected at frame %d", n); 3987 tty->print_cr(" Bailing out: CallerSensitive annotation expected at frame %d", n);
3988 } 3988 }
3989 #endif 3989 #endif
3990 return false; // bail-out; let JVM_GetCallerClass do the work 3990 return false; // bail-out; let JVM_GetCallerClass do the work
3991 } 3991 }
3997 ciInstanceKlass* caller_klass = caller_jvms->method()->holder(); 3997 ciInstanceKlass* caller_klass = caller_jvms->method()->holder();
3998 ciInstance* caller_mirror = caller_klass->java_mirror(); 3998 ciInstance* caller_mirror = caller_klass->java_mirror();
3999 set_result(makecon(TypeInstPtr::make(caller_mirror))); 3999 set_result(makecon(TypeInstPtr::make(caller_mirror)));
4000 4000
4001 #ifndef PRODUCT 4001 #ifndef PRODUCT
4002 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { 4002 if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
4003 tty->print_cr(" Succeeded: caller = %d) %s.%s, JVMS depth = %d", n, caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), jvms()->depth()); 4003 tty->print_cr(" Succeeded: caller = %d) %s.%s, JVMS depth = %d", n, caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), jvms()->depth());
4004 tty->print_cr(" JVM state at this point:"); 4004 tty->print_cr(" JVM state at this point:");
4005 for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { 4005 for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) {
4006 ciMethod* m = jvms()->of_depth(i)->method(); 4006 ciMethod* m = jvms()->of_depth(i)->method();
4007 tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); 4007 tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8());
4013 break; 4013 break;
4014 } 4014 }
4015 } 4015 }
4016 4016
4017 #ifndef PRODUCT 4017 #ifndef PRODUCT
4018 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { 4018 if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
4019 tty->print_cr(" Bailing out because caller depth exceeded inlining depth = %d", jvms()->depth()); 4019 tty->print_cr(" Bailing out because caller depth exceeded inlining depth = %d", jvms()->depth());
4020 tty->print_cr(" JVM state at this point:"); 4020 tty->print_cr(" JVM state at this point:");
4021 for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { 4021 for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) {
4022 ciMethod* m = jvms()->of_depth(i)->method(); 4022 ciMethod* m = jvms()->of_depth(i)->method();
4023 tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); 4023 tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8());