| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 case Bytecode::kLdaUndefined: | 101 case Bytecode::kLdaUndefined: |
| 102 return {PeepholeAction::kTransformLdaStarToLdrLdarAction, | 102 return {PeepholeAction::kTransformLdaStarToLdrLdarAction, |
| 103 Bytecode::kLdrUndefined}; | 103 Bytecode::kLdrUndefined}; |
| 104 default: | 104 default: |
| 105 break; | 105 break; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 // ToName bytecodes can be replaced by Star with the same output register if | 109 // ToName bytecodes can be replaced by Star with the same output register if |
| 110 // the value in the accumulator is already a name. | 110 // the value in the accumulator is already a name. |
| 111 if (current == Bytecode::kToName) { | 111 if (current == Bytecode::kToName && Bytecodes::PutsNameInAccumulator(last)) { |
| 112 if (last == Bytecode::kLdaConstant) { | 112 return {PeepholeAction::kChangeBytecodeAction, Bytecode::kStar}; |
| 113 return {PeepholeAction::kTransformToStarIfLoadingNameConstantAction, | |
| 114 Bytecode::kIllegal}; | |
| 115 } else if (Bytecodes::PutsNameInAccumulator(last)) { | |
| 116 return {PeepholeAction::kChangeBytecodeAction, Bytecode::kStar}; | |
| 117 } | |
| 118 } | 113 } |
| 119 | 114 |
| 120 // Nop are placeholders for holding source position information and can be | 115 // Nop are placeholders for holding source position information and can be |
| 121 // elided if there is no source information. | 116 // elided if there is no source information. |
| 122 if (last == Bytecode::kNop) { | 117 if (last == Bytecode::kNop) { |
| 123 if (Bytecodes::IsJump(current)) { | 118 if (Bytecodes::IsJump(current)) { |
| 124 return {PeepholeAction::kElideLastBeforeJumpAction, Bytecode::kIllegal}; | 119 return {PeepholeAction::kElideLastBeforeJumpAction, Bytecode::kIllegal}; |
| 125 } else { | 120 } else { |
| 126 return {PeepholeAction::kElideLastAction, Bytecode::kIllegal}; | 121 return {PeepholeAction::kElideLastAction, Bytecode::kIllegal}; |
| 127 } | 122 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 374 |
| 380 std::ofstream ofs(argv[1], std::ofstream::trunc); | 375 std::ofstream ofs(argv[1], std::ofstream::trunc); |
| 381 v8::internal::interpreter::PeepholeActionTableWriter writer; | 376 v8::internal::interpreter::PeepholeActionTableWriter writer; |
| 382 writer.BuildTable(); | 377 writer.BuildTable(); |
| 383 writer.Write(ofs); | 378 writer.Write(ofs); |
| 384 ofs.flush(); | 379 ofs.flush(); |
| 385 ofs.close(); | 380 ofs.close(); |
| 386 | 381 |
| 387 return 0; | 382 return 0; |
| 388 } | 383 } |
| OLD | NEW |