Mercurial > hg > graal-jvmci-8
annotate src/share/vm/opto/c2compiler.cpp @ 24234:ea6f94ab283b default tip
Added tag jvmci-0.36 for changeset 8128b98d4736
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 18 Sep 2017 18:49:45 +0200 |
parents | f13e777eb255 |
children |
rev | line source |
---|---|
0 | 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 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
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 * | |
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "opto/c2compiler.hpp" | |
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 | 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 | 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 | 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 | 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 | 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 | 41 |
42 // register information defined by ADLC | |
43 extern const char register_save_policy[]; | |
44 extern const int register_save_type[]; | |
45 | |
46 const char* C2Compiler::retry_no_subsuming_loads() { | |
47 return "retry without subsuming loads"; | |
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 } |
23848
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
22851
diff
changeset
|
52 const char* C2Compiler::retry_class_loading_during_parsing() { |
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
22851
diff
changeset
|
53 return "retry class loading during parsing"; |
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
22851
diff
changeset
|
54 } |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
55 bool C2Compiler::init_c2_runtime() { |
0 | 56 |
57 // Check assumptions used while running ADLC | |
58 Compile::adlc_verification(); | |
59 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts"); | |
60 | |
61 for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) { | |
62 OptoReg::vm2opto[i] = OptoReg::Bad; | |
63 } | |
64 | |
65 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) { | |
66 VMReg r = OptoReg::as_VMReg(i); | |
67 if (r->is_valid()) { | |
68 OptoReg::vm2opto[r->value()] = i; | |
69 } | |
70 } | |
71 | |
72 // Check that runtime and architecture description agree on callee-saved-floats | |
73 bool callee_saved_floats = false; | |
74 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) { | |
75 // Is there a callee-saved float or double? | |
76 if( register_save_policy[i] == 'E' /* callee-saved */ && | |
77 (register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) { | |
78 callee_saved_floats = true; | |
79 } | |
80 } | |
81 | |
82 DEBUG_ONLY( Node::init_NodeProperty(); ) | |
83 | |
84 Compile::pd_compiler2_init(); | |
85 | |
86 CompilerThread* thread = CompilerThread::current(); | |
87 | |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
88 HandleMark handle_mark(thread); |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
89 return OptoRuntime::generate(thread->env()); |
0 | 90 } |
91 | |
92 | |
93 void C2Compiler::initialize() { | |
94 // The first compiler thread that gets here will initialize the | |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
95 // small amount of global state (and runtime stubs) that C2 needs. |
0 | 96 |
97 // There is a race possible once at startup and then we're fine | |
98 | |
99 // Note that this is being called from a compiler thread not the | |
100 // main startup thread. | |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
101 if (should_perform_init()) { |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
102 bool successful = C2Compiler::init_c2_runtime(); |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
103 int new_state = (successful) ? initialized : failed; |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
104 set_state(new_state); |
0 | 105 } |
106 } | |
107 | |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
108 void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
109 assert(is_initialized(), "Compiler thread must be initialized"); |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
110 |
1685 | 111 bool subsume_loads = SubsumeLoads; |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
112 bool do_escape_analysis = DoEscapeAnalysis && !env->jvmti_can_access_local_variables(); |
10278 | 113 bool eliminate_boxing = EliminateAutoBox; |
0 | 114 while (!env->failing()) { |
115 // Attempt to compile while subsuming loads into machine instructions. | |
10278 | 116 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing); |
0 | 117 |
1685 | 118 |
0 | 119 // Check result and retry if appropriate. |
120 if (C.failure_reason() != NULL) { | |
23848
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
22851
diff
changeset
|
121 if (C.failure_reason_is(retry_class_loading_during_parsing())) { |
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
22851
diff
changeset
|
122 env->record_failure(C.failure_reason()); |
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
22851
diff
changeset
|
123 continue; // retry |
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
22851
diff
changeset
|
124 } |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
125 if (C.failure_reason_is(retry_no_subsuming_loads())) { |
0 | 126 assert(subsume_loads, "must make progress"); |
127 subsume_loads = false; | |
128 continue; // retry | |
129 } | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
130 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
|
131 assert(do_escape_analysis, "must make progress"); |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
132 do_escape_analysis = false; |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
133 continue; // retry |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
134 } |
10278 | 135 if (C.has_boxed_value()) { |
136 // Recompile without boxing elimination regardless failure reason. | |
137 assert(eliminate_boxing, "must make progress"); | |
138 eliminate_boxing = false; | |
139 continue; // retry | |
140 } | |
0 | 141 // Pass any other failure reason up to the ciEnv. |
142 // Note that serious, irreversible failures are already logged | |
143 // on the ciEnv via env->record_method_not_compilable(). | |
144 env->record_failure(C.failure_reason()); | |
145 } | |
1685 | 146 if (StressRecompilation) { |
147 if (subsume_loads) { | |
148 subsume_loads = false; | |
149 continue; // retry | |
150 } | |
151 if (do_escape_analysis) { | |
152 do_escape_analysis = false; | |
153 continue; // retry | |
154 } | |
155 } | |
0 | 156 |
157 // No retry; just break the loop. | |
158 break; | |
159 } | |
160 } | |
161 | |
162 | |
163 void C2Compiler::print_timers() { | |
164 // do nothing | |
165 } |