Mercurial > hg > graal-compiler
comparison src/share/vm/c1/c1_Compiler.cpp @ 1930:2d26b0046e0d
Merge.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 30 Nov 2010 14:53:30 +0100 |
parents | 72cfb36c6bb2 b812ff5abc73 |
children | 06f017f7daa7 |
comparison
equal
deleted
inserted
replaced
1484:6b7001391c97 | 1930:2d26b0046e0d |
---|---|
1 /* | 1 /* |
2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. | 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. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
14 * | 14 * |
15 * You should have received a copy of the GNU General Public License version | 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, | 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. | 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
18 * | 18 * |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | 20 * or visit www.oracle.com if you need additional information or have any |
21 * have any questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "incls/_precompiled.incl" | 25 #include "incls/_precompiled.incl" |
26 #include "incls/_c1_Compiler.cpp.incl" | 26 #include "incls/_c1_Compiler.cpp.incl" |
27 | 27 |
28 volatile int Compiler::_runtimes = uninitialized; | 28 volatile int Compiler::_runtimes = uninitialized; |
29 | |
30 volatile bool Compiler::_compiling = false; | |
31 | |
32 | 29 |
33 Compiler::Compiler() { | 30 Compiler::Compiler() { |
34 } | 31 } |
35 | 32 |
36 | 33 |
37 Compiler::~Compiler() { | 34 Compiler::~Compiler() { |
38 Unimplemented(); | 35 Unimplemented(); |
39 } | 36 } |
40 | 37 |
41 | 38 |
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 } | |
53 | |
54 | |
42 void Compiler::initialize() { | 55 void Compiler::initialize() { |
43 if (_runtimes != initialized) { | 56 if (_runtimes != initialized) { |
44 initialize_runtimes( Runtime1::initialize, &_runtimes); | 57 initialize_runtimes( initialize_all, &_runtimes); |
45 } | 58 } |
46 mark_initialized(); | 59 mark_initialized(); |
47 } | 60 } |
48 | 61 |
49 | 62 |
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 } | |
73 | |
74 | |
50 void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) { | 75 void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) { |
51 assert(!UseC1X, "c1 called in UseC1X mode!"); | 76 assert(!UseC1X, "c1 called in UseC1X mode!"); |
77 // Allocate buffer blob once at startup since allocation for each | |
78 // compilation seems to be too expensive (at least on Intel win32). | |
79 BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); | |
80 if (buffer_blob == NULL) { | |
81 buffer_blob = build_buffer_blob(); | |
82 CompilerThread::current()->set_buffer_blob(buffer_blob); | |
83 } | |
52 | 84 |
53 if (!is_initialized()) { | 85 if (!is_initialized()) { |
54 initialize(); | 86 initialize(); |
55 } | 87 } |
56 // invoke compilation | 88 // invoke compilation |
57 #ifdef TIERED | |
58 // We are thread in native here... | |
59 CompilerThread* thread = CompilerThread::current(); | |
60 { | |
61 ThreadInVMfromNative tv(thread); | |
62 MutexLocker only_one (C1_lock, thread); | |
63 while ( _compiling) { | |
64 C1_lock->wait(); | |
65 } | |
66 _compiling = true; | |
67 } | |
68 #endif // TIERED | |
69 { | 89 { |
70 // We are nested here because we need for the destructor | 90 // We are nested here because we need for the destructor |
71 // of Compilation to occur before we release the any | 91 // of Compilation to occur before we release the any |
72 // competing compiler thread | 92 // competing compiler thread |
73 ResourceMark rm; | 93 ResourceMark rm; |
74 Compilation c(this, env, method, entry_bci); | 94 Compilation c(this, env, method, entry_bci, buffer_blob); |
75 } | 95 } |
76 #ifdef TIERED | |
77 { | |
78 ThreadInVMfromNative tv(thread); | |
79 MutexLocker only_one (C1_lock, thread); | |
80 _compiling = false; | |
81 C1_lock->notify(); | |
82 } | |
83 #endif // TIERED | |
84 } | 96 } |
85 | 97 |
86 | 98 |
87 void Compiler::print_timers() { | 99 void Compiler::print_timers() { |
88 Compilation::print_timers(); | 100 Compilation::print_timers(); |