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

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

Issue 14159028: Fixed an issue with HConstant::InNewSpace() for parallel compilation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Be able to recognize if running on the optimizer thread Created 7 years, 7 months 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
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/optimizing-compiler-thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 26 matching lines...) Expand all
37 namespace internal { 37 namespace internal {
38 38
39 class HOptimizedGraphBuilder; 39 class HOptimizedGraphBuilder;
40 class OptimizingCompiler; 40 class OptimizingCompiler;
41 class SharedFunctionInfo; 41 class SharedFunctionInfo;
42 42
43 class OptimizingCompilerThread : public Thread { 43 class OptimizingCompilerThread : public Thread {
44 public: 44 public:
45 explicit OptimizingCompilerThread(Isolate *isolate) : 45 explicit OptimizingCompilerThread(Isolate *isolate) :
46 Thread("OptimizingCompilerThread"), 46 Thread("OptimizingCompilerThread"),
47 #ifdef DEBUG
48 thread_id_(0), 47 thread_id_(0),
49 #endif
50 isolate_(isolate), 48 isolate_(isolate),
51 stop_semaphore_(OS::CreateSemaphore(0)), 49 stop_semaphore_(OS::CreateSemaphore(0)),
52 input_queue_semaphore_(OS::CreateSemaphore(0)), 50 input_queue_semaphore_(OS::CreateSemaphore(0)),
53 time_spent_compiling_(0), 51 time_spent_compiling_(0),
54 time_spent_total_(0) { 52 time_spent_total_(0) {
55 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false)); 53 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false));
56 NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0)); 54 NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0));
57 } 55 }
58 56
59 void Run(); 57 void Run();
60 void Stop(); 58 void Stop();
61 void CompileNext(); 59 void CompileNext();
62 void QueueForOptimization(OptimizingCompiler* optimizing_compiler); 60 void QueueForOptimization(OptimizingCompiler* optimizing_compiler);
63 void InstallOptimizedFunctions(); 61 void InstallOptimizedFunctions();
64 62
65 inline bool IsQueueAvailable() { 63 inline bool IsQueueAvailable() {
66 // We don't need a barrier since we have a data dependency right 64 // We don't need a barrier since we have a data dependency right
67 // after. 65 // after.
68 Atomic32 current_length = NoBarrier_Load(&queue_length_); 66 Atomic32 current_length = NoBarrier_Load(&queue_length_);
69 67
70 // This can be queried only from the execution thread. 68 // This can be queried only from the execution thread.
71 ASSERT(!IsOptimizerThread()); 69 ASSERT(!IsOptimizerThread());
72 // Since only the execution thread increments queue_length_ and 70 // Since only the execution thread increments queue_length_ and
73 // only one thread can run inside an Isolate at one time, a direct 71 // only one thread can run inside an Isolate at one time, a direct
74 // doesn't introduce a race -- queue_length_ may decreased in 72 // doesn't introduce a race -- queue_length_ may decreased in
75 // meantime, but not increased. 73 // meantime, but not increased.
76 return (current_length < FLAG_parallel_recompilation_queue_length); 74 return (current_length < FLAG_parallel_recompilation_queue_length);
77 } 75 }
78 76
79 #ifdef DEBUG
80 bool IsOptimizerThread(); 77 bool IsOptimizerThread();
81 #endif
82 78
83 ~OptimizingCompilerThread() { 79 ~OptimizingCompilerThread() {
84 delete input_queue_semaphore_; 80 delete input_queue_semaphore_;
85 delete stop_semaphore_; 81 delete stop_semaphore_;
86 } 82 }
87 83
88 private: 84 private:
89 #ifdef DEBUG
90 int thread_id_; 85 int thread_id_;
91 #endif
92 86
93 Isolate* isolate_; 87 Isolate* isolate_;
94 Semaphore* stop_semaphore_; 88 Semaphore* stop_semaphore_;
95 Semaphore* input_queue_semaphore_; 89 Semaphore* input_queue_semaphore_;
96 UnboundQueue<OptimizingCompiler*> input_queue_; 90 UnboundQueue<OptimizingCompiler*> input_queue_;
97 UnboundQueue<OptimizingCompiler*> output_queue_; 91 UnboundQueue<OptimizingCompiler*> output_queue_;
98 volatile AtomicWord stop_thread_; 92 volatile AtomicWord stop_thread_;
99 volatile Atomic32 queue_length_; 93 volatile Atomic32 queue_length_;
100 int64_t time_spent_compiling_; 94 int64_t time_spent_compiling_;
101 int64_t time_spent_total_; 95 int64_t time_spent_total_;
102 }; 96 };
103 97
104 } } // namespace v8::internal 98 } } // namespace v8::internal
105 99
106 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_ 100 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/optimizing-compiler-thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698