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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void Finish(HControlInstruction* last); | 135 void Finish(HControlInstruction* last); |
136 void FinishExit(HControlInstruction* instruction); | 136 void FinishExit(HControlInstruction* instruction); |
137 void Goto(HBasicBlock* block, | 137 void Goto(HBasicBlock* block, |
138 FunctionState* state = NULL, | 138 FunctionState* state = NULL, |
139 bool add_simulate = true); | 139 bool add_simulate = true); |
140 void GotoNoSimulate(HBasicBlock* block) { | 140 void GotoNoSimulate(HBasicBlock* block) { |
141 Goto(block, NULL, false); | 141 Goto(block, NULL, false); |
142 } | 142 } |
143 | 143 |
144 int PredecessorIndexOf(HBasicBlock* predecessor) const; | 144 int PredecessorIndexOf(HBasicBlock* predecessor) const; |
145 HSimulate* AddSimulate(BailoutId ast_id, | 145 HPhi* AddNewPhi(int merged_index); |
146 RemovableSimulate removable = FIXED_SIMULATE) { | 146 HSimulate* AddNewSimulate(BailoutId ast_id, |
| 147 RemovableSimulate removable = FIXED_SIMULATE) { |
147 HSimulate* instr = CreateSimulate(ast_id, removable); | 148 HSimulate* instr = CreateSimulate(ast_id, removable); |
148 AddInstruction(instr); | 149 AddInstruction(instr); |
149 return instr; | 150 return instr; |
150 } | 151 } |
151 void AssignCommonDominator(HBasicBlock* other); | 152 void AssignCommonDominator(HBasicBlock* other); |
152 void AssignLoopSuccessorDominators(); | 153 void AssignLoopSuccessorDominators(); |
153 | 154 |
154 // Add the inlined function exit sequence, adding an HLeaveInlined | 155 // Add the inlined function exit sequence, adding an HLeaveInlined |
155 // instruction and updating the bailout environment. | 156 // instruction and updating the bailout environment. |
156 void AddLeaveInlined(HValue* return_value, FunctionState* state); | 157 void AddLeaveInlined(HValue* return_value, FunctionState* state); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 447 } |
447 | 448 |
448 void RecordUint32Instruction(HInstruction* instr) { | 449 void RecordUint32Instruction(HInstruction* instr) { |
449 ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty()); | 450 ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty()); |
450 if (uint32_instructions_ == NULL) { | 451 if (uint32_instructions_ == NULL) { |
451 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); | 452 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); |
452 } | 453 } |
453 uint32_instructions_->Add(instr, zone()); | 454 uint32_instructions_->Add(instr, zone()); |
454 } | 455 } |
455 | 456 |
| 457 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } |
| 458 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } |
| 459 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } |
| 460 |
456 private: | 461 private: |
457 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, | 462 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, |
458 int32_t integer_value); | 463 int32_t integer_value); |
459 | 464 |
460 template<class Phase> | 465 template<class Phase> |
461 void Run() { | 466 void Run() { |
462 Phase phase(this); | 467 Phase phase(this); |
463 phase.Run(); | 468 phase.Run(); |
464 } | 469 } |
465 | 470 |
(...skipping 25 matching lines...) Expand all Loading... |
491 | 496 |
492 CompilationInfo* info_; | 497 CompilationInfo* info_; |
493 Zone* zone_; | 498 Zone* zone_; |
494 | 499 |
495 bool is_recursive_; | 500 bool is_recursive_; |
496 bool use_optimistic_licm_; | 501 bool use_optimistic_licm_; |
497 bool has_soft_deoptimize_; | 502 bool has_soft_deoptimize_; |
498 bool depends_on_empty_array_proto_elements_; | 503 bool depends_on_empty_array_proto_elements_; |
499 int type_change_checksum_; | 504 int type_change_checksum_; |
500 int maximum_environment_size_; | 505 int maximum_environment_size_; |
| 506 int no_side_effects_scope_count_; |
501 | 507 |
502 DISALLOW_COPY_AND_ASSIGN(HGraph); | 508 DISALLOW_COPY_AND_ASSIGN(HGraph); |
503 }; | 509 }; |
504 | 510 |
505 | 511 |
506 Zone* HBasicBlock::zone() const { return graph_->zone(); } | 512 Zone* HBasicBlock::zone() const { return graph_->zone(); } |
507 | 513 |
508 | 514 |
509 // Type of stack frame an environment might refer to. | 515 // Type of stack frame an environment might refer to. |
510 enum FrameType { | 516 enum FrameType { |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 HBasicBlock* false_branch_; | 969 HBasicBlock* false_branch_; |
964 int position_; | 970 int position_; |
965 }; | 971 }; |
966 | 972 |
967 | 973 |
968 class HGraphBuilder { | 974 class HGraphBuilder { |
969 public: | 975 public: |
970 explicit HGraphBuilder(CompilationInfo* info) | 976 explicit HGraphBuilder(CompilationInfo* info) |
971 : info_(info), | 977 : info_(info), |
972 graph_(NULL), | 978 graph_(NULL), |
973 current_block_(NULL), | 979 current_block_(NULL) {} |
974 no_side_effects_scope_count_(0) {} | |
975 virtual ~HGraphBuilder() {} | 980 virtual ~HGraphBuilder() {} |
976 | 981 |
977 HBasicBlock* current_block() const { return current_block_; } | 982 HBasicBlock* current_block() const { return current_block_; } |
978 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 983 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
979 HEnvironment* environment() const { | 984 HEnvironment* environment() const { |
980 return current_block()->last_environment(); | 985 return current_block()->last_environment(); |
981 } | 986 } |
982 Zone* zone() const { return info_->zone(); } | 987 Zone* zone() const { return info_->zone(); } |
983 HGraph* graph() const { return graph_; } | 988 HGraph* graph() const { return graph_; } |
984 Isolate* isolate() const { return graph_->isolate(); } | 989 Isolate* isolate() const { return graph_->isolate(); } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8)); | 1184 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8)); |
1180 } | 1185 } |
1181 | 1186 |
1182 template<class I, class P1, class P2, class P3, class P4, | 1187 template<class I, class P1, class P2, class P3, class P4, |
1183 class P5, class P6, class P7, class P8> | 1188 class P5, class P6, class P7, class P8> |
1184 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { | 1189 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
1185 return I::cast( | 1190 return I::cast( |
1186 AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8))); | 1191 AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8))); |
1187 } | 1192 } |
1188 | 1193 |
1189 void AddSimulate(BailoutId id, | 1194 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); |
1190 RemovableSimulate removable = FIXED_SIMULATE); | |
1191 | |
1192 void IncrementInNoSideEffectsScope() { | |
1193 no_side_effects_scope_count_++; | |
1194 } | |
1195 | |
1196 void DecrementInNoSideEffectsScope() { | |
1197 no_side_effects_scope_count_--; | |
1198 } | |
1199 | 1195 |
1200 protected: | 1196 protected: |
1201 virtual bool BuildGraph() = 0; | 1197 virtual bool BuildGraph() = 0; |
1202 | 1198 |
1203 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1199 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
1204 HBasicBlock* CreateLoopHeaderBlock(); | 1200 HBasicBlock* CreateLoopHeaderBlock(); |
1205 | 1201 |
1206 HValue* BuildCheckHeapObject(HValue* object); | 1202 HValue* BuildCheckHeapObject(HValue* object); |
1207 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | 1203 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
1208 HValue* BuildWrapReceiver(HValue* object, HValue* function); | 1204 HValue* BuildWrapReceiver(HValue* object, HValue* function); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 HValue* context_; | 1430 HValue* context_; |
1435 HInstruction* increment_; | 1431 HInstruction* increment_; |
1436 HPhi* phi_; | 1432 HPhi* phi_; |
1437 HBasicBlock* header_block_; | 1433 HBasicBlock* header_block_; |
1438 HBasicBlock* body_block_; | 1434 HBasicBlock* body_block_; |
1439 HBasicBlock* exit_block_; | 1435 HBasicBlock* exit_block_; |
1440 Direction direction_; | 1436 Direction direction_; |
1441 bool finished_; | 1437 bool finished_; |
1442 }; | 1438 }; |
1443 | 1439 |
1444 class NoObservableSideEffectsScope { | |
1445 public: | |
1446 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : | |
1447 builder_(builder) { | |
1448 builder_->IncrementInNoSideEffectsScope(); | |
1449 } | |
1450 ~NoObservableSideEffectsScope() { | |
1451 builder_->DecrementInNoSideEffectsScope(); | |
1452 } | |
1453 | |
1454 private: | |
1455 HGraphBuilder* builder_; | |
1456 }; | |
1457 | |
1458 HValue* BuildNewElementsCapacity(HValue* old_capacity); | 1440 HValue* BuildNewElementsCapacity(HValue* old_capacity); |
1459 | 1441 |
1460 void BuildNewSpaceArrayCheck(HValue* length, | 1442 void BuildNewSpaceArrayCheck(HValue* length, |
1461 ElementsKind kind); | 1443 ElementsKind kind); |
1462 | 1444 |
1463 class JSArrayBuilder { | 1445 class JSArrayBuilder { |
1464 public: | 1446 public: |
1465 JSArrayBuilder(HGraphBuilder* builder, | 1447 JSArrayBuilder(HGraphBuilder* builder, |
1466 ElementsKind kind, | 1448 ElementsKind kind, |
1467 HValue* allocation_site_payload, | 1449 HValue* allocation_site_payload, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 | 1551 |
1570 private: | 1552 private: |
1571 HGraphBuilder(); | 1553 HGraphBuilder(); |
1572 | 1554 |
1573 void PadEnvironmentForContinuation(HBasicBlock* from, | 1555 void PadEnvironmentForContinuation(HBasicBlock* from, |
1574 HBasicBlock* continuation); | 1556 HBasicBlock* continuation); |
1575 | 1557 |
1576 CompilationInfo* info_; | 1558 CompilationInfo* info_; |
1577 HGraph* graph_; | 1559 HGraph* graph_; |
1578 HBasicBlock* current_block_; | 1560 HBasicBlock* current_block_; |
1579 int no_side_effects_scope_count_; | |
1580 }; | 1561 }; |
1581 | 1562 |
1582 | 1563 |
1583 template<> | 1564 template<> |
1584 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>( | 1565 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>( |
1585 Deoptimizer::BailoutType type) { | 1566 Deoptimizer::BailoutType type) { |
1586 if (type == Deoptimizer::SOFT) { | 1567 if (type == Deoptimizer::SOFT) { |
1587 isolate()->counters()->soft_deopts_requested()->Increment(); | 1568 isolate()->counters()->soft_deopts_requested()->Increment(); |
1588 if (FLAG_always_opt) return NULL; | 1569 if (FLAG_always_opt) return NULL; |
1589 } | 1570 } |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2322 } | 2303 } |
2323 } | 2304 } |
2324 | 2305 |
2325 EmbeddedVector<char, 64> filename_; | 2306 EmbeddedVector<char, 64> filename_; |
2326 HeapStringAllocator string_allocator_; | 2307 HeapStringAllocator string_allocator_; |
2327 StringStream trace_; | 2308 StringStream trace_; |
2328 int indent_; | 2309 int indent_; |
2329 }; | 2310 }; |
2330 | 2311 |
2331 | 2312 |
| 2313 class NoObservableSideEffectsScope { |
| 2314 public: |
| 2315 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : |
| 2316 builder_(builder) { |
| 2317 builder_->graph()->IncrementInNoSideEffectsScope(); |
| 2318 } |
| 2319 ~NoObservableSideEffectsScope() { |
| 2320 builder_->graph()->DecrementInNoSideEffectsScope(); |
| 2321 } |
| 2322 |
| 2323 private: |
| 2324 HGraphBuilder* builder_; |
| 2325 }; |
| 2326 |
| 2327 |
2332 } } // namespace v8::internal | 2328 } } // namespace v8::internal |
2333 | 2329 |
2334 #endif // V8_HYDROGEN_H_ | 2330 #endif // V8_HYDROGEN_H_ |
OLD | NEW |