Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/c1/c1_Compiler.cpp
32285 views
/*1* Copyright (c) 1999, 2013, 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 "c1/c1_Compilation.hpp"26#include "c1/c1_Compiler.hpp"27#include "c1/c1_FrameMap.hpp"28#include "c1/c1_GraphBuilder.hpp"29#include "c1/c1_LinearScan.hpp"30#include "c1/c1_MacroAssembler.hpp"31#include "c1/c1_Runtime1.hpp"32#include "c1/c1_ValueType.hpp"33#include "compiler/compileBroker.hpp"34#include "compiler/compilerOracle.hpp"35#include "interpreter/linkResolver.hpp"36#include "memory/allocation.hpp"37#include "memory/allocation.inline.hpp"38#include "memory/resourceArea.hpp"39#include "prims/nativeLookup.hpp"40#include "runtime/arguments.hpp"41#include "runtime/interfaceSupport.hpp"42#include "runtime/sharedRuntime.hpp"434445Compiler::Compiler () {}4647void Compiler::init_c1_runtime() {48BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();49Arena* arena = new (mtCompiler) Arena(mtCompiler);50Runtime1::initialize(buffer_blob);51FrameMap::initialize();52// initialize data structures53ValueType::initialize(arena);54GraphBuilder::initialize();55// note: to use more than one instance of LinearScan at a time this function call has to56// be moved somewhere outside of this constructor:57Interval::initialize(arena);58}596061void Compiler::initialize() {62// Buffer blob must be allocated per C1 compiler thread at startup63BufferBlob* buffer_blob = init_buffer_blob();6465if (should_perform_init()) {66if (buffer_blob == NULL) {67// When we come here we are in state 'initializing'; entire C1 compilation68// can be shut down.69set_state(failed);70} else {71init_c1_runtime();72set_state(initialized);73}74}75}7677BufferBlob* Compiler::init_buffer_blob() {78// Allocate buffer blob once at startup since allocation for each79// compilation seems to be too expensive (at least on Intel win32).80assert (CompilerThread::current()->get_buffer_blob() == NULL, "Should initialize only once");8182// setup CodeBuffer. Preallocate a BufferBlob of size83// NMethodSizeLimit plus some extra space for constants.84int code_buffer_size = Compilation::desired_max_code_buffer_size() +85Compilation::desired_max_constant_size();8687BufferBlob* buffer_blob = BufferBlob::create("C1 temporary CodeBuffer", code_buffer_size);88if (buffer_blob != NULL) {89CompilerThread::current()->set_buffer_blob(buffer_blob);90}9192return buffer_blob;93}949596void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) {97BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();98assert(buffer_blob != NULL, "Must exist");99// invoke compilation100{101// We are nested here because we need for the destructor102// of Compilation to occur before we release the any103// competing compiler thread104ResourceMark rm;105Compilation c(this, env, method, entry_bci, buffer_blob);106}107}108109110void Compiler::print_timers() {111Compilation::print_timers();112}113114115