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