Chromium Code Reviews| 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 // Clients of this interface shouldn't depend on lots of interpreter internals. | |
| 11 // Do not include anything from src/interpreter here! | |
| 12 #include "src/utils.h" | |
| 13 | |
| 14 namespace v8 { | |
| 15 namespace internal { | |
| 16 namespace interpreter { | |
| 17 | |
| 18 // The list of bytecodes which are interpreted by the interpreter. | |
| 19 #define BYTECODE_LIST(V) \ | |
| 20 V(LoadLiteral0, 1) \ | |
| 21 V(Return, 0) | |
| 22 | |
| 23 enum class Bytecode : uint8_t { | |
| 24 #define DECLARE_BYTECODE(Name, _) k##Name, | |
| 25 BYTECODE_LIST(DECLARE_BYTECODE) | |
| 26 #undef DECLARE_BYTECODE | |
| 27 #define COUNT_BYTECODE(x, _) +1 | |
| 28 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will | |
| 29 // evaluate to the same value as the last real bytecode. | |
| 30 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) | |
| 31 #undef COUNT_BYTECODE | |
| 32 }; | |
| 33 | |
| 34 class Bytecodes { | |
| 35 public: | |
| 36 // Returns string representation of |bytecode|. | |
| 37 static const char* ToString(Bytecode bytecode); | |
| 38 | |
| 39 // Returns the number of arguments expected by |bytecode|. | |
| 40 static const int NumberOfArguments(Bytecode bytecode); | |
| 41 | |
| 42 // Returns the size of the bytecode including its arguments. | |
| 43 static const int Size(Bytecode bytecode); | |
| 44 | |
| 45 private: | |
| 46 Bytecodes() { UNREACHABLE(); } | |
|
Michael Starzinger
2015/07/21 13:51:45
nit: Better use DISALLOW_IMPLICIT_CONSTRUCTORS(Byt
rmcilroy
2015/07/23 10:43:54
Done.
| |
| 47 }; | |
| 48 | |
| 49 | |
| 50 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); | |
| 51 | |
| 52 } // namespace interpreter | |
| 53 } // namespace internal | |
| 54 } // namespace v8 | |
| 55 | |
| 56 #endif // V8_INTERPRETER_BYTECODES_H_ | |
| OLD | NEW |