Mercurial > hg > truffle
annotate src/share/vm/opto/c2compiler.cpp @ 17721:d8a0bb6f62a5
Merge
author | coffeys |
---|---|
date | Wed, 12 Mar 2014 18:53:34 +0000 |
parents | 55fb97c4c58d |
children | abec000618bf 96d2c94bbdd0 |
rev | line source |
---|---|
0 | 1 /* |
17467
55fb97c4c58d
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
12880
diff
changeset
|
2 * Copyright (c) 1999, 2013, 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" | |
28 #ifdef TARGET_ARCH_MODEL_x86_32 | |
29 # include "adfiles/ad_x86_32.hpp" | |
30 #endif | |
31 #ifdef TARGET_ARCH_MODEL_x86_64 | |
32 # include "adfiles/ad_x86_64.hpp" | |
33 #endif | |
34 #ifdef TARGET_ARCH_MODEL_sparc | |
35 # include "adfiles/ad_sparc.hpp" | |
36 #endif | |
37 #ifdef TARGET_ARCH_MODEL_zero | |
38 # include "adfiles/ad_zero.hpp" | |
39 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
40 #ifdef TARGET_ARCH_MODEL_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
41 # include "adfiles/ad_arm.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
42 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
43 #ifdef TARGET_ARCH_MODEL_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
44 # include "adfiles/ad_ppc.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
45 #endif |
0 | 46 |
47 // register information defined by ADLC | |
48 extern const char register_save_policy[]; | |
49 extern const int register_save_type[]; | |
50 | |
51 const char* C2Compiler::retry_no_subsuming_loads() { | |
52 return "retry without subsuming loads"; | |
53 } | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
54 const char* C2Compiler::retry_no_escape_analysis() { |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
55 return "retry without escape analysis"; |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
56 } |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
57 bool C2Compiler::init_c2_runtime() { |
0 | 58 |
59 // Check assumptions used while running ADLC | |
60 Compile::adlc_verification(); | |
61 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts"); | |
62 | |
63 for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) { | |
64 OptoReg::vm2opto[i] = OptoReg::Bad; | |
65 } | |
66 | |
67 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) { | |
68 VMReg r = OptoReg::as_VMReg(i); | |
69 if (r->is_valid()) { | |
70 OptoReg::vm2opto[r->value()] = i; | |
71 } | |
72 } | |
73 | |
74 // Check that runtime and architecture description agree on callee-saved-floats | |
75 bool callee_saved_floats = false; | |
76 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) { | |
77 // Is there a callee-saved float or double? | |
78 if( register_save_policy[i] == 'E' /* callee-saved */ && | |
79 (register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) { | |
80 callee_saved_floats = true; | |
81 } | |
82 } | |
83 | |
84 DEBUG_ONLY( Node::init_NodeProperty(); ) | |
85 | |
86 Compile::pd_compiler2_init(); | |
87 | |
88 CompilerThread* thread = CompilerThread::current(); | |
89 | |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
90 HandleMark handle_mark(thread); |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
91 return OptoRuntime::generate(thread->env()); |
0 | 92 } |
93 | |
94 | |
95 void C2Compiler::initialize() { | |
96 // The first compiler thread that gets here will initialize the | |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
97 // small amount of global state (and runtime stubs) that C2 needs. |
0 | 98 |
99 // There is a race possible once at startup and then we're fine | |
100 | |
101 // Note that this is being called from a compiler thread not the | |
102 // main startup thread. | |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
103 if (should_perform_init()) { |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
104 bool successful = C2Compiler::init_c2_runtime(); |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
105 int new_state = (successful) ? initialized : failed; |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
106 set_state(new_state); |
0 | 107 } |
108 } | |
109 | |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
110 void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
111 assert(is_initialized(), "Compiler thread must be initialized"); |
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
112 |
1685 | 113 bool subsume_loads = SubsumeLoads; |
12880
469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
10278
diff
changeset
|
114 bool do_escape_analysis = DoEscapeAnalysis && !env->jvmti_can_access_local_variables(); |
10278 | 115 bool eliminate_boxing = EliminateAutoBox; |
0 | 116 while (!env->failing()) { |
117 // Attempt to compile while subsuming loads into machine instructions. | |
10278 | 118 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing); |
0 | 119 |
1685 | 120 |
0 | 121 // Check result and retry if appropriate. |
122 if (C.failure_reason() != NULL) { | |
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_subsuming_loads())) { |
0 | 124 assert(subsume_loads, "must make progress"); |
125 subsume_loads = false; | |
126 continue; // retry | |
127 } | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
128 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
|
129 assert(do_escape_analysis, "must make progress"); |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
130 do_escape_analysis = false; |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
131 continue; // retry |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
132 } |
10278 | 133 if (C.has_boxed_value()) { |
134 // Recompile without boxing elimination regardless failure reason. | |
135 assert(eliminate_boxing, "must make progress"); | |
136 eliminate_boxing = false; | |
137 continue; // retry | |
138 } | |
0 | 139 // Pass any other failure reason up to the ciEnv. |
140 // Note that serious, irreversible failures are already logged | |
141 // on the ciEnv via env->record_method_not_compilable(). | |
142 env->record_failure(C.failure_reason()); | |
143 } | |
1685 | 144 if (StressRecompilation) { |
145 if (subsume_loads) { | |
146 subsume_loads = false; | |
147 continue; // retry | |
148 } | |
149 if (do_escape_analysis) { | |
150 do_escape_analysis = false; | |
151 continue; // retry | |
152 } | |
153 } | |
0 | 154 |
155 // No retry; just break the loop. | |
156 break; | |
157 } | |
158 } | |
159 | |
160 | |
161 void C2Compiler::print_timers() { | |
162 // do nothing | |
163 } |