165 void dump(node_idx_t key, outputStream* st) const;
166
167 int clone_idx() const { return _clone_idx; }
168 void set_clone_idx(int x) { _clone_idx = x; }
169 bool is_debug() const { return _debug; }
170 void set_debug(bool debug) { _debug = debug; }
171
172 bool same_idx(node_idx_t k1, node_idx_t k2) const { return idx(k1) == idx(k2); }
173 bool same_gen(node_idx_t k1, node_idx_t k2) const { return gen(k1) == gen(k2); }
174 };
175
176 class Options {
177 friend class Compile;
178 private:
179 const bool _subsume_loads; // Load can be matched as part of a larger op.
180 const bool _do_escape_analysis; // Do escape analysis.
181 const bool _do_iterative_escape_analysis; // Do iterative escape analysis.
182 const bool _do_reduce_allocation_merges; // Do try to reduce allocation merges.
183 const bool _eliminate_boxing; // Do boxing elimination.
184 const bool _do_locks_coarsening; // Do locks coarsening
185 const bool _do_superword; // Do SuperWord
186 const bool _install_code; // Install the code that was compiled
187 public:
188 Options(bool subsume_loads,
189 bool do_escape_analysis,
190 bool do_iterative_escape_analysis,
191 bool do_reduce_allocation_merges,
192 bool eliminate_boxing,
193 bool do_locks_coarsening,
194 bool do_superword,
195 bool install_code) :
196 _subsume_loads(subsume_loads),
197 _do_escape_analysis(do_escape_analysis),
198 _do_iterative_escape_analysis(do_iterative_escape_analysis),
199 _do_reduce_allocation_merges(do_reduce_allocation_merges),
200 _eliminate_boxing(eliminate_boxing),
201 _do_locks_coarsening(do_locks_coarsening),
202 _do_superword(do_superword),
203 _install_code(install_code) {
204 }
205
206 static Options for_runtime_stub() {
207 return Options(
208 /* subsume_loads = */ true,
209 /* do_escape_analysis = */ false,
210 /* do_iterative_escape_analysis = */ false,
211 /* do_reduce_allocation_merges = */ false,
212 /* eliminate_boxing = */ false,
213 /* do_lock_coarsening = */ false,
214 /* do_superword = */ true,
215 /* install_code = */ true
216 );
217 }
218 };
219
220 //------------------------------Compile----------------------------------------
221 // This class defines a top-level Compiler invocation.
222
223 class Compile : public Phase {
224
225 public:
226 // Fixed alias indexes. (See also MergeMemNode.)
227 enum {
228 AliasIdxTop = 1, // pseudo-index, aliases to nothing (used as sentinel value)
229 AliasIdxBot = 2, // pseudo-index, aliases to everything
230 AliasIdxRaw = 3 // hard-wired index for TypeRawPtr::BOTTOM
231 };
232
233 // Variant of TraceTime(nullptr, &_t_accumulator, CITime);
342 bool _do_freq_based_layout; // True if we intend to do frequency based block layout
343 bool _do_vector_loop; // True if allowed to execute loop in parallel iterations
344 bool _use_cmove; // True if CMove should be used without profitability analysis
345 bool _do_aliasing; // True if we intend to do aliasing
346 bool _print_assembly; // True if we should dump assembly code for this compilation
347 bool _print_inlining; // True if we should print inlining for this compilation
348 bool _print_intrinsics; // True if we should print intrinsics for this compilation
349 #ifndef PRODUCT
350 uint _phase_counter; // Counter for the number of already printed phases
351 uint _igv_idx; // Counter for IGV node identifiers
352 uint _igv_phase_iter[PHASE_NUM_TYPES]; // Counters for IGV phase iterations
353 bool _trace_opto_output;
354 bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
355 #endif
356 bool _has_irreducible_loop; // Found irreducible loops
357 // JSR 292
358 bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.
359 bool _has_monitors; // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
360 bool _has_scoped_access; // For shared scope closure
361 bool _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
362 int _loop_opts_cnt; // loop opts round
363 uint _stress_seed; // Seed for stress testing
364
365 // Compilation environment.
366 Arena _comp_arena; // Arena with lifetime equivalent to Compile
367 void* _barrier_set_state; // Potential GC barrier state for Compile
368 ciEnv* _env; // CI interface
369 DirectiveSet* _directive; // Compiler directive
370 CompileLog* _log; // from CompilerThread
371 CHeapStringHolder _failure_reason; // for record_failure/failing pattern
372 CompilationFailureInfo* _first_failure_details; // Details for the first failure happening during compilation
373 GrowableArray<CallGenerator*> _intrinsics; // List of intrinsics.
374 GrowableArray<Node*> _macro_nodes; // List of nodes which need to be expanded before matching.
375 GrowableArray<ParsePredicateNode*> _parse_predicates; // List of Parse Predicates.
376 // List of OpaqueTemplateAssertionPredicateNode nodes for Template Assertion Predicates which can be seen as list
377 // of Template Assertion Predicates themselves.
378 GrowableArray<OpaqueTemplateAssertionPredicateNode*> _template_assertion_predicate_opaques;
379 GrowableArray<Node*> _expensive_nodes; // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
380 GrowableArray<Node*> _for_post_loop_igvn; // List of nodes for IGVN after loop opts are over
381 GrowableArray<Node*> _for_merge_stores_igvn; // List of nodes for IGVN merge stores
545 int compile_id() const { return _compile_id; }
546 DirectiveSet* directive() const { return _directive; }
547
548 // Does this compilation allow instructions to subsume loads? User
549 // instructions that subsume a load may result in an unschedulable
550 // instruction sequence.
551 bool subsume_loads() const { return _options._subsume_loads; }
552 /** Do escape analysis. */
553 bool do_escape_analysis() const { return _options._do_escape_analysis; }
554 bool do_iterative_escape_analysis() const { return _options._do_iterative_escape_analysis; }
555 bool do_reduce_allocation_merges() const { return _options._do_reduce_allocation_merges; }
556 /** Do boxing elimination. */
557 bool eliminate_boxing() const { return _options._eliminate_boxing; }
558 /** Do aggressive boxing elimination. */
559 bool aggressive_unboxing() const { return _options._eliminate_boxing && AggressiveUnboxing; }
560 bool should_install_code() const { return _options._install_code; }
561 /** Do locks coarsening. */
562 bool do_locks_coarsening() const { return _options._do_locks_coarsening; }
563 bool do_superword() const { return _options._do_superword; }
564
565 // Other fixed compilation parameters.
566 ciMethod* method() const { return _method; }
567 int entry_bci() const { return _entry_bci; }
568 bool is_osr_compilation() const { return _entry_bci != InvocationEntryBci; }
569 bool is_method_compilation() const { return (_method != nullptr && !_method->flags().is_native()); }
570 const TypeFunc* tf() const { assert(_tf!=nullptr, ""); return _tf; }
571 void init_tf(const TypeFunc* tf) { assert(_tf==nullptr, ""); _tf = tf; }
572 InlineTree* ilt() const { return _ilt; }
573 address stub_function() const { return _stub_function; }
574 const char* stub_name() const { return _stub_name; }
575 int stub_id() const { return _stub_id; }
576 address stub_entry_point() const { return _stub_entry_point; }
577 void set_stub_entry_point(address z) { _stub_entry_point = z; }
578
579 // Control of this compilation.
580 int fixed_slots() const { assert(_fixed_slots >= 0, ""); return _fixed_slots; }
581 void set_fixed_slots(int n) { _fixed_slots = n; }
582 int major_progress() const { return _major_progress; }
583 void set_inlining_progress(bool z) { _inlining_progress = z; }
584 int inlining_progress() const { return _inlining_progress; }
624 void set_do_freq_based_layout(bool z){ _do_freq_based_layout = z; }
625 bool do_vector_loop() const { return _do_vector_loop; }
626 void set_do_vector_loop(bool z) { _do_vector_loop = z; }
627 bool use_cmove() const { return _use_cmove; }
628 void set_use_cmove(bool z) { _use_cmove = z; }
629 bool do_aliasing() const { return _do_aliasing; }
630 bool print_assembly() const { return _print_assembly; }
631 void set_print_assembly(bool z) { _print_assembly = z; }
632 bool print_inlining() const { return _print_inlining; }
633 void set_print_inlining(bool z) { _print_inlining = z; }
634 bool print_intrinsics() const { return _print_intrinsics; }
635 void set_print_intrinsics(bool z) { _print_intrinsics = z; }
636 uint max_node_limit() const { return (uint)_max_node_limit; }
637 void set_max_node_limit(uint n) { _max_node_limit = n; }
638 bool clinit_barrier_on_entry() { return _clinit_barrier_on_entry; }
639 void set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
640 bool has_monitors() const { return _has_monitors; }
641 void set_has_monitors(bool v) { _has_monitors = v; }
642 bool has_scoped_access() const { return _has_scoped_access; }
643 void set_has_scoped_access(bool v) { _has_scoped_access = v; }
644
645 // check the CompilerOracle for special behaviours for this compile
646 bool method_has_option(CompileCommandEnum option) const {
647 return method() != nullptr && method()->has_option(option);
648 }
649
650 #ifndef PRODUCT
651 uint next_igv_idx() { return _igv_idx++; }
652 bool trace_opto_output() const { return _trace_opto_output; }
653 void print_phase(const char* phase_name);
654 void print_ideal_ir(const char* phase_name);
655 bool should_print_ideal() const { return _directive->PrintIdealOption; }
656 bool parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
657 void set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
658 int _in_dump_cnt; // Required for dumping ir nodes.
659 #endif
660 bool has_irreducible_loop() const { return _has_irreducible_loop; }
661 void set_has_irreducible_loop(bool z) { _has_irreducible_loop = z; }
662
663 // JSR 292
|
165 void dump(node_idx_t key, outputStream* st) const;
166
167 int clone_idx() const { return _clone_idx; }
168 void set_clone_idx(int x) { _clone_idx = x; }
169 bool is_debug() const { return _debug; }
170 void set_debug(bool debug) { _debug = debug; }
171
172 bool same_idx(node_idx_t k1, node_idx_t k2) const { return idx(k1) == idx(k2); }
173 bool same_gen(node_idx_t k1, node_idx_t k2) const { return gen(k1) == gen(k2); }
174 };
175
176 class Options {
177 friend class Compile;
178 private:
179 const bool _subsume_loads; // Load can be matched as part of a larger op.
180 const bool _do_escape_analysis; // Do escape analysis.
181 const bool _do_iterative_escape_analysis; // Do iterative escape analysis.
182 const bool _do_reduce_allocation_merges; // Do try to reduce allocation merges.
183 const bool _eliminate_boxing; // Do boxing elimination.
184 const bool _do_locks_coarsening; // Do locks coarsening
185 const bool _for_preload; // Generate code for preload (before Java method execution), do class init barriers
186 const bool _do_superword; // Do SuperWord
187 const bool _install_code; // Install the code that was compiled
188 public:
189 Options(bool subsume_loads,
190 bool do_escape_analysis,
191 bool do_iterative_escape_analysis,
192 bool do_reduce_allocation_merges,
193 bool eliminate_boxing,
194 bool do_locks_coarsening,
195 bool do_superword,
196 bool for_preload,
197 bool install_code) :
198 _subsume_loads(subsume_loads),
199 _do_escape_analysis(do_escape_analysis),
200 _do_iterative_escape_analysis(do_iterative_escape_analysis),
201 _do_reduce_allocation_merges(do_reduce_allocation_merges),
202 _eliminate_boxing(eliminate_boxing),
203 _do_locks_coarsening(do_locks_coarsening),
204 _for_preload(for_preload),
205 _do_superword(do_superword),
206 _install_code(install_code) {
207 }
208
209 static Options for_runtime_stub() {
210 return Options(
211 /* subsume_loads = */ true,
212 /* do_escape_analysis = */ false,
213 /* do_iterative_escape_analysis = */ false,
214 /* do_reduce_allocation_merges = */ false,
215 /* eliminate_boxing = */ false,
216 /* do_lock_coarsening = */ false,
217 /* for_preload = */ false,
218 /* do_superword = */ true,
219 /* install_code = */ true
220 );
221 }
222 };
223
224 //------------------------------Compile----------------------------------------
225 // This class defines a top-level Compiler invocation.
226
227 class Compile : public Phase {
228
229 public:
230 // Fixed alias indexes. (See also MergeMemNode.)
231 enum {
232 AliasIdxTop = 1, // pseudo-index, aliases to nothing (used as sentinel value)
233 AliasIdxBot = 2, // pseudo-index, aliases to everything
234 AliasIdxRaw = 3 // hard-wired index for TypeRawPtr::BOTTOM
235 };
236
237 // Variant of TraceTime(nullptr, &_t_accumulator, CITime);
346 bool _do_freq_based_layout; // True if we intend to do frequency based block layout
347 bool _do_vector_loop; // True if allowed to execute loop in parallel iterations
348 bool _use_cmove; // True if CMove should be used without profitability analysis
349 bool _do_aliasing; // True if we intend to do aliasing
350 bool _print_assembly; // True if we should dump assembly code for this compilation
351 bool _print_inlining; // True if we should print inlining for this compilation
352 bool _print_intrinsics; // True if we should print intrinsics for this compilation
353 #ifndef PRODUCT
354 uint _phase_counter; // Counter for the number of already printed phases
355 uint _igv_idx; // Counter for IGV node identifiers
356 uint _igv_phase_iter[PHASE_NUM_TYPES]; // Counters for IGV phase iterations
357 bool _trace_opto_output;
358 bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
359 #endif
360 bool _has_irreducible_loop; // Found irreducible loops
361 // JSR 292
362 bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.
363 bool _has_monitors; // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
364 bool _has_scoped_access; // For shared scope closure
365 bool _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
366 bool _has_clinit_barriers; // True if compiled code has clinit barriers
367 int _loop_opts_cnt; // loop opts round
368 uint _stress_seed; // Seed for stress testing
369
370 // Compilation environment.
371 Arena _comp_arena; // Arena with lifetime equivalent to Compile
372 void* _barrier_set_state; // Potential GC barrier state for Compile
373 ciEnv* _env; // CI interface
374 DirectiveSet* _directive; // Compiler directive
375 CompileLog* _log; // from CompilerThread
376 CHeapStringHolder _failure_reason; // for record_failure/failing pattern
377 CompilationFailureInfo* _first_failure_details; // Details for the first failure happening during compilation
378 GrowableArray<CallGenerator*> _intrinsics; // List of intrinsics.
379 GrowableArray<Node*> _macro_nodes; // List of nodes which need to be expanded before matching.
380 GrowableArray<ParsePredicateNode*> _parse_predicates; // List of Parse Predicates.
381 // List of OpaqueTemplateAssertionPredicateNode nodes for Template Assertion Predicates which can be seen as list
382 // of Template Assertion Predicates themselves.
383 GrowableArray<OpaqueTemplateAssertionPredicateNode*> _template_assertion_predicate_opaques;
384 GrowableArray<Node*> _expensive_nodes; // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
385 GrowableArray<Node*> _for_post_loop_igvn; // List of nodes for IGVN after loop opts are over
386 GrowableArray<Node*> _for_merge_stores_igvn; // List of nodes for IGVN merge stores
550 int compile_id() const { return _compile_id; }
551 DirectiveSet* directive() const { return _directive; }
552
553 // Does this compilation allow instructions to subsume loads? User
554 // instructions that subsume a load may result in an unschedulable
555 // instruction sequence.
556 bool subsume_loads() const { return _options._subsume_loads; }
557 /** Do escape analysis. */
558 bool do_escape_analysis() const { return _options._do_escape_analysis; }
559 bool do_iterative_escape_analysis() const { return _options._do_iterative_escape_analysis; }
560 bool do_reduce_allocation_merges() const { return _options._do_reduce_allocation_merges; }
561 /** Do boxing elimination. */
562 bool eliminate_boxing() const { return _options._eliminate_boxing; }
563 /** Do aggressive boxing elimination. */
564 bool aggressive_unboxing() const { return _options._eliminate_boxing && AggressiveUnboxing; }
565 bool should_install_code() const { return _options._install_code; }
566 /** Do locks coarsening. */
567 bool do_locks_coarsening() const { return _options._do_locks_coarsening; }
568 bool do_superword() const { return _options._do_superword; }
569
570 bool do_clinit_barriers() const { return _options._for_preload; }
571 bool for_preload() const { return _options._for_preload; }
572
573 // Other fixed compilation parameters.
574 ciMethod* method() const { return _method; }
575 int entry_bci() const { return _entry_bci; }
576 bool is_osr_compilation() const { return _entry_bci != InvocationEntryBci; }
577 bool is_method_compilation() const { return (_method != nullptr && !_method->flags().is_native()); }
578 const TypeFunc* tf() const { assert(_tf!=nullptr, ""); return _tf; }
579 void init_tf(const TypeFunc* tf) { assert(_tf==nullptr, ""); _tf = tf; }
580 InlineTree* ilt() const { return _ilt; }
581 address stub_function() const { return _stub_function; }
582 const char* stub_name() const { return _stub_name; }
583 int stub_id() const { return _stub_id; }
584 address stub_entry_point() const { return _stub_entry_point; }
585 void set_stub_entry_point(address z) { _stub_entry_point = z; }
586
587 // Control of this compilation.
588 int fixed_slots() const { assert(_fixed_slots >= 0, ""); return _fixed_slots; }
589 void set_fixed_slots(int n) { _fixed_slots = n; }
590 int major_progress() const { return _major_progress; }
591 void set_inlining_progress(bool z) { _inlining_progress = z; }
592 int inlining_progress() const { return _inlining_progress; }
632 void set_do_freq_based_layout(bool z){ _do_freq_based_layout = z; }
633 bool do_vector_loop() const { return _do_vector_loop; }
634 void set_do_vector_loop(bool z) { _do_vector_loop = z; }
635 bool use_cmove() const { return _use_cmove; }
636 void set_use_cmove(bool z) { _use_cmove = z; }
637 bool do_aliasing() const { return _do_aliasing; }
638 bool print_assembly() const { return _print_assembly; }
639 void set_print_assembly(bool z) { _print_assembly = z; }
640 bool print_inlining() const { return _print_inlining; }
641 void set_print_inlining(bool z) { _print_inlining = z; }
642 bool print_intrinsics() const { return _print_intrinsics; }
643 void set_print_intrinsics(bool z) { _print_intrinsics = z; }
644 uint max_node_limit() const { return (uint)_max_node_limit; }
645 void set_max_node_limit(uint n) { _max_node_limit = n; }
646 bool clinit_barrier_on_entry() { return _clinit_barrier_on_entry; }
647 void set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
648 bool has_monitors() const { return _has_monitors; }
649 void set_has_monitors(bool v) { _has_monitors = v; }
650 bool has_scoped_access() const { return _has_scoped_access; }
651 void set_has_scoped_access(bool v) { _has_scoped_access = v; }
652 bool has_clinit_barriers() { return _has_clinit_barriers; }
653 void set_has_clinit_barriers(bool z) { _has_clinit_barriers = z; }
654
655 // check the CompilerOracle for special behaviours for this compile
656 bool method_has_option(CompileCommandEnum option) const {
657 return method() != nullptr && method()->has_option(option);
658 }
659
660 #ifndef PRODUCT
661 uint next_igv_idx() { return _igv_idx++; }
662 bool trace_opto_output() const { return _trace_opto_output; }
663 void print_phase(const char* phase_name);
664 void print_ideal_ir(const char* phase_name);
665 bool should_print_ideal() const { return _directive->PrintIdealOption; }
666 bool parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
667 void set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
668 int _in_dump_cnt; // Required for dumping ir nodes.
669 #endif
670 bool has_irreducible_loop() const { return _has_irreducible_loop; }
671 void set_has_irreducible_loop(bool z) { _has_irreducible_loop = z; }
672
673 // JSR 292
|