0N/A/*
1879N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "c1/c1_Compilation.hpp"
1879N/A#include "c1/c1_Compiler.hpp"
1879N/A#include "c1/c1_FrameMap.hpp"
1879N/A#include "c1/c1_GraphBuilder.hpp"
1879N/A#include "c1/c1_LinearScan.hpp"
1879N/A#include "c1/c1_MacroAssembler.hpp"
1879N/A#include "c1/c1_Runtime1.hpp"
1879N/A#include "c1/c1_ValueType.hpp"
1879N/A#include "compiler/compileBroker.hpp"
1879N/A#include "compiler/compilerOracle.hpp"
1879N/A#include "interpreter/linkResolver.hpp"
1879N/A#include "memory/allocation.hpp"
1879N/A#include "memory/allocation.inline.hpp"
1879N/A#include "memory/resourceArea.hpp"
1879N/A#include "prims/nativeLookup.hpp"
1879N/A#include "runtime/arguments.hpp"
1879N/A#include "runtime/interfaceSupport.hpp"
1879N/A#include "runtime/sharedRuntime.hpp"
0N/A
0N/Avolatile int Compiler::_runtimes = uninitialized;
0N/A
0N/ACompiler::Compiler() {
0N/A}
0N/A
0N/A
0N/ACompiler::~Compiler() {
0N/A Unimplemented();
0N/A}
0N/A
0N/A
1504N/Avoid Compiler::initialize_all() {
1504N/A BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
3863N/A Arena* arena = new (mtCompiler) Arena();
1504N/A Runtime1::initialize(buffer_blob);
1504N/A FrameMap::initialize();
1504N/A // initialize data structures
1504N/A ValueType::initialize(arena);
1504N/A // Instruction::initialize();
1504N/A // BlockBegin::initialize();
1504N/A GraphBuilder::initialize();
1504N/A // note: to use more than one instance of LinearScan at a time this function call has to
1504N/A // be moved somewhere outside of this constructor:
1504N/A Interval::initialize(arena);
1504N/A}
1504N/A
1504N/A
0N/Avoid Compiler::initialize() {
0N/A if (_runtimes != initialized) {
1504N/A initialize_runtimes( initialize_all, &_runtimes);
0N/A }
0N/A mark_initialized();
0N/A}
0N/A
0N/A
1504N/ABufferBlob* Compiler::build_buffer_blob() {
1504N/A // setup CodeBuffer. Preallocate a BufferBlob of size
1504N/A // NMethodSizeLimit plus some extra space for constants.
1504N/A int code_buffer_size = Compilation::desired_max_code_buffer_size() +
1504N/A Compilation::desired_max_constant_size();
1504N/A BufferBlob* blob = BufferBlob::create("Compiler1 temporary CodeBuffer",
1504N/A code_buffer_size);
1504N/A guarantee(blob != NULL, "must create initial code buffer");
1504N/A return blob;
1504N/A}
1504N/A
1504N/A
0N/Avoid Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) {
1504N/A // Allocate buffer blob once at startup since allocation for each
1504N/A // compilation seems to be too expensive (at least on Intel win32).
1504N/A BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
1504N/A if (buffer_blob == NULL) {
1504N/A buffer_blob = build_buffer_blob();
1504N/A CompilerThread::current()->set_buffer_blob(buffer_blob);
1504N/A }
0N/A
0N/A if (!is_initialized()) {
0N/A initialize();
0N/A }
0N/A // invoke compilation
0N/A {
0N/A // We are nested here because we need for the destructor
0N/A // of Compilation to occur before we release the any
0N/A // competing compiler thread
0N/A ResourceMark rm;
1504N/A Compilation c(this, env, method, entry_bci, buffer_blob);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid Compiler::print_timers() {
0N/A Compilation::print_timers();
0N/A}