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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 int block_id() const { return block_id_; } | 62 int block_id() const { return block_id_; } |
63 void set_block_id(int id) { block_id_ = id; } | 63 void set_block_id(int id) { block_id_ = id; } |
64 HGraph* graph() const { return graph_; } | 64 HGraph* graph() const { return graph_; } |
65 Isolate* isolate() const; | 65 Isolate* isolate() const; |
66 const ZoneList<HPhi*>* phis() const { return &phis_; } | 66 const ZoneList<HPhi*>* phis() const { return &phis_; } |
67 HInstruction* first() const { return first_; } | 67 HInstruction* first() const { return first_; } |
68 HInstruction* last() const { return last_; } | 68 HInstruction* last() const { return last_; } |
69 void set_last(HInstruction* instr) { last_ = instr; } | 69 void set_last(HInstruction* instr) { last_ = instr; } |
70 HControlInstruction* end() const { return end_; } | 70 HControlInstruction* end() const { return end_; } |
71 HLoopInformation* loop_information() const { return loop_information_; } | 71 HLoopInformation* loop_information() const { return loop_information_; } |
| 72 HLoopInformation* current_loop() const { |
| 73 return IsLoopHeader() ? loop_information() |
| 74 : (parent_loop_header() != NULL |
| 75 ? parent_loop_header()->loop_information() : NULL); |
| 76 } |
72 const ZoneList<HBasicBlock*>* predecessors() const { return &predecessors_; } | 77 const ZoneList<HBasicBlock*>* predecessors() const { return &predecessors_; } |
73 bool HasPredecessor() const { return predecessors_.length() > 0; } | 78 bool HasPredecessor() const { return predecessors_.length() > 0; } |
74 const ZoneList<HBasicBlock*>* dominated_blocks() const { | 79 const ZoneList<HBasicBlock*>* dominated_blocks() const { |
75 return &dominated_blocks_; | 80 return &dominated_blocks_; |
76 } | 81 } |
77 const ZoneList<int>* deleted_phis() const { | 82 const ZoneList<int>* deleted_phis() const { |
78 return &deleted_phis_; | 83 return &deleted_phis_; |
79 } | 84 } |
80 void RecordDeletedPhi(int merge_index) { | 85 void RecordDeletedPhi(int merge_index) { |
81 deleted_phis_.Add(merge_index, zone()); | 86 deleted_phis_.Add(merge_index, zone()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 void Finish(HControlInstruction* last); | 135 void Finish(HControlInstruction* last); |
131 void FinishExit(HControlInstruction* instruction); | 136 void FinishExit(HControlInstruction* instruction); |
132 void Goto(HBasicBlock* block, | 137 void Goto(HBasicBlock* block, |
133 FunctionState* state = NULL, | 138 FunctionState* state = NULL, |
134 bool add_simulate = true); | 139 bool add_simulate = true); |
135 void GotoNoSimulate(HBasicBlock* block) { | 140 void GotoNoSimulate(HBasicBlock* block) { |
136 Goto(block, NULL, false); | 141 Goto(block, NULL, false); |
137 } | 142 } |
138 | 143 |
139 int PredecessorIndexOf(HBasicBlock* predecessor) const; | 144 int PredecessorIndexOf(HBasicBlock* predecessor) const; |
140 void AddSimulate(BailoutId ast_id, | 145 HSimulate* AddSimulate(BailoutId ast_id, |
141 RemovableSimulate removable = FIXED_SIMULATE) { | 146 RemovableSimulate removable = FIXED_SIMULATE) { |
142 AddInstruction(CreateSimulate(ast_id, removable)); | 147 HSimulate* instr = CreateSimulate(ast_id, removable); |
| 148 AddInstruction(instr); |
| 149 return instr; |
143 } | 150 } |
144 void AssignCommonDominator(HBasicBlock* other); | 151 void AssignCommonDominator(HBasicBlock* other); |
145 void AssignLoopSuccessorDominators(); | 152 void AssignLoopSuccessorDominators(); |
146 | 153 |
147 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) { | |
148 FinishExit(CreateDeoptimize(has_uses)); | |
149 } | |
150 | |
151 // Add the inlined function exit sequence, adding an HLeaveInlined | 154 // Add the inlined function exit sequence, adding an HLeaveInlined |
152 // instruction and updating the bailout environment. | 155 // instruction and updating the bailout environment. |
153 void AddLeaveInlined(HValue* return_value, FunctionState* state); | 156 void AddLeaveInlined(HValue* return_value, FunctionState* state); |
154 | 157 |
155 // If a target block is tagged as an inline function return, all | 158 // If a target block is tagged as an inline function return, all |
156 // predecessors should contain the inlined exit sequence: | 159 // predecessors should contain the inlined exit sequence: |
157 // | 160 // |
158 // LeaveInlined | 161 // LeaveInlined |
159 // Simulate (caller's environment) | 162 // Simulate (caller's environment) |
160 // Goto (target block) | 163 // Goto (target block) |
(...skipping 14 matching lines...) Expand all Loading... |
175 dominates_loop_successors_ = true; | 178 dominates_loop_successors_ = true; |
176 } | 179 } |
177 | 180 |
178 inline Zone* zone() const; | 181 inline Zone* zone() const; |
179 | 182 |
180 #ifdef DEBUG | 183 #ifdef DEBUG |
181 void Verify(); | 184 void Verify(); |
182 #endif | 185 #endif |
183 | 186 |
184 private: | 187 private: |
| 188 friend class HGraphBuilder; |
| 189 |
185 void RegisterPredecessor(HBasicBlock* pred); | 190 void RegisterPredecessor(HBasicBlock* pred); |
186 void AddDominatedBlock(HBasicBlock* block); | 191 void AddDominatedBlock(HBasicBlock* block); |
187 | 192 |
188 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); | 193 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); |
189 HDeoptimize* CreateDeoptimize(HDeoptimize::UseEnvironment has_uses); | |
190 | 194 |
191 int block_id_; | 195 int block_id_; |
192 HGraph* graph_; | 196 HGraph* graph_; |
193 ZoneList<HPhi*> phis_; | 197 ZoneList<HPhi*> phis_; |
194 HInstruction* first_; | 198 HInstruction* first_; |
195 HInstruction* last_; | 199 HInstruction* last_; |
196 HControlInstruction* end_; | 200 HControlInstruction* end_; |
197 HLoopInformation* loop_information_; | 201 HLoopInformation* loop_information_; |
198 ZoneList<HBasicBlock*> predecessors_; | 202 ZoneList<HBasicBlock*> predecessors_; |
199 HBasicBlock* dominator_; | 203 HBasicBlock* dominator_; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } | 269 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } |
266 HBasicBlock* loop_header() const { return loop_header_; } | 270 HBasicBlock* loop_header() const { return loop_header_; } |
267 HBasicBlock* GetLastBackEdge() const; | 271 HBasicBlock* GetLastBackEdge() const; |
268 void RegisterBackEdge(HBasicBlock* block); | 272 void RegisterBackEdge(HBasicBlock* block); |
269 | 273 |
270 HStackCheck* stack_check() const { return stack_check_; } | 274 HStackCheck* stack_check() const { return stack_check_; } |
271 void set_stack_check(HStackCheck* stack_check) { | 275 void set_stack_check(HStackCheck* stack_check) { |
272 stack_check_ = stack_check; | 276 stack_check_ = stack_check; |
273 } | 277 } |
274 | 278 |
| 279 bool IsNestedInThisLoop(HLoopInformation* other) { |
| 280 while (other != NULL) { |
| 281 if (other == this) { |
| 282 return true; |
| 283 } |
| 284 other = other->parent_loop(); |
| 285 } |
| 286 return false; |
| 287 } |
| 288 HLoopInformation* parent_loop() { |
| 289 HBasicBlock* parent_header = loop_header()->parent_loop_header(); |
| 290 return parent_header != NULL ? parent_header->loop_information() : NULL; |
| 291 } |
| 292 |
275 private: | 293 private: |
276 void AddBlock(HBasicBlock* block); | 294 void AddBlock(HBasicBlock* block); |
277 | 295 |
278 ZoneList<HBasicBlock*> back_edges_; | 296 ZoneList<HBasicBlock*> back_edges_; |
279 HBasicBlock* loop_header_; | 297 HBasicBlock* loop_header_; |
280 ZoneList<HBasicBlock*> blocks_; | 298 ZoneList<HBasicBlock*> blocks_; |
281 HStackCheck* stack_check_; | 299 HStackCheck* stack_check_; |
282 }; | 300 }; |
283 | 301 |
284 | 302 |
285 class BoundsCheckTable; | 303 class BoundsCheckTable; |
| 304 class InductionVariableBlocksTable; |
286 class HGraph: public ZoneObject { | 305 class HGraph: public ZoneObject { |
287 public: | 306 public: |
288 explicit HGraph(CompilationInfo* info); | 307 explicit HGraph(CompilationInfo* info); |
289 | 308 |
290 Isolate* isolate() const { return isolate_; } | 309 Isolate* isolate() const { return isolate_; } |
291 Zone* zone() const { return zone_; } | 310 Zone* zone() const { return zone_; } |
292 CompilationInfo* info() const { return info_; } | 311 CompilationInfo* info() const { return info_; } |
293 | 312 |
294 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } | 313 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } |
295 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } | 314 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 template<class Phase> | 461 template<class Phase> |
443 void Run() { | 462 void Run() { |
444 Phase phase(this); | 463 Phase phase(this); |
445 phase.Run(); | 464 phase.Run(); |
446 } | 465 } |
447 | 466 |
448 void RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi); | 467 void RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi); |
449 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor); | 468 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor); |
450 void SetupInformativeDefinitionsInBlock(HBasicBlock* block); | 469 void SetupInformativeDefinitionsInBlock(HBasicBlock* block); |
451 void SetupInformativeDefinitionsRecursively(HBasicBlock* block); | 470 void SetupInformativeDefinitionsRecursively(HBasicBlock* block); |
| 471 void EliminateRedundantBoundsChecksUsingInductionVariables(); |
452 | 472 |
453 Isolate* isolate_; | 473 Isolate* isolate_; |
454 int next_block_id_; | 474 int next_block_id_; |
455 HBasicBlock* entry_block_; | 475 HBasicBlock* entry_block_; |
456 HEnvironment* start_environment_; | 476 HEnvironment* start_environment_; |
457 ZoneList<HBasicBlock*> blocks_; | 477 ZoneList<HBasicBlock*> blocks_; |
458 ZoneList<HValue*> values_; | 478 ZoneList<HValue*> values_; |
459 ZoneList<HPhi*>* phi_list_; | 479 ZoneList<HPhi*>* phi_list_; |
460 ZoneList<HInstruction*>* uint32_instructions_; | 480 ZoneList<HInstruction*>* uint32_instructions_; |
461 SetOncePointer<HConstant> undefined_constant_; | 481 SetOncePointer<HConstant> undefined_constant_; |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); | 1036 new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); |
1017 } | 1037 } |
1018 | 1038 |
1019 template<class I, class P1, class P2, class P3, class P4, | 1039 template<class I, class P1, class P2, class P3, class P4, |
1020 class P5, class P6, class P7, class P8> | 1040 class P5, class P6, class P7, class P8> |
1021 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { | 1041 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
1022 return static_cast<I*>(AddInstruction( | 1042 return static_cast<I*>(AddInstruction( |
1023 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); | 1043 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); |
1024 } | 1044 } |
1025 | 1045 |
1026 void AddSimulate(BailoutId id, | |
1027 RemovableSimulate removable = FIXED_SIMULATE); | |
1028 | |
1029 HReturn* AddReturn(HValue* value); | |
1030 | |
1031 void IncrementInNoSideEffectsScope() { | 1046 void IncrementInNoSideEffectsScope() { |
1032 no_side_effects_scope_count_++; | 1047 no_side_effects_scope_count_++; |
1033 } | 1048 } |
1034 | 1049 |
1035 void DecrementInNoSideEffectsScope() { | 1050 void DecrementInNoSideEffectsScope() { |
1036 no_side_effects_scope_count_--; | 1051 no_side_effects_scope_count_--; |
1037 } | 1052 } |
1038 | 1053 |
1039 protected: | 1054 protected: |
1040 virtual bool BuildGraph() = 0; | 1055 virtual bool BuildGraph() = 0; |
1041 | 1056 |
1042 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1057 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
1043 HBasicBlock* CreateLoopHeaderBlock(); | 1058 HBasicBlock* CreateLoopHeaderBlock(); |
1044 | 1059 |
1045 HValue* BuildCheckHeapObject(HValue* object); | 1060 HValue* BuildCheckHeapObject(HValue* object); |
1046 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | 1061 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
| 1062 HValue* BuildWrapReceiver(HValue* object, HValue* function); |
1047 | 1063 |
1048 // Building common constructs | 1064 // Building common constructs |
1049 HValue* BuildCheckForCapacityGrow(HValue* object, | 1065 HValue* BuildCheckForCapacityGrow(HValue* object, |
1050 HValue* elements, | 1066 HValue* elements, |
1051 ElementsKind kind, | 1067 ElementsKind kind, |
1052 HValue* length, | 1068 HValue* length, |
1053 HValue* key, | 1069 HValue* key, |
1054 bool is_js_array); | 1070 bool is_js_array); |
1055 | 1071 |
1056 HValue* BuildCopyElementsOnWrite(HValue* object, | 1072 HValue* BuildCopyElementsOnWrite(HValue* object, |
(...skipping 14 matching lines...) Expand all Loading... |
1071 HCheckMaps* mapcheck, | 1087 HCheckMaps* mapcheck, |
1072 bool is_js_array, | 1088 bool is_js_array, |
1073 ElementsKind elements_kind, | 1089 ElementsKind elements_kind, |
1074 bool is_store, | 1090 bool is_store, |
1075 LoadKeyedHoleMode load_mode, | 1091 LoadKeyedHoleMode load_mode, |
1076 KeyedAccessStoreMode store_mode); | 1092 KeyedAccessStoreMode store_mode); |
1077 | 1093 |
1078 HLoadNamedField* AddLoad( | 1094 HLoadNamedField* AddLoad( |
1079 HValue *object, | 1095 HValue *object, |
1080 HObjectAccess access, | 1096 HObjectAccess access, |
1081 HValue *typecheck = NULL, | 1097 HValue *typecheck = NULL); |
1082 Representation representation = Representation::Tagged()); | |
1083 | 1098 |
1084 HLoadNamedField* BuildLoadNamedField( | 1099 HLoadNamedField* BuildLoadNamedField( |
1085 HValue* object, | 1100 HValue* object, |
1086 HObjectAccess access, | 1101 HObjectAccess access, |
1087 Representation representation); | 1102 Representation representation); |
1088 | 1103 |
1089 HInstruction* AddExternalArrayElementAccess( | 1104 HInstruction* AddExternalArrayElementAccess( |
1090 HValue* external_elements, | 1105 HValue* external_elements, |
1091 HValue* checked_key, | 1106 HValue* checked_key, |
1092 HValue* val, | 1107 HValue* val, |
1093 HValue* dependency, | 1108 HValue* dependency, |
1094 ElementsKind elements_kind, | 1109 ElementsKind elements_kind, |
1095 bool is_store); | 1110 bool is_store); |
1096 | 1111 |
1097 HInstruction* AddFastElementAccess( | 1112 HInstruction* AddFastElementAccess( |
1098 HValue* elements, | 1113 HValue* elements, |
1099 HValue* checked_key, | 1114 HValue* checked_key, |
1100 HValue* val, | 1115 HValue* val, |
1101 HValue* dependency, | 1116 HValue* dependency, |
1102 ElementsKind elements_kind, | 1117 ElementsKind elements_kind, |
1103 bool is_store, | 1118 bool is_store, |
1104 LoadKeyedHoleMode load_mode, | 1119 LoadKeyedHoleMode load_mode, |
1105 KeyedAccessStoreMode store_mode); | 1120 KeyedAccessStoreMode store_mode); |
1106 | 1121 |
1107 HStoreNamedField* AddStore( | 1122 HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access); |
1108 HValue *object, | 1123 HStoreNamedField* AddStore(HValue *object, HObjectAccess access, HValue *val); |
1109 HObjectAccess access, | |
1110 HValue *val, | |
1111 Representation representation = Representation::Tagged()); | |
1112 | |
1113 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); | 1124 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); |
1114 | |
1115 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); | 1125 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); |
1116 | |
1117 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); | 1126 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); |
1118 | 1127 |
1119 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context); | 1128 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context); |
1120 | 1129 |
1121 enum SoftDeoptimizeMode { | 1130 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); |
1122 MUST_EMIT_SOFT_DEOPT, | |
1123 CAN_OMIT_SOFT_DEOPT | |
1124 }; | |
1125 | 1131 |
1126 void AddSoftDeoptimize(SoftDeoptimizeMode mode = CAN_OMIT_SOFT_DEOPT); | 1132 void PushAndAdd(HInstruction* instr); |
| 1133 |
| 1134 void FinishExitWithHardDeoptimization(HBasicBlock* continuation); |
1127 | 1135 |
1128 class IfBuilder { | 1136 class IfBuilder { |
1129 public: | 1137 public: |
1130 explicit IfBuilder(HGraphBuilder* builder, | 1138 explicit IfBuilder(HGraphBuilder* builder, |
1131 int position = RelocInfo::kNoPosition); | 1139 int position = RelocInfo::kNoPosition); |
1132 IfBuilder(HGraphBuilder* builder, | 1140 IfBuilder(HGraphBuilder* builder, |
1133 HIfContinuation* continuation); | 1141 HIfContinuation* continuation); |
1134 | 1142 |
1135 ~IfBuilder() { | 1143 ~IfBuilder() { |
1136 if (!finished_) End(); | 1144 if (!finished_) End(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 void CaptureContinuation(HIfContinuation* continuation); | 1229 void CaptureContinuation(HIfContinuation* continuation); |
1222 | 1230 |
1223 void Then(); | 1231 void Then(); |
1224 void Else(); | 1232 void Else(); |
1225 void End(); | 1233 void End(); |
1226 | 1234 |
1227 void Deopt(); | 1235 void Deopt(); |
1228 void ElseDeopt() { | 1236 void ElseDeopt() { |
1229 Else(); | 1237 Else(); |
1230 Deopt(); | 1238 Deopt(); |
1231 End(); | |
1232 } | 1239 } |
1233 | 1240 |
1234 void Return(HValue* value); | 1241 void Return(HValue* value); |
1235 | 1242 |
1236 private: | 1243 private: |
1237 void AddCompare(HControlInstruction* compare); | 1244 void AddCompare(HControlInstruction* compare); |
1238 | 1245 |
1239 Zone* zone() { return builder_->zone(); } | 1246 Zone* zone() { return builder_->zone(); } |
1240 | 1247 |
1241 HGraphBuilder* builder_; | 1248 HGraphBuilder* builder_; |
1242 int position_; | 1249 int position_; |
1243 bool finished_ : 1; | 1250 bool finished_ : 1; |
| 1251 bool deopt_then_ : 1; |
| 1252 bool deopt_else_ : 1; |
1244 bool did_then_ : 1; | 1253 bool did_then_ : 1; |
1245 bool did_else_ : 1; | 1254 bool did_else_ : 1; |
1246 bool did_and_ : 1; | 1255 bool did_and_ : 1; |
1247 bool did_or_ : 1; | 1256 bool did_or_ : 1; |
1248 bool captured_ : 1; | 1257 bool captured_ : 1; |
1249 bool needs_compare_ : 1; | 1258 bool needs_compare_ : 1; |
1250 HBasicBlock* first_true_block_; | 1259 HBasicBlock* first_true_block_; |
1251 HBasicBlock* last_true_block_; | 1260 HBasicBlock* last_true_block_; |
1252 HBasicBlock* first_false_block_; | 1261 HBasicBlock* first_false_block_; |
1253 HBasicBlock* split_edge_merge_block_; | 1262 HBasicBlock* split_edge_merge_block_; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 ElementsKind kind, | 1375 ElementsKind kind, |
1367 HValue* capacity); | 1376 HValue* capacity); |
1368 | 1377 |
1369 // array must have been allocated with enough room for | 1378 // array must have been allocated with enough room for |
1370 // 1) the JSArray, 2) a AllocationMemento if mode requires it, | 1379 // 1) the JSArray, 2) a AllocationMemento if mode requires it, |
1371 // 3) a FixedArray or FixedDoubleArray. | 1380 // 3) a FixedArray or FixedDoubleArray. |
1372 // A pointer to the Fixed(Double)Array is returned. | 1381 // A pointer to the Fixed(Double)Array is returned. |
1373 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array, | 1382 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array, |
1374 HValue* array_map, | 1383 HValue* array_map, |
1375 AllocationSiteMode mode, | 1384 AllocationSiteMode mode, |
| 1385 ElementsKind elements_kind, |
1376 HValue* allocation_site_payload, | 1386 HValue* allocation_site_payload, |
1377 HValue* length_field); | 1387 HValue* length_field); |
1378 | 1388 |
1379 HValue* BuildGrowElementsCapacity(HValue* object, | 1389 HValue* BuildGrowElementsCapacity(HValue* object, |
1380 HValue* elements, | 1390 HValue* elements, |
1381 ElementsKind kind, | 1391 ElementsKind kind, |
1382 ElementsKind new_kind, | 1392 ElementsKind new_kind, |
1383 HValue* length, | 1393 HValue* length, |
1384 HValue* new_capacity); | 1394 HValue* new_capacity); |
1385 | 1395 |
(...skipping 29 matching lines...) Expand all Loading... |
1415 | 1425 |
1416 HValue* BuildCreateAllocationMemento(HValue* previous_object, | 1426 HValue* BuildCreateAllocationMemento(HValue* previous_object, |
1417 int previous_object_size, | 1427 int previous_object_size, |
1418 HValue* payload); | 1428 HValue* payload); |
1419 | 1429 |
1420 HInstruction* BuildGetNativeContext(HValue* context); | 1430 HInstruction* BuildGetNativeContext(HValue* context); |
1421 HInstruction* BuildGetArrayFunction(HValue* context); | 1431 HInstruction* BuildGetArrayFunction(HValue* context); |
1422 | 1432 |
1423 private: | 1433 private: |
1424 HGraphBuilder(); | 1434 HGraphBuilder(); |
| 1435 |
| 1436 void PadEnvironmentForContinuation(HBasicBlock* from, |
| 1437 HBasicBlock* continuation); |
| 1438 |
1425 CompilationInfo* info_; | 1439 CompilationInfo* info_; |
1426 HGraph* graph_; | 1440 HGraph* graph_; |
1427 HBasicBlock* current_block_; | 1441 HBasicBlock* current_block_; |
1428 int no_side_effects_scope_count_; | 1442 int no_side_effects_scope_count_; |
1429 }; | 1443 }; |
1430 | 1444 |
| 1445 |
| 1446 template<> |
| 1447 inline HDeoptimize* HGraphBuilder::Add(Deoptimizer::BailoutType type) { |
| 1448 if (type == Deoptimizer::SOFT) { |
| 1449 isolate()->counters()->soft_deopts_requested()->Increment(); |
| 1450 if (FLAG_always_opt) return NULL; |
| 1451 } |
| 1452 if (current_block()->IsDeoptimizing()) return NULL; |
| 1453 HDeoptimize* instr = new(zone()) HDeoptimize(type); |
| 1454 AddInstruction(instr); |
| 1455 if (type == Deoptimizer::SOFT) { |
| 1456 isolate()->counters()->soft_deopts_inserted()->Increment(); |
| 1457 graph()->set_has_soft_deoptimize(true); |
| 1458 } |
| 1459 current_block()->MarkAsDeoptimizing(); |
| 1460 return instr; |
| 1461 } |
| 1462 |
| 1463 |
| 1464 template<> |
| 1465 inline HSimulate* HGraphBuilder::Add(BailoutId id, |
| 1466 RemovableSimulate removable) { |
| 1467 HSimulate* instr = current_block()->CreateSimulate(id, removable); |
| 1468 AddInstruction(instr); |
| 1469 return instr; |
| 1470 } |
| 1471 |
| 1472 |
| 1473 template<> |
| 1474 inline HSimulate* HGraphBuilder::Add(BailoutId id) { |
| 1475 return Add<HSimulate>(id, FIXED_SIMULATE); |
| 1476 } |
| 1477 |
| 1478 |
| 1479 template<> |
| 1480 inline HReturn* HGraphBuilder::Add(HValue* value) { |
| 1481 HValue* context = environment()->LookupContext(); |
| 1482 int num_parameters = graph()->info()->num_parameters(); |
| 1483 HValue* params = Add<HConstant>(num_parameters); |
| 1484 HReturn* return_instruction = new(graph()->zone()) |
| 1485 HReturn(value, context, params); |
| 1486 current_block()->FinishExit(return_instruction); |
| 1487 return return_instruction; |
| 1488 } |
| 1489 |
| 1490 |
| 1491 template<> |
| 1492 inline HReturn* HGraphBuilder::Add(HConstant* p1) { |
| 1493 return Add<HReturn>(static_cast<HValue*>(p1)); |
| 1494 } |
| 1495 |
| 1496 |
1431 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1497 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
1432 public: | 1498 public: |
1433 // A class encapsulating (lazily-allocated) break and continue blocks for | 1499 // A class encapsulating (lazily-allocated) break and continue blocks for |
1434 // a breakable statement. Separated from BreakAndContinueScope so that it | 1500 // a breakable statement. Separated from BreakAndContinueScope so that it |
1435 // can have a separate lifetime. | 1501 // can have a separate lifetime. |
1436 class BreakAndContinueInfo BASE_EMBEDDED { | 1502 class BreakAndContinueInfo BASE_EMBEDDED { |
1437 public: | 1503 public: |
1438 explicit BreakAndContinueInfo(BreakableStatement* target, | 1504 explicit BreakAndContinueInfo(BreakableStatement* target, |
1439 int drop_extra = 0) | 1505 int drop_extra = 0) |
1440 : target_(target), | 1506 : target_(target), |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 HBasicBlock* false_block); | 1725 HBasicBlock* false_block); |
1660 | 1726 |
1661 // Visit an argument subexpression and emit a push to the outgoing arguments. | 1727 // Visit an argument subexpression and emit a push to the outgoing arguments. |
1662 void VisitArgument(Expression* expr); | 1728 void VisitArgument(Expression* expr); |
1663 | 1729 |
1664 void VisitArgumentList(ZoneList<Expression*>* arguments); | 1730 void VisitArgumentList(ZoneList<Expression*>* arguments); |
1665 | 1731 |
1666 // Visit a list of expressions from left to right, each in a value context. | 1732 // Visit a list of expressions from left to right, each in a value context. |
1667 void VisitExpressions(ZoneList<Expression*>* exprs); | 1733 void VisitExpressions(ZoneList<Expression*>* exprs); |
1668 | 1734 |
1669 void PushAndAdd(HInstruction* instr); | |
1670 | |
1671 // Remove the arguments from the bailout environment and emit instructions | 1735 // Remove the arguments from the bailout environment and emit instructions |
1672 // to push them as outgoing parameters. | 1736 // to push them as outgoing parameters. |
1673 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); | 1737 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); |
1674 | 1738 |
1675 void SetUpScope(Scope* scope); | 1739 void SetUpScope(Scope* scope); |
1676 virtual void VisitStatements(ZoneList<Statement*>* statements); | 1740 virtual void VisitStatements(ZoneList<Statement*>* statements); |
1677 | 1741 |
1678 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 1742 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
1679 AST_NODE_LIST(DECLARE_VISIT) | 1743 AST_NODE_LIST(DECLARE_VISIT) |
1680 #undef DECLARE_VISIT | 1744 #undef DECLARE_VISIT |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 HGraph* graph_; | 2078 HGraph* graph_; |
2015 | 2079 |
2016 DISALLOW_COPY_AND_ASSIGN(HPhase); | 2080 DISALLOW_COPY_AND_ASSIGN(HPhase); |
2017 }; | 2081 }; |
2018 | 2082 |
2019 | 2083 |
2020 class HTracer: public Malloced { | 2084 class HTracer: public Malloced { |
2021 public: | 2085 public: |
2022 explicit HTracer(int isolate_id) | 2086 explicit HTracer(int isolate_id) |
2023 : trace_(&string_allocator_), indent_(0) { | 2087 : trace_(&string_allocator_), indent_(0) { |
2024 OS::SNPrintF(filename_, | 2088 if (FLAG_trace_hydrogen_file == NULL) { |
2025 "hydrogen-%d-%d.cfg", | 2089 OS::SNPrintF(filename_, |
2026 OS::GetCurrentProcessId(), | 2090 "hydrogen-%d-%d.cfg", |
2027 isolate_id); | 2091 OS::GetCurrentProcessId(), |
| 2092 isolate_id); |
| 2093 } else { |
| 2094 OS::StrNCpy(filename_, FLAG_trace_hydrogen_file, filename_.length()); |
| 2095 } |
2028 WriteChars(filename_.start(), "", 0, false); | 2096 WriteChars(filename_.start(), "", 0, false); |
2029 } | 2097 } |
2030 | 2098 |
2031 void TraceCompilation(CompilationInfo* info); | 2099 void TraceCompilation(CompilationInfo* info); |
2032 void TraceHydrogen(const char* name, HGraph* graph); | 2100 void TraceHydrogen(const char* name, HGraph* graph); |
2033 void TraceLithium(const char* name, LChunk* chunk); | 2101 void TraceLithium(const char* name, LChunk* chunk); |
2034 void TraceLiveRanges(const char* name, LAllocator* allocator); | 2102 void TraceLiveRanges(const char* name, LAllocator* allocator); |
2035 | 2103 |
2036 private: | 2104 private: |
2037 class Tag BASE_EMBEDDED { | 2105 class Tag BASE_EMBEDDED { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 EmbeddedVector<char, 64> filename_; | 2163 EmbeddedVector<char, 64> filename_; |
2096 HeapStringAllocator string_allocator_; | 2164 HeapStringAllocator string_allocator_; |
2097 StringStream trace_; | 2165 StringStream trace_; |
2098 int indent_; | 2166 int indent_; |
2099 }; | 2167 }; |
2100 | 2168 |
2101 | 2169 |
2102 } } // namespace v8::internal | 2170 } } // namespace v8::internal |
2103 | 2171 |
2104 #endif // V8_HYDROGEN_H_ | 2172 #endif // V8_HYDROGEN_H_ |
OLD | NEW |