Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_H_ | 5 #ifndef V8_COMPILER_H_ |
| 6 #define V8_COMPILER_H_ | 6 #define V8_COMPILER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 kSucceeded, | 155 kSucceeded, |
| 156 kFailed, | 156 kFailed, |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 CompilationJob(Isolate* isolate, CompilationInfo* info, | 159 CompilationJob(Isolate* isolate, CompilationInfo* info, |
| 160 const char* compiler_name, | 160 const char* compiler_name, |
| 161 State initial_state = State::kReadyToPrepare) | 161 State initial_state = State::kReadyToPrepare) |
| 162 : info_(info), | 162 : info_(info), |
| 163 compiler_name_(compiler_name), | 163 compiler_name_(compiler_name), |
| 164 state_(initial_state), | 164 state_(initial_state), |
| 165 stack_limit_(isolate->stack_guard()->real_climit()) {} | 165 stack_limit_(isolate->stack_guard()->real_climit()), |
| 166 executed_on_background_thread_(false) {} | |
| 166 virtual ~CompilationJob() {} | 167 virtual ~CompilationJob() {} |
| 167 | 168 |
| 168 // Prepare the compile job. Must be called on the main thread. | 169 // Prepare the compile job. Must be called on the main thread. |
| 169 MUST_USE_RESULT Status PrepareJob(); | 170 MUST_USE_RESULT Status PrepareJob(); |
| 170 | 171 |
| 171 // Executes the compile job. Can be called on a background thread if | 172 // Executes the compile job. Can be called on a background thread if |
| 172 // can_execute_on_background_thread() returns true. | 173 // can_execute_on_background_thread() returns true. |
| 173 MUST_USE_RESULT Status ExecuteJob(); | 174 MUST_USE_RESULT Status ExecuteJob(); |
| 174 | 175 |
| 175 // Finalizes the compile job. Must be called on the main thread. | 176 // Finalizes the compile job. Must be called on the main thread. |
| 176 MUST_USE_RESULT Status FinalizeJob(); | 177 MUST_USE_RESULT Status FinalizeJob(); |
| 177 | 178 |
| 178 // Report a transient failure, try again next time. Should only be called on | 179 // Report a transient failure, try again next time. Should only be called on |
| 179 // optimization compilation jobs. | 180 // optimization compilation jobs. |
| 180 Status RetryOptimization(BailoutReason reason); | 181 Status RetryOptimization(BailoutReason reason); |
| 181 | 182 |
| 182 // Report a persistent failure, disable future optimization on the function. | 183 // Report a persistent failure, disable future optimization on the function. |
| 183 // Should only be called on optimization compilation jobs. | 184 // Should only be called on optimization compilation jobs. |
| 184 Status AbortOptimization(BailoutReason reason); | 185 Status AbortOptimization(BailoutReason reason); |
| 185 | 186 |
| 186 void RecordOptimizedCompilationStats() const; | 187 void RecordOptimizedCompilationStats() const; |
| 187 void RecordUnoptimizedCompilationStats() const; | 188 void RecordUnoptimizedCompilationStats() const; |
| 188 | 189 |
| 189 virtual bool can_execute_on_background_thread() const { return true; } | 190 virtual bool can_execute_on_background_thread() const { return true; } |
| 190 | 191 |
| 191 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } | 192 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } |
| 192 uintptr_t stack_limit() const { return stack_limit_; } | 193 uintptr_t stack_limit() const { return stack_limit_; } |
| 193 | 194 |
| 195 bool executed_on_background_thread() const { | |
| 196 DCHECK(can_execute_on_background_thread() || | |
| 197 !executed_on_background_thread_); | |
|
Camillo Bruni
2016/12/16 09:25:05
DCHECK_IMPLIES(!can_execute_on_background_thread()
rmcilroy
2016/12/16 23:48:05
Done.
| |
| 198 return executed_on_background_thread_; | |
| 199 } | |
| 194 State state() const { return state_; } | 200 State state() const { return state_; } |
| 195 CompilationInfo* info() const { return info_; } | 201 CompilationInfo* info() const { return info_; } |
| 196 Isolate* isolate() const; | 202 Isolate* isolate() const; |
| 197 | 203 |
| 198 protected: | 204 protected: |
| 199 // Overridden by the actual implementation. | 205 // Overridden by the actual implementation. |
| 200 virtual Status PrepareJobImpl() = 0; | 206 virtual Status PrepareJobImpl() = 0; |
| 201 virtual Status ExecuteJobImpl() = 0; | 207 virtual Status ExecuteJobImpl() = 0; |
| 202 virtual Status FinalizeJobImpl() = 0; | 208 virtual Status FinalizeJobImpl() = 0; |
| 203 | 209 |
| 204 // Registers weak object to optimized code dependencies. | 210 // Registers weak object to optimized code dependencies. |
| 205 // TODO(turbofan): Move this to pipeline.cc once Crankshaft dies. | 211 // TODO(turbofan): Move this to pipeline.cc once Crankshaft dies. |
| 206 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code); | 212 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code); |
| 207 | 213 |
| 208 private: | 214 private: |
| 209 CompilationInfo* info_; | 215 CompilationInfo* info_; |
| 210 base::TimeDelta time_taken_to_prepare_; | 216 base::TimeDelta time_taken_to_prepare_; |
| 211 base::TimeDelta time_taken_to_execute_; | 217 base::TimeDelta time_taken_to_execute_; |
| 212 base::TimeDelta time_taken_to_finalize_; | 218 base::TimeDelta time_taken_to_finalize_; |
| 213 const char* compiler_name_; | 219 const char* compiler_name_; |
| 214 State state_; | 220 State state_; |
| 215 uintptr_t stack_limit_; | 221 uintptr_t stack_limit_; |
| 222 bool executed_on_background_thread_; | |
| 216 | 223 |
| 217 MUST_USE_RESULT Status UpdateState(Status status, State next_state) { | 224 MUST_USE_RESULT Status UpdateState(Status status, State next_state) { |
| 218 if (status == SUCCEEDED) { | 225 if (status == SUCCEEDED) { |
| 219 state_ = next_state; | 226 state_ = next_state; |
| 220 } else { | 227 } else { |
| 221 state_ = State::kFailed; | 228 state_ = State::kFailed; |
| 222 } | 229 } |
| 223 return status; | 230 return status; |
| 224 } | 231 } |
| 225 }; | 232 }; |
| 226 | 233 |
| 227 } // namespace internal | 234 } // namespace internal |
| 228 } // namespace v8 | 235 } // namespace v8 |
| 229 | 236 |
| 230 #endif // V8_COMPILER_H_ | 237 #endif // V8_COMPILER_H_ |
| OLD | NEW |