263 const bool _do_escape_analysis; // Do escape analysis.
264 ciMethod* _method; // The method being compiled.
265 int _entry_bci; // entry bci for osr methods.
266 const TypeFunc* _tf; // My kind of signature
267 InlineTree* _ilt; // Ditto (temporary).
268 address _stub_function; // VM entry for stub being compiled, or NULL
269 const char* _stub_name; // Name of stub or adapter being compiled, or NULL
270 address _stub_entry_point; // Compile code entry for generated stub, or NULL
271
272 // Control of this compilation.
273 int _num_loop_opts; // Number of iterations for doing loop optimiztions
274 int _max_inline_size; // Max inline size for this compilation
275 int _freq_inline_size; // Max hot method inline size for this compilation
276 int _fixed_slots; // count of frame slots not allocated by the register
277 // allocator i.e. locks, original deopt pc, etc.
278 // For deopt
279 int _orig_pc_slot;
280 int _orig_pc_slot_offset_in_bytes;
281
282 int _major_progress; // Count of something big happening
283 bool _has_loops; // True if the method _may_ have some loops
284 bool _has_split_ifs; // True if the method _may_ have some split-if
285 bool _has_unsafe_access; // True if the method _may_ produce faults in unsafe loads or stores.
286 bool _has_stringbuilder; // True StringBuffers or StringBuilders are allocated
287 int _max_vector_size; // Maximum size of generated vectors
288 uint _trap_hist[trapHistLength]; // Cumulative traps
289 bool _trap_can_recompile; // Have we emitted a recompiling trap?
290 uint _decompile_count; // Cumulative decompilation counts.
291 bool _do_inlining; // True if we intend to do inlining
292 bool _do_scheduling; // True if we intend to do scheduling
293 bool _do_freq_based_layout; // True if we intend to do frequency based block layout
294 bool _do_count_invocations; // True if we generate code to count invocations
295 bool _do_method_data_update; // True if we generate code to update MethodData*s
296 int _AliasLevel; // Locally-adjusted version of AliasLevel flag.
297 bool _print_assembly; // True if we should dump assembly code for this compilation
298 #ifndef PRODUCT
299 bool _trace_opto_output;
300 bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
301 #endif
302
352 // Type management
353 Arena _Compile_types; // Arena for all types
354 Arena* _type_arena; // Alias for _Compile_types except in Initialize_shared()
355 Dict* _type_dict; // Intern table
356 void* _type_hwm; // Last allocation (see Type::operator new/delete)
357 size_t _type_last_size; // Last allocation size (see Type::operator new/delete)
358 ciMethod* _last_tf_m; // Cache for
359 const TypeFunc* _last_tf; // TypeFunc::make
360 AliasType** _alias_types; // List of alias types seen so far.
361 int _num_alias_types; // Logical length of _alias_types
362 int _max_alias_types; // Physical length of _alias_types
363 AliasCacheEntry _alias_cache[AliasCacheSize]; // Gets aliases w/o data structure walking
364
365 // Parsing, optimization
366 PhaseGVN* _initial_gvn; // Results of parse-time PhaseGVN
367 Unique_Node_List* _for_igvn; // Initial work-list for next round of Iterative GVN
368 WarmCallInfo* _warm_calls; // Sorted work-list for heat-based inlining.
369
370 GrowableArray<CallGenerator*> _late_inlines; // List of CallGenerators to be revisited after
371 // main parsing has finished.
372
373 // Inlining may not happen in parse order which would make
374 // PrintInlining output confusing. Keep track of PrintInlining
375 // pieces in order.
376 class PrintInliningBuffer : public ResourceObj {
377 private:
378 CallGenerator* _cg;
379 stringStream* _ss;
380
381 public:
382 PrintInliningBuffer()
383 : _cg(NULL) { _ss = new stringStream(); }
384
385 stringStream* ss() const { return _ss; }
386 CallGenerator* cg() const { return _cg; }
387 void set_cg(CallGenerator* cg) { _cg = cg; }
388 };
389
390 GrowableArray<PrintInliningBuffer>* _print_inlining_list;
391 int _print_inlining;
474 bool do_escape_analysis() const { return _do_escape_analysis; }
475 bool save_argument_registers() const { return _save_argument_registers; }
476
477
478 // Other fixed compilation parameters.
479 ciMethod* method() const { return _method; }
480 int entry_bci() const { return _entry_bci; }
481 bool is_osr_compilation() const { return _entry_bci != InvocationEntryBci; }
482 bool is_method_compilation() const { return (_method != NULL && !_method->flags().is_native()); }
483 const TypeFunc* tf() const { assert(_tf!=NULL, ""); return _tf; }
484 void init_tf(const TypeFunc* tf) { assert(_tf==NULL, ""); _tf = tf; }
485 InlineTree* ilt() const { return _ilt; }
486 address stub_function() const { return _stub_function; }
487 const char* stub_name() const { return _stub_name; }
488 address stub_entry_point() const { return _stub_entry_point; }
489
490 // Control of this compilation.
491 int fixed_slots() const { assert(_fixed_slots >= 0, ""); return _fixed_slots; }
492 void set_fixed_slots(int n) { _fixed_slots = n; }
493 int major_progress() const { return _major_progress; }
494 void set_major_progress() { _major_progress++; }
495 void clear_major_progress() { _major_progress = 0; }
496 int num_loop_opts() const { return _num_loop_opts; }
497 void set_num_loop_opts(int n) { _num_loop_opts = n; }
498 int max_inline_size() const { return _max_inline_size; }
499 void set_freq_inline_size(int n) { _freq_inline_size = n; }
500 int freq_inline_size() const { return _freq_inline_size; }
501 void set_max_inline_size(int n) { _max_inline_size = n; }
502 bool has_loops() const { return _has_loops; }
503 void set_has_loops(bool z) { _has_loops = z; }
504 bool has_split_ifs() const { return _has_split_ifs; }
505 void set_has_split_ifs(bool z) { _has_split_ifs = z; }
506 bool has_unsafe_access() const { return _has_unsafe_access; }
507 void set_has_unsafe_access(bool z) { _has_unsafe_access = z; }
508 bool has_stringbuilder() const { return _has_stringbuilder; }
509 void set_has_stringbuilder(bool z) { _has_stringbuilder = z; }
510 int max_vector_size() const { return _max_vector_size; }
511 void set_max_vector_size(int s) { _max_vector_size = s; }
512 void set_trap_count(uint r, uint c) { assert(r < trapHistLength, "oob"); _trap_hist[r] = c; }
513 uint trap_count(uint r) const { assert(r < trapHistLength, "oob"); return _trap_hist[r]; }
712 _last_tf_m = m;
713 _last_tf = tf;
714 }
715
716 AliasType* alias_type(int idx) { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
717 AliasType* alias_type(const TypePtr* adr_type, ciField* field = NULL) { return find_alias_type(adr_type, false, field); }
718 bool have_alias_type(const TypePtr* adr_type);
719 AliasType* alias_type(ciField* field);
720
721 int get_alias_index(const TypePtr* at) { return alias_type(at)->index(); }
722 const TypePtr* get_adr_type(uint aidx) { return alias_type(aidx)->adr_type(); }
723 int get_general_index(uint aidx) { return alias_type(aidx)->general_index(); }
724
725 // Building nodes
726 void rethrow_exceptions(JVMState* jvms);
727 void return_values(JVMState* jvms);
728 JVMState* build_start_state(StartNode* start, const TypeFunc* tf);
729
730 // Decide how to build a call.
731 // The profile factor is a discount to apply to this site's interp. profile.
732 CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_is_virtual, JVMState* jvms, bool allow_inline, float profile_factor, bool allow_intrinsics = true);
733 bool should_delay_inlining(ciMethod* call_method, JVMState* jvms);
734
735 // Report if there were too many traps at a current method and bci.
736 // Report if a trap was recorded, and/or PerMethodTrapLimit was exceeded.
737 // If there is no MDO at all, report no trap unless told to assume it.
738 bool too_many_traps(ciMethod* method, int bci, Deoptimization::DeoptReason reason);
739 // This version, unspecific to a particular bci, asks if
740 // PerMethodTrapLimit was exceeded for all inlined methods seen so far.
741 bool too_many_traps(Deoptimization::DeoptReason reason,
742 // Privately used parameter for logging:
743 ciMethodData* logmd = NULL);
744 // Report if there were too many recompiles at a method and bci.
745 bool too_many_recompiles(ciMethod* method, int bci, Deoptimization::DeoptReason reason);
746
747 // Parsing, optimization
748 PhaseGVN* initial_gvn() { return _initial_gvn; }
749 Unique_Node_List* for_igvn() { return _for_igvn; }
750 inline void record_for_igvn(Node* n); // Body is after class Unique_Node_List.
751 void set_initial_gvn(PhaseGVN *gvn) { _initial_gvn = gvn; }
752 void set_for_igvn(Unique_Node_List *for_igvn) { _for_igvn = for_igvn; }
753
754 // Replace n by nn using initial_gvn, calling hash_delete and
755 // record_for_igvn as needed.
756 void gvn_replace_by(Node* n, Node* nn);
757
758
759 void identify_useful_nodes(Unique_Node_List &useful);
760 void update_dead_node_list(Unique_Node_List &useful);
761 void remove_useless_nodes (Unique_Node_List &useful);
762
763 WarmCallInfo* warm_calls() const { return _warm_calls; }
764 void set_warm_calls(WarmCallInfo* l) { _warm_calls = l; }
765 WarmCallInfo* pop_warm_call();
766
767 // Record this CallGenerator for inlining at the end of parsing.
768 void add_late_inline(CallGenerator* cg) { _late_inlines.push(cg); }
769
770 void dump_inlining();
771
772 // Matching, CFG layout, allocation, code generation
773 PhaseCFG* cfg() { return _cfg; }
774 bool select_24_bit_instr() const { return _select_24_bit_instr; }
775 bool in_24_bit_fp_mode() const { return _in_24_bit_fp_mode; }
776 bool has_java_calls() const { return _java_calls > 0; }
777 int java_calls() const { return _java_calls; }
778 int inner_loops() const { return _inner_loops; }
779 Matcher* matcher() { return _matcher; }
780 PhaseRegAlloc* regalloc() { return _regalloc; }
781 int frame_slots() const { return _frame_slots; }
782 int frame_size_in_words() const; // frame_slots in units of the polymorphic 'words'
783 RegMask& FIRST_STACK_mask() { return _FIRST_STACK_mask; }
784 Arena* indexSet_arena() { return _indexSet_arena; }
785 void* indexSet_free_block_list() { return _indexSet_free_block_list; }
786 uint node_bundling_limit() { return _node_bundling_limit; }
787 Bundle* node_bundling_base() { return _node_bundling_base; }
788 void set_node_bundling_limit(uint n) { _node_bundling_limit = n; }
789 void set_node_bundling_base(Bundle* b) { _node_bundling_base = b; }
790 bool starts_bundle(const Node *n) const;
|
263 const bool _do_escape_analysis; // Do escape analysis.
264 ciMethod* _method; // The method being compiled.
265 int _entry_bci; // entry bci for osr methods.
266 const TypeFunc* _tf; // My kind of signature
267 InlineTree* _ilt; // Ditto (temporary).
268 address _stub_function; // VM entry for stub being compiled, or NULL
269 const char* _stub_name; // Name of stub or adapter being compiled, or NULL
270 address _stub_entry_point; // Compile code entry for generated stub, or NULL
271
272 // Control of this compilation.
273 int _num_loop_opts; // Number of iterations for doing loop optimiztions
274 int _max_inline_size; // Max inline size for this compilation
275 int _freq_inline_size; // Max hot method inline size for this compilation
276 int _fixed_slots; // count of frame slots not allocated by the register
277 // allocator i.e. locks, original deopt pc, etc.
278 // For deopt
279 int _orig_pc_slot;
280 int _orig_pc_slot_offset_in_bytes;
281
282 int _major_progress; // Count of something big happening
283 bool _inlining_progress; // progress doing incremental inlining?
284 bool _inlining_incrementally;// Are we doing incremental inlining (post parse)
285 bool _has_loops; // True if the method _may_ have some loops
286 bool _has_split_ifs; // True if the method _may_ have some split-if
287 bool _has_unsafe_access; // True if the method _may_ produce faults in unsafe loads or stores.
288 bool _has_stringbuilder; // True StringBuffers or StringBuilders are allocated
289 int _max_vector_size; // Maximum size of generated vectors
290 uint _trap_hist[trapHistLength]; // Cumulative traps
291 bool _trap_can_recompile; // Have we emitted a recompiling trap?
292 uint _decompile_count; // Cumulative decompilation counts.
293 bool _do_inlining; // True if we intend to do inlining
294 bool _do_scheduling; // True if we intend to do scheduling
295 bool _do_freq_based_layout; // True if we intend to do frequency based block layout
296 bool _do_count_invocations; // True if we generate code to count invocations
297 bool _do_method_data_update; // True if we generate code to update MethodData*s
298 int _AliasLevel; // Locally-adjusted version of AliasLevel flag.
299 bool _print_assembly; // True if we should dump assembly code for this compilation
300 #ifndef PRODUCT
301 bool _trace_opto_output;
302 bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
303 #endif
304
354 // Type management
355 Arena _Compile_types; // Arena for all types
356 Arena* _type_arena; // Alias for _Compile_types except in Initialize_shared()
357 Dict* _type_dict; // Intern table
358 void* _type_hwm; // Last allocation (see Type::operator new/delete)
359 size_t _type_last_size; // Last allocation size (see Type::operator new/delete)
360 ciMethod* _last_tf_m; // Cache for
361 const TypeFunc* _last_tf; // TypeFunc::make
362 AliasType** _alias_types; // List of alias types seen so far.
363 int _num_alias_types; // Logical length of _alias_types
364 int _max_alias_types; // Physical length of _alias_types
365 AliasCacheEntry _alias_cache[AliasCacheSize]; // Gets aliases w/o data structure walking
366
367 // Parsing, optimization
368 PhaseGVN* _initial_gvn; // Results of parse-time PhaseGVN
369 Unique_Node_List* _for_igvn; // Initial work-list for next round of Iterative GVN
370 WarmCallInfo* _warm_calls; // Sorted work-list for heat-based inlining.
371
372 GrowableArray<CallGenerator*> _late_inlines; // List of CallGenerators to be revisited after
373 // main parsing has finished.
374 GrowableArray<CallGenerator*> _string_late_inlines; // same but for string operations
375
376 int _late_inlines_pos; // Where in the queue should the next late inlining candidate go (emulate depth first inlining)
377 uint _number_of_mh_late_inlines; // number of method handle late inlining still pending
378
379
380 // Inlining may not happen in parse order which would make
381 // PrintInlining output confusing. Keep track of PrintInlining
382 // pieces in order.
383 class PrintInliningBuffer : public ResourceObj {
384 private:
385 CallGenerator* _cg;
386 stringStream* _ss;
387
388 public:
389 PrintInliningBuffer()
390 : _cg(NULL) { _ss = new stringStream(); }
391
392 stringStream* ss() const { return _ss; }
393 CallGenerator* cg() const { return _cg; }
394 void set_cg(CallGenerator* cg) { _cg = cg; }
395 };
396
397 GrowableArray<PrintInliningBuffer>* _print_inlining_list;
398 int _print_inlining;
481 bool do_escape_analysis() const { return _do_escape_analysis; }
482 bool save_argument_registers() const { return _save_argument_registers; }
483
484
485 // Other fixed compilation parameters.
486 ciMethod* method() const { return _method; }
487 int entry_bci() const { return _entry_bci; }
488 bool is_osr_compilation() const { return _entry_bci != InvocationEntryBci; }
489 bool is_method_compilation() const { return (_method != NULL && !_method->flags().is_native()); }
490 const TypeFunc* tf() const { assert(_tf!=NULL, ""); return _tf; }
491 void init_tf(const TypeFunc* tf) { assert(_tf==NULL, ""); _tf = tf; }
492 InlineTree* ilt() const { return _ilt; }
493 address stub_function() const { return _stub_function; }
494 const char* stub_name() const { return _stub_name; }
495 address stub_entry_point() const { return _stub_entry_point; }
496
497 // Control of this compilation.
498 int fixed_slots() const { assert(_fixed_slots >= 0, ""); return _fixed_slots; }
499 void set_fixed_slots(int n) { _fixed_slots = n; }
500 int major_progress() const { return _major_progress; }
501 void set_inlining_progress() { _inlining_progress = true; }
502 void clear_inlining_progress() { _inlining_progress = false; }
503 int inlining_progress() const { return _inlining_progress; }
504 int inlining_incrementally() const { return _inlining_incrementally; }
505 void set_inlining_incrementally() { _inlining_incrementally = true; }
506 void clear_inlining_incrementally() { _inlining_incrementally = false; }
507 void set_major_progress() { _major_progress++; }
508 void clear_major_progress() { _major_progress = 0; }
509 int num_loop_opts() const { return _num_loop_opts; }
510 void set_num_loop_opts(int n) { _num_loop_opts = n; }
511 int max_inline_size() const { return _max_inline_size; }
512 void set_freq_inline_size(int n) { _freq_inline_size = n; }
513 int freq_inline_size() const { return _freq_inline_size; }
514 void set_max_inline_size(int n) { _max_inline_size = n; }
515 bool has_loops() const { return _has_loops; }
516 void set_has_loops(bool z) { _has_loops = z; }
517 bool has_split_ifs() const { return _has_split_ifs; }
518 void set_has_split_ifs(bool z) { _has_split_ifs = z; }
519 bool has_unsafe_access() const { return _has_unsafe_access; }
520 void set_has_unsafe_access(bool z) { _has_unsafe_access = z; }
521 bool has_stringbuilder() const { return _has_stringbuilder; }
522 void set_has_stringbuilder(bool z) { _has_stringbuilder = z; }
523 int max_vector_size() const { return _max_vector_size; }
524 void set_max_vector_size(int s) { _max_vector_size = s; }
525 void set_trap_count(uint r, uint c) { assert(r < trapHistLength, "oob"); _trap_hist[r] = c; }
526 uint trap_count(uint r) const { assert(r < trapHistLength, "oob"); return _trap_hist[r]; }
725 _last_tf_m = m;
726 _last_tf = tf;
727 }
728
729 AliasType* alias_type(int idx) { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
730 AliasType* alias_type(const TypePtr* adr_type, ciField* field = NULL) { return find_alias_type(adr_type, false, field); }
731 bool have_alias_type(const TypePtr* adr_type);
732 AliasType* alias_type(ciField* field);
733
734 int get_alias_index(const TypePtr* at) { return alias_type(at)->index(); }
735 const TypePtr* get_adr_type(uint aidx) { return alias_type(aidx)->adr_type(); }
736 int get_general_index(uint aidx) { return alias_type(aidx)->general_index(); }
737
738 // Building nodes
739 void rethrow_exceptions(JVMState* jvms);
740 void return_values(JVMState* jvms);
741 JVMState* build_start_state(StartNode* start, const TypeFunc* tf);
742
743 // Decide how to build a call.
744 // The profile factor is a discount to apply to this site's interp. profile.
745 CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_is_virtual, JVMState* jvms, bool allow_inline, float profile_factor, bool allow_intrinsics = true, bool delayed_forbidden = false);
746 bool should_delay_inlining(ciMethod* call_method, JVMState* jvms);
747
748 // Report if there were too many traps at a current method and bci.
749 // Report if a trap was recorded, and/or PerMethodTrapLimit was exceeded.
750 // If there is no MDO at all, report no trap unless told to assume it.
751 bool too_many_traps(ciMethod* method, int bci, Deoptimization::DeoptReason reason);
752 // This version, unspecific to a particular bci, asks if
753 // PerMethodTrapLimit was exceeded for all inlined methods seen so far.
754 bool too_many_traps(Deoptimization::DeoptReason reason,
755 // Privately used parameter for logging:
756 ciMethodData* logmd = NULL);
757 // Report if there were too many recompiles at a method and bci.
758 bool too_many_recompiles(ciMethod* method, int bci, Deoptimization::DeoptReason reason);
759
760 // Parsing, optimization
761 PhaseGVN* initial_gvn() { return _initial_gvn; }
762 Unique_Node_List* for_igvn() { return _for_igvn; }
763 inline void record_for_igvn(Node* n); // Body is after class Unique_Node_List.
764 void set_initial_gvn(PhaseGVN *gvn) { _initial_gvn = gvn; }
765 void set_for_igvn(Unique_Node_List *for_igvn) { _for_igvn = for_igvn; }
766
767 // Replace n by nn using initial_gvn, calling hash_delete and
768 // record_for_igvn as needed.
769 void gvn_replace_by(Node* n, Node* nn);
770
771
772 void identify_useful_nodes(Unique_Node_List &useful);
773 void update_dead_node_list(Unique_Node_List &useful);
774 void remove_useless_nodes (Unique_Node_List &useful);
775
776 WarmCallInfo* warm_calls() const { return _warm_calls; }
777 void set_warm_calls(WarmCallInfo* l) { _warm_calls = l; }
778 WarmCallInfo* pop_warm_call();
779
780 // Record this CallGenerator for inlining at the end of parsing.
781 void add_late_inline(CallGenerator* cg) {
782 _late_inlines.insert_before(_late_inlines_pos, cg);
783 _late_inlines_pos++;
784 }
785
786 void prepend_late_inline(CallGenerator* cg) {
787 _late_inlines.insert_before(0, cg);
788 }
789
790 void add_string_late_inline(CallGenerator* cg) {
791 _string_late_inlines.push(cg);
792 }
793
794 void remove_useless_late_inlines(Unique_Node_List &useful, bool string);
795
796 void dump_inlining();
797
798 bool over_inlining_cutoff() const {
799 if (!inlining_incrementally()) {
800 return unique() > (uint)NodeCountInliningCutoff;
801 } else {
802 return live_nodes() > (uint)LiveNodeCountInliningCutoff;
803 }
804 }
805
806 void inc_number_of_mh_late_inlines() { _number_of_mh_late_inlines++; }
807 void dec_number_of_mh_late_inlines() { assert(_number_of_mh_late_inlines > 0, "_number_of_mh_late_inlines < 0 !"); _number_of_mh_late_inlines--; }
808 bool has_mh_late_inlines() const { return _number_of_mh_late_inlines > 0; }
809
810 void incremental_inline_one(PhaseIterGVN& igvn);
811 void incremental_inline(PhaseIterGVN& igvn);
812 void string_inline(bool parse_time);
813
814 // Matching, CFG layout, allocation, code generation
815 PhaseCFG* cfg() { return _cfg; }
816 bool select_24_bit_instr() const { return _select_24_bit_instr; }
817 bool in_24_bit_fp_mode() const { return _in_24_bit_fp_mode; }
818 bool has_java_calls() const { return _java_calls > 0; }
819 int java_calls() const { return _java_calls; }
820 int inner_loops() const { return _inner_loops; }
821 Matcher* matcher() { return _matcher; }
822 PhaseRegAlloc* regalloc() { return _regalloc; }
823 int frame_slots() const { return _frame_slots; }
824 int frame_size_in_words() const; // frame_slots in units of the polymorphic 'words'
825 RegMask& FIRST_STACK_mask() { return _FIRST_STACK_mask; }
826 Arena* indexSet_arena() { return _indexSet_arena; }
827 void* indexSet_free_block_list() { return _indexSet_free_block_list; }
828 uint node_bundling_limit() { return _node_bundling_limit; }
829 Bundle* node_bundling_base() { return _node_bundling_base; }
830 void set_node_bundling_limit(uint n) { _node_bundling_limit = n; }
831 void set_node_bundling_base(Bundle* b) { _node_bundling_base = b; }
832 bool starts_bundle(const Node *n) const;
|