comparison src/share/vm/opto/compile.hpp @ 10278:6f3fd5150b67

6934604: enable parts of EliminateAutoBox by default Summary: Resurrected autobox elimination code and enabled part of it by default. Reviewed-by: roland, twisti
author kvn
date Wed, 08 May 2013 15:08:01 -0700
parents ff55877839bc
children f2110083203d
comparison
equal deleted inserted replaced
10277:aabf54ccedb1 10278:6f3fd5150b67
260 // Fixed parameters to this compilation. 260 // Fixed parameters to this compilation.
261 const int _compile_id; 261 const int _compile_id;
262 const bool _save_argument_registers; // save/restore arg regs for trampolines 262 const bool _save_argument_registers; // save/restore arg regs for trampolines
263 const bool _subsume_loads; // Load can be matched as part of a larger op. 263 const bool _subsume_loads; // Load can be matched as part of a larger op.
264 const bool _do_escape_analysis; // Do escape analysis. 264 const bool _do_escape_analysis; // Do escape analysis.
265 const bool _eliminate_boxing; // Do boxing elimination.
265 ciMethod* _method; // The method being compiled. 266 ciMethod* _method; // The method being compiled.
266 int _entry_bci; // entry bci for osr methods. 267 int _entry_bci; // entry bci for osr methods.
267 const TypeFunc* _tf; // My kind of signature 268 const TypeFunc* _tf; // My kind of signature
268 InlineTree* _ilt; // Ditto (temporary). 269 InlineTree* _ilt; // Ditto (temporary).
269 address _stub_function; // VM entry for stub being compiled, or NULL 270 address _stub_function; // VM entry for stub being compiled, or NULL
285 bool _inlining_incrementally;// Are we doing incremental inlining (post parse) 286 bool _inlining_incrementally;// Are we doing incremental inlining (post parse)
286 bool _has_loops; // True if the method _may_ have some loops 287 bool _has_loops; // True if the method _may_ have some loops
287 bool _has_split_ifs; // True if the method _may_ have some split-if 288 bool _has_split_ifs; // True if the method _may_ have some split-if
288 bool _has_unsafe_access; // True if the method _may_ produce faults in unsafe loads or stores. 289 bool _has_unsafe_access; // True if the method _may_ produce faults in unsafe loads or stores.
289 bool _has_stringbuilder; // True StringBuffers or StringBuilders are allocated 290 bool _has_stringbuilder; // True StringBuffers or StringBuilders are allocated
291 bool _has_boxed_value; // True if a boxed object is allocated
290 int _max_vector_size; // Maximum size of generated vectors 292 int _max_vector_size; // Maximum size of generated vectors
291 uint _trap_hist[trapHistLength]; // Cumulative traps 293 uint _trap_hist[trapHistLength]; // Cumulative traps
292 bool _trap_can_recompile; // Have we emitted a recompiling trap? 294 bool _trap_can_recompile; // Have we emitted a recompiling trap?
293 uint _decompile_count; // Cumulative decompilation counts. 295 uint _decompile_count; // Cumulative decompilation counts.
294 bool _do_inlining; // True if we intend to do inlining 296 bool _do_inlining; // True if we intend to do inlining
373 375
374 GrowableArray<CallGenerator*> _late_inlines; // List of CallGenerators to be revisited after 376 GrowableArray<CallGenerator*> _late_inlines; // List of CallGenerators to be revisited after
375 // main parsing has finished. 377 // main parsing has finished.
376 GrowableArray<CallGenerator*> _string_late_inlines; // same but for string operations 378 GrowableArray<CallGenerator*> _string_late_inlines; // same but for string operations
377 379
380 GrowableArray<CallGenerator*> _boxing_late_inlines; // same but for boxing operations
381
378 int _late_inlines_pos; // Where in the queue should the next late inlining candidate go (emulate depth first inlining) 382 int _late_inlines_pos; // Where in the queue should the next late inlining candidate go (emulate depth first inlining)
379 uint _number_of_mh_late_inlines; // number of method handle late inlining still pending 383 uint _number_of_mh_late_inlines; // number of method handle late inlining still pending
380 384
381 385
382 // Inlining may not happen in parse order which would make 386 // Inlining may not happen in parse order which would make
484 488
485 // Does this compilation allow instructions to subsume loads? User 489 // Does this compilation allow instructions to subsume loads? User
486 // instructions that subsume a load may result in an unschedulable 490 // instructions that subsume a load may result in an unschedulable
487 // instruction sequence. 491 // instruction sequence.
488 bool subsume_loads() const { return _subsume_loads; } 492 bool subsume_loads() const { return _subsume_loads; }
489 // Do escape analysis. 493 /** Do escape analysis. */
490 bool do_escape_analysis() const { return _do_escape_analysis; } 494 bool do_escape_analysis() const { return _do_escape_analysis; }
495 /** Do boxing elimination. */
496 bool eliminate_boxing() const { return _eliminate_boxing; }
497 /** Do aggressive boxing elimination. */
498 bool aggressive_unboxing() const { return _eliminate_boxing && AggressiveUnboxing; }
491 bool save_argument_registers() const { return _save_argument_registers; } 499 bool save_argument_registers() const { return _save_argument_registers; }
492 500
493 501
494 // Other fixed compilation parameters. 502 // Other fixed compilation parameters.
495 ciMethod* method() const { return _method; } 503 ciMethod* method() const { return _method; }
525 void set_has_split_ifs(bool z) { _has_split_ifs = z; } 533 void set_has_split_ifs(bool z) { _has_split_ifs = z; }
526 bool has_unsafe_access() const { return _has_unsafe_access; } 534 bool has_unsafe_access() const { return _has_unsafe_access; }
527 void set_has_unsafe_access(bool z) { _has_unsafe_access = z; } 535 void set_has_unsafe_access(bool z) { _has_unsafe_access = z; }
528 bool has_stringbuilder() const { return _has_stringbuilder; } 536 bool has_stringbuilder() const { return _has_stringbuilder; }
529 void set_has_stringbuilder(bool z) { _has_stringbuilder = z; } 537 void set_has_stringbuilder(bool z) { _has_stringbuilder = z; }
538 bool has_boxed_value() const { return _has_boxed_value; }
539 void set_has_boxed_value(bool z) { _has_boxed_value = z; }
530 int max_vector_size() const { return _max_vector_size; } 540 int max_vector_size() const { return _max_vector_size; }
531 void set_max_vector_size(int s) { _max_vector_size = s; } 541 void set_max_vector_size(int s) { _max_vector_size = s; }
532 void set_trap_count(uint r, uint c) { assert(r < trapHistLength, "oob"); _trap_hist[r] = c; } 542 void set_trap_count(uint r, uint c) { assert(r < trapHistLength, "oob"); _trap_hist[r] = c; }
533 uint trap_count(uint r) const { assert(r < trapHistLength, "oob"); return _trap_hist[r]; } 543 uint trap_count(uint r) const { assert(r < trapHistLength, "oob"); return _trap_hist[r]; }
534 bool trap_can_recompile() const { return _trap_can_recompile; } 544 bool trap_can_recompile() const { return _trap_can_recompile; }
577 #ifndef PRODUCT 587 #ifndef PRODUCT
578 if (_printer) _printer->end_method(); 588 if (_printer) _printer->end_method();
579 #endif 589 #endif
580 } 590 }
581 591
582 int macro_count() { return _macro_nodes->length(); } 592 int macro_count() const { return _macro_nodes->length(); }
583 int predicate_count() { return _predicate_opaqs->length();} 593 int predicate_count() const { return _predicate_opaqs->length();}
584 int expensive_count() { return _expensive_nodes->length(); } 594 int expensive_count() const { return _expensive_nodes->length(); }
585 Node* macro_node(int idx) { return _macro_nodes->at(idx); } 595 Node* macro_node(int idx) const { return _macro_nodes->at(idx); }
586 Node* predicate_opaque1_node(int idx) { return _predicate_opaqs->at(idx);} 596 Node* predicate_opaque1_node(int idx) const { return _predicate_opaqs->at(idx);}
587 Node* expensive_node(int idx) { return _expensive_nodes->at(idx); } 597 Node* expensive_node(int idx) const { return _expensive_nodes->at(idx); }
588 ConnectionGraph* congraph() { return _congraph;} 598 ConnectionGraph* congraph() { return _congraph;}
589 void set_congraph(ConnectionGraph* congraph) { _congraph = congraph;} 599 void set_congraph(ConnectionGraph* congraph) { _congraph = congraph;}
590 void add_macro_node(Node * n) { 600 void add_macro_node(Node * n) {
591 //assert(n->is_macro(), "must be a macro node"); 601 //assert(n->is_macro(), "must be a macro node");
592 assert(!_macro_nodes->contains(n), " duplicate entry in expand list"); 602 assert(!_macro_nodes->contains(n), " duplicate entry in expand list");
764 JVMState* build_start_state(StartNode* start, const TypeFunc* tf); 774 JVMState* build_start_state(StartNode* start, const TypeFunc* tf);
765 775
766 // Decide how to build a call. 776 // Decide how to build a call.
767 // The profile factor is a discount to apply to this site's interp. profile. 777 // The profile factor is a discount to apply to this site's interp. profile.
768 CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch, JVMState* jvms, bool allow_inline, float profile_factor, bool allow_intrinsics = true, bool delayed_forbidden = false); 778 CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch, JVMState* jvms, bool allow_inline, float profile_factor, bool allow_intrinsics = true, bool delayed_forbidden = false);
769 bool should_delay_inlining(ciMethod* call_method, JVMState* jvms); 779 bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
780 return should_delay_string_inlining(call_method, jvms) ||
781 should_delay_boxing_inlining(call_method, jvms);
782 }
783 bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);
784 bool should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms);
770 785
771 // Helper functions to identify inlining potential at call-site 786 // Helper functions to identify inlining potential at call-site
772 ciMethod* optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass, 787 ciMethod* optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass,
773 ciMethod* callee, const TypeOopPtr* receiver_type, 788 ciMethod* callee, const TypeOopPtr* receiver_type,
774 bool is_virtual, 789 bool is_virtual,
820 835
821 void add_string_late_inline(CallGenerator* cg) { 836 void add_string_late_inline(CallGenerator* cg) {
822 _string_late_inlines.push(cg); 837 _string_late_inlines.push(cg);
823 } 838 }
824 839
840 void add_boxing_late_inline(CallGenerator* cg) {
841 _boxing_late_inlines.push(cg);
842 }
843
825 void remove_useless_late_inlines(GrowableArray<CallGenerator*>* inlines, Unique_Node_List &useful); 844 void remove_useless_late_inlines(GrowableArray<CallGenerator*>* inlines, Unique_Node_List &useful);
826 845
827 void dump_inlining(); 846 void dump_inlining();
828 847
829 bool over_inlining_cutoff() const { 848 bool over_inlining_cutoff() const {
839 bool has_mh_late_inlines() const { return _number_of_mh_late_inlines > 0; } 858 bool has_mh_late_inlines() const { return _number_of_mh_late_inlines > 0; }
840 859
841 void inline_incrementally_one(PhaseIterGVN& igvn); 860 void inline_incrementally_one(PhaseIterGVN& igvn);
842 void inline_incrementally(PhaseIterGVN& igvn); 861 void inline_incrementally(PhaseIterGVN& igvn);
843 void inline_string_calls(bool parse_time); 862 void inline_string_calls(bool parse_time);
863 void inline_boxing_calls(PhaseIterGVN& igvn);
844 864
845 // Matching, CFG layout, allocation, code generation 865 // Matching, CFG layout, allocation, code generation
846 PhaseCFG* cfg() { return _cfg; } 866 PhaseCFG* cfg() { return _cfg; }
847 bool select_24_bit_instr() const { return _select_24_bit_instr; } 867 bool select_24_bit_instr() const { return _select_24_bit_instr; }
848 bool in_24_bit_fp_mode() const { return _in_24_bit_fp_mode; } 868 bool in_24_bit_fp_mode() const { return _in_24_bit_fp_mode; }
911 // Major entry point. Given a Scope, compile the associated method. 931 // Major entry point. Given a Scope, compile the associated method.
912 // For normal compilations, entry_bci is InvocationEntryBci. For on stack 932 // For normal compilations, entry_bci is InvocationEntryBci. For on stack
913 // replacement, entry_bci indicates the bytecode for which to compile a 933 // replacement, entry_bci indicates the bytecode for which to compile a
914 // continuation. 934 // continuation.
915 Compile(ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, 935 Compile(ciEnv* ci_env, C2Compiler* compiler, ciMethod* target,
916 int entry_bci, bool subsume_loads, bool do_escape_analysis); 936 int entry_bci, bool subsume_loads, bool do_escape_analysis,
937 bool eliminate_boxing);
917 938
918 // Second major entry point. From the TypeFunc signature, generate code 939 // Second major entry point. From the TypeFunc signature, generate code
919 // to pass arguments from the Java calling convention to the C calling 940 // to pass arguments from the Java calling convention to the C calling
920 // convention. 941 // convention.
921 Compile(ciEnv* ci_env, const TypeFunc *(*gen)(), 942 Compile(ciEnv* ci_env, const TypeFunc *(*gen)(),