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

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

Issue 24543002: Rename "OptimizingCompiler" to the more suitable "RecompileJob". (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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/compiler.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 22 matching lines...) Expand all
33 #include "list.h" 33 #include "list.h"
34 #include "platform.h" 34 #include "platform.h"
35 #include "platform/mutex.h" 35 #include "platform/mutex.h"
36 #include "platform/time.h" 36 #include "platform/time.h"
37 #include "unbound-queue-inl.h" 37 #include "unbound-queue-inl.h"
38 38
39 namespace v8 { 39 namespace v8 {
40 namespace internal { 40 namespace internal {
41 41
42 class HOptimizedGraphBuilder; 42 class HOptimizedGraphBuilder;
43 class OptimizingCompiler; 43 class RecompileJob;
44 class SharedFunctionInfo; 44 class SharedFunctionInfo;
45 45
46 class OptimizingCompilerThread : public Thread { 46 class OptimizingCompilerThread : public Thread {
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_cursor_(0), 56 osr_cursor_(0),
57 osr_hits_(0), 57 osr_hits_(0),
58 osr_attempts_(0) { 58 osr_attempts_(0) {
59 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE)); 59 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
60 NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0)); 60 NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0));
61 if (FLAG_concurrent_osr) { 61 if (FLAG_concurrent_osr) {
62 osr_buffer_size_ = FLAG_concurrent_recompilation_queue_length + 4; 62 osr_buffer_size_ = FLAG_concurrent_recompilation_queue_length + 4;
63 osr_buffer_ = NewArray<OptimizingCompiler*>(osr_buffer_size_); 63 osr_buffer_ = NewArray<RecompileJob*>(osr_buffer_size_);
64 for (int i = 0; i < osr_buffer_size_; i++) osr_buffer_[i] = NULL; 64 for (int i = 0; i < osr_buffer_size_; i++) osr_buffer_[i] = NULL;
65 } 65 }
66 } 66 }
67 67
68 ~OptimizingCompilerThread() { 68 ~OptimizingCompilerThread() {
69 if (FLAG_concurrent_osr) DeleteArray(osr_buffer_); 69 if (FLAG_concurrent_osr) DeleteArray(osr_buffer_);
70 } 70 }
71 71
72 void Run(); 72 void Run();
73 void Stop(); 73 void Stop();
74 void Flush(); 74 void Flush();
75 void QueueForOptimization(OptimizingCompiler* optimizing_compiler); 75 void QueueForOptimization(RecompileJob* optimizing_compiler);
76 void InstallOptimizedFunctions(); 76 void InstallOptimizedFunctions();
77 OptimizingCompiler* FindReadyOSRCandidate(Handle<JSFunction> function, 77 RecompileJob* FindReadyOSRCandidate(Handle<JSFunction> function,
78 uint32_t osr_pc_offset); 78 uint32_t osr_pc_offset);
79 bool IsQueuedForOSR(Handle<JSFunction> function, uint32_t osr_pc_offset); 79 bool IsQueuedForOSR(Handle<JSFunction> function, uint32_t osr_pc_offset);
80 80
81 bool IsQueuedForOSR(JSFunction* function); 81 bool IsQueuedForOSR(JSFunction* function);
82 82
83 inline bool IsQueueAvailable() { 83 inline bool IsQueueAvailable() {
84 // We don't need a barrier since we have a data dependency right 84 // We don't need a barrier since we have a data dependency right
85 // after. 85 // after.
86 Atomic32 current_length = NoBarrier_Load(&queue_length_); 86 Atomic32 current_length = NoBarrier_Load(&queue_length_);
87 87
88 // This can be queried only from the execution thread. 88 // This can be queried only from the execution thread.
(...skipping 12 matching lines...) Expand all
101 private: 101 private:
102 enum StopFlag { CONTINUE, STOP, FLUSH }; 102 enum StopFlag { CONTINUE, STOP, FLUSH };
103 103
104 void FlushInputQueue(bool restore_function_code); 104 void FlushInputQueue(bool restore_function_code);
105 void FlushOutputQueue(bool restore_function_code); 105 void FlushOutputQueue(bool restore_function_code);
106 void FlushOsrBuffer(bool restore_function_code); 106 void FlushOsrBuffer(bool restore_function_code);
107 void CompileNext(); 107 void CompileNext();
108 108
109 // Add a recompilation task for OSR to the cyclic buffer, awaiting OSR entry. 109 // Add a recompilation task for OSR to the cyclic buffer, awaiting OSR entry.
110 // Tasks evicted from the cyclic buffer are discarded. 110 // Tasks evicted from the cyclic buffer are discarded.
111 void AddToOsrBuffer(OptimizingCompiler* compiler); 111 void AddToOsrBuffer(RecompileJob* compiler);
112 void AdvanceOsrCursor() { 112 void AdvanceOsrCursor() {
113 osr_cursor_ = (osr_cursor_ + 1) % osr_buffer_size_; 113 osr_cursor_ = (osr_cursor_ + 1) % osr_buffer_size_;
114 } 114 }
115 115
116 #ifdef DEBUG 116 #ifdef DEBUG
117 int thread_id_; 117 int thread_id_;
118 Mutex thread_id_mutex_; 118 Mutex thread_id_mutex_;
119 #endif 119 #endif
120 120
121 Isolate* isolate_; 121 Isolate* isolate_;
122 Semaphore stop_semaphore_; 122 Semaphore stop_semaphore_;
123 Semaphore input_queue_semaphore_; 123 Semaphore input_queue_semaphore_;
124 124
125 // Queue of incoming recompilation tasks (including OSR). 125 // Queue of incoming recompilation tasks (including OSR).
126 UnboundQueue<OptimizingCompiler*> input_queue_; 126 UnboundQueue<RecompileJob*> input_queue_;
127 // Queue of recompilation tasks ready to be installed (excluding OSR). 127 // Queue of recompilation tasks ready to be installed (excluding OSR).
128 UnboundQueue<OptimizingCompiler*> output_queue_; 128 UnboundQueue<RecompileJob*> output_queue_;
129 // Cyclic buffer of recompilation tasks for OSR. 129 // Cyclic buffer of recompilation tasks for OSR.
130 // TODO(yangguo): This may keep zombie tasks indefinitely, holding on to 130 // TODO(yangguo): This may keep zombie tasks indefinitely, holding on to
131 // a lot of memory. Fix this. 131 // a lot of memory. Fix this.
132 OptimizingCompiler** osr_buffer_; 132 RecompileJob** osr_buffer_;
133 // Cursor for the cyclic buffer. 133 // Cursor for the cyclic buffer.
134 int osr_cursor_; 134 int osr_cursor_;
135 int osr_buffer_size_; 135 int osr_buffer_size_;
136 136
137 volatile AtomicWord stop_thread_; 137 volatile AtomicWord stop_thread_;
138 volatile Atomic32 queue_length_; 138 volatile Atomic32 queue_length_;
139 TimeDelta time_spent_compiling_; 139 TimeDelta time_spent_compiling_;
140 TimeDelta time_spent_total_; 140 TimeDelta time_spent_total_;
141 141
142 // TODO(yangguo): remove this once the memory leak has been figured out. 142 // TODO(yangguo): remove this once the memory leak has been figured out.
143 Mutex queue_mutex_; 143 Mutex queue_mutex_;
144 int osr_hits_; 144 int osr_hits_;
145 int osr_attempts_; 145 int osr_attempts_;
146 }; 146 };
147 147
148 } } // namespace v8::internal 148 } } // namespace v8::internal
149 149
150 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_ 150 #endif // V8_OPTIMIZING_COMPILER_THREAD_H_
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/optimizing-compiler-thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698