comparison src/share/vm/opto/callGenerator.cpp @ 12956:3213ba4d3dff

8024069: replace_in_map() should operate on parent maps Summary: type information gets lost because replace_in_map() doesn't update parent maps Reviewed-by: kvn, twisti
author roland
date Sat, 19 Oct 2013 12:16:43 +0200
parents 6f3fd5150b67
children b2ee5dc63353
comparison
equal deleted inserted replaced
12955:252d541466ea 12956:3213ba4d3dff
61 _expected_uses = expected_uses; 61 _expected_uses = expected_uses;
62 assert(InlineTree::check_can_parse(method) == NULL, "parse must be possible"); 62 assert(InlineTree::check_can_parse(method) == NULL, "parse must be possible");
63 } 63 }
64 64
65 virtual bool is_parse() const { return true; } 65 virtual bool is_parse() const { return true; }
66 virtual JVMState* generate(JVMState* jvms); 66 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser);
67 int is_osr() { return _is_osr; } 67 int is_osr() { return _is_osr; }
68 68
69 }; 69 };
70 70
71 JVMState* ParseGenerator::generate(JVMState* jvms) { 71 JVMState* ParseGenerator::generate(JVMState* jvms, Parse* parent_parser) {
72 Compile* C = Compile::current(); 72 Compile* C = Compile::current();
73 73
74 if (is_osr()) { 74 if (is_osr()) {
75 // The JVMS for a OSR has a single argument (see its TypeFunc). 75 // The JVMS for a OSR has a single argument (see its TypeFunc).
76 assert(jvms->depth() == 1, "no inline OSR"); 76 assert(jvms->depth() == 1, "no inline OSR");
78 78
79 if (C->failing()) { 79 if (C->failing()) {
80 return NULL; // bailing out of the compile; do not try to parse 80 return NULL; // bailing out of the compile; do not try to parse
81 } 81 }
82 82
83 Parse parser(jvms, method(), _expected_uses); 83 Parse parser(jvms, method(), _expected_uses, parent_parser);
84 // Grab signature for matching/allocation 84 // Grab signature for matching/allocation
85 #ifdef ASSERT 85 #ifdef ASSERT
86 if (parser.tf() != (parser.depth() == 1 ? C->tf() : tf())) { 86 if (parser.tf() != (parser.depth() == 1 ? C->tf() : tf())) {
87 MutexLockerEx ml(Compile_lock, Mutex::_no_safepoint_check_flag); 87 MutexLockerEx ml(Compile_lock, Mutex::_no_safepoint_check_flag);
88 assert(C->env()->system_dictionary_modification_counter_changed(), 88 assert(C->env()->system_dictionary_modification_counter_changed(),
117 DirectCallGenerator(ciMethod* method, bool separate_io_proj) 117 DirectCallGenerator(ciMethod* method, bool separate_io_proj)
118 : CallGenerator(method), 118 : CallGenerator(method),
119 _separate_io_proj(separate_io_proj) 119 _separate_io_proj(separate_io_proj)
120 { 120 {
121 } 121 }
122 virtual JVMState* generate(JVMState* jvms); 122 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser);
123 123
124 CallStaticJavaNode* call_node() const { return _call_node; } 124 CallStaticJavaNode* call_node() const { return _call_node; }
125 }; 125 };
126 126
127 JVMState* DirectCallGenerator::generate(JVMState* jvms) { 127 JVMState* DirectCallGenerator::generate(JVMState* jvms, Parse* parent_parser) {
128 GraphKit kit(jvms); 128 GraphKit kit(jvms);
129 bool is_static = method()->is_static(); 129 bool is_static = method()->is_static();
130 address target = is_static ? SharedRuntime::get_resolve_static_call_stub() 130 address target = is_static ? SharedRuntime::get_resolve_static_call_stub()
131 : SharedRuntime::get_resolve_opt_virtual_call_stub(); 131 : SharedRuntime::get_resolve_opt_virtual_call_stub();
132 132
169 { 169 {
170 assert(vtable_index == Method::invalid_vtable_index || 170 assert(vtable_index == Method::invalid_vtable_index ||
171 vtable_index >= 0, "either invalid or usable"); 171 vtable_index >= 0, "either invalid or usable");
172 } 172 }
173 virtual bool is_virtual() const { return true; } 173 virtual bool is_virtual() const { return true; }
174 virtual JVMState* generate(JVMState* jvms); 174 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser);
175 }; 175 };
176 176
177 JVMState* VirtualCallGenerator::generate(JVMState* jvms) { 177 JVMState* VirtualCallGenerator::generate(JVMState* jvms, Parse* parent_parser) {
178 GraphKit kit(jvms); 178 GraphKit kit(jvms);
179 Node* receiver = kit.argument(0); 179 Node* receiver = kit.argument(0);
180 180
181 if (kit.C->log() != NULL) { 181 if (kit.C->log() != NULL) {
182 kit.C->log()->elem("virtual_call bci='%d'", jvms->bci()); 182 kit.C->log()->elem("virtual_call bci='%d'", jvms->bci());
274 virtual bool is_late_inline() const { return true; } 274 virtual bool is_late_inline() const { return true; }
275 275
276 // Convert the CallStaticJava into an inline 276 // Convert the CallStaticJava into an inline
277 virtual void do_late_inline(); 277 virtual void do_late_inline();
278 278
279 virtual JVMState* generate(JVMState* jvms) { 279 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
280 Compile *C = Compile::current(); 280 Compile *C = Compile::current();
281 C->print_inlining_skip(this); 281 C->print_inlining_skip(this);
282 282
283 // Record that this call site should be revisited once the main 283 // Record that this call site should be revisited once the main
284 // parse is finished. 284 // parse is finished.
288 288
289 // Emit the CallStaticJava and request separate projections so 289 // Emit the CallStaticJava and request separate projections so
290 // that the late inlining logic can distinguish between fall 290 // that the late inlining logic can distinguish between fall
291 // through and exceptional uses of the memory and io projections 291 // through and exceptional uses of the memory and io projections
292 // as is done for allocations and macro expansion. 292 // as is done for allocations and macro expansion.
293 return DirectCallGenerator::generate(jvms); 293 return DirectCallGenerator::generate(jvms, parent_parser);
294 } 294 }
295 295
296 virtual void print_inlining_late(const char* msg) { 296 virtual void print_inlining_late(const char* msg) {
297 CallNode* call = call_node(); 297 CallNode* call = call_node();
298 Compile* C = Compile::current(); 298 Compile* C = Compile::current();
387 entry_nn->set_jvms(jvms); 387 entry_nn->set_jvms(jvms);
388 C->set_default_node_notes(entry_nn); 388 C->set_default_node_notes(entry_nn);
389 } 389 }
390 390
391 // Now perform the inling using the synthesized JVMState 391 // Now perform the inling using the synthesized JVMState
392 JVMState* new_jvms = _inline_cg->generate(jvms); 392 JVMState* new_jvms = _inline_cg->generate(jvms, NULL);
393 if (new_jvms == NULL) return; // no change 393 if (new_jvms == NULL) return; // no change
394 if (C->failing()) return; 394 if (C->failing()) return;
395 395
396 // Capture any exceptional control flow 396 // Capture any exceptional control flow
397 GraphKit kit(new_jvms); 397 GraphKit kit(new_jvms);
427 LateInlineMHCallGenerator(ciMethod* caller, ciMethod* callee, bool input_not_const) : 427 LateInlineMHCallGenerator(ciMethod* caller, ciMethod* callee, bool input_not_const) :
428 LateInlineCallGenerator(callee, NULL), _caller(caller), _attempt(0), _input_not_const(input_not_const) {} 428 LateInlineCallGenerator(callee, NULL), _caller(caller), _attempt(0), _input_not_const(input_not_const) {}
429 429
430 virtual bool is_mh_late_inline() const { return true; } 430 virtual bool is_mh_late_inline() const { return true; }
431 431
432 virtual JVMState* generate(JVMState* jvms) { 432 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
433 JVMState* new_jvms = LateInlineCallGenerator::generate(jvms); 433 JVMState* new_jvms = LateInlineCallGenerator::generate(jvms, parent_parser);
434 if (_input_not_const) { 434 if (_input_not_const) {
435 // inlining won't be possible so no need to enqueue right now. 435 // inlining won't be possible so no need to enqueue right now.
436 call_node()->set_generator(this); 436 call_node()->set_generator(this);
437 } else { 437 } else {
438 Compile::current()->add_late_inline(this); 438 Compile::current()->add_late_inline(this);
475 475
476 public: 476 public:
477 LateInlineStringCallGenerator(ciMethod* method, CallGenerator* inline_cg) : 477 LateInlineStringCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
478 LateInlineCallGenerator(method, inline_cg) {} 478 LateInlineCallGenerator(method, inline_cg) {}
479 479
480 virtual JVMState* generate(JVMState* jvms) { 480 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
481 Compile *C = Compile::current(); 481 Compile *C = Compile::current();
482 C->print_inlining_skip(this); 482 C->print_inlining_skip(this);
483 483
484 C->add_string_late_inline(this); 484 C->add_string_late_inline(this);
485 485
486 JVMState* new_jvms = DirectCallGenerator::generate(jvms); 486 JVMState* new_jvms = DirectCallGenerator::generate(jvms, parent_parser);
487 return new_jvms; 487 return new_jvms;
488 } 488 }
489 }; 489 };
490 490
491 CallGenerator* CallGenerator::for_string_late_inline(ciMethod* method, CallGenerator* inline_cg) { 491 CallGenerator* CallGenerator::for_string_late_inline(ciMethod* method, CallGenerator* inline_cg) {
496 496
497 public: 497 public:
498 LateInlineBoxingCallGenerator(ciMethod* method, CallGenerator* inline_cg) : 498 LateInlineBoxingCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
499 LateInlineCallGenerator(method, inline_cg) {} 499 LateInlineCallGenerator(method, inline_cg) {}
500 500
501 virtual JVMState* generate(JVMState* jvms) { 501 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
502 Compile *C = Compile::current(); 502 Compile *C = Compile::current();
503 C->print_inlining_skip(this); 503 C->print_inlining_skip(this);
504 504
505 C->add_boxing_late_inline(this); 505 C->add_boxing_late_inline(this);
506 506
507 JVMState* new_jvms = DirectCallGenerator::generate(jvms); 507 JVMState* new_jvms = DirectCallGenerator::generate(jvms, parent_parser);
508 return new_jvms; 508 return new_jvms;
509 } 509 }
510 }; 510 };
511 511
512 CallGenerator* CallGenerator::for_boxing_late_inline(ciMethod* method, CallGenerator* inline_cg) { 512 CallGenerator* CallGenerator::for_boxing_late_inline(ciMethod* method, CallGenerator* inline_cg) {
538 538
539 virtual bool is_inline() const { return _is_inline; } 539 virtual bool is_inline() const { return _is_inline; }
540 virtual bool is_virtual() const { return _is_virtual; } 540 virtual bool is_virtual() const { return _is_virtual; }
541 virtual bool is_deferred() const { return true; } 541 virtual bool is_deferred() const { return true; }
542 542
543 virtual JVMState* generate(JVMState* jvms); 543 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser);
544 }; 544 };
545 545
546 546
547 CallGenerator* CallGenerator::for_warm_call(WarmCallInfo* ci, 547 CallGenerator* CallGenerator::for_warm_call(WarmCallInfo* ci,
548 CallGenerator* if_cold, 548 CallGenerator* if_cold,
549 CallGenerator* if_hot) { 549 CallGenerator* if_hot) {
550 return new WarmCallGenerator(ci, if_cold, if_hot); 550 return new WarmCallGenerator(ci, if_cold, if_hot);
551 } 551 }
552 552
553 JVMState* WarmCallGenerator::generate(JVMState* jvms) { 553 JVMState* WarmCallGenerator::generate(JVMState* jvms, Parse* parent_parser) {
554 Compile* C = Compile::current(); 554 Compile* C = Compile::current();
555 if (C->log() != NULL) { 555 if (C->log() != NULL) {
556 C->log()->elem("warm_call bci='%d'", jvms->bci()); 556 C->log()->elem("warm_call bci='%d'", jvms->bci());
557 } 557 }
558 jvms = _if_cold->generate(jvms); 558 jvms = _if_cold->generate(jvms, parent_parser);
559 if (jvms != NULL) { 559 if (jvms != NULL) {
560 Node* m = jvms->map()->control(); 560 Node* m = jvms->map()->control();
561 if (m->is_CatchProj()) m = m->in(0); else m = C->top(); 561 if (m->is_CatchProj()) m = m->in(0); else m = C->top();
562 if (m->is_Catch()) m = m->in(0); else m = C->top(); 562 if (m->is_Catch()) m = m->in(0); else m = C->top();
563 if (m->is_Proj()) m = m->in(0); else m = C->top(); 563 if (m->is_Proj()) m = m->in(0); else m = C->top();
614 614
615 virtual bool is_virtual() const { return true; } 615 virtual bool is_virtual() const { return true; }
616 virtual bool is_inline() const { return _if_hit->is_inline(); } 616 virtual bool is_inline() const { return _if_hit->is_inline(); }
617 virtual bool is_deferred() const { return _if_hit->is_deferred(); } 617 virtual bool is_deferred() const { return _if_hit->is_deferred(); }
618 618
619 virtual JVMState* generate(JVMState* jvms); 619 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser);
620 }; 620 };
621 621
622 622
623 CallGenerator* CallGenerator::for_predicted_call(ciKlass* predicted_receiver, 623 CallGenerator* CallGenerator::for_predicted_call(ciKlass* predicted_receiver,
624 CallGenerator* if_missed, 624 CallGenerator* if_missed,
626 float hit_prob) { 626 float hit_prob) {
627 return new PredictedCallGenerator(predicted_receiver, if_missed, if_hit, hit_prob); 627 return new PredictedCallGenerator(predicted_receiver, if_missed, if_hit, hit_prob);
628 } 628 }
629 629
630 630
631 JVMState* PredictedCallGenerator::generate(JVMState* jvms) { 631 JVMState* PredictedCallGenerator::generate(JVMState* jvms, Parse* parent_parser) {
632 GraphKit kit(jvms); 632 GraphKit kit(jvms);
633 PhaseGVN& gvn = kit.gvn(); 633 PhaseGVN& gvn = kit.gvn();
634 // We need an explicit receiver null_check before checking its type. 634 // We need an explicit receiver null_check before checking its type.
635 // We share a map with the caller, so his JVMS gets adjusted. 635 // We share a map with the caller, so his JVMS gets adjusted.
636 Node* receiver = kit.argument(0); 636 Node* receiver = kit.argument(0);
654 SafePointNode* slow_map = NULL; 654 SafePointNode* slow_map = NULL;
655 JVMState* slow_jvms; 655 JVMState* slow_jvms;
656 { PreserveJVMState pjvms(&kit); 656 { PreserveJVMState pjvms(&kit);
657 kit.set_control(slow_ctl); 657 kit.set_control(slow_ctl);
658 if (!kit.stopped()) { 658 if (!kit.stopped()) {
659 slow_jvms = _if_missed->generate(kit.sync_jvms()); 659 slow_jvms = _if_missed->generate(kit.sync_jvms(), parent_parser);
660 if (kit.failing()) 660 if (kit.failing())
661 return NULL; // might happen because of NodeCountInliningCutoff 661 return NULL; // might happen because of NodeCountInliningCutoff
662 assert(slow_jvms != NULL, "must be"); 662 assert(slow_jvms != NULL, "must be");
663 kit.add_exception_states_from(slow_jvms); 663 kit.add_exception_states_from(slow_jvms);
664 kit.set_map(slow_jvms->map()); 664 kit.set_map(slow_jvms->map());
675 675
676 // fall through if the instance exactly matches the desired type 676 // fall through if the instance exactly matches the desired type
677 kit.replace_in_map(receiver, exact_receiver); 677 kit.replace_in_map(receiver, exact_receiver);
678 678
679 // Make the hot call: 679 // Make the hot call:
680 JVMState* new_jvms = _if_hit->generate(kit.sync_jvms()); 680 JVMState* new_jvms = _if_hit->generate(kit.sync_jvms(), parent_parser);
681 if (new_jvms == NULL) { 681 if (new_jvms == NULL) {
682 // Inline failed, so make a direct call. 682 // Inline failed, so make a direct call.
683 assert(_if_hit->is_inline(), "must have been a failed inline"); 683 assert(_if_hit->is_inline(), "must have been a failed inline");
684 CallGenerator* cg = CallGenerator::for_direct_call(_if_hit->method()); 684 CallGenerator* cg = CallGenerator::for_direct_call(_if_hit->method());
685 new_jvms = cg->generate(kit.sync_jvms()); 685 new_jvms = cg->generate(kit.sync_jvms(), parent_parser);
686 } 686 }
687 kit.add_exception_states_from(new_jvms); 687 kit.add_exception_states_from(new_jvms);
688 kit.set_jvms(new_jvms); 688 kit.set_jvms(new_jvms);
689 689
690 // Need to merge slow and fast? 690 // Need to merge slow and fast?
872 872
873 virtual bool is_virtual() const { return true; } 873 virtual bool is_virtual() const { return true; }
874 virtual bool is_inlined() const { return true; } 874 virtual bool is_inlined() const { return true; }
875 virtual bool is_intrinsic() const { return true; } 875 virtual bool is_intrinsic() const { return true; }
876 876
877 virtual JVMState* generate(JVMState* jvms); 877 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser);
878 }; 878 };
879 879
880 880
881 CallGenerator* CallGenerator::for_predicted_intrinsic(CallGenerator* intrinsic, 881 CallGenerator* CallGenerator::for_predicted_intrinsic(CallGenerator* intrinsic,
882 CallGenerator* cg) { 882 CallGenerator* cg) {
883 return new PredictedIntrinsicGenerator(intrinsic, cg); 883 return new PredictedIntrinsicGenerator(intrinsic, cg);
884 } 884 }
885 885
886 886
887 JVMState* PredictedIntrinsicGenerator::generate(JVMState* jvms) { 887 JVMState* PredictedIntrinsicGenerator::generate(JVMState* jvms, Parse* parent_parser) {
888 GraphKit kit(jvms); 888 GraphKit kit(jvms);
889 PhaseGVN& gvn = kit.gvn(); 889 PhaseGVN& gvn = kit.gvn();
890 890
891 CompileLog* log = kit.C->log(); 891 CompileLog* log = kit.C->log();
892 if (log != NULL) { 892 if (log != NULL) {
902 JVMState* slow_jvms; 902 JVMState* slow_jvms;
903 if (slow_ctl != NULL) { 903 if (slow_ctl != NULL) {
904 PreserveJVMState pjvms(&kit); 904 PreserveJVMState pjvms(&kit);
905 kit.set_control(slow_ctl); 905 kit.set_control(slow_ctl);
906 if (!kit.stopped()) { 906 if (!kit.stopped()) {
907 slow_jvms = _cg->generate(kit.sync_jvms()); 907 slow_jvms = _cg->generate(kit.sync_jvms(), parent_parser);
908 if (kit.failing()) 908 if (kit.failing())
909 return NULL; // might happen because of NodeCountInliningCutoff 909 return NULL; // might happen because of NodeCountInliningCutoff
910 assert(slow_jvms != NULL, "must be"); 910 assert(slow_jvms != NULL, "must be");
911 kit.add_exception_states_from(slow_jvms); 911 kit.add_exception_states_from(slow_jvms);
912 kit.set_map(slow_jvms->map()); 912 kit.set_map(slow_jvms->map());
920 kit.set_jvms(slow_jvms); 920 kit.set_jvms(slow_jvms);
921 return kit.transfer_exceptions_into_jvms(); 921 return kit.transfer_exceptions_into_jvms();
922 } 922 }
923 923
924 // Generate intrinsic code: 924 // Generate intrinsic code:
925 JVMState* new_jvms = _intrinsic->generate(kit.sync_jvms()); 925 JVMState* new_jvms = _intrinsic->generate(kit.sync_jvms(), parent_parser);
926 if (new_jvms == NULL) { 926 if (new_jvms == NULL) {
927 // Intrinsic failed, so use slow code or make a direct call. 927 // Intrinsic failed, so use slow code or make a direct call.
928 if (slow_map == NULL) { 928 if (slow_map == NULL) {
929 CallGenerator* cg = CallGenerator::for_direct_call(method()); 929 CallGenerator* cg = CallGenerator::for_direct_call(method());
930 new_jvms = cg->generate(kit.sync_jvms()); 930 new_jvms = cg->generate(kit.sync_jvms(), parent_parser);
931 } else { 931 } else {
932 kit.set_jvms(slow_jvms); 932 kit.set_jvms(slow_jvms);
933 return kit.transfer_exceptions_into_jvms(); 933 return kit.transfer_exceptions_into_jvms();
934 } 934 }
935 } 935 }
995 } 995 }
996 996
997 virtual bool is_virtual() const { ShouldNotReachHere(); return false; } 997 virtual bool is_virtual() const { ShouldNotReachHere(); return false; }
998 virtual bool is_trap() const { return true; } 998 virtual bool is_trap() const { return true; }
999 999
1000 virtual JVMState* generate(JVMState* jvms); 1000 virtual JVMState* generate(JVMState* jvms, Parse* parent_parser);
1001 }; 1001 };
1002 1002
1003 1003
1004 CallGenerator* 1004 CallGenerator*
1005 CallGenerator::for_uncommon_trap(ciMethod* m, 1005 CallGenerator::for_uncommon_trap(ciMethod* m,
1007 Deoptimization::DeoptAction action) { 1007 Deoptimization::DeoptAction action) {
1008 return new UncommonTrapCallGenerator(m, reason, action); 1008 return new UncommonTrapCallGenerator(m, reason, action);
1009 } 1009 }
1010 1010
1011 1011
1012 JVMState* UncommonTrapCallGenerator::generate(JVMState* jvms) { 1012 JVMState* UncommonTrapCallGenerator::generate(JVMState* jvms, Parse* parent_parser) {
1013 GraphKit kit(jvms); 1013 GraphKit kit(jvms);
1014 // Take the trap with arguments pushed on the stack. (Cf. null_check_receiver). 1014 // Take the trap with arguments pushed on the stack. (Cf. null_check_receiver).
1015 int nargs = method()->arg_size(); 1015 int nargs = method()->arg_size();
1016 kit.inc_sp(nargs); 1016 kit.inc_sp(nargs);
1017 assert(nargs <= kit.sp() && kit.sp() <= jvms->stk_size(), "sane sp w/ args pushed"); 1017 assert(nargs <= kit.sp() && kit.sp() <= jvms->stk_size(), "sane sp w/ args pushed");