12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "ci/ciCallSite.hpp"
26 #include "ci/ciMethodHandle.hpp"
27 #include "ci/ciSymbols.hpp"
28 #include "classfile/vmSymbols.hpp"
29 #include "compiler/compileBroker.hpp"
30 #include "compiler/compileLog.hpp"
31 #include "interpreter/linkResolver.hpp"
32 #include "logging/log.hpp"
33 #include "logging/logLevel.hpp"
34 #include "logging/logMessage.hpp"
35 #include "logging/logStream.hpp"
36 #include "opto/addnode.hpp"
37 #include "opto/callGenerator.hpp"
38 #include "opto/castnode.hpp"
39 #include "opto/cfgnode.hpp"
40 #include "opto/mulnode.hpp"
41 #include "opto/parse.hpp"
42 #include "opto/rootnode.hpp"
43 #include "opto/runtime.hpp"
44 #include "opto/subnode.hpp"
45 #include "prims/methodHandles.hpp"
46 #include "runtime/sharedRuntime.hpp"
47 #include "utilities/macros.hpp"
48 #if INCLUDE_JFR
49 #include "jfr/jfr.hpp"
50 #endif
51
52 static void print_trace_type_profile(outputStream* out, int depth, ciKlass* prof_klass, int site_count, int receiver_count,
53 bool with_deco) {
54 if (with_deco) {
55 CompileTask::print_inline_indent(depth, out);
56 }
57 out->print(" \\-> TypeProfile (%d/%d counts) = ", receiver_count, site_count);
58 prof_klass->name()->print_symbol_on(out);
59 if (with_deco) {
128 log->begin_elem("call method='%d' count='%d' prof_factor='%f'",
129 log->identify(callee), site_count, prof_factor);
130 if (call_does_dispatch) log->print(" virtual='1'");
131 if (allow_inline) log->print(" inline='1'");
132 if (receiver_count >= 0) {
133 log->print(" receiver='%d' receiver_count='%d'", rid, receiver_count);
134 if (profile.has_receiver(1)) {
135 log->print(" receiver2='%d' receiver2_count='%d'", r2id, profile.receiver_count(1));
136 }
137 }
138 if (callee->is_method_handle_intrinsic()) {
139 log->print(" method_handle_intrinsic='1'");
140 }
141 log->end_elem();
142 }
143
144 // Special case the handling of certain common, profitable library
145 // methods. If these methods are replaced with specialized code,
146 // then we return it as the inlined version of the call.
147 CallGenerator* cg_intrinsic = nullptr;
148 if (allow_inline && allow_intrinsics) {
149 CallGenerator* cg = find_intrinsic(callee, call_does_dispatch);
150 if (cg != nullptr) {
151 if (cg->is_predicated()) {
152 // Code without intrinsic but, hopefully, inlined.
153 CallGenerator* inline_cg = this->call_generator(callee,
154 vtable_index, call_does_dispatch, jvms, allow_inline, prof_factor, speculative_receiver_type, false);
155 if (inline_cg != nullptr) {
156 cg = CallGenerator::for_predicated_intrinsic(cg, inline_cg);
157 }
158 }
159
160 // If intrinsic does the virtual dispatch, we try to use the type profile
161 // first, and hopefully inline it as the regular virtual call below.
162 // We will retry the intrinsic if nothing had claimed it afterwards.
163 if (cg->does_virtual_dispatch()) {
164 cg_intrinsic = cg;
165 cg = nullptr;
166 } else if (IncrementalInline && should_delay_vector_inlining(callee, jvms)) {
167 return CallGenerator::for_late_inline(callee, cg);
168 } else {
584 // Speculative type of the receiver if any
585 ciKlass* speculative_receiver_type = nullptr;
586 if (is_virtual_or_interface) {
587 Node* receiver_node = stack(sp() - nargs);
588 const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr();
589 // call_does_dispatch and vtable_index are out-parameters. They might be changed.
590 // For arrays, klass below is Object. When vtable calls are used,
591 // resolving the call with Object would allow an illegal call to
592 // finalize() on an array. We use holder instead: illegal calls to
593 // finalize() won't be compiled as vtable calls (IC call
594 // resolution will catch the illegal call) and the few legal calls
595 // on array types won't be either.
596 callee = C->optimize_virtual_call(method(), klass, holder, orig_callee,
597 receiver_type, is_virtual,
598 call_does_dispatch, vtable_index); // out-parameters
599 speculative_receiver_type = receiver_type != nullptr ? receiver_type->speculative_type() : nullptr;
600 }
601
602 // Additional receiver subtype checks for interface calls via invokespecial or invokeinterface.
603 ciKlass* receiver_constraint = nullptr;
604 if (iter().cur_bc_raw() == Bytecodes::_invokespecial && !orig_callee->is_object_initializer()) {
605 ciInstanceKlass* calling_klass = method()->holder();
606 ciInstanceKlass* sender_klass = calling_klass;
607 if (sender_klass->is_interface()) {
608 receiver_constraint = sender_klass;
609 }
610 } else if (iter().cur_bc_raw() == Bytecodes::_invokeinterface && orig_callee->is_private()) {
611 assert(holder->is_interface(), "How did we get a non-interface method here!");
612 receiver_constraint = holder;
613 }
614
615 if (receiver_constraint != nullptr) {
616 Node* receiver_node = stack(sp() - nargs);
617 Node* cls_node = makecon(TypeKlassPtr::make(receiver_constraint, Type::trust_interfaces));
618 Node* bad_type_ctrl = nullptr;
619 Node* casted_receiver = gen_checkcast(receiver_node, cls_node, &bad_type_ctrl);
620 if (bad_type_ctrl != nullptr) {
621 PreserveJVMState pjvms(this);
622 set_control(bad_type_ctrl);
623 uncommon_trap(Deoptimization::Reason_class_check,
624 Deoptimization::Action_none);
626 if (stopped()) {
627 return; // MUST uncommon-trap?
628 }
629 set_stack(sp() - nargs, casted_receiver);
630 }
631
632 // Note: It's OK to try to inline a virtual call.
633 // The call generator will not attempt to inline a polymorphic call
634 // unless it knows how to optimize the receiver dispatch.
635 bool try_inline = (C->do_inlining() || InlineAccessors);
636
637 // ---------------------
638 dec_sp(nargs); // Temporarily pop args for JVM state of call
639 JVMState* jvms = sync_jvms();
640
641 // ---------------------
642 // Decide call tactic.
643 // This call checks with CHA, the interpreter profile, intrinsics table, etc.
644 // It decides whether inlining is desirable or not.
645 CallGenerator* cg = C->call_generator(callee, vtable_index, call_does_dispatch, jvms, try_inline, prof_factor(), speculative_receiver_type);
646
647 // NOTE: Don't use orig_callee and callee after this point! Use cg->method() instead.
648 orig_callee = callee = nullptr;
649
650 // ---------------------
651
652 // Feed profiling data for arguments to the type system so it can
653 // propagate it as speculative types
654 record_profiled_arguments_for_speculation(cg->method(), bc());
655
656 #ifndef PRODUCT
657 // bump global counters for calls
658 count_compiled_calls(/*at_method_entry*/ false, cg->is_inline());
659
660 // Record first part of parsing work for this call
661 parse_histogram()->record_change();
662 #endif // not PRODUCT
663
664 assert(jvms == this->jvms(), "still operating on the right JVMS");
665 assert(jvms_in_sync(), "jvms must carry full info into CG");
712
713 assert(check_call_consistency(jvms, cg), "inconsistent info");
714
715 if (!stopped()) {
716 // This was some sort of virtual call, which did a null check for us.
717 // Now we can assert receiver-not-null, on the normal return path.
718 if (receiver != nullptr && cg->is_virtual()) {
719 Node* cast = cast_not_null(receiver);
720 // %%% assert(receiver == cast, "should already have cast the receiver");
721 }
722
723 ciType* rtype = cg->method()->return_type();
724 ciType* ctype = declared_signature->return_type();
725
726 if (Bytecodes::has_optional_appendix(iter().cur_bc_raw()) || is_signature_polymorphic) {
727 // Be careful here with return types.
728 if (ctype != rtype) {
729 BasicType rt = rtype->basic_type();
730 BasicType ct = ctype->basic_type();
731 if (ct == T_VOID) {
732 // It's OK for a method to return a value that is discarded.
733 // The discarding does not require any special action from the caller.
734 // The Java code knows this, at VerifyType.isNullConversion.
735 pop_node(rt); // whatever it was, pop it
736 } else if (rt == T_INT || is_subword_type(rt)) {
737 // Nothing. These cases are handled in lambda form bytecode.
738 assert(ct == T_INT || is_subword_type(ct), "must match: rt=%s, ct=%s", type2name(rt), type2name(ct));
739 } else if (is_reference_type(rt)) {
740 assert(is_reference_type(ct), "rt=%s, ct=%s", type2name(rt), type2name(ct));
741 if (ctype->is_loaded()) {
742 const TypeOopPtr* arg_type = TypeOopPtr::make_from_klass(rtype->as_klass());
743 const Type* sig_type = TypeOopPtr::make_from_klass(ctype->as_klass());
744 if (arg_type != nullptr && !arg_type->higher_equal(sig_type)) {
745 Node* retnode = pop();
746 Node* cast_obj = _gvn.transform(new CheckCastPPNode(control(), retnode, sig_type));
747 push(cast_obj);
748 }
749 }
750 } else {
751 assert(rt == ct, "unexpected mismatch: rt=%s, ct=%s", type2name(rt), type2name(ct));
752 // push a zero; it's better than getting an oop/int mismatch
770 // If the return type of the method is not loaded, assert that the
771 // value we got is a null. Otherwise, we need to recompile.
772 if (!rtype->is_loaded()) {
773 if (PrintOpto && (Verbose || WizardMode)) {
774 method()->print_name(); tty->print_cr(" asserting nullness of result at bci: %d", bci());
775 cg->method()->print_name(); tty->cr();
776 }
777 if (C->log() != nullptr) {
778 C->log()->elem("assert_null reason='return' klass='%d'",
779 C->log()->identify(rtype));
780 }
781 // If there is going to be a trap, put it at the next bytecode:
782 set_bci(iter().next_bci());
783 null_assert(peek());
784 set_bci(iter().cur_bci()); // put it back
785 }
786 BasicType ct = ctype->basic_type();
787 if (is_reference_type(ct)) {
788 record_profiled_return_for_speculation();
789 }
790 }
791
792 // Restart record of parsing work after possible inlining of call
793 #ifndef PRODUCT
794 parse_histogram()->set_initial_state(bc());
795 #endif
796 }
797
798 //---------------------------catch_call_exceptions-----------------------------
799 // Put a Catch and CatchProj nodes behind a just-created call.
800 // Send their caught exceptions to the proper handler.
801 // This may be used after a call to the rethrow VM stub,
802 // when it is needed to process unloaded exception classes.
803 void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) {
804 // Exceptions are delivered through this channel:
805 Node* i_o = this->i_o();
806
807 // Add a CatchNode.
808 Arena tmp_mem{mtCompiler};
809 GrowableArray<int> bcis(&tmp_mem, 8, 0, -1);
|
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "ci/ciCallSite.hpp"
26 #include "ci/ciMethodHandle.hpp"
27 #include "ci/ciSymbols.hpp"
28 #include "classfile/vmSymbols.hpp"
29 #include "compiler/compileBroker.hpp"
30 #include "compiler/compileLog.hpp"
31 #include "interpreter/linkResolver.hpp"
32 #include "jvm_io.h"
33 #include "logging/log.hpp"
34 #include "logging/logLevel.hpp"
35 #include "logging/logMessage.hpp"
36 #include "logging/logStream.hpp"
37 #include "opto/addnode.hpp"
38 #include "opto/callGenerator.hpp"
39 #include "opto/castnode.hpp"
40 #include "opto/cfgnode.hpp"
41 #include "opto/inlinetypenode.hpp"
42 #include "opto/mulnode.hpp"
43 #include "opto/parse.hpp"
44 #include "opto/rootnode.hpp"
45 #include "opto/runtime.hpp"
46 #include "opto/subnode.hpp"
47 #include "prims/methodHandles.hpp"
48 #include "runtime/sharedRuntime.hpp"
49 #include "utilities/macros.hpp"
50 #if INCLUDE_JFR
51 #include "jfr/jfr.hpp"
52 #endif
53
54 static void print_trace_type_profile(outputStream* out, int depth, ciKlass* prof_klass, int site_count, int receiver_count,
55 bool with_deco) {
56 if (with_deco) {
57 CompileTask::print_inline_indent(depth, out);
58 }
59 out->print(" \\-> TypeProfile (%d/%d counts) = ", receiver_count, site_count);
60 prof_klass->name()->print_symbol_on(out);
61 if (with_deco) {
130 log->begin_elem("call method='%d' count='%d' prof_factor='%f'",
131 log->identify(callee), site_count, prof_factor);
132 if (call_does_dispatch) log->print(" virtual='1'");
133 if (allow_inline) log->print(" inline='1'");
134 if (receiver_count >= 0) {
135 log->print(" receiver='%d' receiver_count='%d'", rid, receiver_count);
136 if (profile.has_receiver(1)) {
137 log->print(" receiver2='%d' receiver2_count='%d'", r2id, profile.receiver_count(1));
138 }
139 }
140 if (callee->is_method_handle_intrinsic()) {
141 log->print(" method_handle_intrinsic='1'");
142 }
143 log->end_elem();
144 }
145
146 // Special case the handling of certain common, profitable library
147 // methods. If these methods are replaced with specialized code,
148 // then we return it as the inlined version of the call.
149 CallGenerator* cg_intrinsic = nullptr;
150 if (callee->intrinsic_id() == vmIntrinsics::_makePrivateBuffer || callee->intrinsic_id() == vmIntrinsics::_finishPrivateBuffer) {
151 // These methods must be inlined so that we don't have larval value objects crossing method
152 // boundaries
153 assert(!call_does_dispatch, "callee should not be virtual %s", callee->name()->as_utf8());
154 CallGenerator* cg = find_intrinsic(callee, call_does_dispatch);
155
156 if (cg == nullptr) {
157 // This is probably because the intrinsics is disabled from the command line
158 char reason[256];
159 jio_snprintf(reason, sizeof(reason), "cannot find an intrinsics for %s", callee->name()->as_utf8());
160 C->record_method_not_compilable(reason);
161 return nullptr;
162 }
163 return cg;
164 } else if (allow_inline && allow_intrinsics) {
165 CallGenerator* cg = find_intrinsic(callee, call_does_dispatch);
166 if (cg != nullptr) {
167 if (cg->is_predicated()) {
168 // Code without intrinsic but, hopefully, inlined.
169 CallGenerator* inline_cg = this->call_generator(callee,
170 vtable_index, call_does_dispatch, jvms, allow_inline, prof_factor, speculative_receiver_type, false);
171 if (inline_cg != nullptr) {
172 cg = CallGenerator::for_predicated_intrinsic(cg, inline_cg);
173 }
174 }
175
176 // If intrinsic does the virtual dispatch, we try to use the type profile
177 // first, and hopefully inline it as the regular virtual call below.
178 // We will retry the intrinsic if nothing had claimed it afterwards.
179 if (cg->does_virtual_dispatch()) {
180 cg_intrinsic = cg;
181 cg = nullptr;
182 } else if (IncrementalInline && should_delay_vector_inlining(callee, jvms)) {
183 return CallGenerator::for_late_inline(callee, cg);
184 } else {
600 // Speculative type of the receiver if any
601 ciKlass* speculative_receiver_type = nullptr;
602 if (is_virtual_or_interface) {
603 Node* receiver_node = stack(sp() - nargs);
604 const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr();
605 // call_does_dispatch and vtable_index are out-parameters. They might be changed.
606 // For arrays, klass below is Object. When vtable calls are used,
607 // resolving the call with Object would allow an illegal call to
608 // finalize() on an array. We use holder instead: illegal calls to
609 // finalize() won't be compiled as vtable calls (IC call
610 // resolution will catch the illegal call) and the few legal calls
611 // on array types won't be either.
612 callee = C->optimize_virtual_call(method(), klass, holder, orig_callee,
613 receiver_type, is_virtual,
614 call_does_dispatch, vtable_index); // out-parameters
615 speculative_receiver_type = receiver_type != nullptr ? receiver_type->speculative_type() : nullptr;
616 }
617
618 // Additional receiver subtype checks for interface calls via invokespecial or invokeinterface.
619 ciKlass* receiver_constraint = nullptr;
620 if (iter().cur_bc_raw() == Bytecodes::_invokespecial && !orig_callee->is_object_constructor()) {
621 ciInstanceKlass* calling_klass = method()->holder();
622 ciInstanceKlass* sender_klass = calling_klass;
623 if (sender_klass->is_interface()) {
624 receiver_constraint = sender_klass;
625 }
626 } else if (iter().cur_bc_raw() == Bytecodes::_invokeinterface && orig_callee->is_private()) {
627 assert(holder->is_interface(), "How did we get a non-interface method here!");
628 receiver_constraint = holder;
629 }
630
631 if (receiver_constraint != nullptr) {
632 Node* receiver_node = stack(sp() - nargs);
633 Node* cls_node = makecon(TypeKlassPtr::make(receiver_constraint, Type::trust_interfaces));
634 Node* bad_type_ctrl = nullptr;
635 Node* casted_receiver = gen_checkcast(receiver_node, cls_node, &bad_type_ctrl);
636 if (bad_type_ctrl != nullptr) {
637 PreserveJVMState pjvms(this);
638 set_control(bad_type_ctrl);
639 uncommon_trap(Deoptimization::Reason_class_check,
640 Deoptimization::Action_none);
642 if (stopped()) {
643 return; // MUST uncommon-trap?
644 }
645 set_stack(sp() - nargs, casted_receiver);
646 }
647
648 // Note: It's OK to try to inline a virtual call.
649 // The call generator will not attempt to inline a polymorphic call
650 // unless it knows how to optimize the receiver dispatch.
651 bool try_inline = (C->do_inlining() || InlineAccessors);
652
653 // ---------------------
654 dec_sp(nargs); // Temporarily pop args for JVM state of call
655 JVMState* jvms = sync_jvms();
656
657 // ---------------------
658 // Decide call tactic.
659 // This call checks with CHA, the interpreter profile, intrinsics table, etc.
660 // It decides whether inlining is desirable or not.
661 CallGenerator* cg = C->call_generator(callee, vtable_index, call_does_dispatch, jvms, try_inline, prof_factor(), speculative_receiver_type);
662 if (failing()) {
663 return;
664 }
665 assert(cg != nullptr, "must find a CallGenerator for callee %s", callee->name()->as_utf8());
666
667 // NOTE: Don't use orig_callee and callee after this point! Use cg->method() instead.
668 orig_callee = callee = nullptr;
669
670 // ---------------------
671
672 // Feed profiling data for arguments to the type system so it can
673 // propagate it as speculative types
674 record_profiled_arguments_for_speculation(cg->method(), bc());
675
676 #ifndef PRODUCT
677 // bump global counters for calls
678 count_compiled_calls(/*at_method_entry*/ false, cg->is_inline());
679
680 // Record first part of parsing work for this call
681 parse_histogram()->record_change();
682 #endif // not PRODUCT
683
684 assert(jvms == this->jvms(), "still operating on the right JVMS");
685 assert(jvms_in_sync(), "jvms must carry full info into CG");
732
733 assert(check_call_consistency(jvms, cg), "inconsistent info");
734
735 if (!stopped()) {
736 // This was some sort of virtual call, which did a null check for us.
737 // Now we can assert receiver-not-null, on the normal return path.
738 if (receiver != nullptr && cg->is_virtual()) {
739 Node* cast = cast_not_null(receiver);
740 // %%% assert(receiver == cast, "should already have cast the receiver");
741 }
742
743 ciType* rtype = cg->method()->return_type();
744 ciType* ctype = declared_signature->return_type();
745
746 if (Bytecodes::has_optional_appendix(iter().cur_bc_raw()) || is_signature_polymorphic) {
747 // Be careful here with return types.
748 if (ctype != rtype) {
749 BasicType rt = rtype->basic_type();
750 BasicType ct = ctype->basic_type();
751 if (ct == T_VOID) {
752 // It's OK for a method to return a value that is discarded.
753 // The discarding does not require any special action from the caller.
754 // The Java code knows this, at VerifyType.isNullConversion.
755 pop_node(rt); // whatever it was, pop it
756 } else if (rt == T_INT || is_subword_type(rt)) {
757 // Nothing. These cases are handled in lambda form bytecode.
758 assert(ct == T_INT || is_subword_type(ct), "must match: rt=%s, ct=%s", type2name(rt), type2name(ct));
759 } else if (is_reference_type(rt)) {
760 assert(is_reference_type(ct), "rt=%s, ct=%s", type2name(rt), type2name(ct));
761 if (ctype->is_loaded()) {
762 const TypeOopPtr* arg_type = TypeOopPtr::make_from_klass(rtype->as_klass());
763 const Type* sig_type = TypeOopPtr::make_from_klass(ctype->as_klass());
764 if (arg_type != nullptr && !arg_type->higher_equal(sig_type)) {
765 Node* retnode = pop();
766 Node* cast_obj = _gvn.transform(new CheckCastPPNode(control(), retnode, sig_type));
767 push(cast_obj);
768 }
769 }
770 } else {
771 assert(rt == ct, "unexpected mismatch: rt=%s, ct=%s", type2name(rt), type2name(ct));
772 // push a zero; it's better than getting an oop/int mismatch
790 // If the return type of the method is not loaded, assert that the
791 // value we got is a null. Otherwise, we need to recompile.
792 if (!rtype->is_loaded()) {
793 if (PrintOpto && (Verbose || WizardMode)) {
794 method()->print_name(); tty->print_cr(" asserting nullness of result at bci: %d", bci());
795 cg->method()->print_name(); tty->cr();
796 }
797 if (C->log() != nullptr) {
798 C->log()->elem("assert_null reason='return' klass='%d'",
799 C->log()->identify(rtype));
800 }
801 // If there is going to be a trap, put it at the next bytecode:
802 set_bci(iter().next_bci());
803 null_assert(peek());
804 set_bci(iter().cur_bci()); // put it back
805 }
806 BasicType ct = ctype->basic_type();
807 if (is_reference_type(ct)) {
808 record_profiled_return_for_speculation();
809 }
810 if (rtype->is_inlinetype() && !peek()->is_InlineType()) {
811 Node* retnode = pop();
812 retnode = InlineTypeNode::make_from_oop(this, retnode, rtype->as_inline_klass());
813 push_node(T_OBJECT, retnode);
814 }
815
816 // Note that:
817 // - The caller map is the state just before the call of the currently parsed method with all arguments
818 // on the stack. Therefore, we have caller_map->arg(0) == this.
819 // - local(0) contains the updated receiver after calling an inline type constructor.
820 // - Abstract value classes are not ciInlineKlass instances and thus abstract_value_klass->is_inlinetype() is false.
821 // We use the bottom type of the receiver node to determine if we have a value class or not.
822 const bool is_current_method_inline_type_constructor =
823 // Is current method a constructor (i.e <init>)?
824 _method->is_object_constructor() &&
825 // Is the holder of the current constructor method an inline type?
826 _caller->map()->argument(_caller, 0)->bottom_type()->is_inlinetypeptr();
827 assert(!is_current_method_inline_type_constructor || !cg->method()->is_object_constructor() || receiver != nullptr,
828 "must have valid receiver after calling another constructor");
829 if (is_current_method_inline_type_constructor &&
830 // Is the just called method an inline type constructor?
831 cg->method()->is_object_constructor() && receiver->bottom_type()->is_inlinetypeptr() &&
832 // AND:
833 // 1) ... invoked on the same receiver? Then it's another constructor on the same object doing the initialization.
834 (receiver == _caller->map()->argument(_caller, 0) ||
835 // 2) ... abstract? Then it's the call to the super constructor which eventually calls Object.<init> to
836 // finish the initialization of this larval.
837 cg->method()->holder()->is_abstract() ||
838 // 3) ... Object.<init>? Then we know it's the final call to finish the larval initialization. Other
839 // Object.<init> calls would have a non-inline-type receiver which we already excluded in the check above.
840 cg->method()->holder()->is_java_lang_Object())
841 ) {
842 assert(local(0)->is_InlineType() && receiver->bottom_type()->is_inlinetypeptr() && receiver->is_InlineType() &&
843 _caller->map()->argument(_caller, 0)->bottom_type()->inline_klass() == receiver->bottom_type()->inline_klass(),
844 "Unexpected receiver");
845 InlineTypeNode* updated_receiver = local(0)->as_InlineType();
846 InlineTypeNode* cloned_updated_receiver = updated_receiver->clone_if_required(&_gvn, _map);
847 cloned_updated_receiver->set_is_larval(false);
848 cloned_updated_receiver = _gvn.transform(cloned_updated_receiver)->as_InlineType();
849 // Receiver updated by the just called constructor. We need to update the map to make the effect visible. After
850 // the super() call, only the updated receiver in local(0) will be used from now on. Therefore, we do not need
851 // to update the original receiver 'receiver' but only the 'updated_receiver'.
852 replace_in_map(updated_receiver, cloned_updated_receiver);
853
854 if (_caller->has_method()) {
855 // If the current method is inlined, we also need to update the exit map to propagate the updated receiver
856 // to the caller map.
857 Node* receiver_in_caller = _caller->map()->argument(_caller, 0);
858 assert(receiver_in_caller->bottom_type()->inline_klass() == receiver->bottom_type()->inline_klass(),
859 "Receiver type mismatch");
860 _exits.map()->replace_edge(receiver_in_caller, cloned_updated_receiver, &_gvn);
861 }
862 }
863 }
864
865 // Restart record of parsing work after possible inlining of call
866 #ifndef PRODUCT
867 parse_histogram()->set_initial_state(bc());
868 #endif
869 }
870
871 //---------------------------catch_call_exceptions-----------------------------
872 // Put a Catch and CatchProj nodes behind a just-created call.
873 // Send their caught exceptions to the proper handler.
874 // This may be used after a call to the rethrow VM stub,
875 // when it is needed to process unloaded exception classes.
876 void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) {
877 // Exceptions are delivered through this channel:
878 Node* i_o = this->i_o();
879
880 // Add a CatchNode.
881 Arena tmp_mem{mtCompiler};
882 GrowableArray<int> bcis(&tmp_mem, 8, 0, -1);
|