OLD | NEW |
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(BailoutId 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(BailoutId ast_id) { AddInstruction(CreateSimulate(ast_id)); } | 128 void AddSimulate(BailoutId ast_id, RemovableSimulate removable = FIXED) { |
| 129 AddInstruction(CreateSimulate(ast_id, removable)); |
| 130 } |
129 void AssignCommonDominator(HBasicBlock* other); | 131 void AssignCommonDominator(HBasicBlock* other); |
130 void AssignLoopSuccessorDominators(); | 132 void AssignLoopSuccessorDominators(); |
131 | 133 |
132 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) { | 134 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) { |
133 FinishExit(CreateDeoptimize(has_uses)); | 135 FinishExit(CreateDeoptimize(has_uses)); |
134 } | 136 } |
135 | 137 |
136 // Add the inlined function exit sequence, adding an HLeaveInlined | 138 // Add the inlined function exit sequence, adding an HLeaveInlined |
137 // instruction and updating the bailout environment. | 139 // instruction and updating the bailout environment. |
138 void AddLeaveInlined(HValue* return_value, FunctionState* state); | 140 void AddLeaveInlined(HValue* return_value, FunctionState* state); |
(...skipping 20 matching lines...) Expand all Loading... |
159 inline Zone* zone() const; | 161 inline Zone* zone() const; |
160 | 162 |
161 #ifdef DEBUG | 163 #ifdef DEBUG |
162 void Verify(); | 164 void Verify(); |
163 #endif | 165 #endif |
164 | 166 |
165 private: | 167 private: |
166 void RegisterPredecessor(HBasicBlock* pred); | 168 void RegisterPredecessor(HBasicBlock* pred); |
167 void AddDominatedBlock(HBasicBlock* block); | 169 void AddDominatedBlock(HBasicBlock* block); |
168 | 170 |
169 HSimulate* CreateSimulate(BailoutId ast_id); | 171 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); |
170 HDeoptimize* CreateDeoptimize(HDeoptimize::UseEnvironment has_uses); | 172 HDeoptimize* CreateDeoptimize(HDeoptimize::UseEnvironment has_uses); |
171 | 173 |
172 int block_id_; | 174 int block_id_; |
173 HGraph* graph_; | 175 HGraph* graph_; |
174 ZoneList<HPhi*> phis_; | 176 ZoneList<HPhi*> phis_; |
175 HInstruction* first_; | 177 HInstruction* first_; |
176 HInstruction* last_; | 178 HInstruction* last_; |
177 HControlInstruction* end_; | 179 HControlInstruction* end_; |
178 HLoopInformation* loop_information_; | 180 HLoopInformation* loop_information_; |
179 ZoneList<HBasicBlock*> predecessors_; | 181 ZoneList<HBasicBlock*> predecessors_; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 Zone* zone() const { return zone_; } | 250 Zone* zone() const { return zone_; } |
249 CompilationInfo* info() const { return info_; } | 251 CompilationInfo* info() const { return info_; } |
250 | 252 |
251 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } | 253 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } |
252 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } | 254 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } |
253 HBasicBlock* entry_block() const { return entry_block_; } | 255 HBasicBlock* entry_block() const { return entry_block_; } |
254 HEnvironment* start_environment() const { return start_environment_; } | 256 HEnvironment* start_environment() const { return start_environment_; } |
255 | 257 |
256 void InitializeInferredTypes(); | 258 void InitializeInferredTypes(); |
257 void InsertTypeConversions(); | 259 void InsertTypeConversions(); |
| 260 void MergeRemovableSimulates(); |
258 void InsertRepresentationChanges(); | 261 void InsertRepresentationChanges(); |
259 void MarkDeoptimizeOnUndefined(); | 262 void MarkDeoptimizeOnUndefined(); |
260 void ComputeMinusZeroChecks(); | 263 void ComputeMinusZeroChecks(); |
261 void ComputeSafeUint32Operations(); | 264 void ComputeSafeUint32Operations(); |
262 bool ProcessArgumentsObject(); | 265 bool ProcessArgumentsObject(); |
263 void EliminateRedundantPhis(); | 266 void EliminateRedundantPhis(); |
264 void EliminateUnreachablePhis(); | 267 void EliminateUnreachablePhis(); |
265 void Canonicalize(); | 268 void Canonicalize(); |
266 void OrderBlocks(); | 269 void OrderBlocks(); |
267 void AssignDominators(); | 270 void AssignDominators(); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 int local_count_; | 608 int local_count_; |
606 HEnvironment* outer_; | 609 HEnvironment* outer_; |
607 HEnterInlined* entry_; | 610 HEnterInlined* entry_; |
608 int pop_count_; | 611 int pop_count_; |
609 int push_count_; | 612 int push_count_; |
610 BailoutId ast_id_; | 613 BailoutId ast_id_; |
611 Zone* zone_; | 614 Zone* zone_; |
612 }; | 615 }; |
613 | 616 |
614 | 617 |
| 618 class HInferRepresentation BASE_EMBEDDED { |
| 619 public: |
| 620 explicit HInferRepresentation(HGraph* graph) |
| 621 : graph_(graph), |
| 622 worklist_(8, graph->zone()), |
| 623 in_worklist_(graph->GetMaximumValueID(), graph->zone()) { } |
| 624 |
| 625 void Analyze(); |
| 626 void AddToWorklist(HValue* current); |
| 627 |
| 628 private: |
| 629 Zone* zone() const { return graph_->zone(); } |
| 630 |
| 631 HGraph* graph_; |
| 632 ZoneList<HValue*> worklist_; |
| 633 BitVector in_worklist_; |
| 634 }; |
| 635 |
| 636 |
615 class HGraphBuilder; | 637 class HGraphBuilder; |
616 | 638 |
617 enum ArgumentsAllowedFlag { | 639 enum ArgumentsAllowedFlag { |
618 ARGUMENTS_NOT_ALLOWED, | 640 ARGUMENTS_NOT_ALLOWED, |
619 ARGUMENTS_ALLOWED | 641 ARGUMENTS_ALLOWED |
620 }; | 642 }; |
621 | 643 |
622 // This class is not BASE_EMBEDDED because our inlining implementation uses | 644 // This class is not BASE_EMBEDDED because our inlining implementation uses |
623 // new and delete. | 645 // new and delete. |
624 class AstContext { | 646 class AstContext { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 HBasicBlock* current_block() const { return current_block_; } | 894 HBasicBlock* current_block() const { return current_block_; } |
873 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 895 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
874 HEnvironment* environment() const { | 896 HEnvironment* environment() const { |
875 return current_block()->last_environment(); | 897 return current_block()->last_environment(); |
876 } | 898 } |
877 | 899 |
878 bool inline_bailout() { return inline_bailout_; } | 900 bool inline_bailout() { return inline_bailout_; } |
879 | 901 |
880 // Adding instructions. | 902 // Adding instructions. |
881 HInstruction* AddInstruction(HInstruction* instr); | 903 HInstruction* AddInstruction(HInstruction* instr); |
882 void AddSimulate(BailoutId ast_id); | 904 void AddSimulate(BailoutId ast_id, RemovableSimulate removable = FIXED); |
883 | 905 |
884 // Bailout environment manipulation. | 906 // Bailout environment manipulation. |
885 void Push(HValue* value) { environment()->Push(value); } | 907 void Push(HValue* value) { environment()->Push(value); } |
886 HValue* Pop() { return environment()->Pop(); } | 908 HValue* Pop() { return environment()->Pop(); } |
887 | 909 |
888 void Bailout(const char* reason); | 910 void Bailout(const char* reason); |
889 | 911 |
890 HBasicBlock* CreateJoin(HBasicBlock* first, | 912 HBasicBlock* CreateJoin(HBasicBlock* first, |
891 HBasicBlock* second, | 913 HBasicBlock* second, |
892 BailoutId join_id); | 914 BailoutId join_id); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 void VisitExpressions(ZoneList<Expression*>* exprs); | 1039 void VisitExpressions(ZoneList<Expression*>* exprs); |
1018 | 1040 |
1019 void AddPhi(HPhi* phi); | 1041 void AddPhi(HPhi* phi); |
1020 | 1042 |
1021 void PushAndAdd(HInstruction* instr); | 1043 void PushAndAdd(HInstruction* instr); |
1022 | 1044 |
1023 // Remove the arguments from the bailout environment and emit instructions | 1045 // Remove the arguments from the bailout environment and emit instructions |
1024 // to push them as outgoing parameters. | 1046 // to push them as outgoing parameters. |
1025 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); | 1047 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); |
1026 | 1048 |
1027 void TraceRepresentation(Token::Value op, | |
1028 TypeInfo info, | |
1029 HValue* value, | |
1030 Representation rep); | |
1031 static Representation ToRepresentation(TypeInfo info); | 1049 static Representation ToRepresentation(TypeInfo info); |
1032 | 1050 |
1033 void SetUpScope(Scope* scope); | 1051 void SetUpScope(Scope* scope); |
1034 virtual void VisitStatements(ZoneList<Statement*>* statements); | 1052 virtual void VisitStatements(ZoneList<Statement*>* statements); |
1035 | 1053 |
1036 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 1054 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
1037 AST_NODE_LIST(DECLARE_VISIT) | 1055 AST_NODE_LIST(DECLARE_VISIT) |
1038 #undef DECLARE_VISIT | 1056 #undef DECLARE_VISIT |
1039 | 1057 |
1040 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1058 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 const char* filename_; | 1508 const char* filename_; |
1491 HeapStringAllocator string_allocator_; | 1509 HeapStringAllocator string_allocator_; |
1492 StringStream trace_; | 1510 StringStream trace_; |
1493 int indent_; | 1511 int indent_; |
1494 }; | 1512 }; |
1495 | 1513 |
1496 | 1514 |
1497 } } // namespace v8::internal | 1515 } } // namespace v8::internal |
1498 | 1516 |
1499 #endif // V8_HYDROGEN_H_ | 1517 #endif // V8_HYDROGEN_H_ |
OLD | NEW |