OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_BYTECODES_H_ |
| 6 #define V8_INTERPRETER_BYTECODES_H_ |
| 7 |
| 8 #include <iosfwd> |
| 9 |
| 10 #include "src/utils.h" |
| 11 |
| 12 namespace v8 { |
| 13 namespace internal { |
| 14 namespace interpreter { |
| 15 |
| 16 // The list of bytecodes which are interpreted by the interpreter. |
| 17 #define BYTECODE_LIST(V) \ |
| 18 V(LoadLiteral0, 1) \ |
| 19 V(Return, 0) |
| 20 |
| 21 enum class Bytecode : uint8_t { |
| 22 #define DECLARE_BYTECODE(Name, _) k##Name, |
| 23 BYTECODE_LIST(DECLARE_BYTECODE) |
| 24 #undef DECLARE_BYTECODE |
| 25 #define COUNT_BYTECODE(x, _) +1 |
| 26 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will |
| 27 // evaluate to the same value as the last real bytecode. |
| 28 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) |
| 29 #undef COUNT_BYTECODE |
| 30 }; |
| 31 |
| 32 class Bytecodes { |
| 33 public: |
| 34 // Returns string representation of |bytecode|. |
| 35 static const char* ToString(Bytecode bytecode); |
| 36 |
| 37 // Returns the number of arguments expected by |bytecode|. |
| 38 static const int NumberOfArguments(Bytecode bytecode); |
| 39 |
| 40 // Returns the size of the bytecode including its arguments. |
| 41 static const int Size(Bytecode bytecode); |
| 42 |
| 43 // Returns true if the bytecode is a function return bytecode. |
| 44 static const bool IsReturn(Bytecode bytecode); |
| 45 |
| 46 private: |
| 47 Bytecodes() { UNREACHABLE(); } |
| 48 }; |
| 49 |
| 50 |
| 51 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); |
| 52 |
| 53 } // namespace interpreter |
| 54 } // namespace internal |
| 55 } // namespace v8 |
| 56 |
| 57 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |