OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <array> | 5 #include <array> |
6 #include <fstream> | 6 #include <fstream> |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 PeepholeAction::kTransformLdaZeroBinaryOpToBinaryOpWithZeroAction, | 188 PeepholeAction::kTransformLdaZeroBinaryOpToBinaryOpWithZeroAction, |
189 Bytecode::kShiftRightSmi}; | 189 Bytecode::kShiftRightSmi}; |
190 default: | 190 default: |
191 break; | 191 break; |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 // Fuse LdaNull/LdaUndefined followed by a equality comparison with test | 195 // Fuse LdaNull/LdaUndefined followed by a equality comparison with test |
196 // undetectable. Testing undetectable is a simple check on the map which is | 196 // undetectable. Testing undetectable is a simple check on the map which is |
197 // more efficient than the full comparison operation. | 197 // more efficient than the full comparison operation. |
198 // Note: StrictEquals cannot use this, they need to compare it with the | |
199 // Null/undefined map. | |
200 if (last == Bytecode::kLdaNull || last == Bytecode::kLdaUndefined) { | 198 if (last == Bytecode::kLdaNull || last == Bytecode::kLdaUndefined) { |
201 if (current == Bytecode::kTestEqual) { | 199 if (current == Bytecode::kTestEqual) { |
202 return {PeepholeAction:: | 200 return {PeepholeAction::kTransformEqualityWithNullOrUndefinedAction, |
203 kTransformEqualityWithNullOrUndefinedToTestUndetectableAction, | 201 Bytecode::kTestUndetectable}; |
204 Bytecode::kIllegal}; | |
205 } | 202 } |
206 } | 203 } |
207 | 204 |
| 205 // Fuse LdaNull/LdaUndefined followed by a strict equals with |
| 206 // TestNull/TestUndefined. |
| 207 if (current == Bytecode::kTestEqualStrict) { |
| 208 if (last == Bytecode::kLdaNull) { |
| 209 return {PeepholeAction::kTransformEqualityWithNullOrUndefinedAction, |
| 210 Bytecode::kTestNull}; |
| 211 } else if (last == Bytecode::kLdaUndefined) { |
| 212 return {PeepholeAction::kTransformEqualityWithNullOrUndefinedAction, |
| 213 Bytecode::kTestUndefined}; |
| 214 } |
| 215 } |
| 216 |
208 // If there is no last bytecode to optimize against, store the incoming | 217 // If there is no last bytecode to optimize against, store the incoming |
209 // bytecode or for jumps emit incoming bytecode immediately. | 218 // bytecode or for jumps emit incoming bytecode immediately. |
210 if (last == Bytecode::kIllegal) { | 219 if (last == Bytecode::kIllegal) { |
211 if (Bytecodes::IsJump(current)) { | 220 if (Bytecodes::IsJump(current)) { |
212 return {PeepholeAction::kUpdateLastJumpAction, Bytecode::kIllegal}; | 221 return {PeepholeAction::kUpdateLastJumpAction, Bytecode::kIllegal}; |
213 } else if (current == Bytecode::kNop) { | 222 } else if (current == Bytecode::kNop) { |
214 return {PeepholeAction::kUpdateLastIfSourceInfoPresentAction, | 223 return {PeepholeAction::kUpdateLastIfSourceInfoPresentAction, |
215 Bytecode::kIllegal}; | 224 Bytecode::kIllegal}; |
216 } else { | 225 } else { |
217 return {PeepholeAction::kUpdateLastAction, Bytecode::kIllegal}; | 226 return {PeepholeAction::kUpdateLastAction, Bytecode::kIllegal}; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 372 |
364 std::ofstream ofs(argv[1], std::ofstream::trunc); | 373 std::ofstream ofs(argv[1], std::ofstream::trunc); |
365 v8::internal::interpreter::PeepholeActionTableWriter writer; | 374 v8::internal::interpreter::PeepholeActionTableWriter writer; |
366 writer.BuildTable(); | 375 writer.BuildTable(); |
367 writer.Write(ofs); | 376 writer.Write(ofs); |
368 ofs.flush(); | 377 ofs.flush(); |
369 ofs.close(); | 378 ofs.close(); |
370 | 379 |
371 return 0; | 380 return 0; |
372 } | 381 } |
OLD | NEW |