src/share/vm/opto/c2compiler.cpp

changeset 435
a61af66fc99e
child 473
b789bcaf2dd9
equal deleted inserted replaced
-1:000000000000 435:a61af66fc99e
1 /*
2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
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 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 #include "incls/_precompiled.incl"
26 #include "incls/_c2compiler.cpp.incl"
27
28
29 volatile int C2Compiler::_runtimes = uninitialized;
30
31 // register information defined by ADLC
32 extern const char register_save_policy[];
33 extern const int register_save_type[];
34
35 const char* C2Compiler::retry_no_subsuming_loads() {
36 return "retry without subsuming loads";
37 }
38 void C2Compiler::initialize_runtime() {
39
40 // Check assumptions used while running ADLC
41 Compile::adlc_verification();
42 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
43
44 for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
45 OptoReg::vm2opto[i] = OptoReg::Bad;
46 }
47
48 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {
49 VMReg r = OptoReg::as_VMReg(i);
50 if (r->is_valid()) {
51 OptoReg::vm2opto[r->value()] = i;
52 }
53 }
54
55 // Check that runtime and architecture description agree on callee-saved-floats
56 bool callee_saved_floats = false;
57 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) {
58 // Is there a callee-saved float or double?
59 if( register_save_policy[i] == 'E' /* callee-saved */ &&
60 (register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) {
61 callee_saved_floats = true;
62 }
63 }
64
65 DEBUG_ONLY( Node::init_NodeProperty(); )
66
67 Compile::pd_compiler2_init();
68
69 CompilerThread* thread = CompilerThread::current();
70
71 HandleMark handle_mark(thread);
72
73 OptoRuntime::generate(thread->env());
74
75 }
76
77
78 void C2Compiler::initialize() {
79
80 // This method can only be called once per C2Compiler object
81 // The first compiler thread that gets here will initialize the
82 // small amount of global state (and runtime stubs) that c2 needs.
83
84 // There is a race possible once at startup and then we're fine
85
86 // Note that this is being called from a compiler thread not the
87 // main startup thread.
88
89 if (_runtimes != initialized) {
90 initialize_runtimes( initialize_runtime, &_runtimes);
91 }
92
93 // Mark this compiler object as ready to roll
94 mark_initialized();
95 }
96
97 void C2Compiler::compile_method(ciEnv* env,
98 ciMethod* target,
99 int entry_bci) {
100 if (!is_initialized()) {
101 initialize();
102 }
103 bool subsume_loads = true;
104 while (!env->failing()) {
105 // Attempt to compile while subsuming loads into machine instructions.
106 Compile C(env, this, target, entry_bci, subsume_loads);
107
108 // Check result and retry if appropriate.
109 if (C.failure_reason() != NULL) {
110 if (C.failure_reason_is(retry_no_subsuming_loads())) {
111 assert(subsume_loads, "must make progress");
112 subsume_loads = false;
113 continue; // retry
114 }
115 // Pass any other failure reason up to the ciEnv.
116 // Note that serious, irreversible failures are already logged
117 // on the ciEnv via env->record_method_not_compilable().
118 env->record_failure(C.failure_reason());
119 }
120
121 // No retry; just break the loop.
122 break;
123 }
124 }
125
126
127 void C2Compiler::print_timers() {
128 // do nothing
129 }

mercurial