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

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: Rename CompilationInfoZone to ZoneWithCompilationInfo 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
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 3041
3042 3042
3043 void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) { 3043 void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) {
3044 for (int i = 0; i < exprs->length(); ++i) { 3044 for (int i = 0; i < exprs->length(); ++i) {
3045 CHECK_ALIVE(VisitForValue(exprs->at(i))); 3045 CHECK_ALIVE(VisitForValue(exprs->at(i)));
3046 } 3046 }
3047 } 3047 }
3048 3048
3049 3049
3050 HGraph* HGraphBuilder::CreateGraph() { 3050 HGraph* HGraphBuilder::CreateGraph() {
3051 graph_ = new(zone()) HGraph(info(), zone()); 3051 graph_ = new(zone()) HGraph(info());
3052 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info()); 3052 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info());
3053 3053
3054 { 3054 {
3055 HPhase phase("H_Block building"); 3055 HPhase phase("H_Block building");
3056 current_block_ = graph()->entry_block(); 3056 current_block_ = graph()->entry_block();
3057 3057
3058 Scope* scope = info()->scope(); 3058 Scope* scope = info()->scope();
3059 if (scope->HasIllegalRedeclaration()) { 3059 if (scope->HasIllegalRedeclaration()) {
3060 Bailout("function with illegal redeclaration"); 3060 Bailout("function with illegal redeclaration");
3061 return NULL; 3061 return NULL;
(...skipping 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after
6469 } 6469 }
6470 6470
6471 // We don't want to add more than a certain number of nodes from inlining. 6471 // We don't want to add more than a certain number of nodes from inlining.
6472 if (inlined_count_ > Min(FLAG_max_inlined_nodes_cumulative, 6472 if (inlined_count_ > Min(FLAG_max_inlined_nodes_cumulative,
6473 kUnlimitedMaxInlinedNodesCumulative)) { 6473 kUnlimitedMaxInlinedNodesCumulative)) {
6474 TraceInline(target, caller, "cumulative AST node limit reached"); 6474 TraceInline(target, caller, "cumulative AST node limit reached");
6475 return false; 6475 return false;
6476 } 6476 }
6477 6477
6478 // Parse and allocate variables. 6478 // Parse and allocate variables.
6479 CompilationInfo target_info(target); 6479 CompilationInfo target_info(target, zone());
6480 if (!ParserApi::Parse(&target_info, kNoParsingFlags) || 6480 if (!ParserApi::Parse(&target_info, kNoParsingFlags) ||
6481 !Scope::Analyze(&target_info)) { 6481 !Scope::Analyze(&target_info)) {
6482 if (target_info.isolate()->has_pending_exception()) { 6482 if (target_info.isolate()->has_pending_exception()) {
6483 // Parse or scope error, never optimize this function. 6483 // Parse or scope error, never optimize this function.
6484 SetStackOverflow(); 6484 SetStackOverflow();
6485 target_shared->DisableOptimization(); 6485 target_shared->DisableOptimization();
6486 } 6486 }
6487 TraceInline(target, caller, "parse failure"); 6487 TraceInline(target, caller, "parse failure");
6488 return false; 6488 return false;
6489 } 6489 }
(...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after
9047 9047
9048 HEnvironment* HEnvironment::CopyForInlining( 9048 HEnvironment* HEnvironment::CopyForInlining(
9049 Handle<JSFunction> target, 9049 Handle<JSFunction> target,
9050 int arguments, 9050 int arguments,
9051 FunctionLiteral* function, 9051 FunctionLiteral* function,
9052 HConstant* undefined, 9052 HConstant* undefined,
9053 CallKind call_kind, 9053 CallKind call_kind,
9054 bool is_construct) const { 9054 bool is_construct) const {
9055 ASSERT(frame_type() == JS_FUNCTION); 9055 ASSERT(frame_type() == JS_FUNCTION);
9056 9056
9057 Zone* zone = closure()->GetIsolate()->zone();
9058
9059 // Outer environment is a copy of this one without the arguments. 9057 // Outer environment is a copy of this one without the arguments.
9060 int arity = function->scope()->num_parameters(); 9058 int arity = function->scope()->num_parameters();
9061 9059
9062 HEnvironment* outer = Copy(); 9060 HEnvironment* outer = Copy();
9063 outer->Drop(arguments + 1); // Including receiver. 9061 outer->Drop(arguments + 1); // Including receiver.
9064 outer->ClearHistory(); 9062 outer->ClearHistory();
9065 9063
9066 if (is_construct) { 9064 if (is_construct) {
9067 // Create artificial constructor stub environment. The receiver should 9065 // Create artificial constructor stub environment. The receiver should
9068 // actually be the constructor function, but we pass the newly allocated 9066 // actually be the constructor function, but we pass the newly allocated
9069 // object instead, DoComputeConstructStubFrame() relies on that. 9067 // object instead, DoComputeConstructStubFrame() relies on that.
9070 outer = CreateStubEnvironment(outer, target, JS_CONSTRUCT, arguments); 9068 outer = CreateStubEnvironment(outer, target, JS_CONSTRUCT, arguments);
9071 } 9069 }
9072 9070
9073 if (arity != arguments) { 9071 if (arity != arguments) {
9074 // Create artificial arguments adaptation environment. 9072 // Create artificial arguments adaptation environment.
9075 outer = CreateStubEnvironment(outer, target, ARGUMENTS_ADAPTOR, arguments); 9073 outer = CreateStubEnvironment(outer, target, ARGUMENTS_ADAPTOR, arguments);
9076 } 9074 }
9077 9075
9078 HEnvironment* inner = 9076 HEnvironment* inner =
9079 new(zone) HEnvironment(outer, function->scope(), target, zone); 9077 new(zone()) HEnvironment(outer, function->scope(), target, zone());
9080 // Get the argument values from the original environment. 9078 // Get the argument values from the original environment.
9081 for (int i = 0; i <= arity; ++i) { // Include receiver. 9079 for (int i = 0; i <= arity; ++i) { // Include receiver.
9082 HValue* push = (i <= arguments) ? 9080 HValue* push = (i <= arguments) ?
9083 ExpressionStackAt(arguments - i) : undefined; 9081 ExpressionStackAt(arguments - i) : undefined;
9084 inner->SetValueAt(i, push); 9082 inner->SetValueAt(i, push);
9085 } 9083 }
9086 // If the function we are inlining is a strict mode function or a 9084 // If the function we are inlining is a strict mode function or a
9087 // builtin function, pass undefined as the receiver for function 9085 // builtin function, pass undefined as the receiver for function
9088 // calls (instead of the global receiver). 9086 // calls (instead of the global receiver).
9089 if ((target->shared()->native() || !function->is_classic_mode()) && 9087 if ((target->shared()->native() || !function->is_classic_mode()) &&
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
9442 } 9440 }
9443 } 9441 }
9444 9442
9445 #ifdef DEBUG 9443 #ifdef DEBUG
9446 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9444 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9447 if (allocator_ != NULL) allocator_->Verify(); 9445 if (allocator_ != NULL) allocator_->Verify();
9448 #endif 9446 #endif
9449 } 9447 }
9450 9448
9451 } } // namespace v8::internal 9449 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698