src/share/vm/opto/c2compiler.cpp

Thu, 20 Jun 2013 16:30:44 -0700

author
goetz
date
Thu, 20 Jun 2013 16:30:44 -0700
changeset 6441
d2907f74462e
parent 5110
6f3fd5150b67
child 6472
2b8e28fdf503
permissions
-rw-r--r--

8016586: PPC64 (part 3): basic changes for PPC64
Summary: added #includes needed for ppc64 port. Renamed _MODEL_ppc to _MODEL_ppc_32 and renamed corresponding old _ppc files to _ppc_32.
Reviewed-by: dholmes, kvn

duke@435 1 /*
trims@2708 2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "opto/c2compiler.hpp"
stefank@2314 27 #include "opto/runtime.hpp"
stefank@2314 28 #ifdef TARGET_ARCH_MODEL_x86_32
stefank@2314 29 # include "adfiles/ad_x86_32.hpp"
stefank@2314 30 #endif
stefank@2314 31 #ifdef TARGET_ARCH_MODEL_x86_64
stefank@2314 32 # include "adfiles/ad_x86_64.hpp"
stefank@2314 33 #endif
stefank@2314 34 #ifdef TARGET_ARCH_MODEL_sparc
stefank@2314 35 # include "adfiles/ad_sparc.hpp"
stefank@2314 36 #endif
stefank@2314 37 #ifdef TARGET_ARCH_MODEL_zero
stefank@2314 38 # include "adfiles/ad_zero.hpp"
stefank@2314 39 #endif
bobv@2508 40 #ifdef TARGET_ARCH_MODEL_arm
bobv@2508 41 # include "adfiles/ad_arm.hpp"
bobv@2508 42 #endif
goetz@6441 43 #ifdef TARGET_ARCH_MODEL_ppc_32
goetz@6441 44 # include "adfiles/ad_ppc_32.hpp"
goetz@6441 45 #endif
goetz@6441 46 #ifdef TARGET_ARCH_MODEL_ppc_64
goetz@6441 47 # include "adfiles/ad_ppc_64.hpp"
bobv@2508 48 #endif
duke@435 49
duke@435 50
duke@435 51 volatile int C2Compiler::_runtimes = uninitialized;
duke@435 52
duke@435 53 // register information defined by ADLC
duke@435 54 extern const char register_save_policy[];
duke@435 55 extern const int register_save_type[];
duke@435 56
duke@435 57 const char* C2Compiler::retry_no_subsuming_loads() {
duke@435 58 return "retry without subsuming loads";
duke@435 59 }
kvn@473 60 const char* C2Compiler::retry_no_escape_analysis() {
kvn@473 61 return "retry without escape analysis";
kvn@473 62 }
duke@435 63 void C2Compiler::initialize_runtime() {
duke@435 64
duke@435 65 // Check assumptions used while running ADLC
duke@435 66 Compile::adlc_verification();
duke@435 67 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
duke@435 68
duke@435 69 for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
duke@435 70 OptoReg::vm2opto[i] = OptoReg::Bad;
duke@435 71 }
duke@435 72
duke@435 73 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {
duke@435 74 VMReg r = OptoReg::as_VMReg(i);
duke@435 75 if (r->is_valid()) {
duke@435 76 OptoReg::vm2opto[r->value()] = i;
duke@435 77 }
duke@435 78 }
duke@435 79
duke@435 80 // Check that runtime and architecture description agree on callee-saved-floats
duke@435 81 bool callee_saved_floats = false;
duke@435 82 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) {
duke@435 83 // Is there a callee-saved float or double?
duke@435 84 if( register_save_policy[i] == 'E' /* callee-saved */ &&
duke@435 85 (register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) {
duke@435 86 callee_saved_floats = true;
duke@435 87 }
duke@435 88 }
duke@435 89
duke@435 90 DEBUG_ONLY( Node::init_NodeProperty(); )
duke@435 91
duke@435 92 Compile::pd_compiler2_init();
duke@435 93
duke@435 94 CompilerThread* thread = CompilerThread::current();
duke@435 95
duke@435 96 HandleMark handle_mark(thread);
duke@435 97
duke@435 98 OptoRuntime::generate(thread->env());
duke@435 99
duke@435 100 }
duke@435 101
duke@435 102
duke@435 103 void C2Compiler::initialize() {
duke@435 104
duke@435 105 // This method can only be called once per C2Compiler object
duke@435 106 // The first compiler thread that gets here will initialize the
duke@435 107 // small amount of global state (and runtime stubs) that c2 needs.
duke@435 108
duke@435 109 // There is a race possible once at startup and then we're fine
duke@435 110
duke@435 111 // Note that this is being called from a compiler thread not the
duke@435 112 // main startup thread.
duke@435 113
duke@435 114 if (_runtimes != initialized) {
duke@435 115 initialize_runtimes( initialize_runtime, &_runtimes);
duke@435 116 }
duke@435 117
duke@435 118 // Mark this compiler object as ready to roll
duke@435 119 mark_initialized();
duke@435 120 }
duke@435 121
duke@435 122 void C2Compiler::compile_method(ciEnv* env,
duke@435 123 ciMethod* target,
duke@435 124 int entry_bci) {
duke@435 125 if (!is_initialized()) {
duke@435 126 initialize();
duke@435 127 }
kvn@2040 128 bool subsume_loads = SubsumeLoads;
kvn@1253 129 bool do_escape_analysis = DoEscapeAnalysis &&
never@1832 130 !env->jvmti_can_access_local_variables();
kvn@5110 131 bool eliminate_boxing = EliminateAutoBox;
duke@435 132 while (!env->failing()) {
duke@435 133 // Attempt to compile while subsuming loads into machine instructions.
kvn@5110 134 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing);
duke@435 135
kvn@2040 136
duke@435 137 // Check result and retry if appropriate.
duke@435 138 if (C.failure_reason() != NULL) {
kvn@473 139 if (C.failure_reason_is(retry_no_subsuming_loads())) {
duke@435 140 assert(subsume_loads, "must make progress");
duke@435 141 subsume_loads = false;
duke@435 142 continue; // retry
duke@435 143 }
kvn@473 144 if (C.failure_reason_is(retry_no_escape_analysis())) {
kvn@473 145 assert(do_escape_analysis, "must make progress");
kvn@473 146 do_escape_analysis = false;
kvn@473 147 continue; // retry
kvn@473 148 }
kvn@5110 149 if (C.has_boxed_value()) {
kvn@5110 150 // Recompile without boxing elimination regardless failure reason.
kvn@5110 151 assert(eliminate_boxing, "must make progress");
kvn@5110 152 eliminate_boxing = false;
kvn@5110 153 continue; // retry
kvn@5110 154 }
duke@435 155 // Pass any other failure reason up to the ciEnv.
duke@435 156 // Note that serious, irreversible failures are already logged
duke@435 157 // on the ciEnv via env->record_method_not_compilable().
duke@435 158 env->record_failure(C.failure_reason());
duke@435 159 }
kvn@2040 160 if (StressRecompilation) {
kvn@2040 161 if (subsume_loads) {
kvn@2040 162 subsume_loads = false;
kvn@2040 163 continue; // retry
kvn@2040 164 }
kvn@2040 165 if (do_escape_analysis) {
kvn@2040 166 do_escape_analysis = false;
kvn@2040 167 continue; // retry
kvn@2040 168 }
kvn@2040 169 }
duke@435 170
duke@435 171 // No retry; just break the loop.
duke@435 172 break;
duke@435 173 }
duke@435 174 }
duke@435 175
duke@435 176
duke@435 177 void C2Compiler::print_timers() {
duke@435 178 // do nothing
duke@435 179 }

mercurial