v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
bytecode-traits.h
Go to the documentation of this file.
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_BYTECODE_TRAITS_H_
6#define V8_INTERPRETER_BYTECODE_TRAITS_H_
7
9
10namespace v8 {
11namespace internal {
12namespace interpreter {
13
14template <OperandTypeInfo>
16
17#define DECLARE_OPERAND_TYPE_INFO(Name, Scalable, Unsigned, BaseSize) \
18 template <> \
19 struct OperandTypeInfoTraits<OperandTypeInfo::k##Name> { \
20 static constexpr bool kIsScalable = Scalable; \
21 static constexpr bool kIsUnsigned = Unsigned; \
22 static constexpr OperandSize kUnscaledSize = BaseSize; \
23 };
25#undef DECLARE_OPERAND_TYPE_INFO
26
27template <OperandType>
29
30#define DECLARE_OPERAND_TYPE_TRAITS(Name, InfoType) \
31 template <> \
32 struct OperandTraits<OperandType::k##Name> { \
33 using TypeInfoTraits = OperandTypeInfoTraits<InfoType>; \
34 static constexpr OperandTypeInfo kOperandTypeInfo = InfoType; \
35 };
37#undef DECLARE_OPERAND_TYPE_TRAITS
38
39template <OperandType operand_type, OperandScale operand_scale>
41 static constexpr int kSize =
42 static_cast<int>(
45 ? static_cast<int>(operand_scale)
46 : 1);
47 static constexpr OperandSize kOperandSize = static_cast<OperandSize>(kSize);
48};
49
50template <ImplicitRegisterUse implicit_register_use, OperandType... operands>
52 static constexpr OperandType kOperandTypes[] = {operands...};
55
62
63 template <OperandScale scale>
64 static constexpr auto CalculateOperandOffsets() {
65 std::array<int, sizeof...(operands) + 1> result{};
66 int offset = 1;
67 int i = 0;
68 (((result[i++] = offset),
70 ...);
71 return result;
72 }
73
74 static constexpr auto kSingleScaleOperandOffsets =
76 static constexpr auto kDoubleScaleOperandOffsets =
78 static constexpr auto kQuadrupleScaleOperandOffsets =
80
81 static constexpr int kSingleScaleSize =
83 static constexpr int kDoubleScaleSize =
85 static constexpr int kQuadrupleScaleSize =
87
89 implicit_register_use;
90 static constexpr int kOperandCount = sizeof...(operands);
91};
92
93template <ImplicitRegisterUse implicit_register_use>
94struct BytecodeTraits<implicit_register_use> {
95 static constexpr OperandType* kOperandTypes = nullptr;
96 static constexpr OperandTypeInfo* kOperandTypeInfos = nullptr;
97 static constexpr OperandSize* kSingleScaleOperandSizes = nullptr;
98 static constexpr OperandSize* kDoubleScaleOperandSizes = nullptr;
99 static constexpr OperandSize* kQuadrupleScaleOperandSizes = nullptr;
100
101 static constexpr auto kSingleScaleOperandOffsets = std::array<int, 0>{};
102 static constexpr auto kDoubleScaleOperandOffsets = std::array<int, 0>{};
103 static constexpr auto kQuadrupleScaleOperandOffsets = std::array<int, 0>{};
104
105 static constexpr int kSingleScaleSize = 1;
106 static constexpr int kDoubleScaleSize = 1;
107 static constexpr int kQuadrupleScaleSize = 1;
109 implicit_register_use;
110 static constexpr int kOperandCount = 0;
111};
112
113} // namespace interpreter
114} // namespace internal
115} // namespace v8
116
117#endif // V8_INTERPRETER_BYTECODE_TRAITS_H_
#define OPERAND_TYPE_LIST(V)
#define OPERAND_TYPE_INFO_LIST(V)
#define DECLARE_OPERAND_TYPE_TRAITS(Name, InfoType)
int32_t offset
ZoneVector< RpoNumber > & result
static constexpr OperandType kOperandTypes[]
static constexpr auto kQuadrupleScaleOperandOffsets
static constexpr OperandSize kDoubleScaleOperandSizes[]
static constexpr OperandTypeInfo kOperandTypeInfos[]
static constexpr OperandSize kSingleScaleOperandSizes[]
static constexpr ImplicitRegisterUse kImplicitRegisterUse
static constexpr OperandSize kQuadrupleScaleOperandSizes[]
static constexpr auto CalculateOperandOffsets()
static constexpr OperandSize kOperandSize