src/share/vm/opto/c2compiler.cpp

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 10015
eb7ce841ccec
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

duke@435 1 /*
dlong@7598 2 * Copyright (c) 1999, 2015, 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
aoqi@1 25 /*
aoqi@1 26 * This file has been modified by Loongson Technology in 2015. These
aoqi@1 27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
aoqi@1 28 * available on the same license terms set forth above.
aoqi@1 29 */
aoqi@1 30
stefank@2314 31 #include "precompiled.hpp"
stefank@2314 32 #include "opto/c2compiler.hpp"
stefank@2314 33 #include "opto/runtime.hpp"
dlong@7598 34 #if defined AD_MD_HPP
dlong@7598 35 # include AD_MD_HPP
dlong@7598 36 #elif defined TARGET_ARCH_MODEL_x86_32
stefank@2314 37 # include "adfiles/ad_x86_32.hpp"
dlong@7598 38 #elif defined TARGET_ARCH_MODEL_x86_64
stefank@2314 39 # include "adfiles/ad_x86_64.hpp"
dlong@7598 40 #elif defined TARGET_ARCH_MODEL_sparc
stefank@2314 41 # include "adfiles/ad_sparc.hpp"
dlong@7598 42 #elif defined TARGET_ARCH_MODEL_zero
stefank@2314 43 # include "adfiles/ad_zero.hpp"
dlong@7598 44 #elif defined TARGET_ARCH_MODEL_ppc_64
goetz@6441 45 # include "adfiles/ad_ppc_64.hpp"
aoqi@7994 46 #elif defined TARGET_ARCH_MODEL_mips_64
aoqi@1 47 # include "adfiles/ad_mips_64.hpp"
bobv@2508 48 #endif
duke@435 49
duke@435 50 // register information defined by ADLC
duke@435 51 extern const char register_save_policy[];
duke@435 52 extern const int register_save_type[];
duke@435 53
duke@435 54 const char* C2Compiler::retry_no_subsuming_loads() {
duke@435 55 return "retry without subsuming loads";
duke@435 56 }
kvn@473 57 const char* C2Compiler::retry_no_escape_analysis() {
kvn@473 58 return "retry without escape analysis";
kvn@473 59 }
shshahma@8421 60 const char* C2Compiler::retry_class_loading_during_parsing() {
shshahma@8421 61 return "retry class loading during parsing";
shshahma@8421 62 }
anoll@5919 63 bool C2Compiler::init_c2_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
anoll@5919 96 HandleMark handle_mark(thread);
anoll@5919 97 return OptoRuntime::generate(thread->env());
duke@435 98 }
duke@435 99
duke@435 100
duke@435 101 void C2Compiler::initialize() {
duke@435 102 // The first compiler thread that gets here will initialize the
anoll@5919 103 // small amount of global state (and runtime stubs) that C2 needs.
duke@435 104
duke@435 105 // There is a race possible once at startup and then we're fine
duke@435 106
duke@435 107 // Note that this is being called from a compiler thread not the
duke@435 108 // main startup thread.
anoll@5919 109 if (should_perform_init()) {
anoll@5919 110 bool successful = C2Compiler::init_c2_runtime();
anoll@5919 111 int new_state = (successful) ? initialized : failed;
anoll@5919 112 set_state(new_state);
duke@435 113 }
duke@435 114 }
duke@435 115
anoll@5919 116 void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
anoll@5919 117 assert(is_initialized(), "Compiler thread must be initialized");
anoll@5919 118
kvn@2040 119 bool subsume_loads = SubsumeLoads;
mgronlun@9942 120 bool do_escape_analysis = DoEscapeAnalysis && !env->should_retain_local_variables();
kvn@5110 121 bool eliminate_boxing = EliminateAutoBox;
duke@435 122 while (!env->failing()) {
duke@435 123 // Attempt to compile while subsuming loads into machine instructions.
kvn@5110 124 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing);
duke@435 125
kvn@2040 126
duke@435 127 // Check result and retry if appropriate.
duke@435 128 if (C.failure_reason() != NULL) {
shshahma@8421 129 if (C.failure_reason_is(retry_class_loading_during_parsing())) {
shshahma@8421 130 env->record_failure(C.failure_reason());
shshahma@8421 131 continue; // retry
shshahma@8421 132 }
kvn@473 133 if (C.failure_reason_is(retry_no_subsuming_loads())) {
duke@435 134 assert(subsume_loads, "must make progress");
duke@435 135 subsume_loads = false;
duke@435 136 continue; // retry
duke@435 137 }
kvn@473 138 if (C.failure_reason_is(retry_no_escape_analysis())) {
kvn@473 139 assert(do_escape_analysis, "must make progress");
kvn@473 140 do_escape_analysis = false;
kvn@473 141 continue; // retry
kvn@473 142 }
kvn@5110 143 if (C.has_boxed_value()) {
kvn@5110 144 // Recompile without boxing elimination regardless failure reason.
kvn@5110 145 assert(eliminate_boxing, "must make progress");
kvn@5110 146 eliminate_boxing = false;
kvn@5110 147 continue; // retry
kvn@5110 148 }
duke@435 149 // Pass any other failure reason up to the ciEnv.
duke@435 150 // Note that serious, irreversible failures are already logged
duke@435 151 // on the ciEnv via env->record_method_not_compilable().
duke@435 152 env->record_failure(C.failure_reason());
duke@435 153 }
kvn@2040 154 if (StressRecompilation) {
kvn@2040 155 if (subsume_loads) {
kvn@2040 156 subsume_loads = false;
kvn@2040 157 continue; // retry
kvn@2040 158 }
kvn@2040 159 if (do_escape_analysis) {
kvn@2040 160 do_escape_analysis = false;
kvn@2040 161 continue; // retry
kvn@2040 162 }
kvn@2040 163 }
duke@435 164
duke@435 165 // No retry; just break the loop.
duke@435 166 break;
duke@435 167 }
duke@435 168 }
duke@435 169
duke@435 170
duke@435 171 void C2Compiler::print_timers() {
duke@435 172 // do nothing
duke@435 173 }

mercurial