OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_INTERPRETER_BYTECODE_PEEPHOLE_TABLE_H_ |
| 6 #define V8_INTERPRETER_BYTECODE_PEEPHOLE_TABLE_H_ |
| 7 |
| 8 #include "src/interpreter/bytecodes.h" |
| 9 |
| 10 namespace v8 { |
| 11 namespace internal { |
| 12 namespace interpreter { |
| 13 |
| 14 #define PEEPHOLE_NON_JUMP_ACTION_LIST(V) \ |
| 15 V(DefaultAction) \ |
| 16 V(UpdateLastAction) \ |
| 17 V(UpdateLastIfSourceInfoPresentAction) \ |
| 18 V(ElideCurrentAction) \ |
| 19 V(ElideCurrentIfOperand0MatchesAction) \ |
| 20 V(ElideCurrentIfLoadingNameConstantAction) \ |
| 21 V(ElideLastAction) \ |
| 22 V(ChangeBytecodeAction) \ |
| 23 V(TransformLdaStarToLdrLdarAction) \ |
| 24 V(TransformLdaSmiBinaryOpToBinaryOpWithSmiAction) \ |
| 25 V(TransformLdaZeroBinaryOpToBinaryOpWithZeroAction) |
| 26 |
| 27 #define PEEPHOLE_JUMP_ACTION_LIST(V) \ |
| 28 V(DefaultJumpAction) \ |
| 29 V(UpdateLastJumpAction) \ |
| 30 V(ChangeJumpBytecodeAction) \ |
| 31 V(ElideLastBeforeJumpAction) |
| 32 |
| 33 #define PEEPHOLE_ACTION_LIST(V) \ |
| 34 PEEPHOLE_NON_JUMP_ACTION_LIST(V) \ |
| 35 PEEPHOLE_JUMP_ACTION_LIST(V) |
| 36 |
| 37 // Actions to take when a pair of bytes is encountered. A handler |
| 38 // exists for each action. |
| 39 enum class PeepholeAction : uint8_t { |
| 40 #define DECLARE_PEEPHOLE_ACTION(Action) k##Action, |
| 41 PEEPHOLE_ACTION_LIST(DECLARE_PEEPHOLE_ACTION) |
| 42 #undef DECLARE_PEEPHOLE_ACTION |
| 43 }; |
| 44 |
| 45 // Tuple of action to take when pair of bytecodes is encountered and |
| 46 // optional data to invoke handler with. |
| 47 struct PeepholeActionAndData final { |
| 48 // Action to take when tuple of bytecodes encountered. |
| 49 PeepholeAction action; |
| 50 |
| 51 // Replacement bytecode (if valid). |
| 52 Bytecode bytecode; |
| 53 }; |
| 54 |
| 55 // Lookup table for matching pairs of bytecodes to peephole optimization |
| 56 // actions. The contents of the table are generated by mkpeephole.cc. |
| 57 struct PeepholeActionTable final { |
| 58 public: |
| 59 static const PeepholeActionAndData* Lookup(Bytecode last, Bytecode current); |
| 60 |
| 61 private: |
| 62 static const size_t kNumberOfBytecodes = |
| 63 static_cast<size_t>(Bytecode::kLast) + 1; |
| 64 |
| 65 static const PeepholeActionAndData row_data_[][kNumberOfBytecodes]; |
| 66 static const PeepholeActionAndData* const row_[kNumberOfBytecodes]; |
| 67 }; |
| 68 |
| 69 } // namespace interpreter |
| 70 } // namespace internal |
| 71 } // namespace v8 |
| 72 |
| 73 #endif // V8_INTERPRETER_BYTECODE_PEEPHOLE_TABLE_H_ |
OLD | NEW |