Chromium Code Reviews| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 void Finish(HControlInstruction* last); | 130 void Finish(HControlInstruction* last); |
| 131 void FinishExit(HControlInstruction* instruction); | 131 void FinishExit(HControlInstruction* instruction); |
| 132 void Goto(HBasicBlock* block, | 132 void Goto(HBasicBlock* block, |
| 133 FunctionState* state = NULL, | 133 FunctionState* state = NULL, |
| 134 bool add_simulate = true); | 134 bool add_simulate = true); |
| 135 void GotoNoSimulate(HBasicBlock* block) { | 135 void GotoNoSimulate(HBasicBlock* block) { |
| 136 Goto(block, NULL, false); | 136 Goto(block, NULL, false); |
| 137 } | 137 } |
| 138 | 138 |
| 139 int PredecessorIndexOf(HBasicBlock* predecessor) const; | 139 int PredecessorIndexOf(HBasicBlock* predecessor) const; |
| 140 void AddSimulate(BailoutId ast_id, | 140 HSimulate* AddSimulate(BailoutId ast_id, |
| 141 RemovableSimulate removable = FIXED_SIMULATE) { | 141 RemovableSimulate removable = FIXED_SIMULATE) { |
| 142 AddInstruction(CreateSimulate(ast_id, removable)); | 142 HSimulate* instr = CreateSimulate(ast_id, removable); |
| 143 AddInstruction(instr); | |
| 144 return instr; | |
| 143 } | 145 } |
| 144 void AssignCommonDominator(HBasicBlock* other); | 146 void AssignCommonDominator(HBasicBlock* other); |
| 145 void AssignLoopSuccessorDominators(); | 147 void AssignLoopSuccessorDominators(); |
| 146 | 148 |
| 147 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) { | |
| 148 FinishExit(CreateDeoptimize(has_uses)); | |
| 149 } | |
| 150 | |
| 151 // Add the inlined function exit sequence, adding an HLeaveInlined | 149 // Add the inlined function exit sequence, adding an HLeaveInlined |
| 152 // instruction and updating the bailout environment. | 150 // instruction and updating the bailout environment. |
| 153 void AddLeaveInlined(HValue* return_value, FunctionState* state); | 151 void AddLeaveInlined(HValue* return_value, FunctionState* state); |
| 154 | 152 |
| 155 // If a target block is tagged as an inline function return, all | 153 // If a target block is tagged as an inline function return, all |
| 156 // predecessors should contain the inlined exit sequence: | 154 // predecessors should contain the inlined exit sequence: |
| 157 // | 155 // |
| 158 // LeaveInlined | 156 // LeaveInlined |
| 159 // Simulate (caller's environment) | 157 // Simulate (caller's environment) |
| 160 // Goto (target block) | 158 // Goto (target block) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 175 dominates_loop_successors_ = true; | 173 dominates_loop_successors_ = true; |
| 176 } | 174 } |
| 177 | 175 |
| 178 inline Zone* zone() const; | 176 inline Zone* zone() const; |
| 179 | 177 |
| 180 #ifdef DEBUG | 178 #ifdef DEBUG |
| 181 void Verify(); | 179 void Verify(); |
| 182 #endif | 180 #endif |
| 183 | 181 |
| 184 private: | 182 private: |
| 183 friend class HGraphBuilder; | |
| 184 | |
| 185 void RegisterPredecessor(HBasicBlock* pred); | 185 void RegisterPredecessor(HBasicBlock* pred); |
| 186 void AddDominatedBlock(HBasicBlock* block); | 186 void AddDominatedBlock(HBasicBlock* block); |
| 187 | 187 |
| 188 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); | 188 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); |
| 189 HDeoptimize* CreateDeoptimize(HDeoptimize::UseEnvironment has_uses); | |
| 190 | 189 |
| 191 int block_id_; | 190 int block_id_; |
| 192 HGraph* graph_; | 191 HGraph* graph_; |
| 193 ZoneList<HPhi*> phis_; | 192 ZoneList<HPhi*> phis_; |
| 194 HInstruction* first_; | 193 HInstruction* first_; |
| 195 HInstruction* last_; | 194 HInstruction* last_; |
| 196 HControlInstruction* end_; | 195 HControlInstruction* end_; |
| 197 HLoopInformation* loop_information_; | 196 HLoopInformation* loop_information_; |
| 198 ZoneList<HBasicBlock*> predecessors_; | 197 ZoneList<HBasicBlock*> predecessors_; |
| 199 HBasicBlock* dominator_; | 198 HBasicBlock* dominator_; |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); | 1015 new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); |
| 1017 } | 1016 } |
| 1018 | 1017 |
| 1019 template<class I, class P1, class P2, class P3, class P4, | 1018 template<class I, class P1, class P2, class P3, class P4, |
| 1020 class P5, class P6, class P7, class P8> | 1019 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) { | 1020 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
| 1022 return static_cast<I*>(AddInstruction( | 1021 return static_cast<I*>(AddInstruction( |
| 1023 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); | 1022 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); |
| 1024 } | 1023 } |
| 1025 | 1024 |
| 1026 void AddSimulate(BailoutId id, | |
| 1027 RemovableSimulate removable = FIXED_SIMULATE); | |
| 1028 | |
| 1029 HReturn* AddReturn(HValue* value); | |
| 1030 | |
| 1031 void IncrementInNoSideEffectsScope() { | 1025 void IncrementInNoSideEffectsScope() { |
| 1032 no_side_effects_scope_count_++; | 1026 no_side_effects_scope_count_++; |
| 1033 } | 1027 } |
| 1034 | 1028 |
| 1035 void DecrementInNoSideEffectsScope() { | 1029 void DecrementInNoSideEffectsScope() { |
| 1036 no_side_effects_scope_count_--; | 1030 no_side_effects_scope_count_--; |
| 1037 } | 1031 } |
| 1038 | 1032 |
| 1039 protected: | 1033 protected: |
| 1040 virtual bool BuildGraph() = 0; | 1034 virtual bool BuildGraph() = 0; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 Representation representation = Representation::Tagged()); | 1105 Representation representation = Representation::Tagged()); |
| 1112 | 1106 |
| 1113 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); | 1107 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); |
| 1114 | 1108 |
| 1115 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); | 1109 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); |
| 1116 | 1110 |
| 1117 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); | 1111 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); |
| 1118 | 1112 |
| 1119 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context); | 1113 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context); |
| 1120 | 1114 |
| 1121 enum SoftDeoptimizeMode { | 1115 void FinishExitWithHardDeoptimization(HBasicBlock* continuation); |
| 1122 MUST_EMIT_SOFT_DEOPT, | |
| 1123 CAN_OMIT_SOFT_DEOPT | |
| 1124 }; | |
| 1125 | |
| 1126 void AddSoftDeoptimize(SoftDeoptimizeMode mode = CAN_OMIT_SOFT_DEOPT); | |
| 1127 | 1116 |
| 1128 class IfBuilder { | 1117 class IfBuilder { |
| 1129 public: | 1118 public: |
| 1130 explicit IfBuilder(HGraphBuilder* builder, | 1119 explicit IfBuilder(HGraphBuilder* builder, |
| 1131 int position = RelocInfo::kNoPosition); | 1120 int position = RelocInfo::kNoPosition); |
| 1132 IfBuilder(HGraphBuilder* builder, | 1121 IfBuilder(HGraphBuilder* builder, |
| 1133 HIfContinuation* continuation); | 1122 HIfContinuation* continuation); |
| 1134 | 1123 |
| 1135 ~IfBuilder() { | 1124 ~IfBuilder() { |
| 1136 if (!finished_) End(); | 1125 if (!finished_) End(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1221 void CaptureContinuation(HIfContinuation* continuation); | 1210 void CaptureContinuation(HIfContinuation* continuation); |
| 1222 | 1211 |
| 1223 void Then(); | 1212 void Then(); |
| 1224 void Else(); | 1213 void Else(); |
| 1225 void End(); | 1214 void End(); |
| 1226 | 1215 |
| 1227 void Deopt(); | 1216 void Deopt(); |
| 1228 void ElseDeopt() { | 1217 void ElseDeopt() { |
| 1229 Else(); | 1218 Else(); |
| 1230 Deopt(); | 1219 Deopt(); |
| 1231 End(); | |
| 1232 } | 1220 } |
| 1233 | 1221 |
| 1234 void Return(HValue* value); | 1222 void Return(HValue* value); |
| 1235 | 1223 |
| 1236 private: | 1224 private: |
| 1237 void AddCompare(HControlInstruction* compare); | 1225 void AddCompare(HControlInstruction* compare); |
| 1238 | 1226 |
| 1239 Zone* zone() { return builder_->zone(); } | 1227 Zone* zone() { return builder_->zone(); } |
| 1240 | 1228 |
| 1241 HGraphBuilder* builder_; | 1229 HGraphBuilder* builder_; |
| 1242 int position_; | 1230 int position_; |
| 1243 bool finished_ : 1; | 1231 bool finished_ : 1; |
| 1232 bool deopt_then_ : 1; | |
| 1233 bool deopt_else_ : 1; | |
| 1244 bool did_then_ : 1; | 1234 bool did_then_ : 1; |
| 1245 bool did_else_ : 1; | 1235 bool did_else_ : 1; |
| 1246 bool did_and_ : 1; | 1236 bool did_and_ : 1; |
| 1247 bool did_or_ : 1; | 1237 bool did_or_ : 1; |
| 1248 bool captured_ : 1; | 1238 bool captured_ : 1; |
| 1249 bool needs_compare_ : 1; | 1239 bool needs_compare_ : 1; |
| 1250 HBasicBlock* first_true_block_; | 1240 HBasicBlock* first_true_block_; |
| 1251 HBasicBlock* last_true_block_; | 1241 HBasicBlock* last_true_block_; |
| 1252 HBasicBlock* first_false_block_; | 1242 HBasicBlock* first_false_block_; |
| 1253 HBasicBlock* split_edge_merge_block_; | 1243 HBasicBlock* split_edge_merge_block_; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 | 1405 |
| 1416 HValue* BuildCreateAllocationSiteInfo(HValue* previous_object, | 1406 HValue* BuildCreateAllocationSiteInfo(HValue* previous_object, |
| 1417 int previous_object_size, | 1407 int previous_object_size, |
| 1418 HValue* payload); | 1408 HValue* payload); |
| 1419 | 1409 |
| 1420 HInstruction* BuildGetNativeContext(HValue* context); | 1410 HInstruction* BuildGetNativeContext(HValue* context); |
| 1421 HInstruction* BuildGetArrayFunction(HValue* context); | 1411 HInstruction* BuildGetArrayFunction(HValue* context); |
| 1422 | 1412 |
| 1423 private: | 1413 private: |
| 1424 HGraphBuilder(); | 1414 HGraphBuilder(); |
| 1415 | |
| 1416 void PadEnvironmentForContinuation(HBasicBlock* from, | |
| 1417 HBasicBlock* continuation); | |
| 1418 | |
| 1425 CompilationInfo* info_; | 1419 CompilationInfo* info_; |
| 1426 HGraph* graph_; | 1420 HGraph* graph_; |
| 1427 HBasicBlock* current_block_; | 1421 HBasicBlock* current_block_; |
| 1428 int no_side_effects_scope_count_; | 1422 int no_side_effects_scope_count_; |
| 1429 }; | 1423 }; |
| 1430 | 1424 |
| 1425 | |
| 1426 template<> | |
| 1427 inline HDeoptimize* HGraphBuilder::Add(Deoptimizer::BailoutType type) { | |
| 1428 isolate()->counters()->soft_deopts_requested()->Increment(); | |
|
Jakob Kummerow
2013/07/22 16:53:12
This sounds pretty SOFT-deopt specific. I think th
danno
2013/07/23 12:18:14
Good catch. Done.
On 2013/07/22 16:53:12, Jakob wr
| |
| 1429 if (FLAG_always_opt && type == Deoptimizer::SOFT) return NULL; | |
| 1430 if (current_block()->IsDeoptimizing()) return NULL; | |
| 1431 HDeoptimize* instr = new(zone()) HDeoptimize(type); | |
| 1432 AddInstruction(instr); | |
| 1433 isolate()->counters()->soft_deopts_inserted()->Increment(); | |
| 1434 current_block()->MarkAsDeoptimizing(); | |
| 1435 graph()->set_has_soft_deoptimize(true); | |
| 1436 return instr; | |
| 1437 } | |
| 1438 | |
| 1439 | |
| 1440 template<> | |
| 1441 inline HDeoptimize* HGraphBuilder::Add() { | |
| 1442 return Add<HDeoptimize>(Deoptimizer::SOFT); | |
| 1443 } | |
| 1444 | |
| 1445 | |
| 1446 template<> | |
| 1447 inline HSimulate* HGraphBuilder::Add(BailoutId id, | |
| 1448 RemovableSimulate removable) { | |
| 1449 HSimulate* instr = current_block()->CreateSimulate(id, removable); | |
| 1450 AddInstruction(instr); | |
| 1451 return instr; | |
| 1452 } | |
| 1453 | |
| 1454 | |
| 1455 template<> | |
| 1456 inline HSimulate* HGraphBuilder::Add(BailoutId id) { | |
| 1457 return Add<HSimulate>(id, FIXED_SIMULATE); | |
| 1458 } | |
| 1459 | |
| 1460 | |
| 1461 template<> | |
| 1462 inline HReturn* HGraphBuilder::Add(HValue* value) { | |
| 1463 HValue* context = environment()->LookupContext(); | |
| 1464 int num_parameters = graph()->info()->num_parameters(); | |
| 1465 HValue* params = Add<HConstant>(num_parameters); | |
| 1466 HReturn* return_instruction = new(graph()->zone()) | |
| 1467 HReturn(value, context, params); | |
| 1468 current_block()->FinishExit(return_instruction); | |
| 1469 return return_instruction; | |
| 1470 } | |
| 1471 | |
| 1472 | |
| 1473 template<> | |
| 1474 inline HReturn* HGraphBuilder::Add(HConstant* p1) { | |
| 1475 return Add<HReturn>(static_cast<HValue*>(p1)); | |
| 1476 } | |
| 1477 | |
| 1478 | |
| 1431 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1479 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
| 1432 public: | 1480 public: |
| 1433 // A class encapsulating (lazily-allocated) break and continue blocks for | 1481 // A class encapsulating (lazily-allocated) break and continue blocks for |
| 1434 // a breakable statement. Separated from BreakAndContinueScope so that it | 1482 // a breakable statement. Separated from BreakAndContinueScope so that it |
| 1435 // can have a separate lifetime. | 1483 // can have a separate lifetime. |
| 1436 class BreakAndContinueInfo BASE_EMBEDDED { | 1484 class BreakAndContinueInfo BASE_EMBEDDED { |
| 1437 public: | 1485 public: |
| 1438 explicit BreakAndContinueInfo(BreakableStatement* target, | 1486 explicit BreakAndContinueInfo(BreakableStatement* target, |
| 1439 int drop_extra = 0) | 1487 int drop_extra = 0) |
| 1440 : target_(target), | 1488 : target_(target), |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1734 void HandlePropertyAssignment(Assignment* expr); | 1782 void HandlePropertyAssignment(Assignment* expr); |
| 1735 void HandleCompoundAssignment(Assignment* expr); | 1783 void HandleCompoundAssignment(Assignment* expr); |
| 1736 void HandlePolymorphicLoadNamedField(Property* expr, | 1784 void HandlePolymorphicLoadNamedField(Property* expr, |
| 1737 HValue* object, | 1785 HValue* object, |
| 1738 SmallMapList* types, | 1786 SmallMapList* types, |
| 1739 Handle<String> name); | 1787 Handle<String> name); |
| 1740 HInstruction* TryLoadPolymorphicAsMonomorphic(Property* expr, | 1788 HInstruction* TryLoadPolymorphicAsMonomorphic(Property* expr, |
| 1741 HValue* object, | 1789 HValue* object, |
| 1742 SmallMapList* types, | 1790 SmallMapList* types, |
| 1743 Handle<String> name); | 1791 Handle<String> name); |
| 1792 | |
| 1793 void HandlePolymorphicStoreNamedFieldHelper(HValue* object, | |
| 1794 Handle<String> name, | |
| 1795 HValue* value, | |
| 1796 SmallMapList* types, | |
| 1797 int current_type, | |
| 1798 int stored_count, | |
| 1799 int position); | |
| 1800 | |
| 1744 void HandlePolymorphicStoreNamedField(BailoutId id, | 1801 void HandlePolymorphicStoreNamedField(BailoutId id, |
| 1745 int position, | 1802 int position, |
| 1746 BailoutId assignment_id, | 1803 BailoutId assignment_id, |
| 1747 HValue* object, | 1804 HValue* object, |
| 1748 HValue* value, | 1805 HValue* value, |
| 1749 HValue* result, | 1806 HValue* result, |
| 1750 SmallMapList* types, | 1807 SmallMapList* types, |
| 1751 Handle<String> name); | 1808 Handle<String> name); |
| 1752 bool TryStorePolymorphicAsMonomorphic(int position, | 1809 bool TryStorePolymorphicAsMonomorphic(int position, |
| 1753 BailoutId assignment_id, | 1810 BailoutId assignment_id, |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2096 EmbeddedVector<char, 64> filename_; | 2153 EmbeddedVector<char, 64> filename_; |
| 2097 HeapStringAllocator string_allocator_; | 2154 HeapStringAllocator string_allocator_; |
| 2098 StringStream trace_; | 2155 StringStream trace_; |
| 2099 int indent_; | 2156 int indent_; |
| 2100 }; | 2157 }; |
| 2101 | 2158 |
| 2102 | 2159 |
| 2103 } } // namespace v8::internal | 2160 } } // namespace v8::internal |
| 2104 | 2161 |
| 2105 #endif // V8_HYDROGEN_H_ | 2162 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |