Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/opto/c2compiler.cpp
32285 views
/*1* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "opto/c2compiler.hpp"26#include "opto/runtime.hpp"27#if defined AD_MD_HPP28# include AD_MD_HPP29#elif defined TARGET_ARCH_MODEL_x86_3230# include "adfiles/ad_x86_32.hpp"31#elif defined TARGET_ARCH_MODEL_x86_6432# include "adfiles/ad_x86_64.hpp"33#elif defined TARGET_ARCH_MODEL_aarch3234# include "adfiles/ad_aarch32.hpp"35#elif defined TARGET_ARCH_MODEL_aarch6436# include "adfiles/ad_aarch64.hpp"37#elif defined TARGET_ARCH_MODEL_sparc38# include "adfiles/ad_sparc.hpp"39#elif defined TARGET_ARCH_MODEL_zero40# include "adfiles/ad_zero.hpp"41#elif defined TARGET_ARCH_MODEL_ppc_6442# include "adfiles/ad_ppc_64.hpp"43#endif4445// register information defined by ADLC46extern const char register_save_policy[];47extern const int register_save_type[];4849const char* C2Compiler::retry_no_subsuming_loads() {50return "retry without subsuming loads";51}52const char* C2Compiler::retry_no_escape_analysis() {53return "retry without escape analysis";54}55const char* C2Compiler::retry_class_loading_during_parsing() {56return "retry class loading during parsing";57}58bool C2Compiler::init_c2_runtime() {5960// Check assumptions used while running ADLC61Compile::adlc_verification();62assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");6364for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {65OptoReg::vm2opto[i] = OptoReg::Bad;66}6768for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {69VMReg r = OptoReg::as_VMReg(i);70if (r->is_valid()) {71OptoReg::vm2opto[r->value()] = i;72}73}7475// Check that runtime and architecture description agree on callee-saved-floats76bool callee_saved_floats = false;77for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) {78// Is there a callee-saved float or double?79if( register_save_policy[i] == 'E' /* callee-saved */ &&80(register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) {81callee_saved_floats = true;82}83}8485DEBUG_ONLY( Node::init_NodeProperty(); )8687Compile::pd_compiler2_init();8889CompilerThread* thread = CompilerThread::current();9091HandleMark handle_mark(thread);92return OptoRuntime::generate(thread->env());93}949596void C2Compiler::initialize() {97// The first compiler thread that gets here will initialize the98// small amount of global state (and runtime stubs) that C2 needs.99100// There is a race possible once at startup and then we're fine101102// Note that this is being called from a compiler thread not the103// main startup thread.104if (should_perform_init()) {105bool successful = C2Compiler::init_c2_runtime();106int new_state = (successful) ? initialized : failed;107set_state(new_state);108}109}110111void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {112assert(is_initialized(), "Compiler thread must be initialized");113114bool subsume_loads = SubsumeLoads;115bool do_escape_analysis = DoEscapeAnalysis && !env->should_retain_local_variables();116bool eliminate_boxing = EliminateAutoBox;117while (!env->failing()) {118// Attempt to compile while subsuming loads into machine instructions.119Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing);120121122// Check result and retry if appropriate.123if (C.failure_reason() != NULL) {124if (C.failure_reason_is(retry_class_loading_during_parsing())) {125env->record_failure(C.failure_reason());126continue; // retry127}128if (C.failure_reason_is(retry_no_subsuming_loads())) {129assert(subsume_loads, "must make progress");130subsume_loads = false;131continue; // retry132}133if (C.failure_reason_is(retry_no_escape_analysis())) {134assert(do_escape_analysis, "must make progress");135do_escape_analysis = false;136continue; // retry137}138if (C.has_boxed_value()) {139// Recompile without boxing elimination regardless failure reason.140assert(eliminate_boxing, "must make progress");141eliminate_boxing = false;142continue; // retry143}144// Pass any other failure reason up to the ciEnv.145// Note that serious, irreversible failures are already logged146// on the ciEnv via env->record_method_not_compilable().147env->record_failure(C.failure_reason());148}149if (StressRecompilation) {150if (subsume_loads) {151subsume_loads = false;152continue; // retry153}154if (do_escape_analysis) {155do_escape_analysis = false;156continue; // retry157}158}159160// No retry; just break the loop.161break;162}163}164165166void C2Compiler::print_timers() {167// do nothing168}169170171