Remove class HSubgraph.

Review URL: http://codereview.chromium.org/6647018

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7100 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d31594fe
......@@ -557,13 +557,15 @@ void HBasicBlock::FinishExit(HControlInstruction* instruction) {
HGraph::HGraph(CompilationInfo* info)
: HSubgraph(this),
next_block_id_(0),
: next_block_id_(0),
entry_block_(NULL),
blocks_(8),
values_(16),
phi_list_(NULL) {
start_environment_ = new HEnvironment(NULL, info->scope(), info->closure());
start_environment_->set_ast_id(info->function()->id());
entry_block_ = CreateBasicBlock();
entry_block_->SetInitialEnvironment(start_environment_);
}
......@@ -785,11 +787,11 @@ void HGraph::EliminateUnreachablePhis() {
bool HGraph::CollectPhis() {
const ZoneList<HBasicBlock*>* blocks = graph_->blocks();
phi_list_ = new ZoneList<HPhi*>(blocks->length());
for (int i = 0; i < blocks->length(); ++i) {
for (int j = 0; j < blocks->at(i)->phis()->length(); j++) {
HPhi* phi = blocks->at(i)->phis()->at(j);
int block_count = blocks_.length();
phi_list_ = new ZoneList<HPhi*>(block_count);
for (int i = 0; i < block_count; ++i) {
for (int j = 0; j < blocks_[i]->phis()->length(); ++j) {
HPhi* phi = blocks_[i]->phis()->at(j);
phi_list_->Add(phi);
// We don't support phi uses of arguments for now.
if (phi->CheckFlag(HValue::kIsArguments)) return false;
......@@ -2080,36 +2082,6 @@ void TestContext::BuildBranch(HValue* value) {
} while (false)
// 'thing' could be an expression, statement, or list of statements.
#define ADD_TO_SUBGRAPH(graph, thing) \
do { \
AddToSubgraph(graph, thing); \
if (HasStackOverflow()) return; \
} while (false)
class HGraphBuilder::SubgraphScope BASE_EMBEDDED {
public:
SubgraphScope(HGraphBuilder* builder, HSubgraph* new_subgraph)
: builder_(builder) {
old_subgraph_ = builder_->current_subgraph_;
subgraph_ = new_subgraph;
builder_->current_subgraph_ = subgraph_;
}
~SubgraphScope() {
builder_->current_subgraph_ = old_subgraph_;
}
HSubgraph* subgraph() const { return subgraph_; }
private:
HGraphBuilder* builder_;
HSubgraph* old_subgraph_;
HSubgraph* subgraph_;
};
void HGraphBuilder::Bailout(const char* reason) {
if (FLAG_trace_bailout) {
SmartPointer<char> name(info()->shared_info()->DebugName()->ToCString());
......@@ -2161,13 +2133,10 @@ void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) {
HGraph* HGraphBuilder::CreateGraph() {
ASSERT(subgraph() == NULL);
graph_ = new HGraph(info());
{
HPhase phase("Block building");
graph()->Initialize(CreateBasicBlock(graph()->start_environment()));
current_subgraph_ = graph();
current_block_ = graph()->entry_block();
Scope* scope = info()->scope();
if (scope->HasIllegalRedeclaration()) {
......@@ -2245,25 +2214,6 @@ HGraph* HGraphBuilder::CreateGraph() {
}
void HGraphBuilder::AddToSubgraph(HSubgraph* graph, Statement* stmt) {
SubgraphScope scope(this, graph);
Visit(stmt);
}
void HGraphBuilder::AddToSubgraph(HSubgraph* graph, Expression* expr) {
SubgraphScope scope(this, graph);
VisitForValue(expr);
}
void HGraphBuilder::AddToSubgraph(HSubgraph* graph,
ZoneList<Statement*>* stmts) {
SubgraphScope scope(this, graph);
VisitStatements(stmts);
}
HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) {
ASSERT(current_block() != NULL);
current_block()->AddInstruction(instr);
......
......@@ -192,40 +192,13 @@ class HLoopInformation: public ZoneObject {
};
class HSubgraph: public ZoneObject {
public:
explicit HSubgraph(HGraph* graph)
: graph_(graph),
entry_block_(NULL),
exit_block_(NULL) {
}
HGraph* graph() const { return graph_; }
HBasicBlock* entry_block() const { return entry_block_; }
HBasicBlock* exit_block() const { return exit_block_; }
void set_exit_block(HBasicBlock* block) {
exit_block_ = block;
}
void Initialize(HBasicBlock* block) {
ASSERT(entry_block_ == NULL);
entry_block_ = block;
exit_block_ = block;
}
protected:
HGraph* graph_; // The graph this is a subgraph of.
HBasicBlock* entry_block_;
HBasicBlock* exit_block_;
};
class HGraph: public HSubgraph {
class HGraph: public ZoneObject {
public:
explicit HGraph(CompilationInfo* info);
const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
const ZoneList<HPhi*>* phi_list() const { return phi_list_; }
HBasicBlock* entry_block() const { return entry_block_; }
HEnvironment* start_environment() const { return start_environment_; }
void InitializeInferredTypes();
......@@ -304,6 +277,7 @@ class HGraph: public HSubgraph {
void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor);
int next_block_id_;
HBasicBlock* entry_block_;
HEnvironment* start_environment_;
ZoneList<HBasicBlock*> blocks_;
ZoneList<HValue*> values_;
......@@ -315,8 +289,6 @@ class HGraph: public HSubgraph {
SetOncePointer<HConstant> constant_false_;
SetOncePointer<HArgumentsObject> arguments_object_;
friend class HSubgraph;
DISALLOW_COPY_AND_ASSIGN(HGraph);
};
......@@ -643,7 +615,7 @@ class HGraphBuilder: public AstVisitor {
ast_context_(NULL),
break_scope_(NULL),
graph_(NULL),
current_subgraph_(NULL),
current_block_(NULL),
inlined_count_(0) {
// This is not initialized in the initializer list because the
// constructor for the initial state relies on function_state_ == NULL
......@@ -655,14 +627,11 @@ class HGraphBuilder: public AstVisitor {
// Simple accessors.
HGraph* graph() const { return graph_; }
HSubgraph* subgraph() const { return current_subgraph_; }
BreakAndContinueScope* break_scope() const { return break_scope_; }
void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; }
HBasicBlock* current_block() const { return subgraph()->exit_block(); }
void set_current_block(HBasicBlock* block) {
subgraph()->set_exit_block(block);
}
HBasicBlock* current_block() const { return current_block_; }
void set_current_block(HBasicBlock* block) { current_block_ = block; }
HEnvironment* environment() const {
return current_block()->last_environment();
}
......@@ -753,10 +722,6 @@ class HGraphBuilder: public AstVisitor {
HBasicBlock* exit_block,
HBasicBlock* continue_block);
void AddToSubgraph(HSubgraph* graph, ZoneList<Statement*>* stmts);
void AddToSubgraph(HSubgraph* graph, Statement* stmt);
void AddToSubgraph(HSubgraph* graph, Expression* expr);
HValue* Top() const { return environment()->Top(); }
void Drop(int n) { environment()->Drop(n); }
void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); }
......@@ -908,7 +873,7 @@ class HGraphBuilder: public AstVisitor {
BreakAndContinueScope* break_scope_;
HGraph* graph_;
HSubgraph* current_subgraph_;
HBasicBlock* current_block_;
int inlined_count_;
......
......@@ -77,7 +77,6 @@ class LCodeGen BASE_EMBEDDED {
Handle<Object> ToHandle(LConstantOperand* op) const;
Operand ToOperand(LOperand* op) const;
// Try to generate code for the entire chunk, but it may fail if the
// chunk contains constructs we cannot handle. Returns true if the
// code generation attempt succeeded.
......
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