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

Side by Side Diff: src/hydrogen.h

Issue 5964005: Shorten live ranges of argument subexpressions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 private: 146 private:
147 void RegisterPredecessor(HBasicBlock* pred); 147 void RegisterPredecessor(HBasicBlock* pred);
148 void AddDominatedBlock(HBasicBlock* block); 148 void AddDominatedBlock(HBasicBlock* block);
149 149
150 HSimulate* CreateSimulate(int id); 150 HSimulate* CreateSimulate(int id);
151 151
152 int block_id_; 152 int block_id_;
153 HGraph* graph_; 153 HGraph* graph_;
154 ZoneList<HPhi*> phis_; 154 ZoneList<HPhi*> phis_;
155 HInstruction* first_; 155 HInstruction* first_;
156 HInstruction* last_; // Last non-control instruction of the block. 156
157 // A cached instruction that is in this block unless it's been deleted.
158 HInstruction* cached_;
159
157 HControlInstruction* end_; 160 HControlInstruction* end_;
158 HLoopInformation* loop_information_; 161 HLoopInformation* loop_information_;
159 ZoneList<HBasicBlock*> predecessors_; 162 ZoneList<HBasicBlock*> predecessors_;
160 HBasicBlock* dominator_; 163 HBasicBlock* dominator_;
161 ZoneList<HBasicBlock*> dominated_blocks_; 164 ZoneList<HBasicBlock*> dominated_blocks_;
162 HEnvironment* last_environment_; 165 HEnvironment* last_environment_;
163 // Outgoing parameter count at block exit, set during lithium translation. 166 // Outgoing parameter count at block exit, set during lithium translation.
164 int argument_count_; 167 int argument_count_;
165 // Instruction indices into the lithium code stream. 168 // Instruction indices into the lithium code stream.
166 int first_instruction_index_; 169 int first_instruction_index_;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 438 }
436 439
437 HValue* Top() const { return ExpressionStackAt(0); } 440 HValue* Top() const { return ExpressionStackAt(0); }
438 441
439 HValue* ExpressionStackAt(int index_from_top) const { 442 HValue* ExpressionStackAt(int index_from_top) const {
440 int index = values_.length() - index_from_top - 1; 443 int index = values_.length() - index_from_top - 1;
441 ASSERT(IsExpressionStackIndex(index)); 444 ASSERT(IsExpressionStackIndex(index));
442 return values_[index]; 445 return values_[index];
443 } 446 }
444 447
445 void SetExpressionStackAt(int index_from_top, HValue* value) {
446 int index = values_.length() - index_from_top - 1;
447 ASSERT(IsExpressionStackIndex(index));
448 values_[index] = value;
449 }
450
451 HValue* Pop() { 448 HValue* Pop() {
452 ASSERT(!IsExpressionStackEmpty()); 449 ASSERT(!IsExpressionStackEmpty());
453 if (push_count_ > 0) { 450 if (push_count_ > 0) {
454 --push_count_; 451 --push_count_;
455 ASSERT(push_count_ >= 0); 452 ASSERT(push_count_ >= 0);
456 } else { 453 } else {
457 ++pop_count_; 454 ++pop_count_;
458 } 455 }
459 return values_.RemoveLast(); 456 return values_.RemoveLast();
460 } 457 }
(...skipping 25 matching lines...) Expand all
486 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const; 483 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const;
487 484
488 // Create an "inlined version" of this environment, where the original 485 // Create an "inlined version" of this environment, where the original
489 // environment is the outer environment but the top expression stack 486 // environment is the outer environment but the top expression stack
490 // elements are moved to an inner environment as parameters. If 487 // elements are moved to an inner environment as parameters. If
491 // is_speculative, the argument values are expected to be PushArgument 488 // is_speculative, the argument values are expected to be PushArgument
492 // instructions, otherwise they are the actual values. 489 // instructions, otherwise they are the actual values.
493 HEnvironment* CopyForInlining(Handle<JSFunction> target, 490 HEnvironment* CopyForInlining(Handle<JSFunction> target,
494 FunctionLiteral* function, 491 FunctionLiteral* function,
495 bool is_speculative, 492 bool is_speculative,
496 HConstant* undefined) const; 493 HConstant* undefined,
494 HGlobalReceiver* receiver) const;
497 495
498 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other); 496 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other);
499 void ClearHistory() { 497 void ClearHistory() {
500 pop_count_ = 0; 498 pop_count_ = 0;
501 push_count_ = 0; 499 push_count_ = 0;
502 assigned_variables_.Clear(); 500 assigned_variables_.Clear();
503 } 501 }
504 void SetValueAt(int index, HValue* value) { 502 void SetValueAt(int index, HValue* value) {
505 ASSERT(index < total_count()); 503 ASSERT(index < total_count());
506 values_[index] = value; 504 values_[index] = value;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // Adding instructions. 654 // Adding instructions.
657 HInstruction* AddInstruction(HInstruction* instr); 655 HInstruction* AddInstruction(HInstruction* instr);
658 void AddSimulate(int id); 656 void AddSimulate(int id);
659 657
660 // Bailout environment manipulation. 658 // Bailout environment manipulation.
661 void Push(HValue* value) { environment()->Push(value); } 659 void Push(HValue* value) { environment()->Push(value); }
662 HValue* Pop() { return environment()->Pop(); } 660 HValue* Pop() { return environment()->Pop(); }
663 661
664 private: 662 private:
665 // Type of a member function that generates inline code for a native function. 663 // Type of a member function that generates inline code for a native function.
666 typedef void (HGraphBuilder::*InlineFunctionGenerator)(int argument_count, 664 typedef void (HGraphBuilder::*InlineFunctionGenerator)(CallRuntime* call);
667 int ast_id);
668 665
669 // Forward declarations for inner scope classes. 666 // Forward declarations for inner scope classes.
670 class SubgraphScope; 667 class SubgraphScope;
671 668
672 static const InlineFunctionGenerator kInlineFunctionGenerators[]; 669 static const InlineFunctionGenerator kInlineFunctionGenerators[];
673 670
674 static const int kMaxCallPolymorphism = 4; 671 static const int kMaxCallPolymorphism = 4;
675 static const int kMaxLoadPolymorphism = 4; 672 static const int kMaxLoadPolymorphism = 4;
676 static const int kMaxStorePolymorphism = 4; 673 static const int kMaxStorePolymorphism = 4;
677 674
678 static const int kMaxInlinedNodes = 196; 675 static const int kMaxInlinedNodes = 196;
679 static const int kMaxInlinedSize = 196; 676 static const int kMaxInlinedSize = 196;
680 static const int kMaxSourceSize = 600; 677 static const int kMaxSourceSize = 600;
681 678
682 // Simple accessors. 679 // Simple accessors.
683 TypeFeedbackOracle* oracle() const { return oracle_; } 680 TypeFeedbackOracle* oracle() const { return oracle_; }
684 AstContext* ast_context() const { return ast_context_; } 681 AstContext* ast_context() const { return ast_context_; }
685 void set_ast_context(AstContext* context) { ast_context_ = context; } 682 void set_ast_context(AstContext* context) { ast_context_ = context; }
686 AstContext* call_context() const { return call_context_; } 683 AstContext* call_context() const { return call_context_; }
687 HBasicBlock* function_return() const { return function_return_; } 684 HBasicBlock* function_return() const { return function_return_; }
688 685
689 // Generators for inline runtime functions. 686 // Generators for inline runtime functions.
690 #define INLINE_FUNCTION_GENERATOR_DECLARATION(Name, argc, ressize) \ 687 #define INLINE_FUNCTION_GENERATOR_DECLARATION(Name, argc, ressize) \
691 void Generate##Name(int argument_count, int ast_id); 688 void Generate##Name(CallRuntime* call);
692 689
693 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION) 690 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION)
694 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION) 691 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION)
695 #undef INLINE_FUNCTION_GENERATOR_DECLARATION 692 #undef INLINE_FUNCTION_GENERATOR_DECLARATION
696 693
697 void Bailout(const char* reason); 694 void Bailout(const char* reason);
698 695
699 void AppendPeeledWhile(IterationStatement* stmt, 696 void AppendPeeledWhile(IterationStatement* stmt,
700 HSubgraph* cond_graph, 697 HSubgraph* cond_graph,
701 HSubgraph* body_graph, 698 HSubgraph* body_graph,
702 HSubgraph* exit_graph); 699 HSubgraph* exit_graph);
703 700
704 void AddToSubgraph(HSubgraph* graph, ZoneList<Statement*>* stmts); 701 void AddToSubgraph(HSubgraph* graph, ZoneList<Statement*>* stmts);
705 void AddToSubgraph(HSubgraph* graph, Statement* stmt); 702 void AddToSubgraph(HSubgraph* graph, Statement* stmt);
706 void AddToSubgraph(HSubgraph* graph, Expression* expr); 703 void AddToSubgraph(HSubgraph* graph, Expression* expr);
707 704
708 HValue* Top() const { return environment()->Top(); } 705 HValue* Top() const { return environment()->Top(); }
709 void Drop(int n) { environment()->Drop(n); } 706 void Drop(int n) { environment()->Drop(n); }
710 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); } 707 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); }
711 708
712 void VisitForValue(Expression* expr); 709 void VisitForValue(Expression* expr);
713 void VisitForEffect(Expression* expr); 710 void VisitForEffect(Expression* expr);
714 void VisitForControl(Expression* expr, 711 void VisitForControl(Expression* expr,
715 HBasicBlock* true_block, 712 HBasicBlock* true_block,
716 HBasicBlock* false_block); 713 HBasicBlock* false_block);
717 714
718 // Visit an argument and wrap it in a PushArgument instruction. 715 // Visit an argument and wrap it in a PushArgument instruction.
719 HValue* VisitArgument(Expression* expr); 716 void VisitArgument(Expression* expr);
720 void VisitArgumentList(ZoneList<Expression*>* arguments); 717 void VisitArgumentList(ZoneList<Expression*>* arguments);
721 718
719 // The top 'count' elements of the environment are assumed to be
720 // PushArgument instructions. Delete their definitions in the graph
721 // and replace all their uses with their argument values.
722 void ReplaceAndDeleteArguments(HEnvironment* env, int count);
723
722 void AddPhi(HPhi* phi); 724 void AddPhi(HPhi* phi);
723 725
724 void PushAndAdd(HInstruction* instr); 726 void PushAndAdd(HInstruction* instr);
725 727
726 void PushArgumentsForStubCall(int argument_count);
727
728 // Remove the arguments from the bailout environment and emit instructions
729 // to push them as outgoing parameters.
730 void ProcessCall(HCall* call);
731
732 void AssumeRepresentation(HValue* value, Representation r); 728 void AssumeRepresentation(HValue* value, Representation r);
733 static Representation ToRepresentation(TypeInfo info); 729 static Representation ToRepresentation(TypeInfo info);
734 730
735 void SetupScope(Scope* scope); 731 void SetupScope(Scope* scope);
736 virtual void VisitStatements(ZoneList<Statement*>* statements); 732 virtual void VisitStatements(ZoneList<Statement*>* statements);
737 733
738 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); 734 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
739 AST_NODE_LIST(DECLARE_VISIT) 735 AST_NODE_LIST(DECLARE_VISIT)
740 #undef DECLARE_VISIT 736 #undef DECLARE_VISIT
741 737
742 bool ShouldPeel(HSubgraph* cond, HSubgraph* body); 738 bool ShouldPeel(HSubgraph* cond, HSubgraph* body);
743 739
744 HBasicBlock* CreateBasicBlock(HEnvironment* env); 740 HBasicBlock* CreateBasicBlock(HEnvironment* env);
745 HSubgraph* CreateEmptySubgraph(); 741 HSubgraph* CreateEmptySubgraph();
746 HSubgraph* CreateGotoSubgraph(HEnvironment* env); 742 HSubgraph* CreateGotoSubgraph(HEnvironment* env);
747 HSubgraph* CreateBranchSubgraph(HEnvironment* env); 743 HSubgraph* CreateBranchSubgraph(HEnvironment* env);
748 HSubgraph* CreateLoopHeaderSubgraph(HEnvironment* env); 744 HSubgraph* CreateLoopHeaderSubgraph(HEnvironment* env);
749 HSubgraph* CreateInlinedSubgraph(HEnvironment* outer, 745 HSubgraph* CreateInlinedSubgraph(HEnvironment* outer,
750 Handle<JSFunction> target, 746 Handle<JSFunction> target,
751 FunctionLiteral* function); 747 FunctionLiteral* function,
748 HGlobalReceiver* receiver);
752 749
753 // Helpers for flow graph construction. 750 // Helpers for flow graph construction.
754 void LookupGlobalPropertyCell(Variable* var, 751 void LookupGlobalPropertyCell(Variable* var,
755 LookupResult* lookup, 752 LookupResult* lookup,
756 bool is_store); 753 bool is_store);
757 754
758 bool TryArgumentsAccess(Property* expr); 755 bool TryArgumentsAccess(Property* expr);
759 bool TryCallApply(Call* expr); 756 bool TryCallApply(Call* expr);
760 bool TryInline(Call* expr); 757
758 bool TryInline(Call* expr, bool is_known_global);
759
761 bool TryMathFunctionInline(Call* expr); 760 bool TryMathFunctionInline(Call* expr);
762 void TraceInline(Handle<JSFunction> target, bool result); 761 void TraceInline(Handle<JSFunction> target, bool result);
763 762
764 void HandleGlobalVariableAssignment(Variable* var, 763 void HandleGlobalVariableAssignment(Variable* var,
765 HValue* value, 764 HValue* value,
766 int position, 765 int position,
767 int ast_id); 766 int ast_id);
768 767
769 void HandlePropertyAssignment(Assignment* expr); 768 void HandlePropertyAssignment(Assignment* expr);
770 void HandleCompoundAssignment(Assignment* expr); 769 void HandleCompoundAssignment(Assignment* expr);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 HValue* switch_value, 826 HValue* switch_value,
828 CaseClause* clause); 827 CaseClause* clause);
829 828
830 void AddCheckConstantFunction(Call* expr, 829 void AddCheckConstantFunction(Call* expr,
831 HValue* receiver, 830 HValue* receiver,
832 Handle<Map> receiver_map, 831 Handle<Map> receiver_map,
833 bool smi_and_map_check); 832 bool smi_and_map_check);
834 833
835 834
836 HBasicBlock* BuildTypeSwitch(ZoneMapList* maps, 835 HBasicBlock* BuildTypeSwitch(ZoneMapList* maps,
837 ZoneList<HSubgraph*>* subgraphs, 836 ZoneList<HSubgraph*>* body_graphs,
837 HSubgraph* default_graph,
838 HValue* receiver, 838 HValue* receiver,
839 int join_id); 839 int join_id);
840 840
841 TypeFeedbackOracle* oracle_; 841 TypeFeedbackOracle* oracle_;
842 HGraph* graph_; 842 HGraph* graph_;
843 HSubgraph* current_subgraph_; 843 HSubgraph* current_subgraph_;
844 IterationStatement* peeled_statement_; 844 IterationStatement* peeled_statement_;
845 // Expression context of the currently visited subexpression. NULL when 845 // Expression context of the currently visited subexpression. NULL when
846 // visiting statements. 846 // visiting statements.
847 AstContext* ast_context_; 847 AstContext* ast_context_;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 const char* filename_; 1061 const char* filename_;
1062 HeapStringAllocator string_allocator_; 1062 HeapStringAllocator string_allocator_;
1063 StringStream trace_; 1063 StringStream trace_;
1064 int indent_; 1064 int indent_;
1065 }; 1065 };
1066 1066
1067 1067
1068 } } // namespace v8::internal 1068 } } // namespace v8::internal
1069 1069
1070 #endif // V8_HYDROGEN_H_ 1070 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen.cc » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698