Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: src/hydrogen.cc

Issue 10534139: One Zone per CompilationInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 return GetConstant(&constant_false_, isolate()->heap()->false_value()); 598 return GetConstant(&constant_false_, isolate()->heap()->false_value());
599 } 599 }
600 600
601 601
602 HConstant* HGraph::GetConstantHole() { 602 HConstant* HGraph::GetConstantHole() {
603 return GetConstant(&constant_hole_, isolate()->heap()->the_hole_value()); 603 return GetConstant(&constant_hole_, isolate()->heap()->the_hole_value());
604 } 604 }
605 605
606 606
607 HGraphBuilder::HGraphBuilder(CompilationInfo* info, 607 HGraphBuilder::HGraphBuilder(CompilationInfo* info,
608 TypeFeedbackOracle* oracle, 608 TypeFeedbackOracle* oracle)
609 Zone* zone)
610 : function_state_(NULL), 609 : function_state_(NULL),
611 initial_function_state_(this, info, oracle, NORMAL_RETURN), 610 initial_function_state_(this, info, oracle, NORMAL_RETURN),
612 ast_context_(NULL), 611 ast_context_(NULL),
613 break_scope_(NULL), 612 break_scope_(NULL),
614 graph_(NULL), 613 graph_(NULL),
615 current_block_(NULL), 614 current_block_(NULL),
616 inlined_count_(0), 615 inlined_count_(0),
617 globals_(10, zone), 616 globals_(10, info->zone()),
618 zone_(zone), 617 zone_(info->zone()),
619 inline_bailout_(false) { 618 inline_bailout_(false) {
620 // This is not initialized in the initializer list because the 619 // This is not initialized in the initializer list because the
621 // constructor for the initial state relies on function_state_ == NULL 620 // constructor for the initial state relies on function_state_ == NULL
622 // to know it's the initial state. 621 // to know it's the initial state.
623 function_state_= &initial_function_state_; 622 function_state_= &initial_function_state_;
624 } 623 }
625 624
626 HBasicBlock* HGraphBuilder::CreateJoin(HBasicBlock* first, 625 HBasicBlock* HGraphBuilder::CreateJoin(HBasicBlock* first,
627 HBasicBlock* second, 626 HBasicBlock* second,
628 int join_id) { 627 int join_id) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 return loop_successor; 666 return loop_successor;
668 } 667 }
669 668
670 669
671 void HBasicBlock::FinishExit(HControlInstruction* instruction) { 670 void HBasicBlock::FinishExit(HControlInstruction* instruction) {
672 Finish(instruction); 671 Finish(instruction);
673 ClearEnvironment(); 672 ClearEnvironment();
674 } 673 }
675 674
676 675
677 HGraph::HGraph(CompilationInfo* info, Zone* zone) 676 HGraph::HGraph(CompilationInfo* info)
678 : isolate_(info->isolate()), 677 : isolate_(info->isolate()),
679 next_block_id_(0), 678 next_block_id_(0),
680 entry_block_(NULL), 679 entry_block_(NULL),
681 blocks_(8, zone), 680 blocks_(8, info->zone()),
682 values_(16, zone), 681 values_(16, info->zone()),
683 phi_list_(NULL), 682 phi_list_(NULL),
684 zone_(zone), 683 info_(info),
684 zone_(info->zone()),
685 is_recursive_(false) { 685 is_recursive_(false) {
686 start_environment_ = 686 start_environment_ =
687 new(zone) HEnvironment(NULL, info->scope(), info->closure(), zone); 687 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_);
688 start_environment_->set_ast_id(AstNode::kFunctionEntryId); 688 start_environment_->set_ast_id(AstNode::kFunctionEntryId);
689 entry_block_ = CreateBasicBlock(); 689 entry_block_ = CreateBasicBlock();
690 entry_block_->SetInitialEnvironment(start_environment_); 690 entry_block_->SetInitialEnvironment(start_environment_);
691 } 691 }
692 692
693 693
694 Handle<Code> HGraph::Compile(CompilationInfo* info, Zone* zone) { 694 Handle<Code> HGraph::Compile() {
695 int values = GetMaximumValueID(); 695 int values = GetMaximumValueID();
696 if (values > LUnallocated::kMaxVirtualRegisters) { 696 if (values > LUnallocated::kMaxVirtualRegisters) {
697 if (FLAG_trace_bailout) { 697 if (FLAG_trace_bailout) {
698 PrintF("Not enough virtual registers for (values).\n"); 698 PrintF("Not enough virtual registers for (values).\n");
699 } 699 }
700 return Handle<Code>::null(); 700 return Handle<Code>::null();
701 } 701 }
702 LAllocator allocator(values, this); 702 LAllocator allocator(values, this);
703 LChunkBuilder builder(info, this, &allocator); 703 LChunkBuilder builder(info(), this, &allocator);
704 LChunk* chunk = builder.Build(); 704 LChunk* chunk = builder.Build();
705 if (chunk == NULL) return Handle<Code>::null(); 705 if (chunk == NULL) return Handle<Code>::null();
706 706
707 if (!allocator.Allocate(chunk)) { 707 if (!allocator.Allocate(chunk)) {
708 if (FLAG_trace_bailout) { 708 if (FLAG_trace_bailout) {
709 PrintF("Not enough virtual registers (regalloc).\n"); 709 PrintF("Not enough virtual registers (regalloc).\n");
710 } 710 }
711 return Handle<Code>::null(); 711 return Handle<Code>::null();
712 } 712 }
713 713
714 MacroAssembler assembler(info->isolate(), NULL, 0); 714 MacroAssembler assembler(isolate(), NULL, 0);
715 LCodeGen generator(chunk, &assembler, info, zone); 715 LCodeGen generator(chunk, &assembler, info());
716 716
717 chunk->MarkEmptyBlocks(); 717 chunk->MarkEmptyBlocks();
718 718
719 if (generator.GenerateCode()) { 719 if (generator.GenerateCode()) {
720 if (FLAG_trace_codegen) { 720 if (FLAG_trace_codegen) {
721 PrintF("Crankshaft Compiler - "); 721 PrintF("Crankshaft Compiler - ");
722 } 722 }
723 CodeGenerator::MakeCodePrologue(info); 723 CodeGenerator::MakeCodePrologue(info());
724 Code::Flags flags = Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); 724 Code::Flags flags = Code::ComputeFlags(Code::OPTIMIZED_FUNCTION);
725 Handle<Code> code = 725 Handle<Code> code =
726 CodeGenerator::MakeCodeEpilogue(&assembler, flags, info); 726 CodeGenerator::MakeCodeEpilogue(&assembler, flags, info());
727 generator.FinishCode(code); 727 generator.FinishCode(code);
728 CodeGenerator::PrintCode(code, info); 728 CodeGenerator::PrintCode(code, info());
729 return code; 729 return code;
730 } 730 }
731 return Handle<Code>::null(); 731 return Handle<Code>::null();
732 } 732 }
733 733
734 734
735 HBasicBlock* HGraph::CreateBasicBlock() { 735 HBasicBlock* HGraph::CreateBasicBlock() {
736 HBasicBlock* result = new(zone()) HBasicBlock(this); 736 HBasicBlock* result = new(zone()) HBasicBlock(this);
737 blocks_.Add(result, zone()); 737 blocks_.Add(result, zone());
738 return result; 738 return result;
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
2788 2788
2789 2789
2790 void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) { 2790 void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) {
2791 for (int i = 0; i < exprs->length(); ++i) { 2791 for (int i = 0; i < exprs->length(); ++i) {
2792 CHECK_ALIVE(VisitForValue(exprs->at(i))); 2792 CHECK_ALIVE(VisitForValue(exprs->at(i)));
2793 } 2793 }
2794 } 2794 }
2795 2795
2796 2796
2797 HGraph* HGraphBuilder::CreateGraph() { 2797 HGraph* HGraphBuilder::CreateGraph() {
2798 graph_ = new(zone()) HGraph(info(), zone()); 2798 graph_ = new(zone()) HGraph(info());
2799 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info()); 2799 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info());
2800 2800
2801 { 2801 {
2802 HPhase phase("H_Block building"); 2802 HPhase phase("H_Block building");
2803 current_block_ = graph()->entry_block(); 2803 current_block_ = graph()->entry_block();
2804 2804
2805 Scope* scope = info()->scope(); 2805 Scope* scope = info()->scope();
2806 if (scope->HasIllegalRedeclaration()) { 2806 if (scope->HasIllegalRedeclaration()) {
2807 Bailout("function with illegal redeclaration"); 2807 Bailout("function with illegal redeclaration");
2808 return NULL; 2808 return NULL;
(...skipping 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after
6216 } 6216 }
6217 6217
6218 // We don't want to add more than a certain number of nodes from inlining. 6218 // We don't want to add more than a certain number of nodes from inlining.
6219 if (inlined_count_ > Min(FLAG_max_inlined_nodes_cumulative, 6219 if (inlined_count_ > Min(FLAG_max_inlined_nodes_cumulative,
6220 kUnlimitedMaxInlinedNodesCumulative)) { 6220 kUnlimitedMaxInlinedNodesCumulative)) {
6221 TraceInline(target, caller, "cumulative AST node limit reached"); 6221 TraceInline(target, caller, "cumulative AST node limit reached");
6222 return false; 6222 return false;
6223 } 6223 }
6224 6224
6225 // Parse and allocate variables. 6225 // Parse and allocate variables.
6226 CompilationInfo target_info(target); 6226 CompilationInfo target_info(target, zone());
6227 if (!ParserApi::Parse(&target_info, kNoParsingFlags) || 6227 if (!ParserApi::Parse(&target_info, kNoParsingFlags) ||
6228 !Scope::Analyze(&target_info)) { 6228 !Scope::Analyze(&target_info)) {
6229 if (target_info.isolate()->has_pending_exception()) { 6229 if (target_info.isolate()->has_pending_exception()) {
6230 // Parse or scope error, never optimize this function. 6230 // Parse or scope error, never optimize this function.
6231 SetStackOverflow(); 6231 SetStackOverflow();
6232 target_shared->DisableOptimization(); 6232 target_shared->DisableOptimization();
6233 } 6233 }
6234 TraceInline(target, caller, "parse failure"); 6234 TraceInline(target, caller, "parse failure");
6235 return false; 6235 return false;
6236 } 6236 }
(...skipping 2545 matching lines...) Expand 10 before | Expand all | Expand 10 after
8782 8782
8783 HEnvironment* HEnvironment::CopyForInlining( 8783 HEnvironment* HEnvironment::CopyForInlining(
8784 Handle<JSFunction> target, 8784 Handle<JSFunction> target,
8785 int arguments, 8785 int arguments,
8786 FunctionLiteral* function, 8786 FunctionLiteral* function,
8787 HConstant* undefined, 8787 HConstant* undefined,
8788 CallKind call_kind, 8788 CallKind call_kind,
8789 bool is_construct) const { 8789 bool is_construct) const {
8790 ASSERT(frame_type() == JS_FUNCTION); 8790 ASSERT(frame_type() == JS_FUNCTION);
8791 8791
8792 Zone* zone = closure()->GetIsolate()->zone();
8793
8794 // Outer environment is a copy of this one without the arguments. 8792 // Outer environment is a copy of this one without the arguments.
8795 int arity = function->scope()->num_parameters(); 8793 int arity = function->scope()->num_parameters();
8796 8794
8797 HEnvironment* outer = Copy(); 8795 HEnvironment* outer = Copy();
8798 outer->Drop(arguments + 1); // Including receiver. 8796 outer->Drop(arguments + 1); // Including receiver.
8799 outer->ClearHistory(); 8797 outer->ClearHistory();
8800 8798
8801 if (is_construct) { 8799 if (is_construct) {
8802 // Create artificial constructor stub environment. The receiver should 8800 // Create artificial constructor stub environment. The receiver should
8803 // actually be the constructor function, but we pass the newly allocated 8801 // actually be the constructor function, but we pass the newly allocated
8804 // object instead, DoComputeConstructStubFrame() relies on that. 8802 // object instead, DoComputeConstructStubFrame() relies on that.
8805 outer = CreateStubEnvironment(outer, target, JS_CONSTRUCT, arguments); 8803 outer = CreateStubEnvironment(outer, target, JS_CONSTRUCT, arguments);
8806 } 8804 }
8807 8805
8808 if (arity != arguments) { 8806 if (arity != arguments) {
8809 // Create artificial arguments adaptation environment. 8807 // Create artificial arguments adaptation environment.
8810 outer = CreateStubEnvironment(outer, target, ARGUMENTS_ADAPTOR, arguments); 8808 outer = CreateStubEnvironment(outer, target, ARGUMENTS_ADAPTOR, arguments);
8811 } 8809 }
8812 8810
8813 HEnvironment* inner = 8811 HEnvironment* inner =
8814 new(zone) HEnvironment(outer, function->scope(), target, zone); 8812 new(zone()) HEnvironment(outer, function->scope(), target, zone());
8815 // Get the argument values from the original environment. 8813 // Get the argument values from the original environment.
8816 for (int i = 0; i <= arity; ++i) { // Include receiver. 8814 for (int i = 0; i <= arity; ++i) { // Include receiver.
8817 HValue* push = (i <= arguments) ? 8815 HValue* push = (i <= arguments) ?
8818 ExpressionStackAt(arguments - i) : undefined; 8816 ExpressionStackAt(arguments - i) : undefined;
8819 inner->SetValueAt(i, push); 8817 inner->SetValueAt(i, push);
8820 } 8818 }
8821 // If the function we are inlining is a strict mode function or a 8819 // If the function we are inlining is a strict mode function or a
8822 // builtin function, pass undefined as the receiver for function 8820 // builtin function, pass undefined as the receiver for function
8823 // calls (instead of the global receiver). 8821 // calls (instead of the global receiver).
8824 if ((target->shared()->native() || !function->is_classic_mode()) && 8822 if ((target->shared()->native() || !function->is_classic_mode()) &&
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
9177 } 9175 }
9178 } 9176 }
9179 9177
9180 #ifdef DEBUG 9178 #ifdef DEBUG
9181 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9179 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9182 if (allocator_ != NULL) allocator_->Verify(); 9180 if (allocator_ != NULL) allocator_->Verify();
9183 #endif 9181 #endif
9184 } 9182 }
9185 9183
9186 } } // namespace v8::internal 9184 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698