• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 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_DEOPTIMIZER_TRANSLATION_OPCODE_H_
6 #define V8_DEOPTIMIZER_TRANSLATION_OPCODE_H_
7 
8 #include "src/base/macros.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 // V(name, operand_count)
14 #define TRANSLATION_OPCODE_LIST(V)                        \
15   V(ARGUMENTS_ADAPTOR_FRAME, 2)                           \
16   V(ARGUMENTS_ELEMENTS, 1)                                \
17   V(ARGUMENTS_LENGTH, 0)                                  \
18   V(BEGIN, 3)                                             \
19   V(BOOL_REGISTER, 1)                                     \
20   V(BOOL_STACK_SLOT, 1)                                   \
21   V(BUILTIN_CONTINUATION_FRAME, 3)                        \
22   V(CAPTURED_OBJECT, 1)                                   \
23   V(CONSTRUCT_STUB_FRAME, 3)                              \
24   V(DOUBLE_REGISTER, 1)                                   \
25   V(DOUBLE_STACK_SLOT, 1)                                 \
26   V(DUPLICATED_OBJECT, 1)                                 \
27   V(FLOAT_REGISTER, 1)                                    \
28   V(FLOAT_STACK_SLOT, 1)                                  \
29   V(INT32_REGISTER, 1)                                    \
30   V(INT32_STACK_SLOT, 1)                                  \
31   V(INT64_REGISTER, 1)                                    \
32   V(INT64_STACK_SLOT, 1)                                  \
33   V(INTERPRETED_FRAME, 5)                                 \
34   V(JAVA_SCRIPT_BUILTIN_CONTINUATION_FRAME, 3)            \
35   V(JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH_FRAME, 3) \
36   IF_WASM(V, JS_TO_WASM_BUILTIN_CONTINUATION_FRAME, 4)    \
37   V(LITERAL, 1)                                           \
38   V(REGISTER, 1)                                          \
39   V(STACK_SLOT, 1)                                        \
40   V(UINT32_REGISTER, 1)                                   \
41   V(UINT32_STACK_SLOT, 1)                                 \
42   V(UPDATE_FEEDBACK, 2)
43 
44 enum class TranslationOpcode {
45 #define CASE(name, ...) name,
46   TRANSLATION_OPCODE_LIST(CASE)
47 #undef CASE
48 };
49 
TranslationOpcodeFromInt(int i)50 constexpr TranslationOpcode TranslationOpcodeFromInt(int i) {
51   return static_cast<TranslationOpcode>(i);
52 }
53 
TranslationOpcodeOperandCount(TranslationOpcode o)54 inline int TranslationOpcodeOperandCount(TranslationOpcode o) {
55 #define CASE(name, operand_count) operand_count,
56   static const int counts[] = {TRANSLATION_OPCODE_LIST(CASE)};
57 #undef CASE
58   return counts[static_cast<int>(o)];
59 }
60 
TranslationOpcodeToString(TranslationOpcode o)61 inline const char* TranslationOpcodeToString(TranslationOpcode o) {
62 #define CASE(name, ...) #name,
63   static const char* const names[] = {TRANSLATION_OPCODE_LIST(CASE)};
64 #undef CASE
65   return names[static_cast<int>(o)];
66 }
67 
68 #undef TRANSLATION_OPCODE_LIST
69 
70 }  // namespace internal
71 }  // namespace v8
72 
73 #endif  // V8_DEOPTIMIZER_TRANSLATION_OPCODE_H_
74