src/share/vm/opto/c2compiler.cpp

Tue, 01 Mar 2016 12:50:37 +0530

author
csahu
date
Tue, 01 Mar 2016 12:50:37 +0530
changeset 8316
626f594dffa6
parent 7598
ddce0b7cee93
child 7994
04ff2f6cd0eb
child 8421
3e1cd663c2d3
permissions
-rw-r--r--

8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
Reviewed-by: stuefe, coleenp, roland

     1 /*
     2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "opto/c2compiler.hpp"
    27 #include "opto/runtime.hpp"
    28 #if defined AD_MD_HPP
    29 # include AD_MD_HPP
    30 #elif defined TARGET_ARCH_MODEL_x86_32
    31 # include "adfiles/ad_x86_32.hpp"
    32 #elif defined TARGET_ARCH_MODEL_x86_64
    33 # include "adfiles/ad_x86_64.hpp"
    34 #elif defined TARGET_ARCH_MODEL_sparc
    35 # include "adfiles/ad_sparc.hpp"
    36 #elif defined TARGET_ARCH_MODEL_zero
    37 # include "adfiles/ad_zero.hpp"
    38 #elif defined TARGET_ARCH_MODEL_ppc_64
    39 # include "adfiles/ad_ppc_64.hpp"
    40 #endif
    42 // register information defined by ADLC
    43 extern const char register_save_policy[];
    44 extern const int  register_save_type[];
    46 const char* C2Compiler::retry_no_subsuming_loads() {
    47   return "retry without subsuming loads";
    48 }
    49 const char* C2Compiler::retry_no_escape_analysis() {
    50   return "retry without escape analysis";
    51 }
    52 bool C2Compiler::init_c2_runtime() {
    54   // Check assumptions used while running ADLC
    55   Compile::adlc_verification();
    56   assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
    58   for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
    59       OptoReg::vm2opto[i] = OptoReg::Bad;
    60   }
    62   for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {
    63     VMReg r = OptoReg::as_VMReg(i);
    64     if (r->is_valid()) {
    65       OptoReg::vm2opto[r->value()] = i;
    66     }
    67   }
    69   // Check that runtime and architecture description agree on callee-saved-floats
    70   bool callee_saved_floats = false;
    71   for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) {
    72     // Is there a callee-saved float or double?
    73     if( register_save_policy[i] == 'E' /* callee-saved */ &&
    74        (register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) {
    75       callee_saved_floats = true;
    76     }
    77   }
    79   DEBUG_ONLY( Node::init_NodeProperty(); )
    81   Compile::pd_compiler2_init();
    83   CompilerThread* thread = CompilerThread::current();
    85   HandleMark handle_mark(thread);
    86   return OptoRuntime::generate(thread->env());
    87 }
    90 void C2Compiler::initialize() {
    91   // The first compiler thread that gets here will initialize the
    92   // small amount of global state (and runtime stubs) that C2 needs.
    94   // There is a race possible once at startup and then we're fine
    96   // Note that this is being called from a compiler thread not the
    97   // main startup thread.
    98   if (should_perform_init()) {
    99     bool successful = C2Compiler::init_c2_runtime();
   100     int new_state = (successful) ? initialized : failed;
   101     set_state(new_state);
   102   }
   103 }
   105 void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
   106   assert(is_initialized(), "Compiler thread must be initialized");
   108   bool subsume_loads = SubsumeLoads;
   109   bool do_escape_analysis = DoEscapeAnalysis && !env->jvmti_can_access_local_variables();
   110   bool eliminate_boxing = EliminateAutoBox;
   111   while (!env->failing()) {
   112     // Attempt to compile while subsuming loads into machine instructions.
   113     Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing);
   116     // Check result and retry if appropriate.
   117     if (C.failure_reason() != NULL) {
   118       if (C.failure_reason_is(retry_no_subsuming_loads())) {
   119         assert(subsume_loads, "must make progress");
   120         subsume_loads = false;
   121         continue;  // retry
   122       }
   123       if (C.failure_reason_is(retry_no_escape_analysis())) {
   124         assert(do_escape_analysis, "must make progress");
   125         do_escape_analysis = false;
   126         continue;  // retry
   127       }
   128       if (C.has_boxed_value()) {
   129         // Recompile without boxing elimination regardless failure reason.
   130         assert(eliminate_boxing, "must make progress");
   131         eliminate_boxing = false;
   132         continue;  // retry
   133       }
   134       // Pass any other failure reason up to the ciEnv.
   135       // Note that serious, irreversible failures are already logged
   136       // on the ciEnv via env->record_method_not_compilable().
   137       env->record_failure(C.failure_reason());
   138     }
   139     if (StressRecompilation) {
   140       if (subsume_loads) {
   141         subsume_loads = false;
   142         continue;  // retry
   143       }
   144       if (do_escape_analysis) {
   145         do_escape_analysis = false;
   146         continue;  // retry
   147       }
   148     }
   150     // No retry; just break the loop.
   151     break;
   152   }
   153 }
   156 void C2Compiler::print_timers() {
   157   // do nothing
   158 }

mercurial