Mercurial > hg > graal-jvmci-8
comparison src/share/vm/c1/c1_Compiler.cpp @ 1584:b812ff5abc73
6958292: C1: Enable parallel compilation
Summary: Enable parallel compilation in C1
Reviewed-by: never, kvn
author | iveresov |
---|---|
date | Fri, 04 Jun 2010 11:18:04 -0700 |
parents | c18cbe5936b8 |
children | 2d26b0046e0d f95d63e2154a |
comparison
equal
deleted
inserted
replaced
1583:02e771df338e | 1584:b812ff5abc73 |
---|---|
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 | 29 |
30 volatile bool Compiler::_compiling = false; | |
31 | |
32 | |
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) { |
76 // Allocate buffer blob once at startup since allocation for each | |
77 // compilation seems to be too expensive (at least on Intel win32). | |
78 BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); | |
79 if (buffer_blob == NULL) { | |
80 buffer_blob = build_buffer_blob(); | |
81 CompilerThread::current()->set_buffer_blob(buffer_blob); | |
82 } | |
51 | 83 |
52 if (!is_initialized()) { | 84 if (!is_initialized()) { |
53 initialize(); | 85 initialize(); |
54 } | 86 } |
55 // invoke compilation | 87 // invoke compilation |
56 #ifdef TIERED | |
57 // We are thread in native here... | |
58 CompilerThread* thread = CompilerThread::current(); | |
59 { | |
60 ThreadInVMfromNative tv(thread); | |
61 MutexLocker only_one (C1_lock, thread); | |
62 while ( _compiling) { | |
63 C1_lock->wait(); | |
64 } | |
65 _compiling = true; | |
66 } | |
67 #endif // TIERED | |
68 { | 88 { |
69 // We are nested here because we need for the destructor | 89 // We are nested here because we need for the destructor |
70 // of Compilation to occur before we release the any | 90 // of Compilation to occur before we release the any |
71 // competing compiler thread | 91 // competing compiler thread |
72 ResourceMark rm; | 92 ResourceMark rm; |
73 Compilation c(this, env, method, entry_bci); | 93 Compilation c(this, env, method, entry_bci, buffer_blob); |
74 } | 94 } |
75 #ifdef TIERED | |
76 { | |
77 ThreadInVMfromNative tv(thread); | |
78 MutexLocker only_one (C1_lock, thread); | |
79 _compiling = false; | |
80 C1_lock->notify(); | |
81 } | |
82 #endif // TIERED | |
83 } | 95 } |
84 | 96 |
85 | 97 |
86 void Compiler::print_timers() { | 98 void Compiler::print_timers() { |
87 Compilation::print_timers(); | 99 Compilation::print_timers(); |