src/share/vm/c1/c1_Compiler.cpp

Fri, 04 Jun 2010 11:18:04 -0700

author
iveresov
date
Fri, 04 Jun 2010 11:18:04 -0700
changeset 1939
b812ff5abc73
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6958292: C1: Enable parallel compilation
Summary: Enable parallel compilation in C1
Reviewed-by: never, kvn

     1 /*
     2  * Copyright (c) 1999, 2007, 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 "incls/_precompiled.incl"
    26 #include "incls/_c1_Compiler.cpp.incl"
    28 volatile int Compiler::_runtimes = uninitialized;
    30 Compiler::Compiler() {
    31 }
    34 Compiler::~Compiler() {
    35   Unimplemented();
    36 }
    39 void Compiler::initialize_all() {
    40   BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
    41   Arena* arena = new Arena();
    42   Runtime1::initialize(buffer_blob);
    43   FrameMap::initialize();
    44   // initialize data structures
    45   ValueType::initialize(arena);
    46   // Instruction::initialize();
    47   // BlockBegin::initialize();
    48   GraphBuilder::initialize();
    49   // note: to use more than one instance of LinearScan at a time this function call has to
    50   //       be moved somewhere outside of this constructor:
    51   Interval::initialize(arena);
    52 }
    55 void Compiler::initialize() {
    56   if (_runtimes != initialized) {
    57     initialize_runtimes( initialize_all, &_runtimes);
    58   }
    59   mark_initialized();
    60 }
    63 BufferBlob* Compiler::build_buffer_blob() {
    64   // setup CodeBuffer.  Preallocate a BufferBlob of size
    65   // NMethodSizeLimit plus some extra space for constants.
    66   int code_buffer_size = Compilation::desired_max_code_buffer_size() +
    67     Compilation::desired_max_constant_size();
    68   BufferBlob* blob = BufferBlob::create("Compiler1 temporary CodeBuffer",
    69                                         code_buffer_size);
    70   guarantee(blob != NULL, "must create initial code buffer");
    71   return blob;
    72 }
    75 void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) {
    76   // Allocate buffer blob once at startup since allocation for each
    77   // compilation seems to be too expensive (at least on Intel win32).
    78   BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
    79   if (buffer_blob == NULL) {
    80     buffer_blob = build_buffer_blob();
    81     CompilerThread::current()->set_buffer_blob(buffer_blob);
    82   }
    84   if (!is_initialized()) {
    85     initialize();
    86   }
    87   // invoke compilation
    88   {
    89     // We are nested here because we need for the destructor
    90     // of Compilation to occur before we release the any
    91     // competing compiler thread
    92     ResourceMark rm;
    93     Compilation c(this, env, method, entry_bci, buffer_blob);
    94   }
    95 }
    98 void Compiler::print_timers() {
    99   Compilation::print_timers();
   100 }

mercurial