comparison src/share/vm/opto/compile.cpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 4ca6dc0799b6 0bf37f737702
children 8b7a143aea6b
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
1 /* 1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
23 */ 23 */
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "asm/macroAssembler.hpp" 26 #include "asm/macroAssembler.hpp"
27 #include "asm/macroAssembler.inline.hpp" 27 #include "asm/macroAssembler.inline.hpp"
28 #include "ci/ciReplay.hpp"
28 #include "classfile/systemDictionary.hpp" 29 #include "classfile/systemDictionary.hpp"
29 #include "code/exceptionHandlerTable.hpp" 30 #include "code/exceptionHandlerTable.hpp"
30 #include "code/nmethod.hpp" 31 #include "code/nmethod.hpp"
31 #include "compiler/compileLog.hpp" 32 #include "compiler/compileLog.hpp"
32 #include "compiler/disassembler.hpp" 33 #include "compiler/disassembler.hpp"
79 # include "adfiles/ad_zero.hpp" 80 # include "adfiles/ad_zero.hpp"
80 #endif 81 #endif
81 #ifdef TARGET_ARCH_MODEL_arm 82 #ifdef TARGET_ARCH_MODEL_arm
82 # include "adfiles/ad_arm.hpp" 83 # include "adfiles/ad_arm.hpp"
83 #endif 84 #endif
84 #ifdef TARGET_ARCH_MODEL_ppc 85 #ifdef TARGET_ARCH_MODEL_ppc_32
85 # include "adfiles/ad_ppc.hpp" 86 # include "adfiles/ad_ppc_32.hpp"
87 #endif
88 #ifdef TARGET_ARCH_MODEL_ppc_64
89 # include "adfiles/ad_ppc_64.hpp"
86 #endif 90 #endif
87 91
88 92
89 // -------------------- Compile::mach_constant_base_node ----------------------- 93 // -------------------- Compile::mach_constant_base_node -----------------------
90 // Constant table base node singleton. 94 // Constant table base node singleton.
431 // shift is 0 in LP32 and 1 in LP64 435 // shift is 0 in LP32 and 1 in LP64
432 const int shift = (LogBytesPerWord - LogBytesPerInt); 436 const int shift = (LogBytesPerWord - LogBytesPerInt);
433 int words = _frame_slots >> shift; 437 int words = _frame_slots >> shift;
434 assert( words << shift == _frame_slots, "frame size must be properly aligned in LP64" ); 438 assert( words << shift == _frame_slots, "frame size must be properly aligned in LP64" );
435 return words; 439 return words;
440 }
441
442 // To bang the stack of this compiled method we use the stack size
443 // that the interpreter would need in case of a deoptimization. This
444 // removes the need to bang the stack in the deoptimization blob which
445 // in turn simplifies stack overflow handling.
446 int Compile::bang_size_in_bytes() const {
447 return MAX2(_interpreter_frame_size, frame_size_in_bytes());
436 } 448 }
437 449
438 // ============================================================================ 450 // ============================================================================
439 //------------------------------CompileWrapper--------------------------------- 451 //------------------------------CompileWrapper---------------------------------
440 class CompileWrapper : public StackObj { 452 class CompileWrapper : public StackObj {
642 _in_scratch_emit_size(false), 654 _in_scratch_emit_size(false),
643 _dead_node_list(comp_arena()), 655 _dead_node_list(comp_arena()),
644 _dead_node_count(0), 656 _dead_node_count(0),
645 #ifndef PRODUCT 657 #ifndef PRODUCT
646 _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")), 658 _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")),
659 _in_dump_cnt(0),
647 _printer(IdealGraphPrinter::printer()), 660 _printer(IdealGraphPrinter::printer()),
648 #endif 661 #endif
649 _congraph(NULL), 662 _congraph(NULL),
663 _replay_inline_data(NULL),
650 _late_inlines(comp_arena(), 2, 0, NULL), 664 _late_inlines(comp_arena(), 2, 0, NULL),
651 _string_late_inlines(comp_arena(), 2, 0, NULL), 665 _string_late_inlines(comp_arena(), 2, 0, NULL),
652 _boxing_late_inlines(comp_arena(), 2, 0, NULL), 666 _boxing_late_inlines(comp_arena(), 2, 0, NULL),
653 _late_inlines_pos(0), 667 _late_inlines_pos(0),
654 _number_of_mh_late_inlines(0), 668 _number_of_mh_late_inlines(0),
655 _inlining_progress(false), 669 _inlining_progress(false),
656 _inlining_incrementally(false), 670 _inlining_incrementally(false),
657 _print_inlining_list(NULL), 671 _print_inlining_list(NULL),
658 _print_inlining_idx(0), 672 _print_inlining_idx(0),
659 _preserve_jvm_state(0) { 673 _preserve_jvm_state(0),
674 _interpreter_frame_size(0) {
660 C = this; 675 C = this;
661 676
662 CompileWrapper cw(this); 677 CompileWrapper cw(this);
663 #ifndef PRODUCT 678 #ifndef PRODUCT
664 if (TimeCompiler2) { 679 if (TimeCompiler2) {
678 print_opto_assembly = true; 693 print_opto_assembly = true;
679 } 694 }
680 } 695 }
681 set_print_assembly(print_opto_assembly); 696 set_print_assembly(print_opto_assembly);
682 set_parsed_irreducible_loop(false); 697 set_parsed_irreducible_loop(false);
698
699 if (method()->has_option("ReplayInline")) {
700 _replay_inline_data = ciReplay::load_inline_data(method(), entry_bci(), ci_env->comp_level());
701 }
683 #endif 702 #endif
684 set_print_inlining(PrintInlining || method()->has_option("PrintInlining") NOT_PRODUCT( || PrintOptoInlining)); 703 set_print_inlining(PrintInlining || method()->has_option("PrintInlining") NOT_PRODUCT( || PrintOptoInlining));
685 set_print_intrinsics(PrintIntrinsics || method()->has_option("PrintIntrinsics")); 704 set_print_intrinsics(PrintIntrinsics || method()->has_option("PrintIntrinsics"));
686 705 set_has_irreducible_loop(true); // conservative until build_loop_tree() reset it
687 if (ProfileTraps) { 706
707 if (ProfileTraps RTM_OPT_ONLY( || UseRTMLocking )) {
688 // Make sure the method being compiled gets its own MDO, 708 // Make sure the method being compiled gets its own MDO,
689 // so we can at least track the decompile_count(). 709 // so we can at least track the decompile_count().
710 // Need MDO to record RTM code generation state.
690 method()->ensure_method_data(); 711 method()->ensure_method_data();
691 } 712 }
692 713
693 Init(::AliasLevel); 714 Init(::AliasLevel);
694 715
695 716
696 print_compile_messages(); 717 print_compile_messages();
697 718
698 if (UseOldInlining || PrintCompilation NOT_PRODUCT( || PrintOpto) ) 719 _ilt = InlineTree::build_inline_tree_root();
699 _ilt = InlineTree::build_inline_tree_root();
700 else
701 _ilt = NULL;
702 720
703 // Even if NO memory addresses are used, MergeMem nodes must have at least 1 slice 721 // Even if NO memory addresses are used, MergeMem nodes must have at least 1 slice
704 assert(num_alias_types() >= AliasIdxRaw, ""); 722 assert(num_alias_types() >= AliasIdxRaw, "");
705 723
706 #define MINIMUM_NODE_HASH 1023 724 #define MINIMUM_NODE_HASH 1023
847 } 865 }
848 } 866 }
849 #endif 867 #endif
850 868
851 NOT_PRODUCT( verify_barriers(); ) 869 NOT_PRODUCT( verify_barriers(); )
870
871 // Dump compilation data to replay it.
872 if (method()->has_option("DumpReplay")) {
873 env()->dump_replay_data(_compile_id);
874 }
875 if (method()->has_option("DumpInline") && (ilt() != NULL)) {
876 env()->dump_inline_data(_compile_id);
877 }
878
852 // Now that we know the size of all the monitors we can add a fixed slot 879 // Now that we know the size of all the monitors we can add a fixed slot
853 // for the original deopt pc. 880 // for the original deopt pc.
854 881
855 _orig_pc_slot = fixed_slots(); 882 _orig_pc_slot = fixed_slots();
856 int next_slot = _orig_pc_slot + (sizeof(address) / VMRegImpl::stack_slot_size); 883 int next_slot = _orig_pc_slot + (sizeof(address) / VMRegImpl::stack_slot_size);
857 set_fixed_slots(next_slot); 884 set_fixed_slots(next_slot);
885
886 // Compute when to use implicit null checks. Used by matching trap based
887 // nodes and NullCheck optimization.
888 set_allowed_deopt_reasons();
858 889
859 // Now generate code 890 // Now generate code
860 Code_Gen(); 891 Code_Gen();
861 if (failing()) return; 892 if (failing()) return;
862 893
885 frame_size_in_words(), _oop_map_set, 916 frame_size_in_words(), _oop_map_set,
886 &_handler_table, &_inc_table, 917 &_handler_table, &_inc_table,
887 compiler, 918 compiler,
888 env()->comp_level(), 919 env()->comp_level(),
889 has_unsafe_access(), 920 has_unsafe_access(),
890 SharedRuntime::is_wide_vector(max_vector_size()) 921 SharedRuntime::is_wide_vector(max_vector_size()),
922 rtm_state()
891 ); 923 );
892 924
893 if (log() != NULL) // Print code cache state into compiler log 925 if (log() != NULL) // Print code cache state into compiler log
894 log()->code_cache_state(); 926 log()->code_cache_state();
895 } 927 }
931 _node_bundling_base(NULL), 963 _node_bundling_base(NULL),
932 _java_calls(0), 964 _java_calls(0),
933 _inner_loops(0), 965 _inner_loops(0),
934 #ifndef PRODUCT 966 #ifndef PRODUCT
935 _trace_opto_output(TraceOptoOutput), 967 _trace_opto_output(TraceOptoOutput),
968 _in_dump_cnt(0),
936 _printer(NULL), 969 _printer(NULL),
937 #endif 970 #endif
938 _dead_node_list(comp_arena()), 971 _dead_node_list(comp_arena()),
939 _dead_node_count(0), 972 _dead_node_count(0),
940 _congraph(NULL), 973 _congraph(NULL),
974 _replay_inline_data(NULL),
941 _number_of_mh_late_inlines(0), 975 _number_of_mh_late_inlines(0),
942 _inlining_progress(false), 976 _inlining_progress(false),
943 _inlining_incrementally(false), 977 _inlining_incrementally(false),
944 _print_inlining_list(NULL), 978 _print_inlining_list(NULL),
945 _print_inlining_idx(0), 979 _print_inlining_idx(0),
946 _preserve_jvm_state(0) { 980 _preserve_jvm_state(0),
981 _allowed_reasons(0),
982 _interpreter_frame_size(0) {
947 C = this; 983 C = this;
948 984
949 #ifndef PRODUCT 985 #ifndef PRODUCT
950 TraceTime t1(NULL, &_t_totalCompilation, TimeCompiler, false); 986 TraceTime t1(NULL, &_t_totalCompilation, TimeCompiler, false);
951 TraceTime t2(NULL, &_t_stubCompilation, TimeCompiler, false); 987 TraceTime t2(NULL, &_t_stubCompilation, TimeCompiler, false);
952 set_print_assembly(PrintFrameConverterAssembly); 988 set_print_assembly(PrintFrameConverterAssembly);
953 set_parsed_irreducible_loop(false); 989 set_parsed_irreducible_loop(false);
954 #endif 990 #endif
991 set_has_irreducible_loop(false); // no loops
992
955 CompileWrapper cw(this); 993 CompileWrapper cw(this);
956 Init(/*AliasLevel=*/ 0); 994 Init(/*AliasLevel=*/ 0);
957 init_tf((*generator)()); 995 init_tf((*generator)());
958 996
959 { 997 {
1048 set_max_inline_size(MaxInlineSize); 1086 set_max_inline_size(MaxInlineSize);
1049 set_freq_inline_size(FreqInlineSize); 1087 set_freq_inline_size(FreqInlineSize);
1050 set_do_scheduling(OptoScheduling); 1088 set_do_scheduling(OptoScheduling);
1051 set_do_count_invocations(false); 1089 set_do_count_invocations(false);
1052 set_do_method_data_update(false); 1090 set_do_method_data_update(false);
1053 1091 set_rtm_state(NoRTM); // No RTM lock eliding by default
1092 #if INCLUDE_RTM_OPT
1093 if (UseRTMLocking && has_method() && (method()->method_data_or_null() != NULL)) {
1094 int rtm_state = method()->method_data()->rtm_state();
1095 if (method_has_option("NoRTMLockEliding") || ((rtm_state & NoRTM) != 0)) {
1096 // Don't generate RTM lock eliding code.
1097 set_rtm_state(NoRTM);
1098 } else if (method_has_option("UseRTMLockEliding") || ((rtm_state & UseRTM) != 0) || !UseRTMDeopt) {
1099 // Generate RTM lock eliding code without abort ratio calculation code.
1100 set_rtm_state(UseRTM);
1101 } else if (UseRTMDeopt) {
1102 // Generate RTM lock eliding code and include abort ratio calculation
1103 // code if UseRTMDeopt is on.
1104 set_rtm_state(ProfileRTM);
1105 }
1106 }
1107 #endif
1054 if (debug_info()->recording_non_safepoints()) { 1108 if (debug_info()->recording_non_safepoints()) {
1055 set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*> 1109 set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*>
1056 (comp_arena(), 8, 0, NULL)); 1110 (comp_arena(), 8, 0, NULL));
1057 set_default_node_notes(Node_Notes::make(this)); 1111 set_default_node_notes(Node_Notes::make(this));
1058 } 1112 }
1104 for (DUIterator_Fast imax, i = root()->fast_outs(imax); i < imax; i++) { 1158 for (DUIterator_Fast imax, i = root()->fast_outs(imax); i < imax; i++) {
1105 Node* start = root()->fast_out(i); 1159 Node* start = root()->fast_out(i);
1106 if( start->is_Start() ) 1160 if( start->is_Start() )
1107 return start->as_Start(); 1161 return start->as_Start();
1108 } 1162 }
1109 ShouldNotReachHere(); 1163 fatal("Did not find Start node!");
1110 return NULL; 1164 return NULL;
1111 } 1165 }
1112 1166
1113 //-------------------------------immutable_memory------------------------------------- 1167 //-------------------------------immutable_memory-------------------------------------
1114 // Access immutable memory 1168 // Access immutable memory
2246 NOT_PRODUCT( TracePhase t2("peephole", &_t_peephole, TimeCompiler); ) 2300 NOT_PRODUCT( TracePhase t2("peephole", &_t_peephole, TimeCompiler); )
2247 PhasePeephole peep( _regalloc, cfg); 2301 PhasePeephole peep( _regalloc, cfg);
2248 peep.do_transform(); 2302 peep.do_transform();
2249 } 2303 }
2250 2304
2305 // Do late expand if CPU requires this.
2306 if (Matcher::require_postalloc_expand) {
2307 NOT_PRODUCT(TracePhase t2c("postalloc_expand", &_t_postalloc_expand, true));
2308 cfg.postalloc_expand(_regalloc);
2309 }
2310
2251 // Convert Nodes to instruction bits in a buffer 2311 // Convert Nodes to instruction bits in a buffer
2252 { 2312 {
2253 // %%%% workspace merge brought two timers together for one job 2313 // %%%% workspace merge brought two timers together for one job
2254 TracePhase t2a("output", &_t_output, true); 2314 TracePhase t2a("output", &_t_output, true);
2255 NOT_PRODUCT( TraceTime t2b(NULL, &_t_codeGeneration, TimeCompiler, false); ) 2315 NOT_PRODUCT( TraceTime t2b(NULL, &_t_codeGeneration, TimeCompiler, false); )
2359 tty->print(" "); 2419 tty->print(" ");
2360 tty->print(" %c ", starts_bundle); 2420 tty->print(" %c ", starts_bundle);
2361 starts_bundle = ' '; 2421 starts_bundle = ' ';
2362 tty->print("\t"); 2422 tty->print("\t");
2363 delay->format(_regalloc, tty); 2423 delay->format(_regalloc, tty);
2364 tty->print_cr(""); 2424 tty->cr();
2365 delay = NULL; 2425 delay = NULL;
2366 } 2426 }
2367 2427
2368 // Dump the exception table as well 2428 // Dump the exception table as well
2369 if( n->is_Catch() && (Verbose || WizardMode) ) { 2429 if( n->is_Catch() && (Verbose || WizardMode) ) {
2373 } 2433 }
2374 2434
2375 if (pcs && n->_idx < pc_limit) 2435 if (pcs && n->_idx < pc_limit)
2376 tty->print_cr("%3.3x", pcs[n->_idx]); 2436 tty->print_cr("%3.3x", pcs[n->_idx]);
2377 else 2437 else
2378 tty->print_cr(""); 2438 tty->cr();
2379 2439
2380 assert(cut_short || delay == NULL, "no unconditional delay branch"); 2440 assert(cut_short || delay == NULL, "no unconditional delay branch");
2381 2441
2382 } // End of per-block dump 2442 } // End of per-block dump
2383 tty->print_cr(""); 2443 tty->cr();
2384 2444
2385 if (cut_short) tty->print_cr("*** disassembly is cut short ***"); 2445 if (cut_short) tty->print_cr("*** disassembly is cut short ***");
2386 } 2446 }
2387 #endif 2447 #endif
2388 2448
2550 case Op_CmpD3: 2610 case Op_CmpD3:
2551 frc.inc_double_count(); 2611 frc.inc_double_count();
2552 break; 2612 break;
2553 case Op_Opaque1: // Remove Opaque Nodes before matching 2613 case Op_Opaque1: // Remove Opaque Nodes before matching
2554 case Op_Opaque2: // Remove Opaque Nodes before matching 2614 case Op_Opaque2: // Remove Opaque Nodes before matching
2615 case Op_Opaque3:
2555 n->subsume_by(n->in(1), this); 2616 n->subsume_by(n->in(1), this);
2556 break; 2617 break;
2557 case Op_CallStaticJava: 2618 case Op_CallStaticJava:
2558 case Op_CallJava: 2619 case Op_CallJava:
2559 case Op_CallDynamicJava: 2620 case Op_CallDynamicJava:
2997 // confuses register allocation. 3058 // confuses register allocation.
2998 if (n->req() > MemBarNode::Precedent) { 3059 if (n->req() > MemBarNode::Precedent) {
2999 n->set_req(MemBarNode::Precedent, top()); 3060 n->set_req(MemBarNode::Precedent, top());
3000 } 3061 }
3001 break; 3062 break;
3002 // Must set a control edge on all nodes that produce a FlagsProj
3003 // so they can't escape the block that consumes the flags.
3004 // Must also set the non throwing branch as the control
3005 // for all nodes that depends on the result. Unless the node
3006 // already have a control that isn't the control of the
3007 // flag producer
3008 case Op_FlagsProj:
3009 {
3010 MathExactNode* math = (MathExactNode*) n->in(0);
3011 Node* ctrl = math->control_node();
3012 Node* non_throwing = math->non_throwing_branch();
3013 math->set_req(0, ctrl);
3014
3015 Node* result = math->result_node();
3016 if (result != NULL) {
3017 for (DUIterator_Fast jmax, j = result->fast_outs(jmax); j < jmax; j++) {
3018 Node* out = result->fast_out(j);
3019 // Phi nodes shouldn't be moved. They would only match below if they
3020 // had the same control as the MathExactNode. The only time that
3021 // would happen is if the Phi is also an input to the MathExact
3022 //
3023 // Cmp nodes shouldn't have control set at all.
3024 if (out->is_Phi() ||
3025 out->is_Cmp()) {
3026 continue;
3027 }
3028
3029 if (out->in(0) == NULL) {
3030 out->set_req(0, non_throwing);
3031 } else if (out->in(0) == ctrl) {
3032 out->set_req(0, non_throwing);
3033 }
3034 }
3035 }
3036 }
3037 break;
3038 default: 3063 default:
3039 assert( !n->is_Call(), "" ); 3064 assert( !n->is_Call(), "" );
3040 assert( !n->is_Mem(), "" ); 3065 assert( !n->is_Mem(), "" );
3041 break; 3066 break;
3042 } 3067 }
3061 if (i < cnt) { 3086 if (i < cnt) {
3062 // Place all non-visited non-null inputs onto stack 3087 // Place all non-visited non-null inputs onto stack
3063 Node* m = n->in(i); 3088 Node* m = n->in(i);
3064 ++i; 3089 ++i;
3065 if (m != NULL && !frc._visited.test_set(m->_idx)) { 3090 if (m != NULL && !frc._visited.test_set(m->_idx)) {
3066 if (m->is_SafePoint() && m->as_SafePoint()->jvms() != NULL) 3091 if (m->is_SafePoint() && m->as_SafePoint()->jvms() != NULL) {
3092 // compute worst case interpreter size in case of a deoptimization
3093 update_interpreter_frame_size(m->as_SafePoint()->jvms()->interpreter_frame_size());
3094
3067 sfpt.push(m); 3095 sfpt.push(m);
3096 }
3068 cnt = m->req(); 3097 cnt = m->req();
3069 nstack.push(n, i); // put on stack parent and next input's index 3098 nstack.push(n, i); // put on stack parent and next input's index
3070 n = m; 3099 n = m;
3071 i = 0; 3100 i = 0;
3072 } 3101 }
3254 if (md->is_empty()) { 3283 if (md->is_empty()) {
3255 // Assume the trap has not occurred, or that it occurred only 3284 // Assume the trap has not occurred, or that it occurred only
3256 // because of a transient condition during start-up in the interpreter. 3285 // because of a transient condition during start-up in the interpreter.
3257 return false; 3286 return false;
3258 } 3287 }
3259 if (md->has_trap_at(bci, reason) != 0) { 3288 ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL;
3289 if (md->has_trap_at(bci, m, reason) != 0) {
3260 // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic. 3290 // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic.
3261 // Also, if there are multiple reasons, or if there is no per-BCI record, 3291 // Also, if there are multiple reasons, or if there is no per-BCI record,
3262 // assume the worst. 3292 // assume the worst.
3263 if (log()) 3293 if (log())
3264 log()->elem("observe trap='%s' count='%d'", 3294 log()->elem("observe trap='%s' count='%d'",
3272 } 3302 }
3273 3303
3274 // Less-accurate variant which does not require a method and bci. 3304 // Less-accurate variant which does not require a method and bci.
3275 bool Compile::too_many_traps(Deoptimization::DeoptReason reason, 3305 bool Compile::too_many_traps(Deoptimization::DeoptReason reason,
3276 ciMethodData* logmd) { 3306 ciMethodData* logmd) {
3277 if (trap_count(reason) >= (uint)PerMethodTrapLimit) { 3307 if (trap_count(reason) >= Deoptimization::per_method_trap_limit(reason)) {
3278 // Too many traps globally. 3308 // Too many traps globally.
3279 // Note that we use cumulative trap_count, not just md->trap_count. 3309 // Note that we use cumulative trap_count, not just md->trap_count.
3280 if (log()) { 3310 if (log()) {
3281 int mcount = (logmd == NULL)? -1: (int)logmd->trap_count(reason); 3311 int mcount = (logmd == NULL)? -1: (int)logmd->trap_count(reason);
3282 log()->elem("observe trap='%s' count='0' mcount='%d' ccount='%d'", 3312 log()->elem("observe trap='%s' count='0' mcount='%d' ccount='%d'",
3307 // Pick a cutoff point well within PerBytecodeRecompilationCutoff. 3337 // Pick a cutoff point well within PerBytecodeRecompilationCutoff.
3308 uint bc_cutoff = (uint) PerBytecodeRecompilationCutoff / 8; 3338 uint bc_cutoff = (uint) PerBytecodeRecompilationCutoff / 8;
3309 uint m_cutoff = (uint) PerMethodRecompilationCutoff / 2 + 1; // not zero 3339 uint m_cutoff = (uint) PerMethodRecompilationCutoff / 2 + 1; // not zero
3310 Deoptimization::DeoptReason per_bc_reason 3340 Deoptimization::DeoptReason per_bc_reason
3311 = Deoptimization::reason_recorded_per_bytecode_if_any(reason); 3341 = Deoptimization::reason_recorded_per_bytecode_if_any(reason);
3342 ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL;
3312 if ((per_bc_reason == Deoptimization::Reason_none 3343 if ((per_bc_reason == Deoptimization::Reason_none
3313 || md->has_trap_at(bci, reason) != 0) 3344 || md->has_trap_at(bci, m, reason) != 0)
3314 // The trap frequency measure we care about is the recompile count: 3345 // The trap frequency measure we care about is the recompile count:
3315 && md->trap_recompiled_at(bci) 3346 && md->trap_recompiled_at(bci, m)
3316 && md->overflow_recompile_count() >= bc_cutoff) { 3347 && md->overflow_recompile_count() >= bc_cutoff) {
3317 // Do not emit a trap here if it has already caused recompilations. 3348 // Do not emit a trap here if it has already caused recompilations.
3318 // Also, if there are multiple reasons, or if there is no per-BCI record, 3349 // Also, if there are multiple reasons, or if there is no per-BCI record,
3319 // assume the worst. 3350 // assume the worst.
3320 if (log()) 3351 if (log())
3337 // The coast is clear. 3368 // The coast is clear.
3338 return false; 3369 return false;
3339 } 3370 }
3340 } 3371 }
3341 3372
3373 // Compute when not to trap. Used by matching trap based nodes and
3374 // NullCheck optimization.
3375 void Compile::set_allowed_deopt_reasons() {
3376 _allowed_reasons = 0;
3377 if (is_method_compilation()) {
3378 for (int rs = (int)Deoptimization::Reason_none+1; rs < Compile::trapHistLength; rs++) {
3379 assert(rs < BitsPerInt, "recode bit map");
3380 if (!too_many_traps((Deoptimization::DeoptReason) rs)) {
3381 _allowed_reasons |= nth_bit(rs);
3382 }
3383 }
3384 }
3385 }
3342 3386
3343 #ifndef PRODUCT 3387 #ifndef PRODUCT
3344 //------------------------------verify_graph_edges--------------------------- 3388 //------------------------------verify_graph_edges---------------------------
3345 // Walk the Graph and verify that there is a one-to-one correspondence 3389 // Walk the Graph and verify that there is a one-to-one correspondence
3346 // between Use-Def edges and Def-Use edges in the graph. 3390 // between Use-Def edges and Def-Use edges in the graph.
3639 break; 3683 break;
3640 } 3684 }
3641 default: ShouldNotReachHere(); 3685 default: ShouldNotReachHere();
3642 } 3686 }
3643 assert(constant_addr, "consts section too small"); 3687 assert(constant_addr, "consts section too small");
3644 assert((constant_addr - _masm.code()->consts()->start()) == con.offset(), err_msg_res("must be: %d == %d", constant_addr - _masm.code()->consts()->start(), con.offset())); 3688 assert((constant_addr - _masm.code()->consts()->start()) == con.offset(),
3689 err_msg_res("must be: %d == %d", (int) (constant_addr - _masm.code()->consts()->start()), (int)(con.offset())));
3645 } 3690 }
3646 } 3691 }
3647 3692
3648 int Compile::ConstantTable::find_offset(Constant& con) const { 3693 int Compile::ConstantTable::find_offset(Constant& con) const {
3649 int idx = _constants.find(con); 3694 int idx = _constants.find(con);
3719 MacroAssembler _masm(&cb); 3764 MacroAssembler _masm(&cb);
3720 address* jump_table_base = (address*) (_masm.code()->consts()->start() + offset); 3765 address* jump_table_base = (address*) (_masm.code()->consts()->start() + offset);
3721 3766
3722 for (uint i = 0; i < n->outcnt(); i++) { 3767 for (uint i = 0; i < n->outcnt(); i++) {
3723 address* constant_addr = &jump_table_base[i]; 3768 address* constant_addr = &jump_table_base[i];
3724 assert(*constant_addr == (((address) n) + i), err_msg_res("all jump-table entries must contain adjusted node pointer: " INTPTR_FORMAT " == " INTPTR_FORMAT, *constant_addr, (((address) n) + i))); 3769 assert(*constant_addr == (((address) n) + i), err_msg_res("all jump-table entries must contain adjusted node pointer: " INTPTR_FORMAT " == " INTPTR_FORMAT, p2i(*constant_addr), p2i(((address) n) + i)));
3725 *constant_addr = cb.consts()->target(*labels.at(i), (address) constant_addr); 3770 *constant_addr = cb.consts()->target(*labels.at(i), (address) constant_addr);
3726 cb.consts()->relocate((address) constant_addr, relocInfo::internal_word_type); 3771 cb.consts()->relocate((address) constant_addr, relocInfo::internal_word_type);
3727 } 3772 }
3728 } 3773 }
3729 3774
3750 if ( m == NULL ) continue; 3795 if ( m == NULL ) continue;
3751 useful.push(m); 3796 useful.push(m);
3752 } 3797 }
3753 } 3798 }
3754 for (int i = 0; i < _print_inlining_list->length(); i++) { 3799 for (int i = 0; i < _print_inlining_list->length(); i++) {
3755 tty->print(_print_inlining_list->adr_at(i)->ss()->as_string()); 3800 tty->print("%s", _print_inlining_list->adr_at(i)->ss()->as_string());
3756 } 3801 }
3802 }
3803 }
3804
3805 // Dump inlining replay data to the stream.
3806 // Don't change thread state and acquire any locks.
3807 void Compile::dump_inline_data(outputStream* out) {
3808 InlineTree* inl_tree = ilt();
3809 if (inl_tree != NULL) {
3810 out->print(" inline %d", inl_tree->count());
3811 inl_tree->dump_replay_data(out);
3757 } 3812 }
3758 } 3813 }
3759 3814
3760 int Compile::cmp_expensive_nodes(Node* n1, Node* n2) { 3815 int Compile::cmp_expensive_nodes(Node* n1, Node* n2) {
3761 if (n1->Opcode() < n2->Opcode()) return -1; 3816 if (n1->Opcode() < n2->Opcode()) return -1;
3891 // Go over all type nodes that carry a speculative type, drop the 3946 // Go over all type nodes that carry a speculative type, drop the
3892 // speculative part of the type and enqueue the node for an igvn 3947 // speculative part of the type and enqueue the node for an igvn
3893 // which may optimize it out. 3948 // which may optimize it out.
3894 for (uint next = 0; next < worklist.size(); ++next) { 3949 for (uint next = 0; next < worklist.size(); ++next) {
3895 Node *n = worklist.at(next); 3950 Node *n = worklist.at(next);
3896 if (n->is_Type() && n->as_Type()->type()->isa_oopptr() != NULL && 3951 if (n->is_Type()) {
3897 n->as_Type()->type()->is_oopptr()->speculative() != NULL) {
3898 TypeNode* tn = n->as_Type(); 3952 TypeNode* tn = n->as_Type();
3899 const TypeOopPtr* t = tn->type()->is_oopptr(); 3953 const Type* t = tn->type();
3900 bool in_hash = igvn.hash_delete(n); 3954 const Type* t_no_spec = t->remove_speculative();
3901 assert(in_hash, "node should be in igvn hash table"); 3955 if (t_no_spec != t) {
3902 tn->set_type(t->remove_speculative()); 3956 bool in_hash = igvn.hash_delete(n);
3903 igvn.hash_insert(n); 3957 assert(in_hash, "node should be in igvn hash table");
3904 igvn._worklist.push(n); // give it a chance to go away 3958 tn->set_type(t_no_spec);
3905 modified++; 3959 igvn.hash_insert(n);
3960 igvn._worklist.push(n); // give it a chance to go away
3961 modified++;
3962 }
3906 } 3963 }
3907 uint max = n->len(); 3964 uint max = n->len();
3908 for( uint i = 0; i < max; ++i ) { 3965 for( uint i = 0; i < max; ++i ) {
3909 Node *m = n->in(i); 3966 Node *m = n->in(i);
3910 if (not_a_node(m)) continue; 3967 if (not_a_node(m)) continue;
3914 // Drop the speculative part of all types in the igvn's type table 3971 // Drop the speculative part of all types in the igvn's type table
3915 igvn.remove_speculative_types(); 3972 igvn.remove_speculative_types();
3916 if (modified > 0) { 3973 if (modified > 0) {
3917 igvn.optimize(); 3974 igvn.optimize();
3918 } 3975 }
3976 #ifdef ASSERT
3977 // Verify that after the IGVN is over no speculative type has resurfaced
3978 worklist.clear();
3979 worklist.push(root());
3980 for (uint next = 0; next < worklist.size(); ++next) {
3981 Node *n = worklist.at(next);
3982 const Type* t = igvn.type_or_null(n);
3983 assert((t == NULL) || (t == t->remove_speculative()), "no more speculative types");
3984 if (n->is_Type()) {
3985 t = n->as_Type()->type();
3986 assert(t == t->remove_speculative(), "no more speculative types");
3987 }
3988 uint max = n->len();
3989 for( uint i = 0; i < max; ++i ) {
3990 Node *m = n->in(i);
3991 if (not_a_node(m)) continue;
3992 worklist.push(m);
3993 }
3994 }
3995 igvn.check_no_speculative_types();
3996 #endif
3919 } 3997 }
3920 } 3998 }
3921 3999
3922 // Auxiliary method to support randomized stressing/fuzzing. 4000 // Auxiliary method to support randomized stressing/fuzzing.
3923 // 4001 //