Thu, 21 Nov 2013 12:30:35 -0800
Merge
duke@435 | 1 | /* |
mikael@4153 | 2 | * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "c1/c1_Compilation.hpp" |
stefank@2314 | 27 | #include "c1/c1_Compiler.hpp" |
stefank@2314 | 28 | #include "c1/c1_FrameMap.hpp" |
stefank@2314 | 29 | #include "c1/c1_GraphBuilder.hpp" |
stefank@2314 | 30 | #include "c1/c1_LinearScan.hpp" |
stefank@2314 | 31 | #include "c1/c1_MacroAssembler.hpp" |
stefank@2314 | 32 | #include "c1/c1_Runtime1.hpp" |
stefank@2314 | 33 | #include "c1/c1_ValueType.hpp" |
stefank@2314 | 34 | #include "compiler/compileBroker.hpp" |
stefank@2314 | 35 | #include "compiler/compilerOracle.hpp" |
stefank@2314 | 36 | #include "interpreter/linkResolver.hpp" |
stefank@2314 | 37 | #include "memory/allocation.hpp" |
stefank@2314 | 38 | #include "memory/allocation.inline.hpp" |
stefank@2314 | 39 | #include "memory/resourceArea.hpp" |
stefank@2314 | 40 | #include "prims/nativeLookup.hpp" |
stefank@2314 | 41 | #include "runtime/arguments.hpp" |
stefank@2314 | 42 | #include "runtime/interfaceSupport.hpp" |
stefank@2314 | 43 | #include "runtime/sharedRuntime.hpp" |
duke@435 | 44 | |
duke@435 | 45 | |
anoll@5919 | 46 | Compiler::Compiler () {} |
duke@435 | 47 | |
anoll@5919 | 48 | void Compiler::init_c1_runtime() { |
iveresov@1939 | 49 | BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); |
zgu@3900 | 50 | Arena* arena = new (mtCompiler) Arena(); |
iveresov@1939 | 51 | Runtime1::initialize(buffer_blob); |
iveresov@1939 | 52 | FrameMap::initialize(); |
iveresov@1939 | 53 | // initialize data structures |
iveresov@1939 | 54 | ValueType::initialize(arena); |
iveresov@1939 | 55 | GraphBuilder::initialize(); |
iveresov@1939 | 56 | // note: to use more than one instance of LinearScan at a time this function call has to |
iveresov@1939 | 57 | // be moved somewhere outside of this constructor: |
iveresov@1939 | 58 | Interval::initialize(arena); |
iveresov@1939 | 59 | } |
iveresov@1939 | 60 | |
iveresov@1939 | 61 | |
duke@435 | 62 | void Compiler::initialize() { |
anoll@5919 | 63 | // Buffer blob must be allocated per C1 compiler thread at startup |
anoll@5919 | 64 | BufferBlob* buffer_blob = init_buffer_blob(); |
anoll@5919 | 65 | |
anoll@5919 | 66 | if (should_perform_init()) { |
anoll@5919 | 67 | if (buffer_blob == NULL) { |
anoll@5919 | 68 | // When we come here we are in state 'initializing'; entire C1 compilation |
anoll@5919 | 69 | // can be shut down. |
anoll@5919 | 70 | set_state(failed); |
anoll@5919 | 71 | } else { |
anoll@5919 | 72 | init_c1_runtime(); |
anoll@5919 | 73 | set_state(initialized); |
anoll@5919 | 74 | } |
duke@435 | 75 | } |
duke@435 | 76 | } |
duke@435 | 77 | |
anoll@5919 | 78 | BufferBlob* Compiler::init_buffer_blob() { |
anoll@5157 | 79 | // Allocate buffer blob once at startup since allocation for each |
anoll@5157 | 80 | // compilation seems to be too expensive (at least on Intel win32). |
anoll@5919 | 81 | assert (CompilerThread::current()->get_buffer_blob() == NULL, "Should initialize only once"); |
anoll@5157 | 82 | |
iveresov@1939 | 83 | // setup CodeBuffer. Preallocate a BufferBlob of size |
iveresov@1939 | 84 | // NMethodSizeLimit plus some extra space for constants. |
iveresov@1939 | 85 | int code_buffer_size = Compilation::desired_max_code_buffer_size() + |
iveresov@1939 | 86 | Compilation::desired_max_constant_size(); |
anoll@5157 | 87 | |
anoll@5919 | 88 | BufferBlob* buffer_blob = BufferBlob::create("C1 temporary CodeBuffer", code_buffer_size); |
anoll@5919 | 89 | if (buffer_blob != NULL) { |
anoll@5157 | 90 | CompilerThread::current()->set_buffer_blob(buffer_blob); |
anoll@5157 | 91 | } |
anoll@5157 | 92 | |
anoll@5157 | 93 | return buffer_blob; |
iveresov@1939 | 94 | } |
iveresov@1939 | 95 | |
iveresov@1939 | 96 | |
duke@435 | 97 | void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) { |
anoll@5919 | 98 | BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); |
anoll@5919 | 99 | assert(buffer_blob != NULL, "Must exist"); |
duke@435 | 100 | // invoke compilation |
duke@435 | 101 | { |
duke@435 | 102 | // We are nested here because we need for the destructor |
duke@435 | 103 | // of Compilation to occur before we release the any |
duke@435 | 104 | // competing compiler thread |
duke@435 | 105 | ResourceMark rm; |
iveresov@1939 | 106 | Compilation c(this, env, method, entry_bci, buffer_blob); |
duke@435 | 107 | } |
duke@435 | 108 | } |
duke@435 | 109 | |
duke@435 | 110 | |
duke@435 | 111 | void Compiler::print_timers() { |
duke@435 | 112 | Compilation::print_timers(); |
duke@435 | 113 | } |