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

src/share/vm/opto/compile.cpp

Print this page
rev 5968 : 8031320: Use Intel RTM instructions for locks
Summary: Use RTM for inflated locks and stack locks.
Reviewed-by: iveresov, twisti, roland, dcubed


 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   _ilt = InlineTree::build_inline_tree_root();
 705 
 706   // Even if NO memory addresses are used, MergeMem nodes must have at least 1 slice
 707   assert(num_alias_types() >= AliasIdxRaw, "");
 708 
 709 #define MINIMUM_NODE_HASH  1023
 710   // Node list that Iterative GVN will start with
 711   Unique_Node_List for_igvn(comp_arena());
 712   set_for_igvn(&for_igvn);
 713 
 714   // GVN that will be run immediately on new nodes
 715   uint estimated_size = method()->code_size()*4+64;


 882     TracePhase t2("install_code", &_t_registerMethod, TimeCompiler);
 883 #endif
 884 
 885     if (is_osr_compilation()) {
 886       _code_offsets.set_value(CodeOffsets::Verified_Entry, 0);
 887       _code_offsets.set_value(CodeOffsets::OSR_Entry, _first_block_size);
 888     } else {
 889       _code_offsets.set_value(CodeOffsets::Verified_Entry, _first_block_size);
 890       _code_offsets.set_value(CodeOffsets::OSR_Entry, 0);
 891     }
 892 
 893     env()->register_method(_method, _entry_bci,
 894                            &_code_offsets,
 895                            _orig_pc_slot_offset_in_bytes,
 896                            code_buffer(),
 897                            frame_size_in_words(), _oop_map_set,
 898                            &_handler_table, &_inc_table,
 899                            compiler,
 900                            env()->comp_level(),
 901                            has_unsafe_access(),
 902                            SharedRuntime::is_wide_vector(max_vector_size())

 903                            );
 904 
 905     if (log() != NULL) // Print code cache state into compiler log
 906       log()->code_cache_state();
 907   }
 908 }
 909 
 910 //------------------------------Compile----------------------------------------
 911 // Compile a runtime stub
 912 Compile::Compile( ciEnv* ci_env,
 913                   TypeFunc_generator generator,
 914                   address stub_function,
 915                   const char *stub_name,
 916                   int is_fancy_jump,
 917                   bool pass_tls,
 918                   bool save_arg_registers,
 919                   bool return_pc )
 920   : Phase(Compiler),
 921     _env(ci_env),
 922     _log(ci_env->log()),


1046   _fixed_slots = 0;
1047   set_has_split_ifs(false);
1048   set_has_loops(has_method() && method()->has_loops()); // first approximation
1049   set_has_stringbuilder(false);
1050   set_has_boxed_value(false);
1051   _trap_can_recompile = false;  // no traps emitted yet
1052   _major_progress = true; // start out assuming good things will happen
1053   set_has_unsafe_access(false);
1054   set_max_vector_size(0);
1055   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
1056   set_decompile_count(0);
1057 
1058   set_do_freq_based_layout(BlockLayoutByFrequency || method_has_option("BlockLayoutByFrequency"));
1059   set_num_loop_opts(LoopOptsCount);
1060   set_do_inlining(Inline);
1061   set_max_inline_size(MaxInlineSize);
1062   set_freq_inline_size(FreqInlineSize);
1063   set_do_scheduling(OptoScheduling);
1064   set_do_count_invocations(false);
1065   set_do_method_data_update(false);
1066 
















1067   if (debug_info()->recording_non_safepoints()) {
1068     set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*>
1069                         (comp_arena(), 8, 0, NULL));
1070     set_default_node_notes(Node_Notes::make(this));
1071   }
1072 
1073   // // -- Initialize types before each compile --
1074   // // Update cached type information
1075   // if( _method && _method->constants() )
1076   //   Type::update_loaded_types(_method, _method->constants());
1077 
1078   // Init alias_type map.
1079   if (!_do_escape_analysis && aliaslevel == 3)
1080     aliaslevel = 2;  // No unique types without escape analysis
1081   _AliasLevel = aliaslevel;
1082   const int grow_ats = 16;
1083   _max_alias_types = grow_ats;
1084   _alias_types   = NEW_ARENA_ARRAY(comp_arena(), AliasType*, grow_ats);
1085   AliasType* ats = NEW_ARENA_ARRAY(comp_arena(), AliasType,  grow_ats);
1086   Copy::zero_to_bytes(ats, sizeof(AliasType)*grow_ats);


2548     break;
2549 
2550   // Count all double operations that may use FPU
2551   case Op_AddD:
2552   case Op_SubD:
2553   case Op_MulD:
2554   case Op_DivD:
2555   case Op_NegD:
2556   case Op_ModD:
2557   case Op_ConvI2D:
2558   case Op_ConvD2I:
2559   // case Op_ConvL2D: // handled by leaf call
2560   // case Op_ConvD2L: // handled by leaf call
2561   case Op_ConD:
2562   case Op_CmpD:
2563   case Op_CmpD3:
2564     frc.inc_double_count();
2565     break;
2566   case Op_Opaque1:              // Remove Opaque Nodes before matching
2567   case Op_Opaque2:              // Remove Opaque Nodes before matching

2568     n->subsume_by(n->in(1), this);
2569     break;
2570   case Op_CallStaticJava:
2571   case Op_CallJava:
2572   case Op_CallDynamicJava:
2573     frc.inc_java_call_count(); // Count java call site;
2574   case Op_CallRuntime:
2575   case Op_CallLeaf:
2576   case Op_CallLeafNoFP: {
2577     assert( n->is_Call(), "" );
2578     CallNode *call = n->as_Call();
2579     // Count call sites where the FP mode bit would have to be flipped.
2580     // Do not count uncommon runtime calls:
2581     // uncommon_trap, _complete_monitor_locking, _complete_monitor_unlocking,
2582     // _new_Java, _new_typeArray, _new_objArray, _rethrow_Java, ...
2583     if( !call->is_CallStaticJava() || !call->as_CallStaticJava()->_name ) {
2584       frc.inc_call_count();   // Count the call site
2585     } else {                  // See if uncommon argument is shared
2586       Node *n = call->in(TypeFunc::Parms);
2587       int nop = n->Opcode();




 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 RTM_OPT_ONLY( || UseRTMLocking )) {
 694     // Make sure the method being compiled gets its own MDO,
 695     // so we can at least track the decompile_count().
 696     // Need MDO to record RTM code generation state.
 697     method()->ensure_method_data();
 698   }
 699 
 700   Init(::AliasLevel);
 701 
 702 
 703   print_compile_messages();
 704 
 705   _ilt = InlineTree::build_inline_tree_root();
 706 
 707   // Even if NO memory addresses are used, MergeMem nodes must have at least 1 slice
 708   assert(num_alias_types() >= AliasIdxRaw, "");
 709 
 710 #define MINIMUM_NODE_HASH  1023
 711   // Node list that Iterative GVN will start with
 712   Unique_Node_List for_igvn(comp_arena());
 713   set_for_igvn(&for_igvn);
 714 
 715   // GVN that will be run immediately on new nodes
 716   uint estimated_size = method()->code_size()*4+64;


 883     TracePhase t2("install_code", &_t_registerMethod, TimeCompiler);
 884 #endif
 885 
 886     if (is_osr_compilation()) {
 887       _code_offsets.set_value(CodeOffsets::Verified_Entry, 0);
 888       _code_offsets.set_value(CodeOffsets::OSR_Entry, _first_block_size);
 889     } else {
 890       _code_offsets.set_value(CodeOffsets::Verified_Entry, _first_block_size);
 891       _code_offsets.set_value(CodeOffsets::OSR_Entry, 0);
 892     }
 893 
 894     env()->register_method(_method, _entry_bci,
 895                            &_code_offsets,
 896                            _orig_pc_slot_offset_in_bytes,
 897                            code_buffer(),
 898                            frame_size_in_words(), _oop_map_set,
 899                            &_handler_table, &_inc_table,
 900                            compiler,
 901                            env()->comp_level(),
 902                            has_unsafe_access(),
 903                            SharedRuntime::is_wide_vector(max_vector_size()),
 904                            rtm_state()
 905                            );
 906 
 907     if (log() != NULL) // Print code cache state into compiler log
 908       log()->code_cache_state();
 909   }
 910 }
 911 
 912 //------------------------------Compile----------------------------------------
 913 // Compile a runtime stub
 914 Compile::Compile( ciEnv* ci_env,
 915                   TypeFunc_generator generator,
 916                   address stub_function,
 917                   const char *stub_name,
 918                   int is_fancy_jump,
 919                   bool pass_tls,
 920                   bool save_arg_registers,
 921                   bool return_pc )
 922   : Phase(Compiler),
 923     _env(ci_env),
 924     _log(ci_env->log()),


1048   _fixed_slots = 0;
1049   set_has_split_ifs(false);
1050   set_has_loops(has_method() && method()->has_loops()); // first approximation
1051   set_has_stringbuilder(false);
1052   set_has_boxed_value(false);
1053   _trap_can_recompile = false;  // no traps emitted yet
1054   _major_progress = true; // start out assuming good things will happen
1055   set_has_unsafe_access(false);
1056   set_max_vector_size(0);
1057   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
1058   set_decompile_count(0);
1059 
1060   set_do_freq_based_layout(BlockLayoutByFrequency || method_has_option("BlockLayoutByFrequency"));
1061   set_num_loop_opts(LoopOptsCount);
1062   set_do_inlining(Inline);
1063   set_max_inline_size(MaxInlineSize);
1064   set_freq_inline_size(FreqInlineSize);
1065   set_do_scheduling(OptoScheduling);
1066   set_do_count_invocations(false);
1067   set_do_method_data_update(false);
1068   set_rtm_state(NoRTM); // No RTM lock eliding by default
1069 #if INCLUDE_RTM_OPT
1070   if (UseRTMLocking && has_method() && (method()->method_data_or_null() != NULL)) {
1071     int rtm_state = method()->method_data()->rtm_state();
1072     if (method_has_option("NoRTMLockEliding") || ((rtm_state & NoRTM) != 0)) {
1073       // Don't generate RTM lock eliding code.
1074       set_rtm_state(NoRTM);
1075     } else if (method_has_option("UseRTMLockEliding") || ((rtm_state & UseRTM) != 0) || !UseRTMDeopt) {
1076       // Generate RTM lock eliding code without abort ratio calculation code.
1077       set_rtm_state(UseRTM);
1078     } else if (UseRTMDeopt) {
1079       // Generate RTM lock eliding code and include abort ratio calculation
1080       // code if UseRTMDeopt is on.
1081       set_rtm_state(ProfileRTM);
1082     }
1083   }
1084 #endif
1085   if (debug_info()->recording_non_safepoints()) {
1086     set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*>
1087                         (comp_arena(), 8, 0, NULL));
1088     set_default_node_notes(Node_Notes::make(this));
1089   }
1090 
1091   // // -- Initialize types before each compile --
1092   // // Update cached type information
1093   // if( _method && _method->constants() )
1094   //   Type::update_loaded_types(_method, _method->constants());
1095 
1096   // Init alias_type map.
1097   if (!_do_escape_analysis && aliaslevel == 3)
1098     aliaslevel = 2;  // No unique types without escape analysis
1099   _AliasLevel = aliaslevel;
1100   const int grow_ats = 16;
1101   _max_alias_types = grow_ats;
1102   _alias_types   = NEW_ARENA_ARRAY(comp_arena(), AliasType*, grow_ats);
1103   AliasType* ats = NEW_ARENA_ARRAY(comp_arena(), AliasType,  grow_ats);
1104   Copy::zero_to_bytes(ats, sizeof(AliasType)*grow_ats);


2566     break;
2567 
2568   // Count all double operations that may use FPU
2569   case Op_AddD:
2570   case Op_SubD:
2571   case Op_MulD:
2572   case Op_DivD:
2573   case Op_NegD:
2574   case Op_ModD:
2575   case Op_ConvI2D:
2576   case Op_ConvD2I:
2577   // case Op_ConvL2D: // handled by leaf call
2578   // case Op_ConvD2L: // handled by leaf call
2579   case Op_ConD:
2580   case Op_CmpD:
2581   case Op_CmpD3:
2582     frc.inc_double_count();
2583     break;
2584   case Op_Opaque1:              // Remove Opaque Nodes before matching
2585   case Op_Opaque2:              // Remove Opaque Nodes before matching
2586   case Op_Opaque3:
2587     n->subsume_by(n->in(1), this);
2588     break;
2589   case Op_CallStaticJava:
2590   case Op_CallJava:
2591   case Op_CallDynamicJava:
2592     frc.inc_java_call_count(); // Count java call site;
2593   case Op_CallRuntime:
2594   case Op_CallLeaf:
2595   case Op_CallLeafNoFP: {
2596     assert( n->is_Call(), "" );
2597     CallNode *call = n->as_Call();
2598     // Count call sites where the FP mode bit would have to be flipped.
2599     // Do not count uncommon runtime calls:
2600     // uncommon_trap, _complete_monitor_locking, _complete_monitor_unlocking,
2601     // _new_Java, _new_typeArray, _new_objArray, _rethrow_Java, ...
2602     if( !call->is_CallStaticJava() || !call->as_CallStaticJava()->_name ) {
2603       frc.inc_call_count();   // Count the call site
2604     } else {                  // See if uncommon argument is shared
2605       Node *n = call->in(TypeFunc::Parms);
2606       int nop = n->Opcode();


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