< prev index next >

src/hotspot/share/opto/compile.cpp

Print this page

 618                   _options(options),
 619                   _method(target),
 620                   _entry_bci(osr_bci),
 621                   _ilt(nullptr),
 622                   _stub_function(nullptr),
 623                   _stub_name(nullptr),
 624                   _stub_entry_point(nullptr),
 625                   _max_node_limit(MaxNodeLimit),
 626                   _post_loop_opts_phase(false),
 627                   _allow_macro_nodes(true),
 628                   _inlining_progress(false),
 629                   _inlining_incrementally(false),
 630                   _do_cleanup(false),
 631                   _has_reserved_stack_access(target->has_reserved_stack_access()),
 632 #ifndef PRODUCT
 633                   _igv_idx(0),
 634                   _trace_opto_output(directive->TraceOptoOutputOption),
 635 #endif
 636                   _has_method_handle_invokes(false),
 637                   _clinit_barrier_on_entry(false),

 638                   _stress_seed(0),
 639                   _comp_arena(mtCompiler),
 640                   _barrier_set_state(BarrierSet::barrier_set()->barrier_set_c2()->create_barrier_state(comp_arena())),
 641                   _env(ci_env),
 642                   _directive(directive),
 643                   _log(ci_env->log()),
 644                   _first_failure_details(nullptr),
 645                   _intrinsics        (comp_arena(), 0, 0, nullptr),
 646                   _macro_nodes       (comp_arena(), 8, 0, nullptr),
 647                   _parse_predicates  (comp_arena(), 8, 0, nullptr),
 648                   _template_assertion_predicate_opaqs (comp_arena(), 8, 0, nullptr),
 649                   _expensive_nodes   (comp_arena(), 8, 0, nullptr),
 650                   _for_post_loop_igvn(comp_arena(), 8, 0, nullptr),
 651                   _unstable_if_traps (comp_arena(), 8, 0, nullptr),
 652                   _coarsened_locks   (comp_arena(), 8, 0, nullptr),
 653                   _congraph(nullptr),
 654                   NOT_PRODUCT(_igv_printer(nullptr) COMMA)
 655                   _unique(0),
 656                   _dead_node_count(0),
 657                   _dead_node_list(comp_arena()),

 898   : Phase(Compiler),
 899     _compile_id(0),
 900     _options(Options::for_runtime_stub()),
 901     _method(nullptr),
 902     _entry_bci(InvocationEntryBci),
 903     _stub_function(stub_function),
 904     _stub_name(stub_name),
 905     _stub_entry_point(nullptr),
 906     _max_node_limit(MaxNodeLimit),
 907     _post_loop_opts_phase(false),
 908     _allow_macro_nodes(true),
 909     _inlining_progress(false),
 910     _inlining_incrementally(false),
 911     _has_reserved_stack_access(false),
 912 #ifndef PRODUCT
 913     _igv_idx(0),
 914     _trace_opto_output(directive->TraceOptoOutputOption),
 915 #endif
 916     _has_method_handle_invokes(false),
 917     _clinit_barrier_on_entry(false),

 918     _stress_seed(0),
 919     _comp_arena(mtCompiler),
 920     _barrier_set_state(BarrierSet::barrier_set()->barrier_set_c2()->create_barrier_state(comp_arena())),
 921     _env(ci_env),
 922     _directive(directive),
 923     _log(ci_env->log()),
 924     _first_failure_details(nullptr),
 925     _for_post_loop_igvn(comp_arena(), 8, 0, nullptr),
 926     _congraph(nullptr),
 927     NOT_PRODUCT(_igv_printer(nullptr) COMMA)
 928     _unique(0),
 929     _dead_node_count(0),
 930     _dead_node_list(comp_arena()),
 931     _node_arena_one(mtCompiler),
 932     _node_arena_two(mtCompiler),
 933     _node_arena(&_node_arena_one),
 934     _mach_constant_base_node(nullptr),
 935     _Compile_types(mtCompiler),
 936     _initial_gvn(nullptr),
 937     _igvn_worklist(nullptr),

1060   set_do_scheduling(OptoScheduling);
1061 
1062   set_do_vector_loop(false);
1063   set_has_monitors(false);
1064   set_has_scoped_access(false);
1065 
1066   if (AllowVectorizeOnDemand) {
1067     if (has_method() && _directive->VectorizeOption) {
1068       set_do_vector_loop(true);
1069       NOT_PRODUCT(if (do_vector_loop() && Verbose) {tty->print("Compile::Init: do vectorized loops (SIMD like) for method %s\n",  method()->name()->as_quoted_ascii());})
1070     } else if (has_method() && method()->name() != nullptr &&
1071                method()->intrinsic_id() == vmIntrinsics::_forEachRemaining) {
1072       set_do_vector_loop(true);
1073     }
1074   }
1075   set_use_cmove(UseCMoveUnconditionally /* || do_vector_loop()*/); //TODO: consider do_vector_loop() mandate use_cmove unconditionally
1076   NOT_PRODUCT(if (use_cmove() && Verbose && has_method()) {tty->print("Compile::Init: use CMove without profitability tests for method %s\n",  method()->name()->as_quoted_ascii());})
1077 
1078   _max_node_limit = _directive->MaxNodeLimitOption;
1079 
1080   if (VM_Version::supports_fast_class_init_checks() && has_method() && !is_osr_compilation() && method()->needs_clinit_barrier()) {

1081     set_clinit_barrier_on_entry(true);



1082   }
1083   if (debug_info()->recording_non_safepoints()) {
1084     set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*>
1085                         (comp_arena(), 8, 0, nullptr));
1086     set_default_node_notes(Node_Notes::make(this));
1087   }
1088 
1089   const int grow_ats = 16;
1090   _max_alias_types = grow_ats;
1091   _alias_types   = NEW_ARENA_ARRAY(comp_arena(), AliasType*, grow_ats);
1092   AliasType* ats = NEW_ARENA_ARRAY(comp_arena(), AliasType,  grow_ats);
1093   Copy::zero_to_bytes(ats, sizeof(AliasType)*grow_ats);
1094   {
1095     for (int i = 0; i < grow_ats; i++)  _alias_types[i] = &ats[i];
1096   }
1097   // Initialize the first few types.
1098   _alias_types[AliasIdxTop]->Init(AliasIdxTop, nullptr);
1099   _alias_types[AliasIdxBot]->Init(AliasIdxBot, TypePtr::BOTTOM);
1100   _alias_types[AliasIdxRaw]->Init(AliasIdxRaw, TypeRawPtr::BOTTOM);
1101   _num_alias_types = AliasIdxRaw+1;

4108       frc.get_float_count() > 32 &&
4109       frc.get_double_count() == 0 &&
4110       (10 * frc.get_call_count() < frc.get_float_count()) ) {
4111     set_24_bit_selection_and_mode(false, true);
4112   }
4113 #endif // IA32
4114 
4115   set_java_calls(frc.get_java_call_count());
4116   set_inner_loops(frc.get_inner_loop_count());
4117 
4118   // No infinite loops, no reason to bail out.
4119   return false;
4120 }
4121 
4122 //-----------------------------too_many_traps----------------------------------
4123 // Report if there are too many traps at the current method and bci.
4124 // Return true if there was a trap, and/or PerMethodTrapLimit is exceeded.
4125 bool Compile::too_many_traps(ciMethod* method,
4126                              int bci,
4127                              Deoptimization::DeoptReason reason) {



4128   ciMethodData* md = method->method_data();
4129   if (md->is_empty()) {
4130     // Assume the trap has not occurred, or that it occurred only
4131     // because of a transient condition during start-up in the interpreter.
4132     return false;
4133   }
4134   ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : nullptr;
4135   if (md->has_trap_at(bci, m, reason) != 0) {
4136     // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic.
4137     // Also, if there are multiple reasons, or if there is no per-BCI record,
4138     // assume the worst.
4139     if (log())
4140       log()->elem("observe trap='%s' count='%d'",
4141                   Deoptimization::trap_reason_name(reason),
4142                   md->trap_count(reason));
4143     return true;
4144   } else {
4145     // Ignore method/bci and see if there have been too many globally.
4146     return too_many_traps(reason, md);
4147   }

4222   _allowed_reasons = 0;
4223   if (is_method_compilation()) {
4224     for (int rs = (int)Deoptimization::Reason_none+1; rs < Compile::trapHistLength; rs++) {
4225       assert(rs < BitsPerInt, "recode bit map");
4226       if (!too_many_traps((Deoptimization::DeoptReason) rs)) {
4227         _allowed_reasons |= nth_bit(rs);
4228       }
4229     }
4230   }
4231 }
4232 
4233 bool Compile::needs_clinit_barrier(ciMethod* method, ciMethod* accessing_method) {
4234   return method->is_static() && needs_clinit_barrier(method->holder(), accessing_method);
4235 }
4236 
4237 bool Compile::needs_clinit_barrier(ciField* field, ciMethod* accessing_method) {
4238   return field->is_static() && needs_clinit_barrier(field->holder(), accessing_method);
4239 }
4240 
4241 bool Compile::needs_clinit_barrier(ciInstanceKlass* holder, ciMethod* accessing_method) {
4242   if (holder->is_initialized()) {
4243     return false;
4244   }
4245   if (holder->is_being_initialized()) {
4246     if (accessing_method->holder() == holder) {
4247       // Access inside a class. The barrier can be elided when access happens in <clinit>,
4248       // <init>, or a static method. In all those cases, there was an initialization
4249       // barrier on the holder klass passed.
4250       if (accessing_method->is_static_initializer() ||
4251           accessing_method->is_object_initializer() ||
4252           accessing_method->is_static()) {
4253         return false;
4254       }
4255     } else if (accessing_method->holder()->is_subclass_of(holder)) {
4256       // Access from a subclass. The barrier can be elided only when access happens in <clinit>.
4257       // In case of <init> or a static method, the barrier is on the subclass is not enough:
4258       // child class can become fully initialized while its parent class is still being initialized.
4259       if (accessing_method->is_static_initializer()) {
4260         return false;
4261       }
4262     }
4263     ciMethod* root = method(); // the root method of compilation
4264     if (root != accessing_method) {
4265       return needs_clinit_barrier(holder, root); // check access in the context of compilation root

4608     // Reset _print_inlining_list, it only contains destructed objects.
4609     // It is on the arena, so it will be freed when the arena is reset.
4610     _print_inlining_list = nullptr;
4611     // _print_inlining_stream won't be used anymore, either.
4612     print_inlining_reset();
4613     size_t end = ss.size();
4614     _print_inlining_output = NEW_ARENA_ARRAY(comp_arena(), char, end+1);
4615     strncpy(_print_inlining_output, ss.freeze(), end+1);
4616     _print_inlining_output[end] = 0;
4617   }
4618 }
4619 
4620 void Compile::dump_print_inlining() {
4621   if (_print_inlining_output != nullptr) {
4622     tty->print_raw(_print_inlining_output);
4623   }
4624 }
4625 
4626 void Compile::log_late_inline(CallGenerator* cg) {
4627   if (log() != nullptr) {
4628     log()->head("late_inline method='%d'  inline_id='" JLONG_FORMAT "'", log()->identify(cg->method()),
4629                 cg->unique_id());
4630     JVMState* p = cg->call_node()->jvms();
4631     while (p != nullptr) {
4632       log()->elem("jvms bci='%d' method='%d'", p->bci(), log()->identify(p->method()));
4633       p = p->caller();
4634     }
4635     log()->tail("late_inline");
4636   }
4637 }
4638 
4639 void Compile::log_late_inline_failure(CallGenerator* cg, const char* msg) {
4640   log_late_inline(cg);
4641   if (log() != nullptr) {
4642     log()->inline_fail(msg);
4643   }
4644 }
4645 
4646 void Compile::log_inline_id(CallGenerator* cg) {
4647   if (log() != nullptr) {
4648     // The LogCompilation tool needs a unique way to identify late

 618                   _options(options),
 619                   _method(target),
 620                   _entry_bci(osr_bci),
 621                   _ilt(nullptr),
 622                   _stub_function(nullptr),
 623                   _stub_name(nullptr),
 624                   _stub_entry_point(nullptr),
 625                   _max_node_limit(MaxNodeLimit),
 626                   _post_loop_opts_phase(false),
 627                   _allow_macro_nodes(true),
 628                   _inlining_progress(false),
 629                   _inlining_incrementally(false),
 630                   _do_cleanup(false),
 631                   _has_reserved_stack_access(target->has_reserved_stack_access()),
 632 #ifndef PRODUCT
 633                   _igv_idx(0),
 634                   _trace_opto_output(directive->TraceOptoOutputOption),
 635 #endif
 636                   _has_method_handle_invokes(false),
 637                   _clinit_barrier_on_entry(false),
 638                   _has_clinit_barriers(false),
 639                   _stress_seed(0),
 640                   _comp_arena(mtCompiler),
 641                   _barrier_set_state(BarrierSet::barrier_set()->barrier_set_c2()->create_barrier_state(comp_arena())),
 642                   _env(ci_env),
 643                   _directive(directive),
 644                   _log(ci_env->log()),
 645                   _first_failure_details(nullptr),
 646                   _intrinsics        (comp_arena(), 0, 0, nullptr),
 647                   _macro_nodes       (comp_arena(), 8, 0, nullptr),
 648                   _parse_predicates  (comp_arena(), 8, 0, nullptr),
 649                   _template_assertion_predicate_opaqs (comp_arena(), 8, 0, nullptr),
 650                   _expensive_nodes   (comp_arena(), 8, 0, nullptr),
 651                   _for_post_loop_igvn(comp_arena(), 8, 0, nullptr),
 652                   _unstable_if_traps (comp_arena(), 8, 0, nullptr),
 653                   _coarsened_locks   (comp_arena(), 8, 0, nullptr),
 654                   _congraph(nullptr),
 655                   NOT_PRODUCT(_igv_printer(nullptr) COMMA)
 656                   _unique(0),
 657                   _dead_node_count(0),
 658                   _dead_node_list(comp_arena()),

 899   : Phase(Compiler),
 900     _compile_id(0),
 901     _options(Options::for_runtime_stub()),
 902     _method(nullptr),
 903     _entry_bci(InvocationEntryBci),
 904     _stub_function(stub_function),
 905     _stub_name(stub_name),
 906     _stub_entry_point(nullptr),
 907     _max_node_limit(MaxNodeLimit),
 908     _post_loop_opts_phase(false),
 909     _allow_macro_nodes(true),
 910     _inlining_progress(false),
 911     _inlining_incrementally(false),
 912     _has_reserved_stack_access(false),
 913 #ifndef PRODUCT
 914     _igv_idx(0),
 915     _trace_opto_output(directive->TraceOptoOutputOption),
 916 #endif
 917     _has_method_handle_invokes(false),
 918     _clinit_barrier_on_entry(false),
 919     _has_clinit_barriers(false),
 920     _stress_seed(0),
 921     _comp_arena(mtCompiler),
 922     _barrier_set_state(BarrierSet::barrier_set()->barrier_set_c2()->create_barrier_state(comp_arena())),
 923     _env(ci_env),
 924     _directive(directive),
 925     _log(ci_env->log()),
 926     _first_failure_details(nullptr),
 927     _for_post_loop_igvn(comp_arena(), 8, 0, nullptr),
 928     _congraph(nullptr),
 929     NOT_PRODUCT(_igv_printer(nullptr) COMMA)
 930     _unique(0),
 931     _dead_node_count(0),
 932     _dead_node_list(comp_arena()),
 933     _node_arena_one(mtCompiler),
 934     _node_arena_two(mtCompiler),
 935     _node_arena(&_node_arena_one),
 936     _mach_constant_base_node(nullptr),
 937     _Compile_types(mtCompiler),
 938     _initial_gvn(nullptr),
 939     _igvn_worklist(nullptr),

1062   set_do_scheduling(OptoScheduling);
1063 
1064   set_do_vector_loop(false);
1065   set_has_monitors(false);
1066   set_has_scoped_access(false);
1067 
1068   if (AllowVectorizeOnDemand) {
1069     if (has_method() && _directive->VectorizeOption) {
1070       set_do_vector_loop(true);
1071       NOT_PRODUCT(if (do_vector_loop() && Verbose) {tty->print("Compile::Init: do vectorized loops (SIMD like) for method %s\n",  method()->name()->as_quoted_ascii());})
1072     } else if (has_method() && method()->name() != nullptr &&
1073                method()->intrinsic_id() == vmIntrinsics::_forEachRemaining) {
1074       set_do_vector_loop(true);
1075     }
1076   }
1077   set_use_cmove(UseCMoveUnconditionally /* || do_vector_loop()*/); //TODO: consider do_vector_loop() mandate use_cmove unconditionally
1078   NOT_PRODUCT(if (use_cmove() && Verbose && has_method()) {tty->print("Compile::Init: use CMove without profitability tests for method %s\n",  method()->name()->as_quoted_ascii());})
1079 
1080   _max_node_limit = _directive->MaxNodeLimitOption;
1081 
1082   if (VM_Version::supports_fast_class_init_checks() && has_method() && !is_osr_compilation() &&
1083       (method()->needs_clinit_barrier() || (do_clinit_barriers() && method()->is_static()))) {
1084     set_clinit_barrier_on_entry(true);
1085     if (do_clinit_barriers()) {
1086       set_has_clinit_barriers(true); // Entry clinit barrier is in prolog code.
1087     }
1088   }
1089   if (debug_info()->recording_non_safepoints()) {
1090     set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*>
1091                         (comp_arena(), 8, 0, nullptr));
1092     set_default_node_notes(Node_Notes::make(this));
1093   }
1094 
1095   const int grow_ats = 16;
1096   _max_alias_types = grow_ats;
1097   _alias_types   = NEW_ARENA_ARRAY(comp_arena(), AliasType*, grow_ats);
1098   AliasType* ats = NEW_ARENA_ARRAY(comp_arena(), AliasType,  grow_ats);
1099   Copy::zero_to_bytes(ats, sizeof(AliasType)*grow_ats);
1100   {
1101     for (int i = 0; i < grow_ats; i++)  _alias_types[i] = &ats[i];
1102   }
1103   // Initialize the first few types.
1104   _alias_types[AliasIdxTop]->Init(AliasIdxTop, nullptr);
1105   _alias_types[AliasIdxBot]->Init(AliasIdxBot, TypePtr::BOTTOM);
1106   _alias_types[AliasIdxRaw]->Init(AliasIdxRaw, TypeRawPtr::BOTTOM);
1107   _num_alias_types = AliasIdxRaw+1;

4114       frc.get_float_count() > 32 &&
4115       frc.get_double_count() == 0 &&
4116       (10 * frc.get_call_count() < frc.get_float_count()) ) {
4117     set_24_bit_selection_and_mode(false, true);
4118   }
4119 #endif // IA32
4120 
4121   set_java_calls(frc.get_java_call_count());
4122   set_inner_loops(frc.get_inner_loop_count());
4123 
4124   // No infinite loops, no reason to bail out.
4125   return false;
4126 }
4127 
4128 //-----------------------------too_many_traps----------------------------------
4129 // Report if there are too many traps at the current method and bci.
4130 // Return true if there was a trap, and/or PerMethodTrapLimit is exceeded.
4131 bool Compile::too_many_traps(ciMethod* method,
4132                              int bci,
4133                              Deoptimization::DeoptReason reason) {
4134   if (method->has_trap_at(bci)) {
4135     return true;
4136   }
4137   ciMethodData* md = method->method_data();
4138   if (md->is_empty()) {
4139     // Assume the trap has not occurred, or that it occurred only
4140     // because of a transient condition during start-up in the interpreter.
4141     return false;
4142   }
4143   ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : nullptr;
4144   if (md->has_trap_at(bci, m, reason) != 0) {
4145     // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic.
4146     // Also, if there are multiple reasons, or if there is no per-BCI record,
4147     // assume the worst.
4148     if (log())
4149       log()->elem("observe trap='%s' count='%d'",
4150                   Deoptimization::trap_reason_name(reason),
4151                   md->trap_count(reason));
4152     return true;
4153   } else {
4154     // Ignore method/bci and see if there have been too many globally.
4155     return too_many_traps(reason, md);
4156   }

4231   _allowed_reasons = 0;
4232   if (is_method_compilation()) {
4233     for (int rs = (int)Deoptimization::Reason_none+1; rs < Compile::trapHistLength; rs++) {
4234       assert(rs < BitsPerInt, "recode bit map");
4235       if (!too_many_traps((Deoptimization::DeoptReason) rs)) {
4236         _allowed_reasons |= nth_bit(rs);
4237       }
4238     }
4239   }
4240 }
4241 
4242 bool Compile::needs_clinit_barrier(ciMethod* method, ciMethod* accessing_method) {
4243   return method->is_static() && needs_clinit_barrier(method->holder(), accessing_method);
4244 }
4245 
4246 bool Compile::needs_clinit_barrier(ciField* field, ciMethod* accessing_method) {
4247   return field->is_static() && needs_clinit_barrier(field->holder(), accessing_method);
4248 }
4249 
4250 bool Compile::needs_clinit_barrier(ciInstanceKlass* holder, ciMethod* accessing_method) {
4251   if (holder->is_initialized() && !do_clinit_barriers()) {
4252     return false;
4253   }
4254   if (holder->is_being_initialized() || do_clinit_barriers()) {
4255     if (accessing_method->holder() == holder) {
4256       // Access inside a class. The barrier can be elided when access happens in <clinit>,
4257       // <init>, or a static method. In all those cases, there was an initialization
4258       // barrier on the holder klass passed.
4259       if (accessing_method->is_static_initializer() ||
4260           accessing_method->is_object_initializer() ||
4261           accessing_method->is_static()) {
4262         return false;
4263       }
4264     } else if (accessing_method->holder()->is_subclass_of(holder)) {
4265       // Access from a subclass. The barrier can be elided only when access happens in <clinit>.
4266       // In case of <init> or a static method, the barrier is on the subclass is not enough:
4267       // child class can become fully initialized while its parent class is still being initialized.
4268       if (accessing_method->is_static_initializer()) {
4269         return false;
4270       }
4271     }
4272     ciMethod* root = method(); // the root method of compilation
4273     if (root != accessing_method) {
4274       return needs_clinit_barrier(holder, root); // check access in the context of compilation root

4617     // Reset _print_inlining_list, it only contains destructed objects.
4618     // It is on the arena, so it will be freed when the arena is reset.
4619     _print_inlining_list = nullptr;
4620     // _print_inlining_stream won't be used anymore, either.
4621     print_inlining_reset();
4622     size_t end = ss.size();
4623     _print_inlining_output = NEW_ARENA_ARRAY(comp_arena(), char, end+1);
4624     strncpy(_print_inlining_output, ss.freeze(), end+1);
4625     _print_inlining_output[end] = 0;
4626   }
4627 }
4628 
4629 void Compile::dump_print_inlining() {
4630   if (_print_inlining_output != nullptr) {
4631     tty->print_raw(_print_inlining_output);
4632   }
4633 }
4634 
4635 void Compile::log_late_inline(CallGenerator* cg) {
4636   if (log() != nullptr) {
4637     log()->head("late_inline method='%d' inline_id='" JLONG_FORMAT "'", log()->identify(cg->method()),
4638                 cg->unique_id());
4639     JVMState* p = cg->call_node()->jvms();
4640     while (p != nullptr) {
4641       log()->elem("jvms bci='%d' method='%d'", p->bci(), log()->identify(p->method()));
4642       p = p->caller();
4643     }
4644     log()->tail("late_inline");
4645   }
4646 }
4647 
4648 void Compile::log_late_inline_failure(CallGenerator* cg, const char* msg) {
4649   log_late_inline(cg);
4650   if (log() != nullptr) {
4651     log()->inline_fail(msg);
4652   }
4653 }
4654 
4655 void Compile::log_inline_id(CallGenerator* cg) {
4656   if (log() != nullptr) {
4657     // The LogCompilation tool needs a unique way to identify late
< prev index next >