| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // values. Only the first bytecode is needed if there's a sequence | 115 // values. Only the first bytecode is needed if there's a sequence |
| 116 // of back-to-back Ldar and Star bytecodes with the same operand. | 116 // of back-to-back Ldar and Star bytecodes with the same operand. |
| 117 if (Bytecodes::IsLdarOrStar(last) && Bytecodes::IsLdarOrStar(current)) { | 117 if (Bytecodes::IsLdarOrStar(last) && Bytecodes::IsLdarOrStar(current)) { |
| 118 return {PeepholeAction::kElideCurrentIfOperand0MatchesAction, | 118 return {PeepholeAction::kElideCurrentIfOperand0MatchesAction, |
| 119 Bytecode::kIllegal}; | 119 Bytecode::kIllegal}; |
| 120 } | 120 } |
| 121 | 121 |
| 122 // TODO(rmcilroy): Add elide for consecutive mov to and from the same | 122 // TODO(rmcilroy): Add elide for consecutive mov to and from the same |
| 123 // register. | 123 // register. |
| 124 | 124 |
| 125 // Remove ToBoolean coercion from conditional jumps where possible. | |
| 126 if (Bytecodes::WritesBooleanToAccumulator(last)) { | |
| 127 if (Bytecodes::IsJumpIfToBoolean(current)) { | |
| 128 return {PeepholeAction::kChangeJumpBytecodeAction, | |
| 129 Bytecodes::GetJumpWithoutToBoolean(current)}; | |
| 130 } else if (current == Bytecode::kToBooleanLogicalNot) { | |
| 131 return {PeepholeAction::kChangeBytecodeAction, Bytecode::kLogicalNot}; | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 // Fuse LdaSmi followed by binary op to produce binary op with a | 125 // Fuse LdaSmi followed by binary op to produce binary op with a |
| 136 // immediate integer argument. This savaes on dispatches and size. | 126 // immediate integer argument. This savaes on dispatches and size. |
| 137 if (last == Bytecode::kLdaSmi) { | 127 if (last == Bytecode::kLdaSmi) { |
| 138 switch (current) { | 128 switch (current) { |
| 139 case Bytecode::kAdd: | 129 case Bytecode::kAdd: |
| 140 return {PeepholeAction::kTransformLdaSmiBinaryOpToBinaryOpWithSmiAction, | 130 return {PeepholeAction::kTransformLdaSmiBinaryOpToBinaryOpWithSmiAction, |
| 141 Bytecode::kAddSmi}; | 131 Bytecode::kAddSmi}; |
| 142 case Bytecode::kSub: | 132 case Bytecode::kSub: |
| 143 return {PeepholeAction::kTransformLdaSmiBinaryOpToBinaryOpWithSmiAction, | 133 return {PeepholeAction::kTransformLdaSmiBinaryOpToBinaryOpWithSmiAction, |
| 144 Bytecode::kSubSmi}; | 134 Bytecode::kSubSmi}; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 340 |
| 351 std::ofstream ofs(argv[1], std::ofstream::trunc); | 341 std::ofstream ofs(argv[1], std::ofstream::trunc); |
| 352 v8::internal::interpreter::PeepholeActionTableWriter writer; | 342 v8::internal::interpreter::PeepholeActionTableWriter writer; |
| 353 writer.BuildTable(); | 343 writer.BuildTable(); |
| 354 writer.Write(ofs); | 344 writer.Write(ofs); |
| 355 ofs.flush(); | 345 ofs.flush(); |
| 356 ofs.close(); | 346 ofs.close(); |
| 357 | 347 |
| 358 return 0; | 348 return 0; |
| 359 } | 349 } |
| OLD | NEW |