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); | 113 void AddInstruction(HInstruction* instr, int position); |
114 bool Dominates(HBasicBlock* other) const; | 114 bool Dominates(HBasicBlock* other) const; |
115 int LoopNestingDepth() const; | 115 int LoopNestingDepth() const; |
116 | 116 |
117 void SetInitialEnvironment(HEnvironment* env); | 117 void SetInitialEnvironment(HEnvironment* env); |
118 void ClearEnvironment() { | 118 void ClearEnvironment() { |
119 ASSERT(IsFinished()); | 119 ASSERT(IsFinished()); |
120 ASSERT(end()->SuccessorCount() == 0); | 120 ASSERT(end()->SuccessorCount() == 0); |
121 last_environment_ = NULL; | 121 last_environment_ = NULL; |
122 } | 122 } |
123 bool HasEnvironment() const { return last_environment_ != NULL; } | 123 bool HasEnvironment() const { return last_environment_ != NULL; } |
124 void UpdateEnvironment(HEnvironment* env); | 124 void UpdateEnvironment(HEnvironment* env); |
125 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } | 125 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } |
126 | 126 |
127 void set_parent_loop_header(HBasicBlock* block) { | 127 void set_parent_loop_header(HBasicBlock* block) { |
128 ASSERT(parent_loop_header_ == NULL); | 128 ASSERT(parent_loop_header_ == NULL); |
129 parent_loop_header_ = block; | 129 parent_loop_header_ = block; |
130 } | 130 } |
131 | 131 |
132 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } | 132 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } |
133 | 133 |
134 void SetJoinId(BailoutId ast_id); | 134 void SetJoinId(BailoutId ast_id); |
135 | 135 |
136 void Finish(HControlInstruction* last); | |
137 void FinishExit(HControlInstruction* instruction); | |
138 void Goto(HBasicBlock* block, | |
139 FunctionState* state = NULL, | |
140 bool add_simulate = true); | |
141 void GotoNoSimulate(HBasicBlock* block) { | |
142 Goto(block, NULL, false); | |
143 } | |
144 | |
145 int PredecessorIndexOf(HBasicBlock* predecessor) const; | 136 int PredecessorIndexOf(HBasicBlock* predecessor) const; |
146 HPhi* AddNewPhi(int merged_index); | 137 HPhi* AddNewPhi(int merged_index); |
147 HSimulate* AddNewSimulate(BailoutId ast_id, | 138 HSimulate* AddNewSimulate(BailoutId ast_id, |
139 int position, | |
148 RemovableSimulate removable = FIXED_SIMULATE) { | 140 RemovableSimulate removable = FIXED_SIMULATE) { |
149 HSimulate* instr = CreateSimulate(ast_id, removable); | 141 HSimulate* instr = CreateSimulate(ast_id, removable); |
150 AddInstruction(instr); | 142 AddInstruction(instr, position); |
151 return instr; | 143 return instr; |
152 } | 144 } |
153 void AssignCommonDominator(HBasicBlock* other); | 145 void AssignCommonDominator(HBasicBlock* other); |
154 void AssignLoopSuccessorDominators(); | 146 void AssignLoopSuccessorDominators(); |
155 | 147 |
156 // Add the inlined function exit sequence, adding an HLeaveInlined | |
157 // instruction and updating the bailout environment. | |
158 void AddLeaveInlined(HValue* return_value, FunctionState* state); | |
159 | |
160 // If a target block is tagged as an inline function return, all | 148 // If a target block is tagged as an inline function return, all |
161 // predecessors should contain the inlined exit sequence: | 149 // predecessors should contain the inlined exit sequence: |
162 // | 150 // |
163 // LeaveInlined | 151 // LeaveInlined |
164 // Simulate (caller's environment) | 152 // Simulate (caller's environment) |
165 // Goto (target block) | 153 // Goto (target block) |
166 bool IsInlineReturnTarget() const { return is_inline_return_target_; } | 154 bool IsInlineReturnTarget() const { return is_inline_return_target_; } |
167 void MarkAsInlineReturnTarget(HBasicBlock* inlined_entry_block) { | 155 void MarkAsInlineReturnTarget(HBasicBlock* inlined_entry_block) { |
168 is_inline_return_target_ = true; | 156 is_inline_return_target_ = true; |
169 inlined_entry_block_ = inlined_entry_block; | 157 inlined_entry_block_ = inlined_entry_block; |
(...skipping 14 matching lines...) Expand all Loading... | |
184 void MarkAsLoopSuccessorDominator() { | 172 void MarkAsLoopSuccessorDominator() { |
185 dominates_loop_successors_ = true; | 173 dominates_loop_successors_ = true; |
186 } | 174 } |
187 | 175 |
188 inline Zone* zone() const; | 176 inline Zone* zone() const; |
189 | 177 |
190 #ifdef DEBUG | 178 #ifdef DEBUG |
191 void Verify(); | 179 void Verify(); |
192 #endif | 180 #endif |
193 | 181 |
194 private: | 182 protected: |
195 friend class HGraphBuilder; | 183 friend class HGraphBuilder; |
196 | 184 |
185 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); | |
186 void Finish(HControlInstruction* last, int position); | |
187 void FinishExit(HControlInstruction* instruction, int position); | |
188 void Goto(HBasicBlock* block, | |
189 int position, | |
190 FunctionState* state = NULL, | |
191 bool add_simulate = true); | |
192 void GotoNoSimulate(HBasicBlock* block, int position) { | |
193 Goto(block, position, NULL, false); | |
194 } | |
195 // Add the inlined function exit sequence, adding an HLeaveInlined | |
Michael Starzinger
2013/10/18 13:04:21
nit: Can we add an empty new-line before the comme
danno
2013/10/19 17:11:40
Done.
| |
196 // instruction and updating the bailout environment. | |
197 void AddLeaveInlined(HValue* return_value, | |
198 FunctionState* state, | |
199 int position); | |
200 | |
201 private: | |
197 void RegisterPredecessor(HBasicBlock* pred); | 202 void RegisterPredecessor(HBasicBlock* pred); |
198 void AddDominatedBlock(HBasicBlock* block); | 203 void AddDominatedBlock(HBasicBlock* block); |
199 | 204 |
200 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); | |
201 | |
202 int block_id_; | 205 int block_id_; |
203 HGraph* graph_; | 206 HGraph* graph_; |
204 ZoneList<HPhi*> phis_; | 207 ZoneList<HPhi*> phis_; |
205 HInstruction* first_; | 208 HInstruction* first_; |
206 HInstruction* last_; | 209 HInstruction* last_; |
207 HControlInstruction* end_; | 210 HControlInstruction* end_; |
208 HLoopInformation* loop_information_; | 211 HLoopInformation* loop_information_; |
209 ZoneList<HBasicBlock*> predecessors_; | 212 ZoneList<HBasicBlock*> predecessors_; |
210 HBasicBlock* dominator_; | 213 HBasicBlock* dominator_; |
211 ZoneList<HBasicBlock*> dominated_blocks_; | 214 ZoneList<HBasicBlock*> dominated_blocks_; |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
933 HArgumentsElements* arguments_elements_; | 936 HArgumentsElements* arguments_elements_; |
934 | 937 |
935 FunctionState* outer_; | 938 FunctionState* outer_; |
936 }; | 939 }; |
937 | 940 |
938 | 941 |
939 class HIfContinuation V8_FINAL { | 942 class HIfContinuation V8_FINAL { |
940 public: | 943 public: |
941 HIfContinuation() : continuation_captured_(false) {} | 944 HIfContinuation() : continuation_captured_(false) {} |
942 HIfContinuation(HBasicBlock* true_branch, | 945 HIfContinuation(HBasicBlock* true_branch, |
943 HBasicBlock* false_branch, | 946 HBasicBlock* false_branch) |
944 int position = RelocInfo::kNoPosition) | |
945 : continuation_captured_(true), true_branch_(true_branch), | 947 : continuation_captured_(true), true_branch_(true_branch), |
946 false_branch_(false_branch), position_(position) {} | 948 false_branch_(false_branch) {} |
947 ~HIfContinuation() { ASSERT(!continuation_captured_); } | 949 ~HIfContinuation() { ASSERT(!continuation_captured_); } |
948 | 950 |
949 void Capture(HBasicBlock* true_branch, | 951 void Capture(HBasicBlock* true_branch, |
950 HBasicBlock* false_branch, | 952 HBasicBlock* false_branch) { |
951 int position) { | |
952 ASSERT(!continuation_captured_); | 953 ASSERT(!continuation_captured_); |
953 true_branch_ = true_branch; | 954 true_branch_ = true_branch; |
954 false_branch_ = false_branch; | 955 false_branch_ = false_branch; |
955 position_ = position; | |
956 continuation_captured_ = true; | 956 continuation_captured_ = true; |
957 } | 957 } |
958 | 958 |
959 void Continue(HBasicBlock** true_branch, | 959 void Continue(HBasicBlock** true_branch, |
960 HBasicBlock** false_branch, | 960 HBasicBlock** false_branch) { |
961 int* position) { | |
962 ASSERT(continuation_captured_); | 961 ASSERT(continuation_captured_); |
963 *true_branch = true_branch_; | 962 *true_branch = true_branch_; |
964 *false_branch = false_branch_; | 963 *false_branch = false_branch_; |
965 if (position != NULL) *position = position_; | |
966 continuation_captured_ = false; | 964 continuation_captured_ = false; |
967 } | 965 } |
968 | 966 |
969 bool IsTrueReachable() { return true_branch_ != NULL; } | 967 bool IsTrueReachable() { return true_branch_ != NULL; } |
970 bool IsFalseReachable() { return false_branch_ != NULL; } | 968 bool IsFalseReachable() { return false_branch_ != NULL; } |
971 bool TrueAndFalseReachable() { | 969 bool TrueAndFalseReachable() { |
972 return IsTrueReachable() || IsFalseReachable(); | 970 return IsTrueReachable() || IsFalseReachable(); |
973 } | 971 } |
974 | 972 |
975 HBasicBlock* true_branch() const { return true_branch_; } | 973 HBasicBlock* true_branch() const { return true_branch_; } |
976 HBasicBlock* false_branch() const { return false_branch_; } | 974 HBasicBlock* false_branch() const { return false_branch_; } |
977 | 975 |
978 private: | 976 private: |
979 bool continuation_captured_; | 977 bool continuation_captured_; |
980 HBasicBlock* true_branch_; | 978 HBasicBlock* true_branch_; |
981 HBasicBlock* false_branch_; | 979 HBasicBlock* false_branch_; |
982 int position_; | |
983 }; | 980 }; |
984 | 981 |
985 | 982 |
986 class HGraphBuilder { | 983 class HGraphBuilder { |
987 public: | 984 public: |
988 explicit HGraphBuilder(CompilationInfo* info) | 985 explicit HGraphBuilder(CompilationInfo* info) |
989 : info_(info), | 986 : info_(info), |
990 graph_(NULL), | 987 graph_(NULL), |
991 current_block_(NULL) {} | 988 current_block_(NULL), |
989 position_(RelocInfo::kNoPosition) {} | |
992 virtual ~HGraphBuilder() {} | 990 virtual ~HGraphBuilder() {} |
993 | 991 |
994 HBasicBlock* current_block() const { return current_block_; } | 992 HBasicBlock* current_block() const { return current_block_; } |
995 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 993 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
996 HEnvironment* environment() const { | 994 HEnvironment* environment() const { |
997 return current_block()->last_environment(); | 995 return current_block()->last_environment(); |
998 } | 996 } |
999 Zone* zone() const { return info_->zone(); } | 997 Zone* zone() const { return info_->zone(); } |
1000 HGraph* graph() const { return graph_; } | 998 HGraph* graph() const { return graph_; } |
1001 Isolate* isolate() const { return graph_->isolate(); } | 999 Isolate* isolate() const { return graph_->isolate(); } |
1002 CompilationInfo* top_info() { return info_; } | 1000 CompilationInfo* top_info() { return info_; } |
1003 | 1001 |
1004 HGraph* CreateGraph(); | 1002 HGraph* CreateGraph(); |
1005 | 1003 |
1006 // Bailout environment manipulation. | 1004 // Bailout environment manipulation. |
1007 void Push(HValue* value) { environment()->Push(value); } | 1005 void Push(HValue* value) { environment()->Push(value); } |
1008 HValue* Pop() { return environment()->Pop(); } | 1006 HValue* Pop() { return environment()->Pop(); } |
1009 | 1007 |
1010 virtual HValue* context() = 0; | 1008 virtual HValue* context() = 0; |
1011 | 1009 |
1012 // Adding instructions. | 1010 // Adding instructions. |
1013 HInstruction* AddInstruction(HInstruction* instr); | 1011 HInstruction* AddInstruction(HInstruction* instr); |
1012 void FinishCurrentBlock(HControlInstruction* last); | |
1013 void FinishExitCurrentBlock(HControlInstruction* instruction); | |
1014 | |
1015 void Goto(HBasicBlock* from, | |
1016 HBasicBlock* target, | |
1017 FunctionState* state = NULL, | |
1018 bool add_simulate = true) { | |
1019 from->Goto(target, position_, state, add_simulate); | |
1020 } | |
1021 void Goto(HBasicBlock* target, | |
1022 FunctionState* state = NULL, | |
1023 bool add_simulate = true) { | |
1024 Goto(current_block(), target, state, add_simulate); | |
1025 } | |
1026 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) { | |
1027 Goto(from, target, NULL, false); | |
1028 } | |
1029 void GotoNoSimulate(HBasicBlock* target) { | |
1030 Goto(target, NULL, false); | |
1031 } | |
1032 void AddLeaveInlined(HBasicBlock* block, | |
1033 HValue* return_value, | |
1034 FunctionState* state) { | |
1035 block->AddLeaveInlined(return_value, state, position_); | |
1036 } | |
1037 void AddLeaveInlined(HValue* return_value, FunctionState* state) { | |
1038 return AddLeaveInlined(current_block(), return_value, state); | |
1039 } | |
1014 | 1040 |
1015 template<class I> | 1041 template<class I> |
1016 HInstruction* NewUncasted() { return I::New(zone(), context()); } | 1042 HInstruction* NewUncasted() { return I::New(zone(), context()); } |
1017 | 1043 |
1018 template<class I> | 1044 template<class I> |
1019 I* New() { return I::cast(NewUncasted<I>()); } | 1045 I* New() { return I::cast(NewUncasted<I>()); } |
1020 | 1046 |
1021 template<class I> | 1047 template<class I> |
1022 HInstruction* AddUncasted() { return AddInstruction(NewUncasted<I>());} | 1048 HInstruction* AddUncasted() { return AddInstruction(NewUncasted<I>());} |
1023 | 1049 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1198 | 1224 |
1199 template<class I, class P1, class P2, class P3, class P4, | 1225 template<class I, class P1, class P2, class P3, class P4, |
1200 class P5, class P6, class P7, class P8> | 1226 class P5, class P6, class P7, class P8> |
1201 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { | 1227 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
1202 return I::cast( | 1228 return I::cast( |
1203 AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8))); | 1229 AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8))); |
1204 } | 1230 } |
1205 | 1231 |
1206 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); | 1232 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); |
1207 | 1233 |
1234 int position() const { return position_; } | |
1235 | |
1208 protected: | 1236 protected: |
1209 virtual bool BuildGraph() = 0; | 1237 virtual bool BuildGraph() = 0; |
1210 | 1238 |
1211 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1239 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
1212 HBasicBlock* CreateLoopHeaderBlock(); | 1240 HBasicBlock* CreateLoopHeaderBlock(); |
1213 | 1241 |
1214 HValue* BuildCheckHeapObject(HValue* object); | 1242 HValue* BuildCheckHeapObject(HValue* object); |
1215 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | 1243 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
1216 HValue* BuildWrapReceiver(HValue* object, HValue* function); | 1244 HValue* BuildWrapReceiver(HValue* object, HValue* function); |
1217 | 1245 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1299 | 1327 |
1300 void PushAndAdd(HInstruction* instr); | 1328 void PushAndAdd(HInstruction* instr); |
1301 | 1329 |
1302 void FinishExitWithHardDeoptimization(const char* reason, | 1330 void FinishExitWithHardDeoptimization(const char* reason, |
1303 HBasicBlock* continuation); | 1331 HBasicBlock* continuation); |
1304 | 1332 |
1305 void AddIncrementCounter(StatsCounter* counter); | 1333 void AddIncrementCounter(StatsCounter* counter); |
1306 | 1334 |
1307 class IfBuilder V8_FINAL { | 1335 class IfBuilder V8_FINAL { |
1308 public: | 1336 public: |
1309 explicit IfBuilder(HGraphBuilder* builder, | 1337 explicit IfBuilder(HGraphBuilder* builder); |
1310 int position = RelocInfo::kNoPosition); | |
1311 IfBuilder(HGraphBuilder* builder, | 1338 IfBuilder(HGraphBuilder* builder, |
1312 HIfContinuation* continuation); | 1339 HIfContinuation* continuation); |
1313 | 1340 |
1314 ~IfBuilder() { | 1341 ~IfBuilder() { |
1315 if (!finished_) End(); | 1342 if (!finished_) End(); |
1316 } | 1343 } |
1317 | 1344 |
1318 template<class Condition> | 1345 template<class Condition> |
1319 Condition* If(HValue *p) { | 1346 Condition* If(HValue *p) { |
1320 Condition* compare = builder()->New<Condition>(p); | 1347 Condition* compare = builder()->New<Condition>(p); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1451 } | 1478 } |
1452 | 1479 |
1453 void Return(HValue* value); | 1480 void Return(HValue* value); |
1454 | 1481 |
1455 private: | 1482 private: |
1456 HControlInstruction* AddCompare(HControlInstruction* compare); | 1483 HControlInstruction* AddCompare(HControlInstruction* compare); |
1457 | 1484 |
1458 HGraphBuilder* builder() const { return builder_; } | 1485 HGraphBuilder* builder() const { return builder_; } |
1459 | 1486 |
1460 HGraphBuilder* builder_; | 1487 HGraphBuilder* builder_; |
1461 int position_; | |
1462 bool finished_ : 1; | 1488 bool finished_ : 1; |
1463 bool deopt_then_ : 1; | 1489 bool deopt_then_ : 1; |
1464 bool deopt_else_ : 1; | 1490 bool deopt_else_ : 1; |
1465 bool did_then_ : 1; | 1491 bool did_then_ : 1; |
1466 bool did_else_ : 1; | 1492 bool did_else_ : 1; |
1467 bool did_and_ : 1; | 1493 bool did_and_ : 1; |
1468 bool did_or_ : 1; | 1494 bool did_or_ : 1; |
1469 bool captured_ : 1; | 1495 bool captured_ : 1; |
1470 bool needs_compare_ : 1; | 1496 bool needs_compare_ : 1; |
1471 HBasicBlock* first_true_block_; | 1497 HBasicBlock* first_true_block_; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1612 | 1638 |
1613 HValue* BuildCloneShallowArray(HValue* boilerplate, | 1639 HValue* BuildCloneShallowArray(HValue* boilerplate, |
1614 HValue* allocation_site, | 1640 HValue* allocation_site, |
1615 AllocationSiteMode mode, | 1641 AllocationSiteMode mode, |
1616 ElementsKind kind, | 1642 ElementsKind kind, |
1617 int length); | 1643 int length); |
1618 | 1644 |
1619 void BuildCompareNil( | 1645 void BuildCompareNil( |
1620 HValue* value, | 1646 HValue* value, |
1621 Handle<Type> type, | 1647 Handle<Type> type, |
1622 int position, | |
1623 HIfContinuation* continuation); | 1648 HIfContinuation* continuation); |
1624 | 1649 |
1625 HValue* BuildCreateAllocationMemento(HValue* previous_object, | 1650 HValue* BuildCreateAllocationMemento(HValue* previous_object, |
1626 int previous_object_size, | 1651 int previous_object_size, |
1627 HValue* payload); | 1652 HValue* payload); |
1628 | 1653 |
1629 HInstruction* BuildConstantMapCheck(Handle<JSObject> constant, | 1654 HInstruction* BuildConstantMapCheck(Handle<JSObject> constant, |
1630 CompilationInfo* info); | 1655 CompilationInfo* info); |
1631 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, | 1656 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, |
1632 Handle<JSObject> holder); | 1657 Handle<JSObject> holder); |
1633 | 1658 |
1634 HInstruction* BuildGetNativeContext(); | 1659 HInstruction* BuildGetNativeContext(); |
1635 HInstruction* BuildGetArrayFunction(); | 1660 HInstruction* BuildGetArrayFunction(); |
1636 | 1661 |
1662 protected: | |
1663 void SetSourcePosition(int position) { | |
1664 ASSERT(position != RelocInfo::kNoPosition); | |
1665 position_ = position; | |
1666 } | |
1667 | |
1637 private: | 1668 private: |
1638 HGraphBuilder(); | 1669 HGraphBuilder(); |
1639 | 1670 |
1640 void PadEnvironmentForContinuation(HBasicBlock* from, | 1671 void PadEnvironmentForContinuation(HBasicBlock* from, |
1641 HBasicBlock* continuation); | 1672 HBasicBlock* continuation); |
1642 | 1673 |
1643 CompilationInfo* info_; | 1674 CompilationInfo* info_; |
1644 HGraph* graph_; | 1675 HGraph* graph_; |
1645 HBasicBlock* current_block_; | 1676 HBasicBlock* current_block_; |
1677 int position_; | |
1646 }; | 1678 }; |
1647 | 1679 |
1648 | 1680 |
1649 template<> | 1681 template<> |
1650 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>( | 1682 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>( |
1651 const char* reason, Deoptimizer::BailoutType type) { | 1683 const char* reason, Deoptimizer::BailoutType type) { |
1652 if (type == Deoptimizer::SOFT) { | 1684 if (type == Deoptimizer::SOFT) { |
1653 isolate()->counters()->soft_deopts_requested()->Increment(); | 1685 isolate()->counters()->soft_deopts_requested()->Increment(); |
1654 if (FLAG_always_opt) return NULL; | 1686 if (FLAG_always_opt) return NULL; |
1655 } | 1687 } |
1656 if (current_block()->IsDeoptimizing()) return NULL; | 1688 if (current_block()->IsDeoptimizing()) return NULL; |
1657 HBasicBlock* after_deopt_block = CreateBasicBlock( | 1689 HBasicBlock* after_deopt_block = CreateBasicBlock( |
1658 current_block()->last_environment()); | 1690 current_block()->last_environment()); |
1659 HDeoptimize* instr = New<HDeoptimize>(reason, type, after_deopt_block); | 1691 HDeoptimize* instr = New<HDeoptimize>(reason, type, after_deopt_block); |
1660 if (type == Deoptimizer::SOFT) { | 1692 if (type == Deoptimizer::SOFT) { |
1661 isolate()->counters()->soft_deopts_inserted()->Increment(); | 1693 isolate()->counters()->soft_deopts_inserted()->Increment(); |
1662 } | 1694 } |
1663 current_block()->Finish(instr); | 1695 FinishCurrentBlock(instr); |
1664 set_current_block(after_deopt_block); | 1696 set_current_block(after_deopt_block); |
1665 return instr; | 1697 return instr; |
1666 } | 1698 } |
1667 | 1699 |
1668 | 1700 |
1669 template<> | 1701 template<> |
1670 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( | 1702 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( |
1671 const char* reason, Deoptimizer::BailoutType type) { | 1703 const char* reason, Deoptimizer::BailoutType type) { |
1672 return static_cast<HDeoptimize*>(AddUncasted<HDeoptimize>(reason, type)); | 1704 return static_cast<HDeoptimize*>(AddUncasted<HDeoptimize>(reason, type)); |
1673 } | 1705 } |
(...skipping 13 matching lines...) Expand all Loading... | |
1687 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>(BailoutId id) { | 1719 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>(BailoutId id) { |
1688 return AddUncasted<HSimulate>(id, FIXED_SIMULATE); | 1720 return AddUncasted<HSimulate>(id, FIXED_SIMULATE); |
1689 } | 1721 } |
1690 | 1722 |
1691 | 1723 |
1692 template<> | 1724 template<> |
1693 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HValue* value) { | 1725 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HValue* value) { |
1694 int num_parameters = graph()->info()->num_parameters(); | 1726 int num_parameters = graph()->info()->num_parameters(); |
1695 HValue* params = AddUncasted<HConstant>(num_parameters); | 1727 HValue* params = AddUncasted<HConstant>(num_parameters); |
1696 HReturn* return_instruction = New<HReturn>(value, params); | 1728 HReturn* return_instruction = New<HReturn>(value, params); |
1697 current_block()->FinishExit(return_instruction); | 1729 FinishExitCurrentBlock(return_instruction); |
1698 return return_instruction; | 1730 return return_instruction; |
1699 } | 1731 } |
1700 | 1732 |
1701 | 1733 |
1702 template<> | 1734 template<> |
1703 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HConstant* value) { | 1735 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HConstant* value) { |
1704 return AddUncasted<HReturn>(static_cast<HValue*>(value)); | 1736 return AddUncasted<HReturn>(static_cast<HValue*>(value)); |
1705 } | 1737 } |
1706 | 1738 |
1707 | 1739 |
(...skipping 13 matching lines...) Expand all Loading... | |
1721 return instr; | 1753 return instr; |
1722 } | 1754 } |
1723 | 1755 |
1724 | 1756 |
1725 template<> | 1757 template<> |
1726 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { | 1758 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { |
1727 return HContext::New(zone()); | 1759 return HContext::New(zone()); |
1728 } | 1760 } |
1729 | 1761 |
1730 | 1762 |
1731 class HOptimizedGraphBuilder V8_FINAL | 1763 class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { |
1732 : public HGraphBuilder, public AstVisitor { | |
1733 public: | 1764 public: |
1734 // A class encapsulating (lazily-allocated) break and continue blocks for | 1765 // A class encapsulating (lazily-allocated) break and continue blocks for |
1735 // a breakable statement. Separated from BreakAndContinueScope so that it | 1766 // a breakable statement. Separated from BreakAndContinueScope so that it |
1736 // can have a separate lifetime. | 1767 // can have a separate lifetime. |
1737 class BreakAndContinueInfo V8_FINAL BASE_EMBEDDED { | 1768 class BreakAndContinueInfo V8_FINAL BASE_EMBEDDED { |
1738 public: | 1769 public: |
1739 explicit BreakAndContinueInfo(BreakableStatement* target, | 1770 explicit BreakAndContinueInfo(BreakableStatement* target, |
1740 int drop_extra = 0) | 1771 int drop_extra = 0) |
1741 : target_(target), | 1772 : target_(target), |
1742 break_block_(NULL), | 1773 break_block_(NULL), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1809 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 1840 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
1810 | 1841 |
1811 void* operator new(size_t size, Zone* zone) { | 1842 void* operator new(size_t size, Zone* zone) { |
1812 return zone->New(static_cast<int>(size)); | 1843 return zone->New(static_cast<int>(size)); |
1813 } | 1844 } |
1814 void operator delete(void* pointer, Zone* zone) { } | 1845 void operator delete(void* pointer, Zone* zone) { } |
1815 void operator delete(void* pointer) { } | 1846 void operator delete(void* pointer) { } |
1816 | 1847 |
1817 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 1848 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
1818 | 1849 |
1819 private: | 1850 protected: |
1820 // Type of a member function that generates inline code for a native function. | 1851 // Type of a member function that generates inline code for a native function. |
1821 typedef void (HOptimizedGraphBuilder::*InlineFunctionGenerator) | 1852 typedef void (HOptimizedGraphBuilder::*InlineFunctionGenerator) |
1822 (CallRuntime* call); | 1853 (CallRuntime* call); |
1823 | 1854 |
1824 // Forward declarations for inner scope classes. | 1855 // Forward declarations for inner scope classes. |
1825 class SubgraphScope; | 1856 class SubgraphScope; |
1826 | 1857 |
1827 static const InlineFunctionGenerator kInlineFunctionGenerators[]; | 1858 static const InlineFunctionGenerator kInlineFunctionGenerators[]; |
1828 | 1859 |
1829 static const int kMaxCallPolymorphism = 4; | 1860 static const int kMaxCallPolymorphism = 4; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2030 | 2061 |
2031 // If --trace-inlining, print a line of the inlining trace. Inlining | 2062 // If --trace-inlining, print a line of the inlining trace. Inlining |
2032 // succeeded if the reason string is NULL and failed if there is a | 2063 // succeeded if the reason string is NULL and failed if there is a |
2033 // non-NULL reason string. | 2064 // non-NULL reason string. |
2034 void TraceInline(Handle<JSFunction> target, | 2065 void TraceInline(Handle<JSFunction> target, |
2035 Handle<JSFunction> caller, | 2066 Handle<JSFunction> caller, |
2036 const char* failure_reason); | 2067 const char* failure_reason); |
2037 | 2068 |
2038 void HandleGlobalVariableAssignment(Variable* var, | 2069 void HandleGlobalVariableAssignment(Variable* var, |
2039 HValue* value, | 2070 HValue* value, |
2040 int position, | |
2041 BailoutId ast_id); | 2071 BailoutId ast_id); |
2042 | 2072 |
2043 void HandlePropertyAssignment(Assignment* expr); | 2073 void HandlePropertyAssignment(Assignment* expr); |
2044 void HandleCompoundAssignment(Assignment* expr); | 2074 void HandleCompoundAssignment(Assignment* expr); |
2045 void HandlePolymorphicLoadNamedField(int position, | 2075 void HandlePolymorphicLoadNamedField(BailoutId ast_id, |
2046 BailoutId ast_id, | |
2047 BailoutId return_id, | 2076 BailoutId return_id, |
2048 HValue* object, | 2077 HValue* object, |
2049 SmallMapList* types, | 2078 SmallMapList* types, |
2050 Handle<String> name); | 2079 Handle<String> name); |
2051 | 2080 |
2052 class PropertyAccessInfo { | 2081 class PropertyAccessInfo { |
2053 public: | 2082 public: |
2054 PropertyAccessInfo(Isolate* isolate, Handle<Map> map, Handle<String> name) | 2083 PropertyAccessInfo(Isolate* isolate, Handle<Map> map, Handle<String> name) |
2055 : lookup_(isolate), | 2084 : lookup_(isolate), |
2056 map_(map), | 2085 map_(map), |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2133 HObjectAccess access_; | 2162 HObjectAccess access_; |
2134 }; | 2163 }; |
2135 | 2164 |
2136 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, | 2165 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, |
2137 HValue* object, | 2166 HValue* object, |
2138 HInstruction* checked_object, | 2167 HInstruction* checked_object, |
2139 BailoutId ast_id, | 2168 BailoutId ast_id, |
2140 BailoutId return_id, | 2169 BailoutId return_id, |
2141 bool can_inline_accessor = true); | 2170 bool can_inline_accessor = true); |
2142 | 2171 |
2143 void HandlePolymorphicStoreNamedField(int position, | 2172 void HandlePolymorphicStoreNamedField(BailoutId assignment_id, |
2144 BailoutId assignment_id, | |
2145 HValue* object, | 2173 HValue* object, |
2146 HValue* value, | 2174 HValue* value, |
2147 SmallMapList* types, | 2175 SmallMapList* types, |
2148 Handle<String> name); | 2176 Handle<String> name); |
2149 bool TryStorePolymorphicAsMonomorphic(int position, | 2177 bool TryStorePolymorphicAsMonomorphic(BailoutId assignment_id, |
2150 BailoutId assignment_id, | |
2151 HValue* object, | 2178 HValue* object, |
2152 HValue* value, | 2179 HValue* value, |
2153 SmallMapList* types, | 2180 SmallMapList* types, |
2154 Handle<String> name); | 2181 Handle<String> name); |
2155 void HandlePolymorphicCallNamed(Call* expr, | 2182 void HandlePolymorphicCallNamed(Call* expr, |
2156 HValue* receiver, | 2183 HValue* receiver, |
2157 SmallMapList* types, | 2184 SmallMapList* types, |
2158 Handle<String> name); | 2185 Handle<String> name); |
2159 bool TryCallPolymorphicAsMonomorphic(Call* expr, | 2186 bool TryCallPolymorphicAsMonomorphic(Call* expr, |
2160 HValue* receiver, | 2187 HValue* receiver, |
(...skipping 29 matching lines...) Expand all Loading... | |
2190 HValue* dependency, | 2217 HValue* dependency, |
2191 Handle<Map> map, | 2218 Handle<Map> map, |
2192 bool is_store, | 2219 bool is_store, |
2193 KeyedAccessStoreMode store_mode); | 2220 KeyedAccessStoreMode store_mode); |
2194 | 2221 |
2195 HValue* HandlePolymorphicElementAccess(HValue* object, | 2222 HValue* HandlePolymorphicElementAccess(HValue* object, |
2196 HValue* key, | 2223 HValue* key, |
2197 HValue* val, | 2224 HValue* val, |
2198 SmallMapList* maps, | 2225 SmallMapList* maps, |
2199 BailoutId ast_id, | 2226 BailoutId ast_id, |
2200 int position, | |
2201 bool is_store, | 2227 bool is_store, |
2202 KeyedAccessStoreMode store_mode, | 2228 KeyedAccessStoreMode store_mode, |
2203 bool* has_side_effects); | 2229 bool* has_side_effects); |
2204 | 2230 |
2205 HValue* HandleKeyedElementAccess(HValue* obj, | 2231 HValue* HandleKeyedElementAccess(HValue* obj, |
2206 HValue* key, | 2232 HValue* key, |
2207 HValue* val, | 2233 HValue* val, |
2208 Expression* expr, | 2234 Expression* expr, |
2209 BailoutId ast_id, | 2235 BailoutId ast_id, |
2210 int position, | |
2211 bool is_store, | 2236 bool is_store, |
2212 bool* has_side_effects); | 2237 bool* has_side_effects); |
2213 | 2238 |
2214 HInstruction* BuildLoadNamedGeneric(HValue* object, | 2239 HInstruction* BuildLoadNamedGeneric(HValue* object, |
2215 Handle<String> name, | 2240 Handle<String> name, |
2216 Property* expr); | 2241 Property* expr); |
2217 | 2242 |
2218 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); | 2243 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); |
2219 | 2244 |
2220 void BuildLoad(Property* property, | 2245 void BuildLoad(Property* property, |
2221 int position, | |
2222 BailoutId ast_id); | 2246 BailoutId ast_id); |
2223 void PushLoad(Property* property, | 2247 void PushLoad(Property* property, |
2224 HValue* object, | 2248 HValue* object, |
2225 HValue* key, | 2249 HValue* key); |
2226 int position); | |
2227 | 2250 |
2228 void BuildStoreForEffect(Expression* expression, | 2251 void BuildStoreForEffect(Expression* expression, |
2229 Property* prop, | 2252 Property* prop, |
2230 BailoutId ast_id, | 2253 BailoutId ast_id, |
2231 BailoutId return_id, | 2254 BailoutId return_id, |
2232 HValue* object, | 2255 HValue* object, |
2233 HValue* key, | 2256 HValue* key, |
2234 HValue* value); | 2257 HValue* value); |
2235 | 2258 |
2236 void BuildStore(Expression* expression, | 2259 void BuildStore(Expression* expression, |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2474 } | 2497 } |
2475 | 2498 |
2476 private: | 2499 private: |
2477 HGraphBuilder* builder_; | 2500 HGraphBuilder* builder_; |
2478 }; | 2501 }; |
2479 | 2502 |
2480 | 2503 |
2481 } } // namespace v8::internal | 2504 } } // namespace v8::internal |
2482 | 2505 |
2483 #endif // V8_HYDROGEN_H_ | 2506 #endif // V8_HYDROGEN_H_ |
OLD | NEW |