| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return {PeepholeAction::kTransformLdaStarToLdrLdarAction, | 99 return {PeepholeAction::kTransformLdaStarToLdrLdarAction, |
| 100 Bytecode::kLdrContextSlot}; | 100 Bytecode::kLdrContextSlot}; |
| 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 optimizations: remove unnecessary ToName bytecodes. | 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 if (current == Bytecode::kToName) { | 111 if (current == Bytecode::kToName) { |
| 111 if (last == Bytecode::kLdaConstant) { | 112 if (last == Bytecode::kLdaConstant) { |
| 112 return {PeepholeAction::kElideCurrentIfLoadingNameConstantAction, | 113 return {PeepholeAction::kTransformToStarIfLoadingNameConstantAction, |
| 113 Bytecode::kIllegal}; | 114 Bytecode::kIllegal}; |
| 114 } else if (Bytecodes::PutsNameInAccumulator(last)) { | 115 } else if (Bytecodes::PutsNameInAccumulator(last)) { |
| 115 return {PeepholeAction::kElideCurrentAction, Bytecode::kIllegal}; | 116 return {PeepholeAction::kChangeBytecodeAction, Bytecode::kStar}; |
| 116 } | 117 } |
| 117 } | 118 } |
| 118 | 119 |
| 119 // Nop are placeholders for holding source position information and can be | 120 // Nop are placeholders for holding source position information and can be |
| 120 // elided if there is no source information. | 121 // elided if there is no source information. |
| 121 if (last == Bytecode::kNop) { | 122 if (last == Bytecode::kNop) { |
| 122 if (Bytecodes::IsJump(current)) { | 123 if (Bytecodes::IsJump(current)) { |
| 123 return {PeepholeAction::kElideLastBeforeJumpAction, Bytecode::kIllegal}; | 124 return {PeepholeAction::kElideLastBeforeJumpAction, Bytecode::kIllegal}; |
| 124 } else { | 125 } else { |
| 125 return {PeepholeAction::kElideLastAction, Bytecode::kIllegal}; | 126 return {PeepholeAction::kElideLastAction, Bytecode::kIllegal}; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 379 |
| 379 std::ofstream ofs(argv[1], std::ofstream::trunc); | 380 std::ofstream ofs(argv[1], std::ofstream::trunc); |
| 380 v8::internal::interpreter::PeepholeActionTableWriter writer; | 381 v8::internal::interpreter::PeepholeActionTableWriter writer; |
| 381 writer.BuildTable(); | 382 writer.BuildTable(); |
| 382 writer.Write(ofs); | 383 writer.Write(ofs); |
| 383 ofs.flush(); | 384 ofs.flush(); |
| 384 ofs.close(); | 385 ofs.close(); |
| 385 | 386 |
| 386 return 0; | 387 return 0; |
| 387 } | 388 } |
| OLD | NEW |