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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 void AttachLoopInformation(); | 104 void AttachLoopInformation(); |
105 void DetachLoopInformation(); | 105 void DetachLoopInformation(); |
106 bool IsLoopHeader() const { return loop_information() != NULL; } | 106 bool IsLoopHeader() const { return loop_information() != NULL; } |
107 bool IsStartBlock() const { return block_id() == 0; } | 107 bool IsStartBlock() const { return block_id() == 0; } |
108 void PostProcessLoopHeader(IterationStatement* stmt); | 108 void PostProcessLoopHeader(IterationStatement* stmt); |
109 | 109 |
110 bool IsFinished() const { return end_ != NULL; } | 110 bool IsFinished() const { return end_ != NULL; } |
111 void AddPhi(HPhi* phi); | 111 void AddPhi(HPhi* phi); |
112 void RemovePhi(HPhi* phi); | 112 void RemovePhi(HPhi* phi); |
113 void AddInstruction(HInstruction* instr, int position); | 113 void AddInstruction(HInstruction* instr, HSourcePosition position); |
114 bool Dominates(HBasicBlock* other) const; | 114 bool Dominates(HBasicBlock* other) const; |
115 bool EqualToOrDominates(HBasicBlock* other) const; | 115 bool EqualToOrDominates(HBasicBlock* other) const; |
116 int LoopNestingDepth() const; | 116 int LoopNestingDepth() const; |
117 | 117 |
118 void SetInitialEnvironment(HEnvironment* env); | 118 void SetInitialEnvironment(HEnvironment* env); |
119 void ClearEnvironment() { | 119 void ClearEnvironment() { |
120 ASSERT(IsFinished()); | 120 ASSERT(IsFinished()); |
121 ASSERT(end()->SuccessorCount() == 0); | 121 ASSERT(end()->SuccessorCount() == 0); |
122 last_environment_ = NULL; | 122 last_environment_ = NULL; |
123 } | 123 } |
124 bool HasEnvironment() const { return last_environment_ != NULL; } | 124 bool HasEnvironment() const { return last_environment_ != NULL; } |
125 void UpdateEnvironment(HEnvironment* env); | 125 void UpdateEnvironment(HEnvironment* env); |
126 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } | 126 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } |
127 | 127 |
128 void set_parent_loop_header(HBasicBlock* block) { | 128 void set_parent_loop_header(HBasicBlock* block) { |
129 ASSERT(parent_loop_header_ == NULL); | 129 ASSERT(parent_loop_header_ == NULL); |
130 parent_loop_header_ = block; | 130 parent_loop_header_ = block; |
131 } | 131 } |
132 | 132 |
133 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } | 133 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } |
134 | 134 |
135 void SetJoinId(BailoutId ast_id); | 135 void SetJoinId(BailoutId ast_id); |
136 | 136 |
137 int PredecessorIndexOf(HBasicBlock* predecessor) const; | 137 int PredecessorIndexOf(HBasicBlock* predecessor) const; |
138 HPhi* AddNewPhi(int merged_index); | 138 HPhi* AddNewPhi(int merged_index); |
139 HSimulate* AddNewSimulate(BailoutId ast_id, | 139 HSimulate* AddNewSimulate(BailoutId ast_id, |
140 int position, | 140 HSourcePosition position, |
141 RemovableSimulate removable = FIXED_SIMULATE) { | 141 RemovableSimulate removable = FIXED_SIMULATE) { |
142 HSimulate* instr = CreateSimulate(ast_id, removable); | 142 HSimulate* instr = CreateSimulate(ast_id, removable); |
143 AddInstruction(instr, position); | 143 AddInstruction(instr, position); |
144 return instr; | 144 return instr; |
145 } | 145 } |
146 void AssignCommonDominator(HBasicBlock* other); | 146 void AssignCommonDominator(HBasicBlock* other); |
147 void AssignLoopSuccessorDominators(); | 147 void AssignLoopSuccessorDominators(); |
148 | 148 |
149 // If a target block is tagged as an inline function return, all | 149 // If a target block is tagged as an inline function return, all |
150 // predecessors should contain the inlined exit sequence: | 150 // predecessors should contain the inlined exit sequence: |
(...skipping 28 matching lines...) Expand all Loading... |
179 inline Zone* zone() const; | 179 inline Zone* zone() const; |
180 | 180 |
181 #ifdef DEBUG | 181 #ifdef DEBUG |
182 void Verify(); | 182 void Verify(); |
183 #endif | 183 #endif |
184 | 184 |
185 protected: | 185 protected: |
186 friend class HGraphBuilder; | 186 friend class HGraphBuilder; |
187 | 187 |
188 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); | 188 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); |
189 void Finish(HControlInstruction* last, int position); | 189 void Finish(HControlInstruction* last, HSourcePosition position); |
190 void FinishExit(HControlInstruction* instruction, int position); | 190 void FinishExit(HControlInstruction* instruction, HSourcePosition position); |
191 void Goto(HBasicBlock* block, | 191 void Goto(HBasicBlock* block, |
192 int position, | 192 HSourcePosition position, |
193 FunctionState* state = NULL, | 193 FunctionState* state = NULL, |
194 bool add_simulate = true); | 194 bool add_simulate = true); |
195 void GotoNoSimulate(HBasicBlock* block, int position) { | 195 void GotoNoSimulate(HBasicBlock* block, HSourcePosition position) { |
196 Goto(block, position, NULL, false); | 196 Goto(block, position, NULL, false); |
197 } | 197 } |
198 | 198 |
199 // Add the inlined function exit sequence, adding an HLeaveInlined | 199 // Add the inlined function exit sequence, adding an HLeaveInlined |
200 // instruction and updating the bailout environment. | 200 // instruction and updating the bailout environment. |
201 void AddLeaveInlined(HValue* return_value, | 201 void AddLeaveInlined(HValue* return_value, |
202 FunctionState* state, | 202 FunctionState* state, |
203 int position); | 203 HSourcePosition position); |
204 | 204 |
205 private: | 205 private: |
206 void RegisterPredecessor(HBasicBlock* pred); | 206 void RegisterPredecessor(HBasicBlock* pred); |
207 void AddDominatedBlock(HBasicBlock* block); | 207 void AddDominatedBlock(HBasicBlock* block); |
208 | 208 |
209 int block_id_; | 209 int block_id_; |
210 HGraph* graph_; | 210 HGraph* graph_; |
211 ZoneList<HPhi*> phis_; | 211 ZoneList<HPhi*> phis_; |
212 HInstruction* first_; | 212 HInstruction* first_; |
213 HInstruction* last_; | 213 HInstruction* last_; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 if (uint32_instructions_ == NULL) { | 464 if (uint32_instructions_ == NULL) { |
465 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); | 465 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); |
466 } | 466 } |
467 uint32_instructions_->Add(instr, zone()); | 467 uint32_instructions_->Add(instr, zone()); |
468 } | 468 } |
469 | 469 |
470 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } | 470 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } |
471 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } | 471 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } |
472 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } | 472 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } |
473 | 473 |
| 474 // If we are tracking source positions then this function assigns a unique |
| 475 // identifier to each inlining and dumps function source if it was inlined |
| 476 // for the first time during the current optimization. |
| 477 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
| 478 HSourcePosition position); |
| 479 |
| 480 // Converts given HSourcePosition to the absolute offset from the start of |
| 481 // the corresponding script. |
| 482 int SourcePositionToScriptPosition(HSourcePosition position); |
| 483 |
474 private: | 484 private: |
475 HConstant* ReinsertConstantIfNecessary(HConstant* constant); | 485 HConstant* ReinsertConstantIfNecessary(HConstant* constant); |
476 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, | 486 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, |
477 int32_t integer_value); | 487 int32_t integer_value); |
478 | 488 |
479 template<class Phase> | 489 template<class Phase> |
480 void Run() { | 490 void Run() { |
481 Phase phase(this); | 491 Phase phase(this); |
482 phase.Run(); | 492 phase.Run(); |
483 } | 493 } |
(...skipping 25 matching lines...) Expand all Loading... |
509 Zone* zone_; | 519 Zone* zone_; |
510 | 520 |
511 bool is_recursive_; | 521 bool is_recursive_; |
512 bool use_optimistic_licm_; | 522 bool use_optimistic_licm_; |
513 bool depends_on_empty_array_proto_elements_; | 523 bool depends_on_empty_array_proto_elements_; |
514 int type_change_checksum_; | 524 int type_change_checksum_; |
515 int maximum_environment_size_; | 525 int maximum_environment_size_; |
516 int no_side_effects_scope_count_; | 526 int no_side_effects_scope_count_; |
517 bool disallow_adding_new_values_; | 527 bool disallow_adding_new_values_; |
518 | 528 |
| 529 class InlinedFunctionInfo { |
| 530 public: |
| 531 explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared) |
| 532 : shared_(shared), start_position_(shared->start_position()) { |
| 533 } |
| 534 |
| 535 Handle<SharedFunctionInfo> shared() const { return shared_; } |
| 536 int start_position() const { return start_position_; } |
| 537 |
| 538 private: |
| 539 Handle<SharedFunctionInfo> shared_; |
| 540 int start_position_; |
| 541 }; |
| 542 |
| 543 int next_inline_id_; |
| 544 ZoneList<InlinedFunctionInfo> inlined_functions_; |
| 545 |
519 DISALLOW_COPY_AND_ASSIGN(HGraph); | 546 DISALLOW_COPY_AND_ASSIGN(HGraph); |
520 }; | 547 }; |
521 | 548 |
522 | 549 |
523 Zone* HBasicBlock::zone() const { return graph_->zone(); } | 550 Zone* HBasicBlock::zone() const { return graph_->zone(); } |
524 | 551 |
525 | 552 |
526 // Type of stack frame an environment might refer to. | 553 // Type of stack frame an environment might refer to. |
527 enum FrameType { | 554 enum FrameType { |
528 JS_FUNCTION, | 555 JS_FUNCTION, |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 Expression* condition_; | 902 Expression* condition_; |
876 HBasicBlock* if_true_; | 903 HBasicBlock* if_true_; |
877 HBasicBlock* if_false_; | 904 HBasicBlock* if_false_; |
878 }; | 905 }; |
879 | 906 |
880 | 907 |
881 class FunctionState V8_FINAL { | 908 class FunctionState V8_FINAL { |
882 public: | 909 public: |
883 FunctionState(HOptimizedGraphBuilder* owner, | 910 FunctionState(HOptimizedGraphBuilder* owner, |
884 CompilationInfo* info, | 911 CompilationInfo* info, |
885 InliningKind inlining_kind); | 912 InliningKind inlining_kind, |
| 913 int inlining_id); |
886 ~FunctionState(); | 914 ~FunctionState(); |
887 | 915 |
888 CompilationInfo* compilation_info() { return compilation_info_; } | 916 CompilationInfo* compilation_info() { return compilation_info_; } |
889 AstContext* call_context() { return call_context_; } | 917 AstContext* call_context() { return call_context_; } |
890 InliningKind inlining_kind() const { return inlining_kind_; } | 918 InliningKind inlining_kind() const { return inlining_kind_; } |
891 HBasicBlock* function_return() { return function_return_; } | 919 HBasicBlock* function_return() { return function_return_; } |
892 TestContext* test_context() { return test_context_; } | 920 TestContext* test_context() { return test_context_; } |
893 void ClearInlinedTestContext() { | 921 void ClearInlinedTestContext() { |
894 delete test_context_; | 922 delete test_context_; |
895 test_context_ = NULL; | 923 test_context_ = NULL; |
896 } | 924 } |
897 | 925 |
898 FunctionState* outer() { return outer_; } | 926 FunctionState* outer() { return outer_; } |
899 | 927 |
900 HEnterInlined* entry() { return entry_; } | 928 HEnterInlined* entry() { return entry_; } |
901 void set_entry(HEnterInlined* entry) { entry_ = entry; } | 929 void set_entry(HEnterInlined* entry) { entry_ = entry; } |
902 | 930 |
903 HArgumentsObject* arguments_object() { return arguments_object_; } | 931 HArgumentsObject* arguments_object() { return arguments_object_; } |
904 void set_arguments_object(HArgumentsObject* arguments_object) { | 932 void set_arguments_object(HArgumentsObject* arguments_object) { |
905 arguments_object_ = arguments_object; | 933 arguments_object_ = arguments_object; |
906 } | 934 } |
907 | 935 |
908 HArgumentsElements* arguments_elements() { return arguments_elements_; } | 936 HArgumentsElements* arguments_elements() { return arguments_elements_; } |
909 void set_arguments_elements(HArgumentsElements* arguments_elements) { | 937 void set_arguments_elements(HArgumentsElements* arguments_elements) { |
910 arguments_elements_ = arguments_elements; | 938 arguments_elements_ = arguments_elements; |
911 } | 939 } |
912 | 940 |
913 bool arguments_pushed() { return arguments_elements() != NULL; } | 941 bool arguments_pushed() { return arguments_elements() != NULL; } |
914 | 942 |
| 943 int inlining_id() const { return inlining_id_; } |
| 944 |
915 private: | 945 private: |
916 HOptimizedGraphBuilder* owner_; | 946 HOptimizedGraphBuilder* owner_; |
917 | 947 |
918 CompilationInfo* compilation_info_; | 948 CompilationInfo* compilation_info_; |
919 | 949 |
920 // During function inlining, expression context of the call being | 950 // During function inlining, expression context of the call being |
921 // inlined. NULL when not inlining. | 951 // inlined. NULL when not inlining. |
922 AstContext* call_context_; | 952 AstContext* call_context_; |
923 | 953 |
924 // The kind of call which is currently being inlined. | 954 // The kind of call which is currently being inlined. |
925 InliningKind inlining_kind_; | 955 InliningKind inlining_kind_; |
926 | 956 |
927 // When inlining in an effect or value context, this is the return block. | 957 // When inlining in an effect or value context, this is the return block. |
928 // It is NULL otherwise. When inlining in a test context, there are a | 958 // It is NULL otherwise. When inlining in a test context, there are a |
929 // pair of return blocks in the context. When not inlining, there is no | 959 // pair of return blocks in the context. When not inlining, there is no |
930 // local return point. | 960 // local return point. |
931 HBasicBlock* function_return_; | 961 HBasicBlock* function_return_; |
932 | 962 |
933 // When inlining a call in a test context, a context containing a pair of | 963 // When inlining a call in a test context, a context containing a pair of |
934 // return blocks. NULL in all other cases. | 964 // return blocks. NULL in all other cases. |
935 TestContext* test_context_; | 965 TestContext* test_context_; |
936 | 966 |
937 // When inlining HEnterInlined instruction corresponding to the function | 967 // When inlining HEnterInlined instruction corresponding to the function |
938 // entry. | 968 // entry. |
939 HEnterInlined* entry_; | 969 HEnterInlined* entry_; |
940 | 970 |
941 HArgumentsObject* arguments_object_; | 971 HArgumentsObject* arguments_object_; |
942 HArgumentsElements* arguments_elements_; | 972 HArgumentsElements* arguments_elements_; |
943 | 973 |
| 974 int inlining_id_; |
| 975 HSourcePosition outer_source_position_; |
| 976 |
944 FunctionState* outer_; | 977 FunctionState* outer_; |
945 }; | 978 }; |
946 | 979 |
947 | 980 |
948 class HIfContinuation V8_FINAL { | 981 class HIfContinuation V8_FINAL { |
949 public: | 982 public: |
950 HIfContinuation() | 983 HIfContinuation() |
951 : continuation_captured_(false), | 984 : continuation_captured_(false), |
952 true_branch_(NULL), | 985 true_branch_(NULL), |
953 false_branch_(NULL) {} | 986 false_branch_(NULL) {} |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 PretenureFlag pretenure_flag_; | 1050 PretenureFlag pretenure_flag_; |
1018 }; | 1051 }; |
1019 | 1052 |
1020 | 1053 |
1021 class HGraphBuilder { | 1054 class HGraphBuilder { |
1022 public: | 1055 public: |
1023 explicit HGraphBuilder(CompilationInfo* info) | 1056 explicit HGraphBuilder(CompilationInfo* info) |
1024 : info_(info), | 1057 : info_(info), |
1025 graph_(NULL), | 1058 graph_(NULL), |
1026 current_block_(NULL), | 1059 current_block_(NULL), |
1027 position_(RelocInfo::kNoPosition) {} | 1060 position_(HSourcePosition::Unknown()), |
| 1061 start_position_(0) {} |
1028 virtual ~HGraphBuilder() {} | 1062 virtual ~HGraphBuilder() {} |
1029 | 1063 |
1030 HBasicBlock* current_block() const { return current_block_; } | 1064 HBasicBlock* current_block() const { return current_block_; } |
1031 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 1065 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
1032 HEnvironment* environment() const { | 1066 HEnvironment* environment() const { |
1033 return current_block()->last_environment(); | 1067 return current_block()->last_environment(); |
1034 } | 1068 } |
1035 Zone* zone() const { return info_->zone(); } | 1069 Zone* zone() const { return info_->zone(); } |
1036 HGraph* graph() const { return graph_; } | 1070 HGraph* graph() const { return graph_; } |
1037 Isolate* isolate() const { return graph_->isolate(); } | 1071 Isolate* isolate() const { return graph_->isolate(); } |
1038 CompilationInfo* top_info() { return info_; } | 1072 CompilationInfo* top_info() { return info_; } |
1039 | 1073 |
1040 HGraph* CreateGraph(); | 1074 HGraph* CreateGraph(); |
1041 | 1075 |
1042 // Bailout environment manipulation. | 1076 // Bailout environment manipulation. |
1043 void Push(HValue* value) { environment()->Push(value); } | 1077 void Push(HValue* value) { environment()->Push(value); } |
1044 HValue* Pop() { return environment()->Pop(); } | 1078 HValue* Pop() { return environment()->Pop(); } |
1045 | 1079 |
1046 virtual HValue* context() = 0; | 1080 virtual HValue* context() = 0; |
1047 | 1081 |
1048 // Adding instructions. | 1082 // Adding instructions. |
1049 HInstruction* AddInstruction(HInstruction* instr); | 1083 HInstruction* AddInstruction(HInstruction* instr); |
1050 void FinishCurrentBlock(HControlInstruction* last); | 1084 void FinishCurrentBlock(HControlInstruction* last); |
1051 void FinishExitCurrentBlock(HControlInstruction* instruction); | 1085 void FinishExitCurrentBlock(HControlInstruction* instruction); |
1052 | 1086 |
1053 void Goto(HBasicBlock* from, | 1087 void Goto(HBasicBlock* from, |
1054 HBasicBlock* target, | 1088 HBasicBlock* target, |
1055 FunctionState* state = NULL, | 1089 FunctionState* state = NULL, |
1056 bool add_simulate = true) { | 1090 bool add_simulate = true) { |
1057 from->Goto(target, position_, state, add_simulate); | 1091 from->Goto(target, source_position(), state, add_simulate); |
1058 } | 1092 } |
1059 void Goto(HBasicBlock* target, | 1093 void Goto(HBasicBlock* target, |
1060 FunctionState* state = NULL, | 1094 FunctionState* state = NULL, |
1061 bool add_simulate = true) { | 1095 bool add_simulate = true) { |
1062 Goto(current_block(), target, state, add_simulate); | 1096 Goto(current_block(), target, state, add_simulate); |
1063 } | 1097 } |
1064 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) { | 1098 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) { |
1065 Goto(from, target, NULL, false); | 1099 Goto(from, target, NULL, false); |
1066 } | 1100 } |
1067 void GotoNoSimulate(HBasicBlock* target) { | 1101 void GotoNoSimulate(HBasicBlock* target) { |
1068 Goto(target, NULL, false); | 1102 Goto(target, NULL, false); |
1069 } | 1103 } |
1070 void AddLeaveInlined(HBasicBlock* block, | 1104 void AddLeaveInlined(HBasicBlock* block, |
1071 HValue* return_value, | 1105 HValue* return_value, |
1072 FunctionState* state) { | 1106 FunctionState* state) { |
1073 block->AddLeaveInlined(return_value, state, position_); | 1107 block->AddLeaveInlined(return_value, state, source_position()); |
1074 } | 1108 } |
1075 void AddLeaveInlined(HValue* return_value, FunctionState* state) { | 1109 void AddLeaveInlined(HValue* return_value, FunctionState* state) { |
1076 return AddLeaveInlined(current_block(), return_value, state); | 1110 return AddLeaveInlined(current_block(), return_value, state); |
1077 } | 1111 } |
1078 | 1112 |
1079 template<class I> | 1113 template<class I> |
1080 HInstruction* NewUncasted() { return I::New(zone(), context()); } | 1114 HInstruction* NewUncasted() { return I::New(zone(), context()); } |
1081 | 1115 |
1082 template<class I> | 1116 template<class I> |
1083 I* New() { return I::New(zone(), context()); } | 1117 I* New() { return I::New(zone(), context()); } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 } | 1303 } |
1270 | 1304 |
1271 template<class I, class P1, class P2, class P3, class P4, | 1305 template<class I, class P1, class P2, class P3, class P4, |
1272 class P5, class P6, class P7, class P8> | 1306 class P5, class P6, class P7, class P8> |
1273 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { | 1307 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
1274 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8)); | 1308 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8)); |
1275 } | 1309 } |
1276 | 1310 |
1277 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); | 1311 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); |
1278 | 1312 |
1279 int position() const { return position_; } | |
1280 | |
1281 protected: | 1313 protected: |
1282 virtual bool BuildGraph() = 0; | 1314 virtual bool BuildGraph() = 0; |
1283 | 1315 |
1284 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1316 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
1285 HBasicBlock* CreateLoopHeaderBlock(); | 1317 HBasicBlock* CreateLoopHeaderBlock(); |
1286 | 1318 |
1287 HValue* BuildCheckHeapObject(HValue* object); | 1319 HValue* BuildCheckHeapObject(HValue* object); |
1288 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | 1320 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
1289 HValue* BuildCheckString(HValue* string); | 1321 HValue* BuildCheckString(HValue* string); |
1290 HValue* BuildWrapReceiver(HValue* object, HValue* function); | 1322 HValue* BuildWrapReceiver(HValue* object, HValue* function); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, | 1804 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, |
1773 Handle<JSObject> holder); | 1805 Handle<JSObject> holder); |
1774 | 1806 |
1775 HInstruction* BuildGetNativeContext(HValue* closure); | 1807 HInstruction* BuildGetNativeContext(HValue* closure); |
1776 HInstruction* BuildGetNativeContext(); | 1808 HInstruction* BuildGetNativeContext(); |
1777 HInstruction* BuildGetArrayFunction(); | 1809 HInstruction* BuildGetArrayFunction(); |
1778 | 1810 |
1779 protected: | 1811 protected: |
1780 void SetSourcePosition(int position) { | 1812 void SetSourcePosition(int position) { |
1781 ASSERT(position != RelocInfo::kNoPosition); | 1813 ASSERT(position != RelocInfo::kNoPosition); |
| 1814 position_.set_position(position - start_position_); |
| 1815 } |
| 1816 |
| 1817 void EnterInlinedSource(int start_position, int id) { |
| 1818 if (FLAG_hydrogen_track_positions) { |
| 1819 start_position_ = start_position; |
| 1820 position_.set_inlining_id(id); |
| 1821 } |
| 1822 } |
| 1823 |
| 1824 // Convert the given absolute offset from the start of the script to |
| 1825 // the HSourcePosition assuming that this position corresponds to the |
| 1826 // same function as current position_. |
| 1827 HSourcePosition ScriptPositionToSourcePosition(int position) { |
| 1828 HSourcePosition pos = position_; |
| 1829 pos.set_position(position - start_position_); |
| 1830 return pos; |
| 1831 } |
| 1832 |
| 1833 HSourcePosition source_position() { return position_; } |
| 1834 void set_source_position(HSourcePosition position) { |
1782 position_ = position; | 1835 position_ = position; |
1783 } | 1836 } |
1784 | 1837 |
1785 template <typename ViewClass> | 1838 template <typename ViewClass> |
1786 void BuildArrayBufferViewInitialization(HValue* obj, | 1839 void BuildArrayBufferViewInitialization(HValue* obj, |
1787 HValue* buffer, | 1840 HValue* buffer, |
1788 HValue* byte_offset, | 1841 HValue* byte_offset, |
1789 HValue* byte_length); | 1842 HValue* byte_length); |
1790 | 1843 |
1791 private: | 1844 private: |
(...skipping 10 matching lines...) Expand all Loading... |
1802 HBasicBlock* continuation); | 1855 HBasicBlock* continuation); |
1803 | 1856 |
1804 template <class I> | 1857 template <class I> |
1805 I* AddInstructionTyped(I* instr) { | 1858 I* AddInstructionTyped(I* instr) { |
1806 return I::cast(AddInstruction(instr)); | 1859 return I::cast(AddInstruction(instr)); |
1807 } | 1860 } |
1808 | 1861 |
1809 CompilationInfo* info_; | 1862 CompilationInfo* info_; |
1810 HGraph* graph_; | 1863 HGraph* graph_; |
1811 HBasicBlock* current_block_; | 1864 HBasicBlock* current_block_; |
1812 int position_; | 1865 HSourcePosition position_; |
| 1866 int start_position_; |
1813 }; | 1867 }; |
1814 | 1868 |
1815 | 1869 |
1816 template<> | 1870 template<> |
1817 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( | 1871 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( |
1818 const char* reason, Deoptimizer::BailoutType type) { | 1872 const char* reason, Deoptimizer::BailoutType type) { |
1819 if (type == Deoptimizer::SOFT) { | 1873 if (type == Deoptimizer::SOFT) { |
1820 isolate()->counters()->soft_deopts_requested()->Increment(); | 1874 isolate()->counters()->soft_deopts_requested()->Increment(); |
1821 if (FLAG_always_opt) return NULL; | 1875 if (FLAG_always_opt) return NULL; |
1822 } | 1876 } |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2206 | 2260 |
2207 HValue* ImplicitReceiverFor(HValue* function, | 2261 HValue* ImplicitReceiverFor(HValue* function, |
2208 Handle<JSFunction> target); | 2262 Handle<JSFunction> target); |
2209 | 2263 |
2210 int InliningAstSize(Handle<JSFunction> target); | 2264 int InliningAstSize(Handle<JSFunction> target); |
2211 bool TryInline(Handle<JSFunction> target, | 2265 bool TryInline(Handle<JSFunction> target, |
2212 int arguments_count, | 2266 int arguments_count, |
2213 HValue* implicit_return_value, | 2267 HValue* implicit_return_value, |
2214 BailoutId ast_id, | 2268 BailoutId ast_id, |
2215 BailoutId return_id, | 2269 BailoutId return_id, |
2216 InliningKind inlining_kind); | 2270 InliningKind inlining_kind, |
| 2271 HSourcePosition position); |
2217 | 2272 |
2218 bool TryInlineCall(Call* expr); | 2273 bool TryInlineCall(Call* expr); |
2219 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); | 2274 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); |
2220 bool TryInlineGetter(Handle<JSFunction> getter, | 2275 bool TryInlineGetter(Handle<JSFunction> getter, |
2221 Handle<Map> receiver_map, | 2276 Handle<Map> receiver_map, |
2222 BailoutId ast_id, | 2277 BailoutId ast_id, |
2223 BailoutId return_id); | 2278 BailoutId return_id); |
2224 bool TryInlineSetter(Handle<JSFunction> setter, | 2279 bool TryInlineSetter(Handle<JSFunction> setter, |
2225 Handle<Map> receiver_map, | 2280 Handle<Map> receiver_map, |
2226 BailoutId id, | 2281 BailoutId id, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2416 Handle<String> check); | 2471 Handle<String> check); |
2417 void HandleLiteralCompareNil(CompareOperation* expr, | 2472 void HandleLiteralCompareNil(CompareOperation* expr, |
2418 Expression* sub_expr, | 2473 Expression* sub_expr, |
2419 NilValue nil); | 2474 NilValue nil); |
2420 HControlInstruction* BuildCompareInstruction(Token::Value op, | 2475 HControlInstruction* BuildCompareInstruction(Token::Value op, |
2421 HValue* left, | 2476 HValue* left, |
2422 HValue* right, | 2477 HValue* right, |
2423 Type* left_type, | 2478 Type* left_type, |
2424 Type* right_type, | 2479 Type* right_type, |
2425 Type* combined_type, | 2480 Type* combined_type, |
2426 int left_position, | 2481 HSourcePosition left_position, |
2427 int right_position, | 2482 HSourcePosition right_position, |
2428 BailoutId bailout_id); | 2483 BailoutId bailout_id); |
2429 | 2484 |
2430 HInstruction* BuildStringCharCodeAt(HValue* string, | 2485 HInstruction* BuildStringCharCodeAt(HValue* string, |
2431 HValue* index); | 2486 HValue* index); |
2432 | 2487 |
2433 enum PushBeforeSimulateBehavior { | 2488 enum PushBeforeSimulateBehavior { |
2434 PUSH_BEFORE_SIMULATE, | 2489 PUSH_BEFORE_SIMULATE, |
2435 NO_PUSH_BEFORE_SIMULATE | 2490 NO_PUSH_BEFORE_SIMULATE |
2436 }; | 2491 }; |
2437 HValue* BuildBinaryOperation( | 2492 HValue* BuildBinaryOperation( |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2739 } | 2794 } |
2740 | 2795 |
2741 private: | 2796 private: |
2742 HGraphBuilder* builder_; | 2797 HGraphBuilder* builder_; |
2743 }; | 2798 }; |
2744 | 2799 |
2745 | 2800 |
2746 } } // namespace v8::internal | 2801 } } // namespace v8::internal |
2747 | 2802 |
2748 #endif // V8_HYDROGEN_H_ | 2803 #endif // V8_HYDROGEN_H_ |
OLD | NEW |