v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
translation-opcode.h
Go to the documentation of this file.
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
10namespace v8 {
11namespace internal {
12
13// V(name, operand_count)
14#define TRANSLATION_JS_FRAME_OPCODE_LIST(V) \
15 V(INTERPRETED_FRAME_WITH_RETURN, 6) \
16 V(INTERPRETED_FRAME_WITHOUT_RETURN, 4) \
17 V(JAVASCRIPT_BUILTIN_CONTINUATION_FRAME, 3) \
18 V(JAVASCRIPT_BUILTIN_CONTINUATION_WITH_CATCH_FRAME, 3)
19
20#define TRANSLATION_FRAME_OPCODE_LIST(V) \
21 V(CONSTRUCT_CREATE_STUB_FRAME, 2) \
22 V(CONSTRUCT_INVOKE_STUB_FRAME, 1) \
23 V(BUILTIN_CONTINUATION_FRAME, 3) \
24 IF_WASM(V, JS_TO_WASM_BUILTIN_CONTINUATION_FRAME, 4) \
25 IF_WASM(V, WASM_INLINED_INTO_JS_FRAME, 3) \
26 IF_WASM(V, LIFTOFF_FRAME, 3) \
27 V(INLINED_EXTRA_ARGUMENTS, 3)
28
29#define TRANSLATION_OPCODE_LIST(V) \
30 TRANSLATION_JS_FRAME_OPCODE_LIST(V) \
31 TRANSLATION_FRAME_OPCODE_LIST(V) \
32 V(ARGUMENTS_ELEMENTS, 1) \
33 V(ARGUMENTS_LENGTH, 0) \
34 V(REST_LENGTH, 0) \
35 V(BEGIN_WITHOUT_FEEDBACK, 3) \
36 V(BEGIN_WITH_FEEDBACK, 3) \
37 V(BOOL_REGISTER, 1) \
38 V(BOOL_STACK_SLOT, 1) \
39 V(CAPTURED_OBJECT, 1) \
40 V(STRING_CONCAT, 0) \
41 V(DOUBLE_REGISTER, 1) \
42 V(DOUBLE_STACK_SLOT, 1) \
43 V(SIMD128_STACK_SLOT, 1) \
44 V(HOLEY_DOUBLE_REGISTER, 1) \
45 V(HOLEY_DOUBLE_STACK_SLOT, 1) \
46 V(SIMD128_REGISTER, 1) \
47 V(DUPLICATED_OBJECT, 1) \
48 V(FLOAT_REGISTER, 1) \
49 V(FLOAT_STACK_SLOT, 1) \
50 V(INT32_REGISTER, 1) \
51 V(INT32_STACK_SLOT, 1) \
52 V(INT64_REGISTER, 1) \
53 V(INT64_STACK_SLOT, 1) \
54 V(SIGNED_BIGINT64_REGISTER, 1) \
55 V(SIGNED_BIGINT64_STACK_SLOT, 1) \
56 V(UNSIGNED_BIGINT64_REGISTER, 1) \
57 V(UNSIGNED_BIGINT64_STACK_SLOT, 1) \
58 V(OPTIMIZED_OUT, 0) \
59 V(LITERAL, 1) \
60 V(REGISTER, 1) \
61 V(TAGGED_STACK_SLOT, 1) \
62 V(UINT32_REGISTER, 1) \
63 V(UINT32_STACK_SLOT, 1) \
64 V(UPDATE_FEEDBACK, 2) \
65 V(MATCH_PREVIOUS_TRANSLATION, 1)
66
68#define CASE(name, ...) name,
70#undef CASE
71};
72
73#define PLUS_ONE(...) +1
74static constexpr int kNumTranslationOpcodes =
76static constexpr int kNumTranslationJsFrameOpcodes =
78static constexpr int kNumTranslationFrameOpcodes =
80#undef PLUS_ONE
81
83#define CASE(name, operand_count) operand_count,
84 static const int counts[] = {TRANSLATION_OPCODE_LIST(CASE)};
85#undef CASE
86 return counts[static_cast<int>(o)];
87}
88
90#define CASE(name, operand_count) \
91 static_assert(operand_count <= kMaxTranslationOperandCount);
93#undef CASE
94
96 return o == TranslationOpcode::BEGIN_WITH_FEEDBACK ||
97 o == TranslationOpcode::BEGIN_WITHOUT_FEEDBACK;
98}
99
101 static_assert(
102 0 == static_cast<int>(TranslationOpcode::INTERPRETED_FRAME_WITH_RETURN));
104 return static_cast<int>(o) < kNumTranslationFrameOpcodes;
105}
106
108 static_assert(
110 static_cast<int>(TranslationOpcode::CONSTRUCT_CREATE_STUB_FRAME));
111 return static_cast<int>(o) < kNumTranslationJsFrameOpcodes;
112}
113
115 return o == TranslationOpcode::INTERPRETED_FRAME_WITH_RETURN ||
116 o == TranslationOpcode::INTERPRETED_FRAME_WITHOUT_RETURN;
117}
118
119inline std::ostream& operator<<(std::ostream& out, TranslationOpcode opcode) {
120 switch (opcode) {
121#define CASE(name, _) \
122 case TranslationOpcode::name: \
123 out << #name; \
124 break;
126#undef CASE
127 default:
128 out << "BROKEN_OPCODE_" << static_cast<uint8_t>(opcode);
129 break;
130 }
131 return out;
132}
133
134#undef TRANSLATION_OPCODE_LIST
135#undef TRANSLATION_FRAME_OPCODE_LIST
136
137} // namespace internal
138} // namespace v8
139
140#endif // V8_DEOPTIMIZER_TRANSLATION_OPCODE_H_
static constexpr int kNumTranslationJsFrameOpcodes
bool IsTranslationFrameOpcode(TranslationOpcode o)
static constexpr int kNumTranslationFrameOpcodes
bool TranslationOpcodeIsBegin(TranslationOpcode o)
bool IsTranslationInterpreterFrameOpcode(TranslationOpcode o)
int TranslationOpcodeOperandCount(TranslationOpcode o)
std::ostream & operator<<(std::ostream &os, AtomicMemoryOrder order)
static constexpr int kNumTranslationOpcodes
bool IsTranslationJsFrameOpcode(TranslationOpcode o)
constexpr int kMaxTranslationOperandCount
#define PLUS_ONE(...)
#define TRANSLATION_FRAME_OPCODE_LIST(V)
#define TRANSLATION_JS_FRAME_OPCODE_LIST(V)
#define TRANSLATION_OPCODE_LIST(V)