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

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

Issue 24237009: Less aggressive polling when concurrently compiling for OSR. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: platform ports Created 7 years, 3 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
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 public: 47 public:
48 explicit OptimizingCompilerThread(Isolate *isolate) : 48 explicit OptimizingCompilerThread(Isolate *isolate) :
49 Thread("OptimizingCompilerThread"), 49 Thread("OptimizingCompilerThread"),
50 #ifdef DEBUG 50 #ifdef DEBUG
51 thread_id_(0), 51 thread_id_(0),
52 #endif 52 #endif
53 isolate_(isolate), 53 isolate_(isolate),
54 stop_semaphore_(0), 54 stop_semaphore_(0),
55 input_queue_semaphore_(0), 55 input_queue_semaphore_(0),
56 osr_candidates_(2), 56 osr_candidates_(2),
57 ready_for_osr_(2), 57 osr_cursor_(0),
58 osr_hits_(0), 58 osr_hits_(0),
59 osr_attempts_(0) { 59 osr_attempts_(0) {
60 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE)); 60 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
61 NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0)); 61 NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0));
62 for (int i = 0; i < kOsrBufferSize; i++) osr_buffer_[i] = NULL;
62 } 63 }
63 ~OptimizingCompilerThread() {} 64 ~OptimizingCompilerThread() {}
64 65
65 void Run(); 66 void Run();
66 void Stop(); 67 void Stop();
67 void Flush(); 68 void Flush();
68 void QueueForOptimization(OptimizingCompiler* optimizing_compiler); 69 void QueueForOptimization(OptimizingCompiler* optimizing_compiler);
69 void InstallOptimizedFunctions(); 70 void InstallOptimizedFunctions();
70 OptimizingCompiler* FindReadyOSRCandidate(Handle<JSFunction> function, 71 OptimizingCompiler* FindReadyOSRCandidate(Handle<JSFunction> function,
71 uint32_t osr_pc_offset); 72 uint32_t osr_pc_offset);
(...skipping 15 matching lines...) Expand all
87 return (current_length < FLAG_concurrent_recompilation_queue_length); 88 return (current_length < FLAG_concurrent_recompilation_queue_length);
88 } 89 }
89 90
90 #ifdef DEBUG 91 #ifdef DEBUG
91 bool IsOptimizerThread(); 92 bool IsOptimizerThread();
92 #endif 93 #endif
93 94
94 private: 95 private:
95 enum StopFlag { CONTINUE, STOP, FLUSH }; 96 enum StopFlag { CONTINUE, STOP, FLUSH };
96 97
97 // Remove the oldest OSR candidates that are ready so that we
98 // only have |limit| left waiting.
99 void RemoveStaleOSRCandidates(int limit = kReadyForOSRLimit);
100
101 void FlushInputQueue(bool restore_function_code); 98 void FlushInputQueue(bool restore_function_code);
102 void FlushOutputQueue(bool restore_function_code); 99 void FlushOutputQueue(bool restore_function_code);
103 void CompileNext(); 100 void CompileNext();
104 101
102 // Add a recompilation task for OSR to the cyclic buffer, awaiting OSR entry.
103 // Tasks evicted from the cyclic buffer are discarded.
104 void AddToOsrBuffer(OptimizingCompiler* compiler);
105
106 static const int kOsrBufferSize = 8;
107
105 #ifdef DEBUG 108 #ifdef DEBUG
106 int thread_id_; 109 int thread_id_;
107 Mutex thread_id_mutex_; 110 Mutex thread_id_mutex_;
108 #endif 111 #endif
109 112
110 Isolate* isolate_; 113 Isolate* isolate_;
111 Semaphore stop_semaphore_; 114 Semaphore stop_semaphore_;
112 Semaphore input_queue_semaphore_; 115 Semaphore input_queue_semaphore_;
113 116
114 // Queue of incoming recompilation tasks (including OSR). 117 // Queue of incoming recompilation tasks (including OSR).
115 UnboundQueue<OptimizingCompiler*> input_queue_; 118 UnboundQueue<OptimizingCompiler*> input_queue_;
116 // Queue of recompilation tasks ready to be installed (excluding OSR). 119 // Queue of recompilation tasks ready to be installed (excluding OSR).
117 UnboundQueue<OptimizingCompiler*> output_queue_; 120 UnboundQueue<OptimizingCompiler*> output_queue_;
118 // List of recompilation tasks for OSR in the input queue. 121 // List of recompilation tasks for OSR in the input queue.
119 List<OptimizingCompiler*> osr_candidates_; 122 List<OptimizingCompiler*> osr_candidates_;
titzer 2013/09/24 09:42:01 First, I am not even sure why you need two buffers
Yang 2013/09/24 10:07:11 osr_candidates_ simply mirrors OSR jobs that are e
120 // List of recompilation tasks ready for OSR. 123 // Cyclic buffer of recompilation tasks ready for OSR.
121 List<OptimizingCompiler*> ready_for_osr_; 124 OptimizingCompiler* osr_buffer_[kOsrBufferSize];
125 // Cursor for the cyclic buffer.
126 int osr_cursor_;
122 127
123 volatile AtomicWord stop_thread_; 128 volatile AtomicWord stop_thread_;
124 volatile Atomic32 queue_length_; 129 volatile Atomic32 queue_length_;
125 TimeDelta time_spent_compiling_; 130 TimeDelta time_spent_compiling_;
126 TimeDelta time_spent_total_; 131 TimeDelta time_spent_total_;
127 132
128 // TODO(yangguo): remove this once the memory leak has been figured out. 133 // TODO(yangguo): remove this once the memory leak has been figured out.
129 Mutex queue_mutex_; 134 Mutex queue_mutex_;
130 Mutex osr_list_mutex_;
131 int osr_hits_; 135 int osr_hits_;
132 int osr_attempts_; 136 int osr_attempts_;
133
134 static const int kReadyForOSRLimit = 4;
135 }; 137 };
136 138
137 } } // namespace v8::internal 139 } } // namespace v8::internal
138 140
139 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_ 141 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698