annotate src/share/vm/opto/c2compiler.cpp @ 23286:dd9cc155639c

Merge with jdk8u66-b17
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Thu, 07 Jan 2016 17:28:46 +0100
parents 52b4284cb496 ddce0b7cee93
children f13e777eb255
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1397
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1397
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1397
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
26 #include "opto/c2compiler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
27 #include "opto/runtime.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
28 #if defined AD_MD_HPP
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
29 # include AD_MD_HPP
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
30 #elif defined TARGET_ARCH_MODEL_x86_32
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
31 # include "adfiles/ad_x86_32.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
32 #elif defined TARGET_ARCH_MODEL_x86_64
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
33 # include "adfiles/ad_x86_64.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
34 #elif defined TARGET_ARCH_MODEL_sparc
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
35 # include "adfiles/ad_sparc.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
36 #elif defined TARGET_ARCH_MODEL_zero
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
37 # include "adfiles/ad_zero.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
38 #elif defined TARGET_ARCH_MODEL_ppc_64
14391
d2907f74462e 8016586: PPC64 (part 3): basic changes for PPC64
goetz
parents: 10278
diff changeset
39 # include "adfiles/ad_ppc_64.hpp"
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
40 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // register information defined by ADLC
a61af66fc99e Initial load
duke
parents:
diff changeset
43 extern const char register_save_policy[];
a61af66fc99e Initial load
duke
parents:
diff changeset
44 extern const int register_save_type[];
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 const char* C2Compiler::retry_no_subsuming_loads() {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 return "retry without subsuming loads";
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
38
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
49 const char* C2Compiler::retry_no_escape_analysis() {
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
50 return "retry without escape analysis";
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
51 }
12880
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
52 bool C2Compiler::init_c2_runtime() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Check assumptions used while running ADLC
a61af66fc99e Initial load
duke
parents:
diff changeset
55 Compile::adlc_verification();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 OptoReg::vm2opto[i] = OptoReg::Bad;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 VMReg r = OptoReg::as_VMReg(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 if (r->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 OptoReg::vm2opto[r->value()] = i;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Check that runtime and architecture description agree on callee-saved-floats
a61af66fc99e Initial load
duke
parents:
diff changeset
70 bool callee_saved_floats = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // Is there a callee-saved float or double?
a61af66fc99e Initial load
duke
parents:
diff changeset
73 if( register_save_policy[i] == 'E' /* callee-saved */ &&
a61af66fc99e Initial load
duke
parents:
diff changeset
74 (register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 callee_saved_floats = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 DEBUG_ONLY( Node::init_NodeProperty(); )
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 Compile::pd_compiler2_init();
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 CompilerThread* thread = CompilerThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
84
12880
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
85 HandleMark handle_mark(thread);
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
86 return OptoRuntime::generate(thread->env());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 void C2Compiler::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // The first compiler thread that gets here will initialize the
12880
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
92 // small amount of global state (and runtime stubs) that C2 needs.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // There is a race possible once at startup and then we're fine
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Note that this is being called from a compiler thread not the
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // main startup thread.
12880
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
98 if (should_perform_init()) {
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
99 bool successful = C2Compiler::init_c2_runtime();
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
100 int new_state = (successful) ? initialized : failed;
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
101 set_state(new_state);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
12880
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
105 void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
106 assert(is_initialized(), "Compiler thread must be initialized");
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
107
1685
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
108 bool subsume_loads = SubsumeLoads;
12880
469216acdb28 8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents: 10278
diff changeset
109 bool do_escape_analysis = DoEscapeAnalysis && !env->jvmti_can_access_local_variables();
10278
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 2426
diff changeset
110 bool eliminate_boxing = EliminateAutoBox;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
111 while (!env->failing()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Attempt to compile while subsuming loads into machine instructions.
10278
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 2426
diff changeset
113 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114
1685
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
115
0
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Check result and retry if appropriate.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 if (C.failure_reason() != NULL) {
38
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
118 if (C.failure_reason_is(retry_no_subsuming_loads())) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119 assert(subsume_loads, "must make progress");
a61af66fc99e Initial load
duke
parents:
diff changeset
120 subsume_loads = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 continue; // retry
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
38
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
123 if (C.failure_reason_is(retry_no_escape_analysis())) {
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
124 assert(do_escape_analysis, "must make progress");
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
125 do_escape_analysis = false;
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
126 continue; // retry
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
127 }
10278
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 2426
diff changeset
128 if (C.has_boxed_value()) {
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 2426
diff changeset
129 // Recompile without boxing elimination regardless failure reason.
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 2426
diff changeset
130 assert(eliminate_boxing, "must make progress");
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 2426
diff changeset
131 eliminate_boxing = false;
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 2426
diff changeset
132 continue; // retry
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 2426
diff changeset
133 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Pass any other failure reason up to the ciEnv.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // Note that serious, irreversible failures are already logged
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // on the ciEnv via env->record_method_not_compilable().
a61af66fc99e Initial load
duke
parents:
diff changeset
137 env->record_failure(C.failure_reason());
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
1685
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
139 if (StressRecompilation) {
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
140 if (subsume_loads) {
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
141 subsume_loads = false;
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
142 continue; // retry
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
143 }
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
144 if (do_escape_analysis) {
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
145 do_escape_analysis = false;
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
146 continue; // retry
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
147 }
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
148 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // No retry; just break the loop.
a61af66fc99e Initial load
duke
parents:
diff changeset
151 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 void C2Compiler::print_timers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // do nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }