| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 575 |
| 576 HGraph::HGraph(CompilationInfo* info) | 576 HGraph::HGraph(CompilationInfo* info) |
| 577 : isolate_(info->isolate()), | 577 : isolate_(info->isolate()), |
| 578 next_block_id_(0), | 578 next_block_id_(0), |
| 579 entry_block_(NULL), | 579 entry_block_(NULL), |
| 580 blocks_(8), | 580 blocks_(8), |
| 581 values_(16), | 581 values_(16), |
| 582 phi_list_(NULL) { | 582 phi_list_(NULL) { |
| 583 start_environment_ = | 583 start_environment_ = |
| 584 new(zone()) HEnvironment(NULL, info->scope(), info->closure()); | 584 new(zone()) HEnvironment(NULL, info->scope(), info->closure()); |
| 585 start_environment_->set_ast_id(info->function()->id()); | 585 start_environment_->set_ast_id(AstNode::kRootAstId); |
| 586 entry_block_ = CreateBasicBlock(); | 586 entry_block_ = CreateBasicBlock(); |
| 587 entry_block_->SetInitialEnvironment(start_environment_); | 587 entry_block_->SetInitialEnvironment(start_environment_); |
| 588 } | 588 } |
| 589 | 589 |
| 590 | 590 |
| 591 Handle<Code> HGraph::Compile(CompilationInfo* info) { | 591 Handle<Code> HGraph::Compile(CompilationInfo* info) { |
| 592 int values = GetMaximumValueID(); | 592 int values = GetMaximumValueID(); |
| 593 if (values > LAllocator::max_initial_value_ids()) { | 593 if (values > LAllocator::max_initial_value_ids()) { |
| 594 if (FLAG_trace_bailout) PrintF("Function is too big\n"); | 594 if (FLAG_trace_bailout) PrintF("Function is too big\n"); |
| 595 return Handle<Code>::null(); | 595 return Handle<Code>::null(); |
| (...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2196 // block in HInstruction::InsertAfter) seals the start block from | 2196 // block in HInstruction::InsertAfter) seals the start block from |
| 2197 // getting unwanted instructions inserted. | 2197 // getting unwanted instructions inserted. |
| 2198 // | 2198 // |
| 2199 // TODO(kmillikin): Fix this. Stop mutating the initial environment. | 2199 // TODO(kmillikin): Fix this. Stop mutating the initial environment. |
| 2200 // Make the Hydrogen instructions in the initial block into Hydrogen | 2200 // Make the Hydrogen instructions in the initial block into Hydrogen |
| 2201 // values (but not instructions), present in the initial environment and | 2201 // values (but not instructions), present in the initial environment and |
| 2202 // not replayed by the Lithium translation. | 2202 // not replayed by the Lithium translation. |
| 2203 HEnvironment* initial_env = environment()->CopyWithoutHistory(); | 2203 HEnvironment* initial_env = environment()->CopyWithoutHistory(); |
| 2204 HBasicBlock* body_entry = CreateBasicBlock(initial_env); | 2204 HBasicBlock* body_entry = CreateBasicBlock(initial_env); |
| 2205 current_block()->Goto(body_entry); | 2205 current_block()->Goto(body_entry); |
| 2206 body_entry->SetJoinId(info()->function()->id()); | 2206 body_entry->SetJoinId(AstNode::kRootAstId); |
| 2207 set_current_block(body_entry); | 2207 set_current_block(body_entry); |
| 2208 VisitStatements(info()->function()->body()); | 2208 VisitStatements(info()->function()->body()); |
| 2209 if (HasStackOverflow()) return NULL; | 2209 if (HasStackOverflow()) return NULL; |
| 2210 | 2210 |
| 2211 if (current_block() != NULL) { | 2211 if (current_block() != NULL) { |
| 2212 HReturn* instr = new(zone()) HReturn(graph()->GetConstantUndefined()); | 2212 HReturn* instr = new(zone()) HReturn(graph()->GetConstantUndefined()); |
| 2213 current_block()->FinishExit(instr); | 2213 current_block()->FinishExit(instr); |
| 2214 set_current_block(NULL); | 2214 set_current_block(NULL); |
| 2215 } | 2215 } |
| 2216 } | 2216 } |
| (...skipping 3450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5667 } | 5667 } |
| 5668 } | 5668 } |
| 5669 | 5669 |
| 5670 // Initialize the stack-allocated locals to undefined. | 5670 // Initialize the stack-allocated locals to undefined. |
| 5671 int local_base = arity + 1; | 5671 int local_base = arity + 1; |
| 5672 int local_count = function->scope()->num_stack_slots(); | 5672 int local_count = function->scope()->num_stack_slots(); |
| 5673 for (int i = 0; i < local_count; ++i) { | 5673 for (int i = 0; i < local_count; ++i) { |
| 5674 inner->SetValueAt(local_base + i, undefined); | 5674 inner->SetValueAt(local_base + i, undefined); |
| 5675 } | 5675 } |
| 5676 | 5676 |
| 5677 inner->set_ast_id(function->id()); | 5677 inner->set_ast_id(AstNode::kRootAstId); |
| 5678 return inner; | 5678 return inner; |
| 5679 } | 5679 } |
| 5680 | 5680 |
| 5681 | 5681 |
| 5682 void HEnvironment::PrintTo(StringStream* stream) { | 5682 void HEnvironment::PrintTo(StringStream* stream) { |
| 5683 for (int i = 0; i < length(); i++) { | 5683 for (int i = 0; i < length(); i++) { |
| 5684 if (i == 0) stream->Add("parameters\n"); | 5684 if (i == 0) stream->Add("parameters\n"); |
| 5685 if (i == parameter_count()) stream->Add("locals\n"); | 5685 if (i == parameter_count()) stream->Add("locals\n"); |
| 5686 if (i == parameter_count() + local_count()) stream->Add("expressions"); | 5686 if (i == parameter_count() + local_count()) stream->Add("expressions"); |
| 5687 HValue* val = values_.at(i); | 5687 HValue* val = values_.at(i); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6002 } | 6002 } |
| 6003 } | 6003 } |
| 6004 | 6004 |
| 6005 #ifdef DEBUG | 6005 #ifdef DEBUG |
| 6006 if (graph_ != NULL) graph_->Verify(); | 6006 if (graph_ != NULL) graph_->Verify(); |
| 6007 if (allocator_ != NULL) allocator_->Verify(); | 6007 if (allocator_ != NULL) allocator_->Verify(); |
| 6008 #endif | 6008 #endif |
| 6009 } | 6009 } |
| 6010 | 6010 |
| 6011 } } // namespace v8::internal | 6011 } } // namespace v8::internal |
| OLD | NEW |