src/share/vm/opto/c2compiler.cpp

Wed, 02 Jul 2008 12:55:16 -0700

author
xdono
date
Wed, 02 Jul 2008 12:55:16 -0700
changeset 631
d1605aabd0a1
parent 473
b789bcaf2dd9
child 1253
b109e761e927
permissions
-rw-r--r--

6719955: Update copyright year
Summary: Update copyright year for files that have been modified in 2008
Reviewed-by: ohair, tbell

duke@435 1 /*
xdono@631 2 * Copyright 1999-2008 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 }
kvn@473 38 const char* C2Compiler::retry_no_escape_analysis() {
kvn@473 39 return "retry without escape analysis";
kvn@473 40 }
duke@435 41 void C2Compiler::initialize_runtime() {
duke@435 42
duke@435 43 // Check assumptions used while running ADLC
duke@435 44 Compile::adlc_verification();
duke@435 45 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
duke@435 46
duke@435 47 for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
duke@435 48 OptoReg::vm2opto[i] = OptoReg::Bad;
duke@435 49 }
duke@435 50
duke@435 51 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {
duke@435 52 VMReg r = OptoReg::as_VMReg(i);
duke@435 53 if (r->is_valid()) {
duke@435 54 OptoReg::vm2opto[r->value()] = i;
duke@435 55 }
duke@435 56 }
duke@435 57
duke@435 58 // Check that runtime and architecture description agree on callee-saved-floats
duke@435 59 bool callee_saved_floats = false;
duke@435 60 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) {
duke@435 61 // Is there a callee-saved float or double?
duke@435 62 if( register_save_policy[i] == 'E' /* callee-saved */ &&
duke@435 63 (register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) {
duke@435 64 callee_saved_floats = true;
duke@435 65 }
duke@435 66 }
duke@435 67
duke@435 68 DEBUG_ONLY( Node::init_NodeProperty(); )
duke@435 69
duke@435 70 Compile::pd_compiler2_init();
duke@435 71
duke@435 72 CompilerThread* thread = CompilerThread::current();
duke@435 73
duke@435 74 HandleMark handle_mark(thread);
duke@435 75
duke@435 76 OptoRuntime::generate(thread->env());
duke@435 77
duke@435 78 }
duke@435 79
duke@435 80
duke@435 81 void C2Compiler::initialize() {
duke@435 82
duke@435 83 // This method can only be called once per C2Compiler object
duke@435 84 // The first compiler thread that gets here will initialize the
duke@435 85 // small amount of global state (and runtime stubs) that c2 needs.
duke@435 86
duke@435 87 // There is a race possible once at startup and then we're fine
duke@435 88
duke@435 89 // Note that this is being called from a compiler thread not the
duke@435 90 // main startup thread.
duke@435 91
duke@435 92 if (_runtimes != initialized) {
duke@435 93 initialize_runtimes( initialize_runtime, &_runtimes);
duke@435 94 }
duke@435 95
duke@435 96 // Mark this compiler object as ready to roll
duke@435 97 mark_initialized();
duke@435 98 }
duke@435 99
duke@435 100 void C2Compiler::compile_method(ciEnv* env,
duke@435 101 ciMethod* target,
duke@435 102 int entry_bci) {
duke@435 103 if (!is_initialized()) {
duke@435 104 initialize();
duke@435 105 }
duke@435 106 bool subsume_loads = true;
kvn@473 107 bool do_escape_analysis = DoEscapeAnalysis;
duke@435 108 while (!env->failing()) {
duke@435 109 // Attempt to compile while subsuming loads into machine instructions.
kvn@473 110 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis);
duke@435 111
duke@435 112 // Check result and retry if appropriate.
duke@435 113 if (C.failure_reason() != NULL) {
kvn@473 114 if (C.failure_reason_is(retry_no_subsuming_loads())) {
duke@435 115 assert(subsume_loads, "must make progress");
duke@435 116 subsume_loads = false;
duke@435 117 continue; // retry
duke@435 118 }
kvn@473 119 if (C.failure_reason_is(retry_no_escape_analysis())) {
kvn@473 120 assert(do_escape_analysis, "must make progress");
kvn@473 121 do_escape_analysis = false;
kvn@473 122 continue; // retry
kvn@473 123 }
duke@435 124 // Pass any other failure reason up to the ciEnv.
duke@435 125 // Note that serious, irreversible failures are already logged
duke@435 126 // on the ciEnv via env->record_method_not_compilable().
duke@435 127 env->record_failure(C.failure_reason());
duke@435 128 }
duke@435 129
duke@435 130 // No retry; just break the loop.
duke@435 131 break;
duke@435 132 }
duke@435 133 }
duke@435 134
duke@435 135
duke@435 136 void C2Compiler::print_timers() {
duke@435 137 // do nothing
duke@435 138 }

mercurial