Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: src/optimizing-compiler-thread.h

Issue 11419012: Introduce helper functions to test parallel recompilation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_OPTIMIZING_COMPILER_THREAD_H_ 28 #ifndef V8_OPTIMIZING_COMPILER_THREAD_H_
29 #define V8_OPTIMIZING_COMPILER_THREAD_H_ 29 #define V8_OPTIMIZING_COMPILER_THREAD_H_
30 30
31 #include "atomicops.h" 31 #include "atomicops.h"
32 #include "flags.h"
32 #include "platform.h" 33 #include "platform.h"
33 #include "flags.h"
34 #include "unbound-queue.h" 34 #include "unbound-queue.h"
35 35
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 class HGraphBuilder; 39 class HGraphBuilder;
40 class OptimizingCompiler; 40 class OptimizingCompiler;
41 class SharedFunctionInfo;
41 42
42 class OptimizingCompilerThread : public Thread { 43 class OptimizingCompilerThread : public Thread {
43 public: 44 public:
44 explicit OptimizingCompilerThread(Isolate *isolate) : 45 explicit OptimizingCompilerThread(Isolate *isolate) :
45 Thread("OptimizingCompilerThread"), 46 Thread("OptimizingCompilerThread"),
46 isolate_(isolate), 47 isolate_(isolate),
47 stop_semaphore_(OS::CreateSemaphore(0)), 48 stop_semaphore_(OS::CreateSemaphore(0)),
48 input_queue_semaphore_(OS::CreateSemaphore(0)), 49 input_queue_semaphore_(OS::CreateSemaphore(0)),
50 output_queue_semaphore_(OS::CreateSemaphore(0)),
49 time_spent_compiling_(0), 51 time_spent_compiling_(0),
50 time_spent_total_(0) { 52 time_spent_total_(0) {
51 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false)); 53 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false));
52 NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0)); 54 NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0));
53 } 55 }
54 56
55 void Run(); 57 void Run();
56 void Stop(); 58 void Stop();
57 void QueueForOptimization(OptimizingCompiler* optimizing_compiler); 59 void QueueForOptimization(OptimizingCompiler* optimizing_compiler);
58 void InstallOptimizedFunctions(); 60 void InstallOptimizedFunctions();
59 61
62 // Wait for the next optimized function and install it.
63 Handle<SharedFunctionInfo> InstallNextOptimizedFunction();
64
60 inline bool IsQueueAvailable() { 65 inline bool IsQueueAvailable() {
61 // We don't need a barrier since we have a data dependency right 66 // We don't need a barrier since we have a data dependency right
62 // after. 67 // after.
63 Atomic32 current_length = NoBarrier_Load(&queue_length_); 68 Atomic32 current_length = NoBarrier_Load(&queue_length_);
64 69
65 // This can be queried only from the execution thread. 70 // This can be queried only from the execution thread.
66 ASSERT(!IsOptimizerThread()); 71 ASSERT(!IsOptimizerThread());
67 // Since only the execution thread increments queue_length_ and 72 // Since only the execution thread increments queue_length_ and
68 // only one thread can run inside an Isolate at one time, a direct 73 // only one thread can run inside an Isolate at one time, a direct
69 // doesn't introduce a race -- queue_length_ may decreased in 74 // doesn't introduce a race -- queue_length_ may decreased in
70 // meantime, but not increased. 75 // meantime, but not increased.
71 return (current_length < FLAG_parallel_recompilation_queue_length); 76 return (current_length < FLAG_parallel_recompilation_queue_length);
72 } 77 }
73 78
74 #ifdef DEBUG 79 #ifdef DEBUG
75 bool IsOptimizerThread(); 80 bool IsOptimizerThread();
76 #endif 81 #endif
77 82
78 ~OptimizingCompilerThread() { 83 ~OptimizingCompilerThread() {
79 delete input_queue_semaphore_; 84 delete input_queue_semaphore_;
85 delete output_queue_semaphore_; // Only used for manual mode.
80 delete stop_semaphore_; 86 delete stop_semaphore_;
81 } 87 }
82 88
83 private: 89 private:
84 Isolate* isolate_; 90 Isolate* isolate_;
85 Semaphore* stop_semaphore_; 91 Semaphore* stop_semaphore_;
86 Semaphore* input_queue_semaphore_; 92 Semaphore* input_queue_semaphore_;
93 Semaphore* output_queue_semaphore_;
87 UnboundQueue<OptimizingCompiler*> input_queue_; 94 UnboundQueue<OptimizingCompiler*> input_queue_;
88 UnboundQueue<OptimizingCompiler*> output_queue_; 95 UnboundQueue<OptimizingCompiler*> output_queue_;
89 volatile AtomicWord stop_thread_; 96 volatile AtomicWord stop_thread_;
90 volatile Atomic32 queue_length_; 97 volatile Atomic32 queue_length_;
91 int64_t time_spent_compiling_; 98 int64_t time_spent_compiling_;
92 int64_t time_spent_total_; 99 int64_t time_spent_total_;
93 100
94 #ifdef DEBUG 101 #ifdef DEBUG
95 int thread_id_; 102 int thread_id_;
96 #endif 103 #endif
97 }; 104 };
98 105
99 } } // namespace v8::internal 106 } } // namespace v8::internal
100 107
101 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_ 108 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/optimizing-compiler-thread.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698