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

Side by Side Diff: src/hydrogen.h

Issue 10831172: Introduced TypeFeedbackId and BailoutId types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Incorporated review feedback. Created 8 years, 4 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/full-codegen.cc ('k') | src/hydrogen.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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 void UpdateEnvironment(HEnvironment* env) { last_environment_ = env; } 111 void UpdateEnvironment(HEnvironment* env) { last_environment_ = env; }
112 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } 112 HBasicBlock* parent_loop_header() const { return parent_loop_header_; }
113 113
114 void set_parent_loop_header(HBasicBlock* block) { 114 void set_parent_loop_header(HBasicBlock* block) {
115 ASSERT(parent_loop_header_ == NULL); 115 ASSERT(parent_loop_header_ == NULL);
116 parent_loop_header_ = block; 116 parent_loop_header_ = block;
117 } 117 }
118 118
119 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } 119 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; }
120 120
121 void SetJoinId(int ast_id); 121 void SetJoinId(BailoutId ast_id);
122 122
123 void Finish(HControlInstruction* last); 123 void Finish(HControlInstruction* last);
124 void FinishExit(HControlInstruction* instruction); 124 void FinishExit(HControlInstruction* instruction);
125 void Goto(HBasicBlock* block, FunctionState* state = NULL); 125 void Goto(HBasicBlock* block, FunctionState* state = NULL);
126 126
127 int PredecessorIndexOf(HBasicBlock* predecessor) const; 127 int PredecessorIndexOf(HBasicBlock* predecessor) const;
128 void AddSimulate(int ast_id) { AddInstruction(CreateSimulate(ast_id)); } 128 void AddSimulate(BailoutId ast_id) { AddInstruction(CreateSimulate(ast_id)); }
129 void AssignCommonDominator(HBasicBlock* other); 129 void AssignCommonDominator(HBasicBlock* other);
130 void AssignLoopSuccessorDominators(); 130 void AssignLoopSuccessorDominators();
131 131
132 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) { 132 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) {
133 FinishExit(CreateDeoptimize(has_uses)); 133 FinishExit(CreateDeoptimize(has_uses));
134 } 134 }
135 135
136 // Add the inlined function exit sequence, adding an HLeaveInlined 136 // Add the inlined function exit sequence, adding an HLeaveInlined
137 // instruction and updating the bailout environment. 137 // instruction and updating the bailout environment.
138 void AddLeaveInlined(HValue* return_value, 138 void AddLeaveInlined(HValue* return_value,
(...skipping 22 matching lines...) Expand all
161 inline Zone* zone() const; 161 inline Zone* zone() const;
162 162
163 #ifdef DEBUG 163 #ifdef DEBUG
164 void Verify(); 164 void Verify();
165 #endif 165 #endif
166 166
167 private: 167 private:
168 void RegisterPredecessor(HBasicBlock* pred); 168 void RegisterPredecessor(HBasicBlock* pred);
169 void AddDominatedBlock(HBasicBlock* block); 169 void AddDominatedBlock(HBasicBlock* block);
170 170
171 HSimulate* CreateSimulate(int ast_id); 171 HSimulate* CreateSimulate(BailoutId ast_id);
172 HDeoptimize* CreateDeoptimize(HDeoptimize::UseEnvironment has_uses); 172 HDeoptimize* CreateDeoptimize(HDeoptimize::UseEnvironment has_uses);
173 173
174 int block_id_; 174 int block_id_;
175 HGraph* graph_; 175 HGraph* graph_;
176 ZoneList<HPhi*> phis_; 176 ZoneList<HPhi*> phis_;
177 HInstruction* first_; 177 HInstruction* first_;
178 HInstruction* last_; 178 HInstruction* last_;
179 HControlInstruction* end_; 179 HControlInstruction* end_;
180 HLoopInformation* loop_information_; 180 HLoopInformation* loop_information_;
181 ZoneList<HBasicBlock*> predecessors_; 181 ZoneList<HBasicBlock*> predecessors_;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 return &assigned_variables_; 424 return &assigned_variables_;
425 } 425 }
426 FrameType frame_type() const { return frame_type_; } 426 FrameType frame_type() const { return frame_type_; }
427 int parameter_count() const { return parameter_count_; } 427 int parameter_count() const { return parameter_count_; }
428 int specials_count() const { return specials_count_; } 428 int specials_count() const { return specials_count_; }
429 int local_count() const { return local_count_; } 429 int local_count() const { return local_count_; }
430 HEnvironment* outer() const { return outer_; } 430 HEnvironment* outer() const { return outer_; }
431 int pop_count() const { return pop_count_; } 431 int pop_count() const { return pop_count_; }
432 int push_count() const { return push_count_; } 432 int push_count() const { return push_count_; }
433 433
434 int ast_id() const { return ast_id_; } 434 BailoutId ast_id() const { return ast_id_; }
435 void set_ast_id(int id) { ast_id_ = id; } 435 void set_ast_id(BailoutId id) { ast_id_ = id; }
436 436
437 int length() const { return values_.length(); } 437 int length() const { return values_.length(); }
438 bool is_special_index(int i) const { 438 bool is_special_index(int i) const {
439 return i >= parameter_count() && i < parameter_count() + specials_count(); 439 return i >= parameter_count() && i < parameter_count() + specials_count();
440 } 440 }
441 441
442 int first_expression_index() const { 442 int first_expression_index() const {
443 return parameter_count() + specials_count() + local_count(); 443 return parameter_count() + specials_count() + local_count();
444 } 444 }
445 445
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 // Value array [parameters] [specials] [locals] [temporaries]. 567 // Value array [parameters] [specials] [locals] [temporaries].
568 ZoneList<HValue*> values_; 568 ZoneList<HValue*> values_;
569 ZoneList<int> assigned_variables_; 569 ZoneList<int> assigned_variables_;
570 FrameType frame_type_; 570 FrameType frame_type_;
571 int parameter_count_; 571 int parameter_count_;
572 int specials_count_; 572 int specials_count_;
573 int local_count_; 573 int local_count_;
574 HEnvironment* outer_; 574 HEnvironment* outer_;
575 int pop_count_; 575 int pop_count_;
576 int push_count_; 576 int push_count_;
577 int ast_id_; 577 BailoutId ast_id_;
578 Zone* zone_; 578 Zone* zone_;
579 }; 579 };
580 580
581 581
582 class HGraphBuilder; 582 class HGraphBuilder;
583 583
584 enum ArgumentsAllowedFlag { 584 enum ArgumentsAllowedFlag {
585 ARGUMENTS_NOT_ALLOWED, 585 ARGUMENTS_NOT_ALLOWED,
586 ARGUMENTS_ALLOWED 586 ARGUMENTS_ALLOWED
587 }; 587 };
588 588
589 // This class is not BASE_EMBEDDED because our inlining implementation uses 589 // This class is not BASE_EMBEDDED because our inlining implementation uses
590 // new and delete. 590 // new and delete.
591 class AstContext { 591 class AstContext {
592 public: 592 public:
593 bool IsEffect() const { return kind_ == Expression::kEffect; } 593 bool IsEffect() const { return kind_ == Expression::kEffect; }
594 bool IsValue() const { return kind_ == Expression::kValue; } 594 bool IsValue() const { return kind_ == Expression::kValue; }
595 bool IsTest() const { return kind_ == Expression::kTest; } 595 bool IsTest() const { return kind_ == Expression::kTest; }
596 596
597 // 'Fill' this context with a hydrogen value. The value is assumed to 597 // 'Fill' this context with a hydrogen value. The value is assumed to
598 // have already been inserted in the instruction stream (or not need to 598 // have already been inserted in the instruction stream (or not need to
599 // be, e.g., HPhi). Call this function in tail position in the Visit 599 // be, e.g., HPhi). Call this function in tail position in the Visit
600 // functions for expressions. 600 // functions for expressions.
601 virtual void ReturnValue(HValue* value) = 0; 601 virtual void ReturnValue(HValue* value) = 0;
602 602
603 // Add a hydrogen instruction to the instruction stream (recording an 603 // Add a hydrogen instruction to the instruction stream (recording an
604 // environment simulation if necessary) and then fill this context with 604 // environment simulation if necessary) and then fill this context with
605 // the instruction as value. 605 // the instruction as value.
606 virtual void ReturnInstruction(HInstruction* instr, int ast_id) = 0; 606 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id) = 0;
607 607
608 // Finishes the current basic block and materialize a boolean for 608 // Finishes the current basic block and materialize a boolean for
609 // value context, nothing for effect, generate a branch for test context. 609 // value context, nothing for effect, generate a branch for test context.
610 // Call this function in tail position in the Visit functions for 610 // Call this function in tail position in the Visit functions for
611 // expressions. 611 // expressions.
612 virtual void ReturnControl(HControlInstruction* instr, int ast_id) = 0; 612 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id) = 0;
613 613
614 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; } 614 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; }
615 bool is_for_typeof() { return for_typeof_; } 615 bool is_for_typeof() { return for_typeof_; }
616 616
617 protected: 617 protected:
618 AstContext(HGraphBuilder* owner, Expression::Context kind); 618 AstContext(HGraphBuilder* owner, Expression::Context kind);
619 virtual ~AstContext(); 619 virtual ~AstContext();
620 620
621 HGraphBuilder* owner() const { return owner_; } 621 HGraphBuilder* owner() const { return owner_; }
622 622
(...skipping 14 matching lines...) Expand all
637 637
638 638
639 class EffectContext: public AstContext { 639 class EffectContext: public AstContext {
640 public: 640 public:
641 explicit EffectContext(HGraphBuilder* owner) 641 explicit EffectContext(HGraphBuilder* owner)
642 : AstContext(owner, Expression::kEffect) { 642 : AstContext(owner, Expression::kEffect) {
643 } 643 }
644 virtual ~EffectContext(); 644 virtual ~EffectContext();
645 645
646 virtual void ReturnValue(HValue* value); 646 virtual void ReturnValue(HValue* value);
647 virtual void ReturnInstruction(HInstruction* instr, int ast_id); 647 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id);
648 virtual void ReturnControl(HControlInstruction* instr, int ast_id); 648 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id);
649 }; 649 };
650 650
651 651
652 class ValueContext: public AstContext { 652 class ValueContext: public AstContext {
653 public: 653 public:
654 explicit ValueContext(HGraphBuilder* owner, ArgumentsAllowedFlag flag) 654 explicit ValueContext(HGraphBuilder* owner, ArgumentsAllowedFlag flag)
655 : AstContext(owner, Expression::kValue), flag_(flag) { 655 : AstContext(owner, Expression::kValue), flag_(flag) {
656 } 656 }
657 virtual ~ValueContext(); 657 virtual ~ValueContext();
658 658
659 virtual void ReturnValue(HValue* value); 659 virtual void ReturnValue(HValue* value);
660 virtual void ReturnInstruction(HInstruction* instr, int ast_id); 660 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id);
661 virtual void ReturnControl(HControlInstruction* instr, int ast_id); 661 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id);
662 662
663 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } 663 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; }
664 664
665 private: 665 private:
666 ArgumentsAllowedFlag flag_; 666 ArgumentsAllowedFlag flag_;
667 }; 667 };
668 668
669 669
670 class TestContext: public AstContext { 670 class TestContext: public AstContext {
671 public: 671 public:
672 TestContext(HGraphBuilder* owner, 672 TestContext(HGraphBuilder* owner,
673 Expression* condition, 673 Expression* condition,
674 HBasicBlock* if_true, 674 HBasicBlock* if_true,
675 HBasicBlock* if_false) 675 HBasicBlock* if_false)
676 : AstContext(owner, Expression::kTest), 676 : AstContext(owner, Expression::kTest),
677 condition_(condition), 677 condition_(condition),
678 if_true_(if_true), 678 if_true_(if_true),
679 if_false_(if_false) { 679 if_false_(if_false) {
680 } 680 }
681 681
682 virtual void ReturnValue(HValue* value); 682 virtual void ReturnValue(HValue* value);
683 virtual void ReturnInstruction(HInstruction* instr, int ast_id); 683 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id);
684 virtual void ReturnControl(HControlInstruction* instr, int ast_id); 684 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id);
685 685
686 static TestContext* cast(AstContext* context) { 686 static TestContext* cast(AstContext* context) {
687 ASSERT(context->IsTest()); 687 ASSERT(context->IsTest());
688 return reinterpret_cast<TestContext*>(context); 688 return reinterpret_cast<TestContext*>(context);
689 } 689 }
690 690
691 Expression* condition() const { return condition_; } 691 Expression* condition() const { return condition_; }
692 HBasicBlock* if_true() const { return if_true_; } 692 HBasicBlock* if_true() const { return if_true_; }
693 HBasicBlock* if_false() const { return if_false_; } 693 HBasicBlock* if_false() const { return if_false_; }
694 694
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 HBasicBlock* current_block() const { return current_block_; } 846 HBasicBlock* current_block() const { return current_block_; }
847 void set_current_block(HBasicBlock* block) { current_block_ = block; } 847 void set_current_block(HBasicBlock* block) { current_block_ = block; }
848 HEnvironment* environment() const { 848 HEnvironment* environment() const {
849 return current_block()->last_environment(); 849 return current_block()->last_environment();
850 } 850 }
851 851
852 bool inline_bailout() { return inline_bailout_; } 852 bool inline_bailout() { return inline_bailout_; }
853 853
854 // Adding instructions. 854 // Adding instructions.
855 HInstruction* AddInstruction(HInstruction* instr); 855 HInstruction* AddInstruction(HInstruction* instr);
856 void AddSimulate(int ast_id); 856 void AddSimulate(BailoutId ast_id);
857 857
858 // Bailout environment manipulation. 858 // Bailout environment manipulation.
859 void Push(HValue* value) { environment()->Push(value); } 859 void Push(HValue* value) { environment()->Push(value); }
860 HValue* Pop() { return environment()->Pop(); } 860 HValue* Pop() { return environment()->Pop(); }
861 861
862 void Bailout(const char* reason); 862 void Bailout(const char* reason);
863 863
864 HBasicBlock* CreateJoin(HBasicBlock* first, 864 HBasicBlock* CreateJoin(HBasicBlock* first,
865 HBasicBlock* second, 865 HBasicBlock* second,
866 int join_id); 866 BailoutId join_id);
867 867
868 TypeFeedbackOracle* oracle() const { return function_state()->oracle(); } 868 TypeFeedbackOracle* oracle() const { return function_state()->oracle(); }
869 869
870 FunctionState* function_state() const { return function_state_; } 870 FunctionState* function_state() const { return function_state_; }
871 871
872 void VisitDeclarations(ZoneList<Declaration*>* declarations); 872 void VisitDeclarations(ZoneList<Declaration*>* declarations);
873 873
874 void* operator new(size_t size, Zone* zone) { 874 void* operator new(size_t size, Zone* zone) {
875 return zone->New(static_cast<int>(size)); 875 return zone->New(static_cast<int>(size));
876 } 876 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 bool TryArgumentsAccess(Property* expr); 1027 bool TryArgumentsAccess(Property* expr);
1028 1028
1029 // Try to optimize fun.apply(receiver, arguments) pattern. 1029 // Try to optimize fun.apply(receiver, arguments) pattern.
1030 bool TryCallApply(Call* expr); 1030 bool TryCallApply(Call* expr);
1031 1031
1032 int InliningAstSize(Handle<JSFunction> target); 1032 int InliningAstSize(Handle<JSFunction> target);
1033 bool TryInline(CallKind call_kind, 1033 bool TryInline(CallKind call_kind,
1034 Handle<JSFunction> target, 1034 Handle<JSFunction> target,
1035 int arguments_count, 1035 int arguments_count,
1036 HValue* receiver, 1036 HValue* receiver,
1037 int ast_id, 1037 BailoutId ast_id,
1038 int return_id, 1038 BailoutId return_id,
1039 ReturnHandlingFlag return_handling); 1039 ReturnHandlingFlag return_handling);
1040 1040
1041 bool TryInlineCall(Call* expr, bool drop_extra = false); 1041 bool TryInlineCall(Call* expr, bool drop_extra = false);
1042 bool TryInlineConstruct(CallNew* expr, HValue* receiver); 1042 bool TryInlineConstruct(CallNew* expr, HValue* receiver);
1043 bool TryInlineGetter(Handle<JSFunction> getter, Property* prop); 1043 bool TryInlineGetter(Handle<JSFunction> getter, Property* prop);
1044 bool TryInlineBuiltinMethodCall(Call* expr, 1044 bool TryInlineBuiltinMethodCall(Call* expr,
1045 HValue* receiver, 1045 HValue* receiver,
1046 Handle<Map> receiver_map, 1046 Handle<Map> receiver_map,
1047 CheckType check_type); 1047 CheckType check_type);
1048 bool TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra); 1048 bool TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra);
1049 1049
1050 // If --trace-inlining, print a line of the inlining trace. Inlining 1050 // If --trace-inlining, print a line of the inlining trace. Inlining
1051 // succeeded if the reason string is NULL and failed if there is a 1051 // succeeded if the reason string is NULL and failed if there is a
1052 // non-NULL reason string. 1052 // non-NULL reason string.
1053 void TraceInline(Handle<JSFunction> target, 1053 void TraceInline(Handle<JSFunction> target,
1054 Handle<JSFunction> caller, 1054 Handle<JSFunction> caller,
1055 const char* failure_reason); 1055 const char* failure_reason);
1056 1056
1057 void HandleGlobalVariableAssignment(Variable* var, 1057 void HandleGlobalVariableAssignment(Variable* var,
1058 HValue* value, 1058 HValue* value,
1059 int position, 1059 int position,
1060 int ast_id); 1060 BailoutId ast_id);
1061 1061
1062 void HandlePropertyAssignment(Assignment* expr); 1062 void HandlePropertyAssignment(Assignment* expr);
1063 void HandleCompoundAssignment(Assignment* expr); 1063 void HandleCompoundAssignment(Assignment* expr);
1064 void HandlePolymorphicLoadNamedField(Property* expr, 1064 void HandlePolymorphicLoadNamedField(Property* expr,
1065 HValue* object, 1065 HValue* object,
1066 SmallMapList* types, 1066 SmallMapList* types,
1067 Handle<String> name); 1067 Handle<String> name);
1068 void HandlePolymorphicStoreNamedField(Assignment* expr, 1068 void HandlePolymorphicStoreNamedField(Assignment* expr,
1069 HValue* object, 1069 HValue* object,
1070 HValue* value, 1070 HValue* value,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 HValue* key, 1112 HValue* key,
1113 HValue* val, 1113 HValue* val,
1114 HValue* dependency, 1114 HValue* dependency,
1115 Handle<Map> map, 1115 Handle<Map> map,
1116 bool is_store); 1116 bool is_store);
1117 1117
1118 HValue* HandlePolymorphicElementAccess(HValue* object, 1118 HValue* HandlePolymorphicElementAccess(HValue* object,
1119 HValue* key, 1119 HValue* key,
1120 HValue* val, 1120 HValue* val,
1121 Expression* prop, 1121 Expression* prop,
1122 int ast_id, 1122 BailoutId ast_id,
1123 int position, 1123 int position,
1124 bool is_store, 1124 bool is_store,
1125 bool* has_side_effects); 1125 bool* has_side_effects);
1126 1126
1127 HValue* HandleKeyedElementAccess(HValue* obj, 1127 HValue* HandleKeyedElementAccess(HValue* obj,
1128 HValue* key, 1128 HValue* key,
1129 HValue* val, 1129 HValue* val,
1130 Expression* expr, 1130 Expression* expr,
1131 int ast_id, 1131 BailoutId ast_id,
1132 int position, 1132 int position,
1133 bool is_store, 1133 bool is_store,
1134 bool* has_side_effects); 1134 bool* has_side_effects);
1135 1135
1136 // Tries to find a JavaScript accessor of the given name in the prototype 1136 // Tries to find a JavaScript accessor of the given name in the prototype
1137 // chain starting at the given map. Return true iff there is one, including 1137 // chain starting at the given map. Return true iff there is one, including
1138 // the corresponding AccessorPair plus its holder (which could be null when 1138 // the corresponding AccessorPair plus its holder (which could be null when
1139 // the accessor is found directly in the given map). 1139 // the accessor is found directly in the given map).
1140 bool LookupAccessorPair(Handle<Map> map, 1140 bool LookupAccessorPair(Handle<Map> map,
1141 Handle<String> name, 1141 Handle<String> name,
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 const char* filename_; 1467 const char* filename_;
1468 HeapStringAllocator string_allocator_; 1468 HeapStringAllocator string_allocator_;
1469 StringStream trace_; 1469 StringStream trace_;
1470 int indent_; 1470 int indent_;
1471 }; 1471 };
1472 1472
1473 1473
1474 } } // namespace v8::internal 1474 } } // namespace v8::internal
1475 1475
1476 #endif // V8_HYDROGEN_H_ 1476 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698