Commit 3ec32fd3 authored by sanjoy@chromium.org's avatar sanjoy@chromium.org

Introduce an OptimizingCompiler class, responsible for maintaining the state...

Introduce an OptimizingCompiler class, responsible for maintaining the state needed to run Crankshaft.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10700188

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12112 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 66964965
This diff is collapsed.
......@@ -312,6 +312,79 @@ 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),
last_status_(FAILED) { }
enum Status {
FAILED, BAILED_OUT, SUCCEEDED
};
MUST_USE_RESULT Status CreateGraph();
MUST_USE_RESULT Status OptimizeGraph();
MUST_USE_RESULT 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_;
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();
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
......
......@@ -871,6 +871,11 @@ class HGraphBuilder: public AstVisitor {
void VisitDeclarations(ZoneList<Declaration*>* declarations);
void* operator new(size_t size, Zone* zone) {
return zone->New(size);
}
void operator delete(void* ptr) { }
private:
// Type of a member function that generates inline code for a native function.
typedef void (HGraphBuilder::*InlineFunctionGenerator)(CallRuntime* call);
......
......@@ -232,7 +232,7 @@ class UnaryOperation;
class ForInStatement;
class TypeFeedbackOracle BASE_EMBEDDED {
class TypeFeedbackOracle: public ZoneObject {
public:
TypeFeedbackOracle(Handle<Code> code,
Handle<Context> global_context,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment