src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 8028468 Sdiff src/share/vm/opto

src/share/vm/opto/compile.cpp

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"

  28 #include "classfile/systemDictionary.hpp"
  29 #include "code/exceptionHandlerTable.hpp"
  30 #include "code/nmethod.hpp"
  31 #include "compiler/compileLog.hpp"
  32 #include "compiler/disassembler.hpp"
  33 #include "compiler/oopMap.hpp"
  34 #include "opto/addnode.hpp"
  35 #include "opto/block.hpp"
  36 #include "opto/c2compiler.hpp"
  37 #include "opto/callGenerator.hpp"
  38 #include "opto/callnode.hpp"
  39 #include "opto/cfgnode.hpp"
  40 #include "opto/chaitin.hpp"
  41 #include "opto/compile.hpp"
  42 #include "opto/connode.hpp"
  43 #include "opto/divnode.hpp"
  44 #include "opto/escape.hpp"
  45 #include "opto/idealGraphPrinter.hpp"
  46 #include "opto/loopnode.hpp"
  47 #include "opto/machnode.hpp"


 630                   _eliminate_boxing(eliminate_boxing),
 631                   _failure_reason(NULL),
 632                   _code_buffer("Compile::Fill_buffer"),
 633                   _orig_pc_slot(0),
 634                   _orig_pc_slot_offset_in_bytes(0),
 635                   _has_method_handle_invokes(false),
 636                   _mach_constant_base_node(NULL),
 637                   _node_bundling_limit(0),
 638                   _node_bundling_base(NULL),
 639                   _java_calls(0),
 640                   _inner_loops(0),
 641                   _scratch_const_size(-1),
 642                   _in_scratch_emit_size(false),
 643                   _dead_node_list(comp_arena()),
 644                   _dead_node_count(0),
 645 #ifndef PRODUCT
 646                   _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")),
 647                   _printer(IdealGraphPrinter::printer()),
 648 #endif
 649                   _congraph(NULL),

 650                   _late_inlines(comp_arena(), 2, 0, NULL),
 651                   _string_late_inlines(comp_arena(), 2, 0, NULL),
 652                   _boxing_late_inlines(comp_arena(), 2, 0, NULL),
 653                   _late_inlines_pos(0),
 654                   _number_of_mh_late_inlines(0),
 655                   _inlining_progress(false),
 656                   _inlining_incrementally(false),
 657                   _print_inlining_list(NULL),
 658                   _print_inlining_idx(0),
 659                   _preserve_jvm_state(0) {
 660   C = this;
 661 
 662   CompileWrapper cw(this);
 663 #ifndef PRODUCT
 664   if (TimeCompiler2) {
 665     tty->print(" ");
 666     target->holder()->name()->print();
 667     tty->print(".");
 668     target->print_short_name();
 669     tty->print("  ");
 670   }
 671   TraceTime t1("Total compilation time", &_t_totalCompilation, TimeCompiler, TimeCompiler2);
 672   TraceTime t2(NULL, &_t_methodCompilation, TimeCompiler, false);
 673   bool print_opto_assembly = PrintOptoAssembly || _method->has_option("PrintOptoAssembly");
 674   if (!print_opto_assembly) {
 675     bool print_assembly = (PrintAssembly || _method->should_print_assembly());
 676     if (print_assembly && !Disassembler::can_decode()) {
 677       tty->print_cr("PrintAssembly request changed to PrintOptoAssembly");
 678       print_opto_assembly = true;
 679     }
 680   }
 681   set_print_assembly(print_opto_assembly);
 682   set_parsed_irreducible_loop(false);




 683 #endif
 684   set_print_inlining(PrintInlining || method()->has_option("PrintInlining") NOT_PRODUCT( || PrintOptoInlining));
 685   set_print_intrinsics(PrintIntrinsics || method()->has_option("PrintIntrinsics"));
 686 
 687   if (ProfileTraps) {
 688     // Make sure the method being compiled gets its own MDO,
 689     // so we can at least track the decompile_count().
 690     method()->ensure_method_data();
 691   }
 692 
 693   Init(::AliasLevel);
 694 
 695 
 696   print_compile_messages();
 697 
 698   if (UseOldInlining || PrintCompilation NOT_PRODUCT( || PrintOpto) )
 699     _ilt = InlineTree::build_inline_tree_root();
 700   else
 701     _ilt = NULL;
 702 


 832 
 833 #ifndef PRODUCT
 834   if (PrintIdeal) {
 835     ttyLocker ttyl;  // keep the following output all in one block
 836     // This output goes directly to the tty, not the compiler log.
 837     // To enable tools to match it up with the compilation activity,
 838     // be sure to tag this tty output with the compile ID.
 839     if (xtty != NULL) {
 840       xtty->head("ideal compile_id='%d'%s", compile_id(),
 841                  is_osr_compilation()    ? " compile_kind='osr'" :
 842                  "");
 843     }
 844     root()->dump(9999);
 845     if (xtty != NULL) {
 846       xtty->tail("ideal");
 847     }
 848   }
 849 #endif
 850 
 851   NOT_PRODUCT( verify_barriers(); )









 852   // Now that we know the size of all the monitors we can add a fixed slot
 853   // for the original deopt pc.
 854 
 855   _orig_pc_slot =  fixed_slots();
 856   int next_slot = _orig_pc_slot + (sizeof(address) / VMRegImpl::stack_slot_size);
 857   set_fixed_slots(next_slot);
 858 
 859   // Now generate code
 860   Code_Gen();
 861   if (failing())  return;
 862 
 863   // Check if we want to skip execution of all compiled code.
 864   {
 865 #ifndef PRODUCT
 866     if (OptoNoExecute) {
 867       record_method_not_compilable("+OptoNoExecute");  // Flag as failed
 868       return;
 869     }
 870     TracePhase t2("install_code", &_t_registerMethod, TimeCompiler);
 871 #endif


 921     _orig_pc_slot(0),
 922     _orig_pc_slot_offset_in_bytes(0),
 923     _subsume_loads(true),
 924     _do_escape_analysis(false),
 925     _eliminate_boxing(false),
 926     _failure_reason(NULL),
 927     _code_buffer("Compile::Fill_buffer"),
 928     _has_method_handle_invokes(false),
 929     _mach_constant_base_node(NULL),
 930     _node_bundling_limit(0),
 931     _node_bundling_base(NULL),
 932     _java_calls(0),
 933     _inner_loops(0),
 934 #ifndef PRODUCT
 935     _trace_opto_output(TraceOptoOutput),
 936     _printer(NULL),
 937 #endif
 938     _dead_node_list(comp_arena()),
 939     _dead_node_count(0),
 940     _congraph(NULL),

 941     _number_of_mh_late_inlines(0),
 942     _inlining_progress(false),
 943     _inlining_incrementally(false),
 944     _print_inlining_list(NULL),
 945     _print_inlining_idx(0),
 946     _preserve_jvm_state(0) {
 947   C = this;
 948 
 949 #ifndef PRODUCT
 950   TraceTime t1(NULL, &_t_totalCompilation, TimeCompiler, false);
 951   TraceTime t2(NULL, &_t_stubCompilation, TimeCompiler, false);
 952   set_print_assembly(PrintFrameConverterAssembly);
 953   set_parsed_irreducible_loop(false);
 954 #endif
 955   CompileWrapper cw(this);
 956   Init(/*AliasLevel=*/ 0);
 957   init_tf((*generator)());
 958 
 959   {
 960     // The following is a dummy for the sake of GraphKit::gen_stub


3936 // This is useful when we don't have the complete list of candidates to choose
3937 // from uniformly. In this case, we need to adjust the randomicity of the
3938 // selection, or else we will end up biasing the selection towards the latter
3939 // candidates.
3940 //
3941 // Quick back-envelope calculation shows that for the list of n candidates
3942 // the equal probability for the candidate to persist as "best" can be
3943 // achieved by replacing it with "next" k-th candidate with the probability
3944 // of 1/k. It can be easily shown that by the end of the run, the
3945 // probability for any candidate is converged to 1/n, thus giving the
3946 // uniform distribution among all the candidates.
3947 //
3948 // We don't care about the domain size as long as (RANDOMIZED_DOMAIN / count) is large.
3949 #define RANDOMIZED_DOMAIN_POW 29
3950 #define RANDOMIZED_DOMAIN (1 << RANDOMIZED_DOMAIN_POW)
3951 #define RANDOMIZED_DOMAIN_MASK ((1 << (RANDOMIZED_DOMAIN_POW + 1)) - 1)
3952 bool Compile::randomized_select(int count) {
3953   assert(count > 0, "only positive");
3954   return (os::random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count);
3955 }











   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "ci/ciReplay.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "code/exceptionHandlerTable.hpp"
  31 #include "code/nmethod.hpp"
  32 #include "compiler/compileLog.hpp"
  33 #include "compiler/disassembler.hpp"
  34 #include "compiler/oopMap.hpp"
  35 #include "opto/addnode.hpp"
  36 #include "opto/block.hpp"
  37 #include "opto/c2compiler.hpp"
  38 #include "opto/callGenerator.hpp"
  39 #include "opto/callnode.hpp"
  40 #include "opto/cfgnode.hpp"
  41 #include "opto/chaitin.hpp"
  42 #include "opto/compile.hpp"
  43 #include "opto/connode.hpp"
  44 #include "opto/divnode.hpp"
  45 #include "opto/escape.hpp"
  46 #include "opto/idealGraphPrinter.hpp"
  47 #include "opto/loopnode.hpp"
  48 #include "opto/machnode.hpp"


 631                   _eliminate_boxing(eliminate_boxing),
 632                   _failure_reason(NULL),
 633                   _code_buffer("Compile::Fill_buffer"),
 634                   _orig_pc_slot(0),
 635                   _orig_pc_slot_offset_in_bytes(0),
 636                   _has_method_handle_invokes(false),
 637                   _mach_constant_base_node(NULL),
 638                   _node_bundling_limit(0),
 639                   _node_bundling_base(NULL),
 640                   _java_calls(0),
 641                   _inner_loops(0),
 642                   _scratch_const_size(-1),
 643                   _in_scratch_emit_size(false),
 644                   _dead_node_list(comp_arena()),
 645                   _dead_node_count(0),
 646 #ifndef PRODUCT
 647                   _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")),
 648                   _printer(IdealGraphPrinter::printer()),
 649 #endif
 650                   _congraph(NULL),
 651                   _replay_inline_data(NULL),
 652                   _late_inlines(comp_arena(), 2, 0, NULL),
 653                   _string_late_inlines(comp_arena(), 2, 0, NULL),
 654                   _boxing_late_inlines(comp_arena(), 2, 0, NULL),
 655                   _late_inlines_pos(0),
 656                   _number_of_mh_late_inlines(0),
 657                   _inlining_progress(false),
 658                   _inlining_incrementally(false),
 659                   _print_inlining_list(NULL),
 660                   _print_inlining_idx(0),
 661                   _preserve_jvm_state(0) {
 662   C = this;
 663 
 664   CompileWrapper cw(this);
 665 #ifndef PRODUCT
 666   if (TimeCompiler2) {
 667     tty->print(" ");
 668     target->holder()->name()->print();
 669     tty->print(".");
 670     target->print_short_name();
 671     tty->print("  ");
 672   }
 673   TraceTime t1("Total compilation time", &_t_totalCompilation, TimeCompiler, TimeCompiler2);
 674   TraceTime t2(NULL, &_t_methodCompilation, TimeCompiler, false);
 675   bool print_opto_assembly = PrintOptoAssembly || _method->has_option("PrintOptoAssembly");
 676   if (!print_opto_assembly) {
 677     bool print_assembly = (PrintAssembly || _method->should_print_assembly());
 678     if (print_assembly && !Disassembler::can_decode()) {
 679       tty->print_cr("PrintAssembly request changed to PrintOptoAssembly");
 680       print_opto_assembly = true;
 681     }
 682   }
 683   set_print_assembly(print_opto_assembly);
 684   set_parsed_irreducible_loop(false);
 685 
 686   if (method()->has_option("ReplayInline")) {
 687     _replay_inline_data = ciReplay::load_inline_data(method(), entry_bci(), ci_env->comp_level());
 688   }
 689 #endif
 690   set_print_inlining(PrintInlining || method()->has_option("PrintInlining") NOT_PRODUCT( || PrintOptoInlining));
 691   set_print_intrinsics(PrintIntrinsics || method()->has_option("PrintIntrinsics"));
 692 
 693   if (ProfileTraps) {
 694     // Make sure the method being compiled gets its own MDO,
 695     // so we can at least track the decompile_count().
 696     method()->ensure_method_data();
 697   }
 698 
 699   Init(::AliasLevel);
 700 
 701 
 702   print_compile_messages();
 703 
 704   if (UseOldInlining || PrintCompilation NOT_PRODUCT( || PrintOpto) )
 705     _ilt = InlineTree::build_inline_tree_root();
 706   else
 707     _ilt = NULL;
 708 


 838 
 839 #ifndef PRODUCT
 840   if (PrintIdeal) {
 841     ttyLocker ttyl;  // keep the following output all in one block
 842     // This output goes directly to the tty, not the compiler log.
 843     // To enable tools to match it up with the compilation activity,
 844     // be sure to tag this tty output with the compile ID.
 845     if (xtty != NULL) {
 846       xtty->head("ideal compile_id='%d'%s", compile_id(),
 847                  is_osr_compilation()    ? " compile_kind='osr'" :
 848                  "");
 849     }
 850     root()->dump(9999);
 851     if (xtty != NULL) {
 852       xtty->tail("ideal");
 853     }
 854   }
 855 #endif
 856 
 857   NOT_PRODUCT( verify_barriers(); )
 858 
 859   // Dump compilation data to replay it.
 860   if (method()->has_option("DumpReplay")) {
 861     env()->dump_replay_data(_compile_id);
 862   }
 863   if (method()->has_option("DumpInline") && (ilt() != NULL)) {
 864     env()->dump_inline_data(_compile_id);
 865   }
 866 
 867   // Now that we know the size of all the monitors we can add a fixed slot
 868   // for the original deopt pc.
 869 
 870   _orig_pc_slot =  fixed_slots();
 871   int next_slot = _orig_pc_slot + (sizeof(address) / VMRegImpl::stack_slot_size);
 872   set_fixed_slots(next_slot);
 873 
 874   // Now generate code
 875   Code_Gen();
 876   if (failing())  return;
 877 
 878   // Check if we want to skip execution of all compiled code.
 879   {
 880 #ifndef PRODUCT
 881     if (OptoNoExecute) {
 882       record_method_not_compilable("+OptoNoExecute");  // Flag as failed
 883       return;
 884     }
 885     TracePhase t2("install_code", &_t_registerMethod, TimeCompiler);
 886 #endif


 936     _orig_pc_slot(0),
 937     _orig_pc_slot_offset_in_bytes(0),
 938     _subsume_loads(true),
 939     _do_escape_analysis(false),
 940     _eliminate_boxing(false),
 941     _failure_reason(NULL),
 942     _code_buffer("Compile::Fill_buffer"),
 943     _has_method_handle_invokes(false),
 944     _mach_constant_base_node(NULL),
 945     _node_bundling_limit(0),
 946     _node_bundling_base(NULL),
 947     _java_calls(0),
 948     _inner_loops(0),
 949 #ifndef PRODUCT
 950     _trace_opto_output(TraceOptoOutput),
 951     _printer(NULL),
 952 #endif
 953     _dead_node_list(comp_arena()),
 954     _dead_node_count(0),
 955     _congraph(NULL),
 956     _replay_inline_data(NULL),
 957     _number_of_mh_late_inlines(0),
 958     _inlining_progress(false),
 959     _inlining_incrementally(false),
 960     _print_inlining_list(NULL),
 961     _print_inlining_idx(0),
 962     _preserve_jvm_state(0) {
 963   C = this;
 964 
 965 #ifndef PRODUCT
 966   TraceTime t1(NULL, &_t_totalCompilation, TimeCompiler, false);
 967   TraceTime t2(NULL, &_t_stubCompilation, TimeCompiler, false);
 968   set_print_assembly(PrintFrameConverterAssembly);
 969   set_parsed_irreducible_loop(false);
 970 #endif
 971   CompileWrapper cw(this);
 972   Init(/*AliasLevel=*/ 0);
 973   init_tf((*generator)());
 974 
 975   {
 976     // The following is a dummy for the sake of GraphKit::gen_stub


3952 // This is useful when we don't have the complete list of candidates to choose
3953 // from uniformly. In this case, we need to adjust the randomicity of the
3954 // selection, or else we will end up biasing the selection towards the latter
3955 // candidates.
3956 //
3957 // Quick back-envelope calculation shows that for the list of n candidates
3958 // the equal probability for the candidate to persist as "best" can be
3959 // achieved by replacing it with "next" k-th candidate with the probability
3960 // of 1/k. It can be easily shown that by the end of the run, the
3961 // probability for any candidate is converged to 1/n, thus giving the
3962 // uniform distribution among all the candidates.
3963 //
3964 // We don't care about the domain size as long as (RANDOMIZED_DOMAIN / count) is large.
3965 #define RANDOMIZED_DOMAIN_POW 29
3966 #define RANDOMIZED_DOMAIN (1 << RANDOMIZED_DOMAIN_POW)
3967 #define RANDOMIZED_DOMAIN_MASK ((1 << (RANDOMIZED_DOMAIN_POW + 1)) - 1)
3968 bool Compile::randomized_select(int count) {
3969   assert(count > 0, "only positive");
3970   return (os::random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count);
3971 }
3972 
3973 // Don't change thread state and acquire any locks.
3974 void Compile::dump_inline_data(outputStream* out) {
3975   InlineTree* inl_tree = ilt();
3976   if (inl_tree != NULL) {
3977     out->print(" inline %d", inl_tree->count());
3978     inl_tree->dump_replay_data(out);
3979   }
3980 }
src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File