Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: src/interpreter/bytecode-operands.h

Issue 2351763002: [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. (Closed)
Patch Set: [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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_OPERANDS_H_
6 #define V8_INTERPRETER_BYTECODE_OPERANDS_H_
7
8 #include "src/globals.h"
9
10 namespace v8 {
11 namespace internal {
12 namespace interpreter {
13
14 #define INVALID_OPERAND_TYPE_LIST(V) V(None, OperandTypeInfo::kNone)
15
16 #define REGISTER_INPUT_OPERAND_TYPE_LIST(V) \
17 V(MaybeReg, OperandTypeInfo::kScalableSignedByte) \
18 V(Reg, OperandTypeInfo::kScalableSignedByte) \
19 V(RegPair, OperandTypeInfo::kScalableSignedByte)
20
21 #define REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) \
22 V(RegOut, OperandTypeInfo::kScalableSignedByte) \
23 V(RegOutPair, OperandTypeInfo::kScalableSignedByte) \
24 V(RegOutTriple, OperandTypeInfo::kScalableSignedByte)
25
26 #define SCALAR_OPERAND_TYPE_LIST(V) \
27 V(Flag8, OperandTypeInfo::kFixedUnsignedByte) \
28 V(IntrinsicId, OperandTypeInfo::kFixedUnsignedByte) \
29 V(Idx, OperandTypeInfo::kScalableUnsignedByte) \
30 V(UImm, OperandTypeInfo::kScalableUnsignedByte) \
31 V(Imm, OperandTypeInfo::kScalableSignedByte) \
32 V(RegCount, OperandTypeInfo::kScalableUnsignedByte) \
33 V(RuntimeId, OperandTypeInfo::kFixedUnsignedShort)
34
35 #define REGISTER_OPERAND_TYPE_LIST(V) \
36 REGISTER_INPUT_OPERAND_TYPE_LIST(V) \
37 REGISTER_OUTPUT_OPERAND_TYPE_LIST(V)
38
39 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \
40 INVALID_OPERAND_TYPE_LIST(V) \
41 SCALAR_OPERAND_TYPE_LIST(V)
42
43 // The list of operand types used by bytecodes.
44 #define OPERAND_TYPE_LIST(V) \
45 NON_REGISTER_OPERAND_TYPE_LIST(V) \
46 REGISTER_OPERAND_TYPE_LIST(V)
47
48 // Enumeration of scaling factors applicable to scalable operands. Code
49 // relies on being able to cast values to integer scaling values.
50 #define OPERAND_SCALE_LIST(V) \
51 V(Single, 1) \
52 V(Double, 2) \
53 V(Quadruple, 4)
54
55 enum class OperandScale : uint8_t {
56 #define DECLARE_OPERAND_SCALE(Name, Scale) k##Name = Scale,
57 OPERAND_SCALE_LIST(DECLARE_OPERAND_SCALE)
58 #undef DECLARE_OPERAND_SCALE
59 kLast = kQuadruple
60 };
61
62 // Enumeration of the size classes of operand types used by
63 // bytecodes. Code relies on being able to cast values to integer
64 // types to get the size in bytes.
65 enum class OperandSize : uint8_t {
66 kNone = 0,
67 kByte = 1,
68 kShort = 2,
69 kQuad = 4,
70 kLast = kQuad
71 };
72
73 // Primitive operand info used that summarize properties of operands.
74 // Columns are Name, IsScalable, IsUnsigned, UnscaledSize.
75 #define OPERAND_TYPE_INFO_LIST(V) \
76 V(None, false, false, OperandSize::kNone) \
77 V(ScalableSignedByte, true, false, OperandSize::kByte) \
78 V(ScalableUnsignedByte, true, true, OperandSize::kByte) \
79 V(FixedUnsignedByte, false, true, OperandSize::kByte) \
80 V(FixedUnsignedShort, false, true, OperandSize::kShort)
81
82 enum class OperandTypeInfo : uint8_t {
83 #define DECLARE_OPERAND_TYPE_INFO(Name, ...) k##Name,
84 OPERAND_TYPE_INFO_LIST(DECLARE_OPERAND_TYPE_INFO)
85 #undef DECLARE_OPERAND_TYPE_INFO
86 };
87
88 // Enumeration of operand types used by bytecodes.
89 enum class OperandType : uint8_t {
90 #define DECLARE_OPERAND_TYPE(Name, _) k##Name,
91 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE)
92 #undef DECLARE_OPERAND_TYPE
93 #define COUNT_OPERAND_TYPES(x, _) +1
94 // The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will
95 // evaluate to the same value as the last operand.
96 kLast = -1 OPERAND_TYPE_LIST(COUNT_OPERAND_TYPES)
97 #undef COUNT_OPERAND_TYPES
98 };
99
100 enum class AccumulatorUse : uint8_t {
101 kNone = 0,
102 kRead = 1 << 0,
103 kWrite = 1 << 1,
104 kReadWrite = kRead | kWrite
105 };
106
107 inline AccumulatorUse operator&(AccumulatorUse lhs, AccumulatorUse rhs) {
108 int result = static_cast<int>(lhs) & static_cast<int>(rhs);
109 return static_cast<AccumulatorUse>(result);
110 }
111
112 inline AccumulatorUse operator|(AccumulatorUse lhs, AccumulatorUse rhs) {
113 int result = static_cast<int>(lhs) | static_cast<int>(rhs);
114 return static_cast<AccumulatorUse>(result);
115 }
116
117 std::ostream& operator<<(std::ostream& os, const AccumulatorUse& use);
118 std::ostream& operator<<(std::ostream& os, const OperandScale& operand_scale);
119 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size);
120 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type);
121
122 } // namespace interpreter
123 } // namespace internal
124 } // namespace v8
125
126 #endif // V8_INTERPRETER_BYTECODE_OPERANDS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698