src/share/vm/opto/c2compiler.cpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 473
b789bcaf2dd9
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
duke@435 26 #include "incls/_c2compiler.cpp.incl"
duke@435 27
duke@435 28
duke@435 29 volatile int C2Compiler::_runtimes = uninitialized;
duke@435 30
duke@435 31 // register information defined by ADLC
duke@435 32 extern const char register_save_policy[];
duke@435 33 extern const int register_save_type[];
duke@435 34
duke@435 35 const char* C2Compiler::retry_no_subsuming_loads() {
duke@435 36 return "retry without subsuming loads";
duke@435 37 }
duke@435 38 void C2Compiler::initialize_runtime() {
duke@435 39
duke@435 40 // Check assumptions used while running ADLC
duke@435 41 Compile::adlc_verification();
duke@435 42 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
duke@435 43
duke@435 44 for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
duke@435 45 OptoReg::vm2opto[i] = OptoReg::Bad;
duke@435 46 }
duke@435 47
duke@435 48 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {
duke@435 49 VMReg r = OptoReg::as_VMReg(i);
duke@435 50 if (r->is_valid()) {
duke@435 51 OptoReg::vm2opto[r->value()] = i;
duke@435 52 }
duke@435 53 }
duke@435 54
duke@435 55 // Check that runtime and architecture description agree on callee-saved-floats
duke@435 56 bool callee_saved_floats = false;
duke@435 57 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) {
duke@435 58 // Is there a callee-saved float or double?
duke@435 59 if( register_save_policy[i] == 'E' /* callee-saved */ &&
duke@435 60 (register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) {
duke@435 61 callee_saved_floats = true;
duke@435 62 }
duke@435 63 }
duke@435 64
duke@435 65 DEBUG_ONLY( Node::init_NodeProperty(); )
duke@435 66
duke@435 67 Compile::pd_compiler2_init();
duke@435 68
duke@435 69 CompilerThread* thread = CompilerThread::current();
duke@435 70
duke@435 71 HandleMark handle_mark(thread);
duke@435 72
duke@435 73 OptoRuntime::generate(thread->env());
duke@435 74
duke@435 75 }
duke@435 76
duke@435 77
duke@435 78 void C2Compiler::initialize() {
duke@435 79
duke@435 80 // This method can only be called once per C2Compiler object
duke@435 81 // The first compiler thread that gets here will initialize the
duke@435 82 // small amount of global state (and runtime stubs) that c2 needs.
duke@435 83
duke@435 84 // There is a race possible once at startup and then we're fine
duke@435 85
duke@435 86 // Note that this is being called from a compiler thread not the
duke@435 87 // main startup thread.
duke@435 88
duke@435 89 if (_runtimes != initialized) {
duke@435 90 initialize_runtimes( initialize_runtime, &_runtimes);
duke@435 91 }
duke@435 92
duke@435 93 // Mark this compiler object as ready to roll
duke@435 94 mark_initialized();
duke@435 95 }
duke@435 96
duke@435 97 void C2Compiler::compile_method(ciEnv* env,
duke@435 98 ciMethod* target,
duke@435 99 int entry_bci) {
duke@435 100 if (!is_initialized()) {
duke@435 101 initialize();
duke@435 102 }
duke@435 103 bool subsume_loads = true;
duke@435 104 while (!env->failing()) {
duke@435 105 // Attempt to compile while subsuming loads into machine instructions.
duke@435 106 Compile C(env, this, target, entry_bci, subsume_loads);
duke@435 107
duke@435 108 // Check result and retry if appropriate.
duke@435 109 if (C.failure_reason() != NULL) {
duke@435 110 if (C.failure_reason_is(retry_no_subsuming_loads())) {
duke@435 111 assert(subsume_loads, "must make progress");
duke@435 112 subsume_loads = false;
duke@435 113 continue; // retry
duke@435 114 }
duke@435 115 // Pass any other failure reason up to the ciEnv.
duke@435 116 // Note that serious, irreversible failures are already logged
duke@435 117 // on the ciEnv via env->record_method_not_compilable().
duke@435 118 env->record_failure(C.failure_reason());
duke@435 119 }
duke@435 120
duke@435 121 // No retry; just break the loop.
duke@435 122 break;
duke@435 123 }
duke@435 124 }
duke@435 125
duke@435 126
duke@435 127 void C2Compiler::print_timers() {
duke@435 128 // do nothing
duke@435 129 }

mercurial