Index: src/compiler.h |
diff --git a/src/compiler.h b/src/compiler.h |
index 135904860eaea42e4790182d113bcd173b29bd2c..ea9e43689c4e3c0bf4d10bea6f9beeaec55ac755 100644 |
--- a/src/compiler.h |
+++ b/src/compiler.h |
@@ -312,6 +312,85 @@ class CompilationHandleScope BASE_EMBEDDED { |
}; |
+class HGraph; |
+class HGraphBuilder; |
+class LChunk; |
+ |
+// A helper class that calls the three compilation phases in |
+// Crankshaft and keeps track of its state. The three phases |
+// CreateGraph, OptimizeGraph and GenerateAndInstallCode can either |
+// fail, bail-out to the full code generator or succeed. Apart from |
+// their return value, the status of the phase last run can be checked |
+// using last_status(). |
+class OptimizingCompiler: public ZoneObject { |
+ public: |
+ explicit OptimizingCompiler(CompilationInfo* info) |
+ : info_(info), |
+ oracle_(NULL), |
+ graph_builder_(NULL), |
+ graph_(NULL), |
+ chunk_(NULL), |
+ time_taken_to_create_graph_(0), |
+ time_taken_to_optimize_(0), |
+ time_taken_to_codegen_(0), |
+ is_inline_bailout_(false), |
+ last_status_(FAILED) { } |
+ |
+ enum Status { |
+ FAILED, BAILED_OUT, SUCCEEDED |
+ }; |
+ |
+ Status CreateGraph(); |
danno
2012/07/16 15:05:02
MUST_USE_RESULT for this and the next two?
sanjoy
2012/07/17 08:09:39
Done.
|
+ Status OptimizeGraph(); |
+ Status GenerateAndInstallCode(); |
+ |
+ Status last_status() const { return last_status_; } |
+ CompilationInfo* info() const { return info_; } |
+ |
+ private: |
+ CompilationInfo* info_; |
+ TypeFeedbackOracle* oracle_; |
+ HGraphBuilder* graph_builder_; |
+ HGraph* graph_; |
+ LChunk* chunk_; |
+ int64_t time_taken_to_create_graph_; |
+ int64_t time_taken_to_optimize_; |
+ int64_t time_taken_to_codegen_; |
+ bool is_inline_bailout_; |
+ Status last_status_; |
+ |
+ MUST_USE_RESULT Status SetLastStatus(Status status) { |
+ last_status_ = status; |
+ return last_status_; |
+ } |
+ void RecordOptimizationStats(); |
+ MUST_USE_RESULT Status AbortOptimization() { |
+ info_->AbortOptimization(); |
+ if (!is_inline_bailout_) { |
+ // Mark the shared code as unoptimizable unless it was an inlined |
+ // function that bailed out. |
+ info_->shared_info()->DisableOptimization(); |
+ } |
+ return SetLastStatus(BAILED_OUT); |
+ } |
+ |
+ struct Timer { |
+ Timer(OptimizingCompiler* compiler, int64_t* location) |
+ : compiler_(compiler), |
+ start_(OS::Ticks()), |
+ location_(location) { } |
+ |
+ ~Timer() { |
+ *location_ += (OS::Ticks() - start_); |
+ } |
+ |
+ OptimizingCompiler* compiler_; |
+ int64_t start_; |
+ int64_t* location_; |
+ }; |
+}; |
+ |
+ |
// The V8 compiler |
// |
// General strategy: Source code is translated into an anonymous function w/o |