545 ciObject* appendix_arg = iter().get_appendix();
546 const TypeOopPtr* appendix_arg_type = TypeOopPtr::make_from_constant(appendix_arg);
547 Node* appendix_arg_node = _gvn.makecon(appendix_arg_type);
548 push(appendix_arg_node);
549 }
550
551 // ---------------------
552 // Does Class Hierarchy Analysis reveal only a single target of a v-call?
553 // Then we may inline or make a static call, but become dependent on there being only 1 target.
554 // Does the call-site type profile reveal only one receiver?
555 // Then we may introduce a run-time check and inline on the path where it succeeds.
556 // The other path may uncommon_trap, check for another receiver, or do a v-call.
557
558 // Try to get the most accurate receiver type
559 ciMethod* callee = orig_callee;
560 int vtable_index = Method::invalid_vtable_index;
561 bool call_does_dispatch = false;
562
563 // Speculative type of the receiver if any
564 ciKlass* speculative_receiver_type = NULL;
565 if (is_virtual_or_interface || is_direct) {
566 Node* receiver_node = stack(sp() - nargs);
567 const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr();
568 // call_does_dispatch and vtable_index are out-parameters. They might be changed.
569 // For arrays, klass below is Object. When vtable calls are used,
570 // resolving the call with Object would allow an illegal call to
571 // finalize() on an array. We use holder instead: illegal calls to
572 // finalize() won't be compiled as vtable calls (IC call
573 // resolution will catch the illegal call) and the few legal calls
574 // on array types won't be either.
575 callee = C->optimize_virtual_call(method(), bci(), klass, holder, orig_callee,
576 receiver_type, is_virtual,
577 call_does_dispatch, vtable_index); // out-parameters
578 speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL;
579 }
580
581 // Note: It's OK to try to inline a virtual call.
582 // The call generator will not attempt to inline a polymorphic call
583 // unless it knows how to optimize the receiver dispatch.
584 bool try_inline = (C->do_inlining() || InlineAccessors);
585
1006 catch_call_exceptions(handlers);
1007 }
1008
1009
1010 // (Note: Moved add_debug_info into GraphKit::add_safepoint_edges.)
1011
1012
1013 #ifndef PRODUCT
1014 void Parse::count_compiled_calls(bool at_method_entry, bool is_inline) {
1015 if( CountCompiledCalls ) {
1016 if( at_method_entry ) {
1017 // bump invocation counter if top method (for statistics)
1018 if (CountCompiledCalls && depth() == 1) {
1019 const TypePtr* addr_type = TypeMetadataPtr::make(method());
1020 Node* adr1 = makecon(addr_type);
1021 Node* adr2 = basic_plus_adr(adr1, adr1, in_bytes(Method::compiled_invocation_counter_offset()));
1022 increment_counter(adr2);
1023 }
1024 } else if (is_inline) {
1025 switch (bc()) {
1026 case Bytecodes::_invokedirect:
1027 case Bytecodes::_invokevirtual: increment_counter(SharedRuntime::nof_inlined_calls_addr()); break;
1028 case Bytecodes::_invokeinterface: increment_counter(SharedRuntime::nof_inlined_interface_calls_addr()); break;
1029 case Bytecodes::_invokestatic:
1030 case Bytecodes::_invokedynamic:
1031 case Bytecodes::_invokespecial: increment_counter(SharedRuntime::nof_inlined_static_calls_addr()); break;
1032 default: fatal("unexpected call bytecode");
1033 }
1034 } else {
1035 switch (bc()) {
1036 case Bytecodes::_invokedirect:
1037 case Bytecodes::_invokevirtual: increment_counter(SharedRuntime::nof_normal_calls_addr()); break;
1038 case Bytecodes::_invokeinterface: increment_counter(SharedRuntime::nof_interface_calls_addr()); break;
1039 case Bytecodes::_invokestatic:
1040 case Bytecodes::_invokedynamic:
1041 case Bytecodes::_invokespecial: increment_counter(SharedRuntime::nof_static_calls_addr()); break;
1042 default: fatal("unexpected call bytecode");
1043 }
1044 }
1045 }
1046 }
1047 #endif //PRODUCT
1048
1049
1050 ciMethod* Compile::optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass,
1051 ciKlass* holder, ciMethod* callee,
1052 const TypeOopPtr* receiver_type, bool is_virtual,
1053 bool& call_does_dispatch, int& vtable_index,
1054 bool check_access) {
1055 // Set default values for out-parameters.
1056 call_does_dispatch = true;
1057 vtable_index = Method::invalid_vtable_index;
1058
|
545 ciObject* appendix_arg = iter().get_appendix();
546 const TypeOopPtr* appendix_arg_type = TypeOopPtr::make_from_constant(appendix_arg);
547 Node* appendix_arg_node = _gvn.makecon(appendix_arg_type);
548 push(appendix_arg_node);
549 }
550
551 // ---------------------
552 // Does Class Hierarchy Analysis reveal only a single target of a v-call?
553 // Then we may inline or make a static call, but become dependent on there being only 1 target.
554 // Does the call-site type profile reveal only one receiver?
555 // Then we may introduce a run-time check and inline on the path where it succeeds.
556 // The other path may uncommon_trap, check for another receiver, or do a v-call.
557
558 // Try to get the most accurate receiver type
559 ciMethod* callee = orig_callee;
560 int vtable_index = Method::invalid_vtable_index;
561 bool call_does_dispatch = false;
562
563 // Speculative type of the receiver if any
564 ciKlass* speculative_receiver_type = NULL;
565 if (is_virtual_or_interface) {
566 Node* receiver_node = stack(sp() - nargs);
567 const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr();
568 // call_does_dispatch and vtable_index are out-parameters. They might be changed.
569 // For arrays, klass below is Object. When vtable calls are used,
570 // resolving the call with Object would allow an illegal call to
571 // finalize() on an array. We use holder instead: illegal calls to
572 // finalize() won't be compiled as vtable calls (IC call
573 // resolution will catch the illegal call) and the few legal calls
574 // on array types won't be either.
575 callee = C->optimize_virtual_call(method(), bci(), klass, holder, orig_callee,
576 receiver_type, is_virtual,
577 call_does_dispatch, vtable_index); // out-parameters
578 speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL;
579 }
580
581 // Note: It's OK to try to inline a virtual call.
582 // The call generator will not attempt to inline a polymorphic call
583 // unless it knows how to optimize the receiver dispatch.
584 bool try_inline = (C->do_inlining() || InlineAccessors);
585
1006 catch_call_exceptions(handlers);
1007 }
1008
1009
1010 // (Note: Moved add_debug_info into GraphKit::add_safepoint_edges.)
1011
1012
1013 #ifndef PRODUCT
1014 void Parse::count_compiled_calls(bool at_method_entry, bool is_inline) {
1015 if( CountCompiledCalls ) {
1016 if( at_method_entry ) {
1017 // bump invocation counter if top method (for statistics)
1018 if (CountCompiledCalls && depth() == 1) {
1019 const TypePtr* addr_type = TypeMetadataPtr::make(method());
1020 Node* adr1 = makecon(addr_type);
1021 Node* adr2 = basic_plus_adr(adr1, adr1, in_bytes(Method::compiled_invocation_counter_offset()));
1022 increment_counter(adr2);
1023 }
1024 } else if (is_inline) {
1025 switch (bc()) {
1026 case Bytecodes::_invokevirtual: increment_counter(SharedRuntime::nof_inlined_calls_addr()); break;
1027 case Bytecodes::_invokeinterface: increment_counter(SharedRuntime::nof_inlined_interface_calls_addr()); break;
1028 case Bytecodes::_invokedirect:
1029 case Bytecodes::_invokestatic:
1030 case Bytecodes::_invokedynamic:
1031 case Bytecodes::_invokespecial: increment_counter(SharedRuntime::nof_inlined_static_calls_addr()); break;
1032 default: fatal("unexpected call bytecode");
1033 }
1034 } else {
1035 switch (bc()) {
1036 case Bytecodes::_invokevirtual: increment_counter(SharedRuntime::nof_normal_calls_addr()); break;
1037 case Bytecodes::_invokeinterface: increment_counter(SharedRuntime::nof_interface_calls_addr()); break;
1038 case Bytecodes::_invokedirect:
1039 case Bytecodes::_invokestatic:
1040 case Bytecodes::_invokedynamic:
1041 case Bytecodes::_invokespecial: increment_counter(SharedRuntime::nof_static_calls_addr()); break;
1042 default: fatal("unexpected call bytecode");
1043 }
1044 }
1045 }
1046 }
1047 #endif //PRODUCT
1048
1049
1050 ciMethod* Compile::optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass,
1051 ciKlass* holder, ciMethod* callee,
1052 const TypeOopPtr* receiver_type, bool is_virtual,
1053 bool& call_does_dispatch, int& vtable_index,
1054 bool check_access) {
1055 // Set default values for out-parameters.
1056 call_does_dispatch = true;
1057 vtable_index = Method::invalid_vtable_index;
1058
|