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

Side by Side Diff: src/interpreter/bytecodes.h

Issue 1783483002: [interpreter] Add support for scalable operands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Operand renaming. Created 4 years, 9 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
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_INTERPRETER_BYTECODES_H_ 5 #ifndef V8_INTERPRETER_BYTECODES_H_
6 #define V8_INTERPRETER_BYTECODES_H_ 6 #define V8_INTERPRETER_BYTECODES_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 // Clients of this interface shouldn't depend on lots of interpreter internals. 10 // Clients of this interface shouldn't depend on lots of interpreter internals.
11 // Do not include anything from src/interpreter here! 11 // Do not include anything from src/interpreter here!
12 #include "src/utils.h" 12 #include "src/utils.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 namespace interpreter { 16 namespace interpreter {
17 17
18 #define INVALID_OPERAND_TYPE_LIST(V) \ 18 #define INVALID_OPERAND_TYPE_LIST(V) \
19 V(None, OperandSize::kNone) 19 V(None, OperandSize::kNone, OperandTypeTrait::kFixed)
20 20
21 #define REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ 21 #define REGISTER_INPUT_OPERAND_TYPE_LIST(V) \
22 /* Byte operands. */ \ 22 V(MaybeReg, OperandSize::kByte, OperandTypeTrait::kScalable) \
23 V(MaybeReg8, OperandSize::kByte) \ 23 V(Reg, OperandSize::kByte, OperandTypeTrait::kScalable) \
24 V(Reg8, OperandSize::kByte) \ 24 V(RegPair, OperandSize::kByte, OperandTypeTrait::kScalable)
rmcilroy 2016/03/10 16:45:37 Can we get rid of the OperandSize attribute in the
oth 2016/03/11 16:26:12 Acknowledged. Working on it with the signed variat
oth 2016/03/15 09:58:28 Done.
25 V(RegPair8, OperandSize::kByte) \
26 /* Short operands. */ \
27 V(MaybeReg16, OperandSize::kShort) \
28 V(Reg16, OperandSize::kShort) \
29 V(RegPair16, OperandSize::kShort)
30 25
31 #define REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) \ 26 #define REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) \
32 /* Byte operands. */ \ 27 V(RegOut, OperandSize::kByte, OperandTypeTrait::kScalable) \
33 V(RegOut8, OperandSize::kByte) \ 28 V(RegOutPair, OperandSize::kByte, OperandTypeTrait::kScalable) \
34 V(RegOutPair8, OperandSize::kByte) \ 29 V(RegOutTriple, OperandSize::kByte, OperandTypeTrait::kScalable)
35 V(RegOutTriple8, OperandSize::kByte) \
36 /* Short operands. */ \
37 V(RegOut16, OperandSize::kShort) \
38 V(RegOutPair16, OperandSize::kShort) \
39 V(RegOutTriple16, OperandSize::kShort)
40 30
41 #define SCALAR_OPERAND_TYPE_LIST(V) \ 31 #define SCALAR_OPERAND_TYPE_LIST(V) \
42 /* Byte operands. */ \ 32 V(Flag8, OperandSize::kByte, OperandTypeTrait::kFixed) \
43 V(Idx8, OperandSize::kByte) \ 33 V(Idx, OperandSize::kByte, OperandTypeTrait::kScalable) \
44 V(Imm8, OperandSize::kByte) \ 34 V(Imm, OperandSize::kByte, OperandTypeTrait::kScalable) \
45 V(RegCount8, OperandSize::kByte) \ 35 V(RegCount, OperandSize::kByte, OperandTypeTrait::kScalable) \
46 /* Short operands. */ \ 36 V(RuntimeId, OperandSize::kShort, OperandTypeTrait::kFixed)
47 V(Idx16, OperandSize::kShort) \
48 V(RegCount16, OperandSize::kShort)
49 37
50 #define REGISTER_OPERAND_TYPE_LIST(V) \ 38 #define REGISTER_OPERAND_TYPE_LIST(V) \
51 REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ 39 REGISTER_INPUT_OPERAND_TYPE_LIST(V) \
52 REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) 40 REGISTER_OUTPUT_OPERAND_TYPE_LIST(V)
53 41
54 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \ 42 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \
55 INVALID_OPERAND_TYPE_LIST(V) \ 43 INVALID_OPERAND_TYPE_LIST(V) \
56 SCALAR_OPERAND_TYPE_LIST(V) 44 SCALAR_OPERAND_TYPE_LIST(V)
57 45
58 // The list of operand types used by bytecodes. 46 // The list of operand types used by bytecodes.
59 #define OPERAND_TYPE_LIST(V) \ 47 #define OPERAND_TYPE_LIST(V) \
60 NON_REGISTER_OPERAND_TYPE_LIST(V) \ 48 NON_REGISTER_OPERAND_TYPE_LIST(V) \
61 REGISTER_OPERAND_TYPE_LIST(V) 49 REGISTER_OPERAND_TYPE_LIST(V)
62 50
63 // Define one debug break bytecode for each operands size. 51 // Define one debug break bytecode for each operands size.
64 #define DEBUG_BREAK_BYTECODE_LIST(V) \ 52 #define DEBUG_BREAK_BYTECODE_LIST(V) \
65 V(DebugBreak0, OperandType::kNone) \ 53 V(DebugBreak0, OperandType::kNone) \
66 V(DebugBreak1, OperandType::kReg8) \ 54 V(DebugBreak1, OperandType::kReg) \
67 V(DebugBreak2, OperandType::kReg16) \ 55 V(DebugBreak2, OperandType::kReg, OperandType::kReg) \
68 V(DebugBreak3, OperandType::kReg16, OperandType::kReg8) \ 56 V(DebugBreak3, OperandType::kReg, OperandType::kReg, OperandType::kReg) \
69 V(DebugBreak4, OperandType::kReg16, OperandType::kReg16) \ 57 V(DebugBreak4, OperandType::kReg, OperandType::kReg, OperandType::kReg, \
70 V(DebugBreak5, OperandType::kReg16, OperandType::kReg16, OperandType::kReg8) \ 58 OperandType::kReg) \
71 V(DebugBreak6, OperandType::kReg16, OperandType::kReg16, \ 59 V(DebugBreak5, OperandType::kRuntimeId, OperandType::kReg, \
72 OperandType::kReg16) \ 60 OperandType::kReg) \
73 V(DebugBreak7, OperandType::kReg16, OperandType::kReg16, \ 61 V(DebugBreak6, OperandType::kRuntimeId, OperandType::kReg, \
74 OperandType::kReg16, OperandType::kReg8) \ 62 OperandType::kReg, OperandType::kReg) \
75 V(DebugBreak8, OperandType::kReg16, OperandType::kReg16, \ 63 V(DebugBreak7, OperandType::kIdx, OperandType::kFlag8) \
76 OperandType::kReg16, OperandType::kReg16) 64 V(DebugBreak8, OperandType::kIdx, OperandType::kIdx, OperandType::kFlag8)
77 65
78 // The list of bytecodes which are interpreted by the interpreter. 66 // The list of bytecodes which are interpreted by the interpreter.
79 #define BYTECODE_LIST(V) \ 67 #define BYTECODE_LIST(V) \
80 \ 68 /* Extended width operands */ \
81 /* Loading the accumulator */ \ 69 V(Wide, OperandType::kNone) \
82 V(LdaZero, OperandType::kNone) \ 70 V(ExtraWide, OperandType::kNone) \
83 V(LdaSmi8, OperandType::kImm8) \ 71 \
84 V(LdaUndefined, OperandType::kNone) \ 72 /* Loading the accumulator */ \
85 V(LdaNull, OperandType::kNone) \ 73 V(LdaZero, OperandType::kNone) \
86 V(LdaTheHole, OperandType::kNone) \ 74 V(LdaSmi, OperandType::kImm) \
87 V(LdaTrue, OperandType::kNone) \ 75 V(LdaUndefined, OperandType::kNone) \
88 V(LdaFalse, OperandType::kNone) \ 76 V(LdaNull, OperandType::kNone) \
89 V(LdaConstant, OperandType::kIdx8) \ 77 V(LdaTheHole, OperandType::kNone) \
90 V(LdaConstantWide, OperandType::kIdx16) \ 78 V(LdaTrue, OperandType::kNone) \
91 \ 79 V(LdaFalse, OperandType::kNone) \
92 /* Globals */ \ 80 V(LdaConstant, OperandType::kIdx) \
93 V(LdaGlobal, OperandType::kIdx8, OperandType::kIdx8) \ 81 \
94 V(LdaGlobalInsideTypeof, OperandType::kIdx8, OperandType::kIdx8) \ 82 /* Globals */ \
95 V(LdaGlobalWide, OperandType::kIdx16, OperandType::kIdx16) \ 83 V(LdaGlobal, OperandType::kIdx, OperandType::kIdx) \
96 V(LdaGlobalInsideTypeofWide, OperandType::kIdx16, OperandType::kIdx16) \ 84 V(LdaGlobalInsideTypeof, OperandType::kIdx, OperandType::kIdx) \
97 V(StaGlobalSloppy, OperandType::kIdx8, OperandType::kIdx8) \ 85 V(StaGlobalSloppy, OperandType::kIdx, OperandType::kIdx) \
98 V(StaGlobalStrict, OperandType::kIdx8, OperandType::kIdx8) \ 86 V(StaGlobalStrict, OperandType::kIdx, OperandType::kIdx) \
99 V(StaGlobalSloppyWide, OperandType::kIdx16, OperandType::kIdx16) \ 87 \
100 V(StaGlobalStrictWide, OperandType::kIdx16, OperandType::kIdx16) \ 88 /* Context operations */ \
101 \ 89 V(PushContext, OperandType::kReg) \
102 /* Context operations */ \ 90 V(PopContext, OperandType::kReg) \
103 V(PushContext, OperandType::kReg8) \ 91 V(LdaContextSlot, OperandType::kReg, OperandType::kIdx) \
104 V(PopContext, OperandType::kReg8) \ 92 V(StaContextSlot, OperandType::kReg, OperandType::kIdx) \
105 V(LdaContextSlot, OperandType::kReg8, OperandType::kIdx8) \ 93 \
106 V(StaContextSlot, OperandType::kReg8, OperandType::kIdx8) \ 94 /* Load-Store lookup slots */ \
107 V(LdaContextSlotWide, OperandType::kReg8, OperandType::kIdx16) \ 95 V(LdaLookupSlot, OperandType::kIdx) \
108 V(StaContextSlotWide, OperandType::kReg8, OperandType::kIdx16) \ 96 V(LdaLookupSlotInsideTypeof, OperandType::kIdx) \
109 \ 97 V(StaLookupSlotSloppy, OperandType::kIdx) \
110 /* Load-Store lookup slots */ \ 98 V(StaLookupSlotStrict, OperandType::kIdx) \
111 V(LdaLookupSlot, OperandType::kIdx8) \ 99 \
112 V(LdaLookupSlotInsideTypeof, OperandType::kIdx8) \ 100 /* Register-accumulator transfers */ \
113 V(LdaLookupSlotWide, OperandType::kIdx16) \ 101 V(Ldar, OperandType::kReg) \
114 V(LdaLookupSlotInsideTypeofWide, OperandType::kIdx16) \ 102 V(Star, OperandType::kRegOut) \
115 V(StaLookupSlotSloppy, OperandType::kIdx8) \ 103 \
116 V(StaLookupSlotStrict, OperandType::kIdx8) \ 104 /* Register-register transfers */ \
117 V(StaLookupSlotSloppyWide, OperandType::kIdx16) \ 105 V(Mov, OperandType::kReg, OperandType::kRegOut) \
118 V(StaLookupSlotStrictWide, OperandType::kIdx16) \ 106 \
119 \ 107 /* LoadIC operations */ \
120 /* Register-accumulator transfers */ \ 108 V(LoadIC, OperandType::kReg, OperandType::kIdx, OperandType::kIdx) \
121 V(Ldar, OperandType::kReg8) \ 109 V(KeyedLoadIC, OperandType::kReg, OperandType::kIdx) \
122 V(Star, OperandType::kRegOut8) \ 110 \
123 \ 111 /* StoreIC operations */ \
124 /* Register-register transfers */ \ 112 V(StoreICSloppy, OperandType::kReg, OperandType::kIdx, OperandType::kIdx) \
125 V(Mov, OperandType::kReg8, OperandType::kRegOut8) \ 113 V(StoreICStrict, OperandType::kReg, OperandType::kIdx, OperandType::kIdx) \
126 V(MovWide, OperandType::kReg16, OperandType::kRegOut16) \ 114 V(KeyedStoreICSloppy, OperandType::kReg, OperandType::kReg, \
127 \ 115 OperandType::kIdx) \
128 /* LoadIC operations */ \ 116 V(KeyedStoreICStrict, OperandType::kReg, OperandType::kReg, \
129 V(LoadIC, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 117 OperandType::kIdx) \
130 V(KeyedLoadIC, OperandType::kReg8, OperandType::kIdx8) \ 118 \
131 V(LoadICWide, OperandType::kReg8, OperandType::kIdx16, OperandType::kIdx16) \ 119 /* Binary Operators */ \
132 V(KeyedLoadICWide, OperandType::kReg8, OperandType::kIdx16) \ 120 V(Add, OperandType::kReg) \
133 \ 121 V(Sub, OperandType::kReg) \
134 /* StoreIC operations */ \ 122 V(Mul, OperandType::kReg) \
135 V(StoreICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 123 V(Div, OperandType::kReg) \
136 V(StoreICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 124 V(Mod, OperandType::kReg) \
137 V(KeyedStoreICSloppy, OperandType::kReg8, OperandType::kReg8, \ 125 V(BitwiseOr, OperandType::kReg) \
138 OperandType::kIdx8) \ 126 V(BitwiseXor, OperandType::kReg) \
139 V(KeyedStoreICStrict, OperandType::kReg8, OperandType::kReg8, \ 127 V(BitwiseAnd, OperandType::kReg) \
140 OperandType::kIdx8) \ 128 V(ShiftLeft, OperandType::kReg) \
141 V(StoreICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ 129 V(ShiftRight, OperandType::kReg) \
142 OperandType::kIdx16) \ 130 V(ShiftRightLogical, OperandType::kReg) \
143 V(StoreICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ 131 \
144 OperandType::kIdx16) \ 132 /* Unary Operators */ \
145 V(KeyedStoreICSloppyWide, OperandType::kReg8, OperandType::kReg8, \ 133 V(Inc, OperandType::kNone) \
146 OperandType::kIdx16) \ 134 V(Dec, OperandType::kNone) \
147 V(KeyedStoreICStrictWide, OperandType::kReg8, OperandType::kReg8, \ 135 V(LogicalNot, OperandType::kNone) \
148 OperandType::kIdx16) \ 136 V(TypeOf, OperandType::kNone) \
149 \ 137 V(DeletePropertyStrict, OperandType::kReg) \
150 /* Binary Operators */ \ 138 V(DeletePropertySloppy, OperandType::kReg) \
151 V(Add, OperandType::kReg8) \ 139 \
152 V(Sub, OperandType::kReg8) \ 140 /* Call operations */ \
153 V(Mul, OperandType::kReg8) \ 141 V(Call, OperandType::kReg, OperandType::kReg, OperandType::kRegCount, \
154 V(Div, OperandType::kReg8) \ 142 OperandType::kIdx) \
155 V(Mod, OperandType::kReg8) \ 143 V(TailCall, OperandType::kReg, OperandType::kReg, OperandType::kRegCount, \
156 V(BitwiseOr, OperandType::kReg8) \ 144 OperandType::kIdx) \
157 V(BitwiseXor, OperandType::kReg8) \ 145 V(CallRuntime, OperandType::kRuntimeId, OperandType::kMaybeReg, \
158 V(BitwiseAnd, OperandType::kReg8) \ 146 OperandType::kRegCount) \
159 V(ShiftLeft, OperandType::kReg8) \ 147 V(CallRuntimeForPair, OperandType::kRuntimeId, OperandType::kMaybeReg, \
160 V(ShiftRight, OperandType::kReg8) \ 148 OperandType::kRegCount, OperandType::kRegOutPair) \
161 V(ShiftRightLogical, OperandType::kReg8) \ 149 V(CallJSRuntime, OperandType::kIdx, OperandType::kReg, \
162 \ 150 OperandType::kRegCount) \
163 /* Unary Operators */ \ 151 \
164 V(Inc, OperandType::kNone) \ 152 /* New operator */ \
165 V(Dec, OperandType::kNone) \ 153 V(New, OperandType::kReg, OperandType::kMaybeReg, OperandType::kRegCount) \
166 V(LogicalNot, OperandType::kNone) \ 154 \
167 V(TypeOf, OperandType::kNone) \ 155 /* Test Operators */ \
168 V(DeletePropertyStrict, OperandType::kReg8) \ 156 V(TestEqual, OperandType::kReg) \
169 V(DeletePropertySloppy, OperandType::kReg8) \ 157 V(TestNotEqual, OperandType::kReg) \
170 \ 158 V(TestEqualStrict, OperandType::kReg) \
171 /* Call operations */ \ 159 V(TestLessThan, OperandType::kReg) \
172 V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kRegCount8, \ 160 V(TestGreaterThan, OperandType::kReg) \
173 OperandType::kIdx8) \ 161 V(TestLessThanOrEqual, OperandType::kReg) \
174 V(CallWide, OperandType::kReg16, OperandType::kReg16, \ 162 V(TestGreaterThanOrEqual, OperandType::kReg) \
175 OperandType::kRegCount16, OperandType::kIdx16) \ 163 V(TestInstanceOf, OperandType::kReg) \
176 V(TailCall, OperandType::kReg8, OperandType::kReg8, OperandType::kRegCount8, \ 164 V(TestIn, OperandType::kReg) \
177 OperandType::kIdx8) \ 165 \
178 V(TailCallWide, OperandType::kReg16, OperandType::kReg16, \ 166 /* Cast operators */ \
179 OperandType::kRegCount16, OperandType::kIdx16) \ 167 V(ToName, OperandType::kNone) \
180 V(CallRuntime, OperandType::kIdx16, OperandType::kMaybeReg8, \ 168 V(ToNumber, OperandType::kNone) \
181 OperandType::kRegCount8) \ 169 V(ToObject, OperandType::kNone) \
182 V(CallRuntimeWide, OperandType::kIdx16, OperandType::kMaybeReg16, \ 170 \
183 OperandType::kRegCount8) \ 171 /* Literals */ \
184 V(CallRuntimeForPair, OperandType::kIdx16, OperandType::kMaybeReg8, \ 172 V(CreateRegExpLiteral, OperandType::kIdx, OperandType::kIdx, \
185 OperandType::kRegCount8, OperandType::kRegOutPair8) \ 173 OperandType::kFlag8) \
186 V(CallRuntimeForPairWide, OperandType::kIdx16, OperandType::kMaybeReg16, \ 174 V(CreateArrayLiteral, OperandType::kIdx, OperandType::kIdx, \
187 OperandType::kRegCount8, OperandType::kRegOutPair16) \ 175 OperandType::kFlag8) \
188 V(CallJSRuntime, OperandType::kIdx16, OperandType::kReg8, \ 176 V(CreateObjectLiteral, OperandType::kIdx, OperandType::kIdx, \
189 OperandType::kRegCount8) \ 177 OperandType::kFlag8) \
190 V(CallJSRuntimeWide, OperandType::kIdx16, OperandType::kReg16, \ 178 \
191 OperandType::kRegCount16) \ 179 /* Closure allocation */ \
192 \ 180 V(CreateClosure, OperandType::kIdx, OperandType::kFlag8) \
193 /* New operator */ \ 181 \
194 V(New, OperandType::kReg8, OperandType::kMaybeReg8, OperandType::kRegCount8) \ 182 /* Arguments allocation */ \
195 V(NewWide, OperandType::kReg16, OperandType::kMaybeReg16, \ 183 V(CreateMappedArguments, OperandType::kNone) \
196 OperandType::kRegCount16) \ 184 V(CreateUnmappedArguments, OperandType::kNone) \
197 \ 185 V(CreateRestParameter, OperandType::kNone) \
198 /* Test Operators */ \ 186 \
199 V(TestEqual, OperandType::kReg8) \ 187 /* Control Flow */ \
200 V(TestNotEqual, OperandType::kReg8) \ 188 V(Jump, OperandType::kImm) \
201 V(TestEqualStrict, OperandType::kReg8) \ 189 V(JumpConstant, OperandType::kIdx) \
202 V(TestLessThan, OperandType::kReg8) \ 190 V(JumpIfTrue, OperandType::kImm) \
203 V(TestGreaterThan, OperandType::kReg8) \ 191 V(JumpIfTrueConstant, OperandType::kIdx) \
204 V(TestLessThanOrEqual, OperandType::kReg8) \ 192 V(JumpIfFalse, OperandType::kImm) \
205 V(TestGreaterThanOrEqual, OperandType::kReg8) \ 193 V(JumpIfFalseConstant, OperandType::kIdx) \
206 V(TestInstanceOf, OperandType::kReg8) \ 194 V(JumpIfToBooleanTrue, OperandType::kImm) \
207 V(TestIn, OperandType::kReg8) \ 195 V(JumpIfToBooleanTrueConstant, OperandType::kIdx) \
208 \ 196 V(JumpIfToBooleanFalse, OperandType::kImm) \
209 /* Cast operators */ \ 197 V(JumpIfToBooleanFalseConstant, OperandType::kIdx) \
210 V(ToName, OperandType::kNone) \ 198 V(JumpIfNull, OperandType::kImm) \
211 V(ToNumber, OperandType::kNone) \ 199 V(JumpIfNullConstant, OperandType::kIdx) \
212 V(ToObject, OperandType::kNone) \ 200 V(JumpIfUndefined, OperandType::kImm) \
213 \ 201 V(JumpIfUndefinedConstant, OperandType::kIdx) \
214 /* Literals */ \ 202 V(JumpIfNotHole, OperandType::kImm) \
215 V(CreateRegExpLiteral, OperandType::kIdx8, OperandType::kIdx8, \ 203 V(JumpIfNotHoleConstant, OperandType::kIdx) \
216 OperandType::kImm8) \ 204 \
217 V(CreateArrayLiteral, OperandType::kIdx8, OperandType::kIdx8, \ 205 /* Complex flow control For..in */ \
218 OperandType::kImm8) \ 206 V(ForInPrepare, OperandType::kRegOutTriple) \
219 V(CreateObjectLiteral, OperandType::kIdx8, OperandType::kIdx8, \ 207 V(ForInDone, OperandType::kReg, OperandType::kReg) \
220 OperandType::kImm8) \ 208 V(ForInNext, OperandType::kReg, OperandType::kReg, OperandType::kRegPair, \
221 V(CreateRegExpLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \ 209 OperandType::kIdx) \
222 OperandType::kImm8) \ 210 V(ForInStep, OperandType::kReg) \
223 V(CreateArrayLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \ 211 \
224 OperandType::kImm8) \ 212 /* Perform a stack guard check */ \
225 V(CreateObjectLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \ 213 V(StackCheck, OperandType::kNone) \
226 OperandType::kImm8) \ 214 \
227 \ 215 /* Non-local flow control */ \
228 /* Closure allocation */ \ 216 V(Throw, OperandType::kNone) \
229 V(CreateClosure, OperandType::kIdx8, OperandType::kImm8) \ 217 V(ReThrow, OperandType::kNone) \
230 V(CreateClosureWide, OperandType::kIdx16, OperandType::kImm8) \ 218 V(Return, OperandType::kNone) \
231 \ 219 \
232 /* Arguments allocation */ \ 220 /* Debugger */ \
233 V(CreateMappedArguments, OperandType::kNone) \ 221 V(Debugger, OperandType::kNone) \
234 V(CreateUnmappedArguments, OperandType::kNone) \
235 V(CreateRestParameter, OperandType::kNone) \
236 \
237 /* Control Flow */ \
238 V(Jump, OperandType::kImm8) \
239 V(JumpConstant, OperandType::kIdx8) \
240 V(JumpConstantWide, OperandType::kIdx16) \
241 V(JumpIfTrue, OperandType::kImm8) \
242 V(JumpIfTrueConstant, OperandType::kIdx8) \
243 V(JumpIfTrueConstantWide, OperandType::kIdx16) \
244 V(JumpIfFalse, OperandType::kImm8) \
245 V(JumpIfFalseConstant, OperandType::kIdx8) \
246 V(JumpIfFalseConstantWide, OperandType::kIdx16) \
247 V(JumpIfToBooleanTrue, OperandType::kImm8) \
248 V(JumpIfToBooleanTrueConstant, OperandType::kIdx8) \
249 V(JumpIfToBooleanTrueConstantWide, OperandType::kIdx16) \
250 V(JumpIfToBooleanFalse, OperandType::kImm8) \
251 V(JumpIfToBooleanFalseConstant, OperandType::kIdx8) \
252 V(JumpIfToBooleanFalseConstantWide, OperandType::kIdx16) \
253 V(JumpIfNull, OperandType::kImm8) \
254 V(JumpIfNullConstant, OperandType::kIdx8) \
255 V(JumpIfNullConstantWide, OperandType::kIdx16) \
256 V(JumpIfUndefined, OperandType::kImm8) \
257 V(JumpIfUndefinedConstant, OperandType::kIdx8) \
258 V(JumpIfUndefinedConstantWide, OperandType::kIdx16) \
259 V(JumpIfNotHole, OperandType::kImm8) \
260 V(JumpIfNotHoleConstant, OperandType::kIdx8) \
261 V(JumpIfNotHoleConstantWide, OperandType::kIdx16) \
262 \
263 /* Complex flow control For..in */ \
264 V(ForInPrepare, OperandType::kRegOutTriple8) \
265 V(ForInPrepareWide, OperandType::kRegOutTriple16) \
266 V(ForInDone, OperandType::kReg8, OperandType::kReg8) \
267 V(ForInNext, OperandType::kReg8, OperandType::kReg8, OperandType::kRegPair8, \
268 OperandType::kIdx8) \
269 V(ForInNextWide, OperandType::kReg16, OperandType::kReg16, \
270 OperandType::kRegPair16, OperandType::kIdx16) \
271 V(ForInStep, OperandType::kReg8) \
272 \
273 /* Perform a stack guard check */ \
274 V(StackCheck, OperandType::kNone) \
275 \
276 /* Non-local flow control */ \
277 V(Throw, OperandType::kNone) \
278 V(ReThrow, OperandType::kNone) \
279 V(Return, OperandType::kNone) \
280 \
281 /* Debugger */ \
282 V(Debugger, OperandType::kNone) \
283 DEBUG_BREAK_BYTECODE_LIST(V) 222 DEBUG_BREAK_BYTECODE_LIST(V)
284 223
285 // Enumeration of the size classes of operand types used by bytecodes. 224 // Enumeration of the size classes of operand types used by bytecodes.
286 enum class OperandSize : uint8_t { 225 enum class OperandSize : uint8_t {
287 kNone = 0, 226 kNone = 0,
288 kByte = 1, 227 kByte = 1,
289 kShort = 2, 228 kShort = 2,
229 kQuad = 4,
230 kLast = kQuad
290 }; 231 };
291 232
233 enum class OperandTypeTrait : uint8_t { kScalable = 0, kFixed = 1 };
292 234
293 // Enumeration of operand types used by bytecodes. 235 // Enumeration of operand types used by bytecodes.
294 enum class OperandType : uint8_t { 236 enum class OperandType : uint8_t {
295 #define DECLARE_OPERAND_TYPE(Name, _) k##Name, 237 #define DECLARE_OPERAND_TYPE(Name, _, __) k##Name,
296 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE) 238 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE)
297 #undef DECLARE_OPERAND_TYPE 239 #undef DECLARE_OPERAND_TYPE
298 #define COUNT_OPERAND_TYPES(x, _) +1 240 #define COUNT_OPERAND_TYPES(x, _, __) +1
299 // The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will 241 // The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will
300 // evaluate to the same value as the last operand. 242 // evaluate to the same value as the last operand.
301 kLast = -1 OPERAND_TYPE_LIST(COUNT_OPERAND_TYPES) 243 kLast = -1 OPERAND_TYPE_LIST(COUNT_OPERAND_TYPES)
302 #undef COUNT_OPERAND_TYPES 244 #undef COUNT_OPERAND_TYPES
303 }; 245 };
304 246
305 247
306 // Enumeration of interpreter bytecodes. 248 // Enumeration of interpreter bytecodes.
307 enum class Bytecode : uint8_t { 249 enum class Bytecode : uint8_t {
308 #define DECLARE_BYTECODE(Name, ...) k##Name, 250 #define DECLARE_BYTECODE(Name, ...) k##Name,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 352
411 // Returns bytecode for |value|. 353 // Returns bytecode for |value|.
412 static Bytecode FromByte(uint8_t value); 354 static Bytecode FromByte(uint8_t value);
413 355
414 // Returns the number of operands expected by |bytecode|. 356 // Returns the number of operands expected by |bytecode|.
415 static int NumberOfOperands(Bytecode bytecode); 357 static int NumberOfOperands(Bytecode bytecode);
416 358
417 // Returns the number of register operands expected by |bytecode|. 359 // Returns the number of register operands expected by |bytecode|.
418 static int NumberOfRegisterOperands(Bytecode bytecode); 360 static int NumberOfRegisterOperands(Bytecode bytecode);
419 361
362 // Returns the scaling applied to scalable operands if bytecode is
363 // is a scaling prefix, returns 1 otherwise..
364 static int GetPrefixBytecodeScale(Bytecode bytecode);
rmcilroy 2016/03/10 16:45:37 Could we have this return operand sizes instead (i
oth 2016/03/11 16:26:12 Ack. Leaving this to last piece to try in the CL.
oth 2016/03/15 09:58:28 We have a difference of opinion here. I pushed thi
rmcilroy 2016/03/16 11:55:53 Ok, can we make this an enum then? It doesn't seem
oth 2016/03/17 13:48:38 Done.
365
420 // Returns the i-th operand of |bytecode|. 366 // Returns the i-th operand of |bytecode|.
421 static OperandType GetOperandType(Bytecode bytecode, int i); 367 static OperandType GetOperandType(Bytecode bytecode, int i);
422 368
423 // Returns the size of the i-th operand of |bytecode|. 369 // Returns the size of the i-th operand of |bytecode|.
424 static OperandSize GetOperandSize(Bytecode bytecode, int i); 370 static OperandSize GetOperandSize(Bytecode bytecode, int i, int scale);
425 371
426 // Returns the offset of the i-th operand of |bytecode| relative to the start 372 // Returns the offset of the i-th operand of |bytecode| relative to the start
427 // of the bytecode. 373 // of the bytecode.
428 static int GetOperandOffset(Bytecode bytecode, int i); 374 static int GetOperandOffset(Bytecode bytecode, int i, int scale);
429 375
430 // Returns a zero-based bitmap of the register operand positions of 376 // Returns a zero-based bitmap of the register operand positions of
431 // |bytecode|. 377 // |bytecode|.
432 static int GetRegisterOperandBitmap(Bytecode bytecode); 378 static int GetRegisterOperandBitmap(Bytecode bytecode);
433 379
434 // Returns a debug break bytecode with a matching operand size. 380 // Returns a debug break bytecode with a matching operand size.
435 static Bytecode GetDebugBreak(Bytecode bytecode); 381 static Bytecode GetDebugBreak(Bytecode bytecode, int scale);
436 382
437 // Returns the size of the bytecode including its operands. 383 // Returns the size of the bytecode including its operands and
438 static int Size(Bytecode bytecode); 384 // prefix byte when scaling active.
385 static int Size(Bytecode bytecode, int operand_scale);
439 386
440 // Returns the size of |operand|. 387 // Returns the size of |operand|.
441 static OperandSize SizeOfOperand(OperandType operand); 388 static OperandSize SizeOfOperand(OperandType operand, int scale);
442 389
443 // Returns true if the bytecode is a conditional jump taking 390 // Returns true if the bytecode is a conditional jump taking
444 // an immediate byte operand (OperandType::kImm8). 391 // an immediate byte operand (OperandType::kImm).
445 static bool IsConditionalJumpImmediate(Bytecode bytecode); 392 static bool IsConditionalJumpImmediate(Bytecode bytecode);
446 393
447 // Returns true if the bytecode is a conditional jump taking 394 // Returns true if the bytecode is a conditional jump taking
448 // a constant pool entry (OperandType::kIdx8). 395 // a constant pool entry (OperandType::kIdx).
449 static bool IsConditionalJumpConstant(Bytecode bytecode); 396 static bool IsConditionalJumpConstant(Bytecode bytecode);
450 397
451 // Returns true if the bytecode is a conditional jump taking 398 // Returns true if the bytecode is a conditional jump taking
452 // a constant pool entry (OperandType::kIdx16).
453 static bool IsConditionalJumpConstantWide(Bytecode bytecode);
454
455 // Returns true if the bytecode is a conditional jump taking
456 // any kind of operand. 399 // any kind of operand.
457 static bool IsConditionalJump(Bytecode bytecode); 400 static bool IsConditionalJump(Bytecode bytecode);
458 401
459 // Returns true if the bytecode is a jump or a conditional jump taking 402 // Returns true if the bytecode is a jump or a conditional jump taking
460 // an immediate byte operand (OperandType::kImm8). 403 // an immediate byte operand (OperandType::kImm).
461 static bool IsJumpImmediate(Bytecode bytecode); 404 static bool IsJumpImmediate(Bytecode bytecode);
462 405
463 // Returns true if the bytecode is a jump or conditional jump taking a 406 // Returns true if the bytecode is a jump or conditional jump taking a
464 // constant pool entry (OperandType::kIdx8). 407 // constant pool entry (OperandType::kIdx).
465 static bool IsJumpConstant(Bytecode bytecode); 408 static bool IsJumpConstant(Bytecode bytecode);
466 409
467 // Returns true if the bytecode is a jump or conditional jump taking a
468 // constant pool entry (OperandType::kIdx16).
469 static bool IsJumpConstantWide(Bytecode bytecode);
470
471 // Returns true if the bytecode is a jump or conditional jump taking 410 // Returns true if the bytecode is a jump or conditional jump taking
472 // any kind of operand. 411 // any kind of operand.
473 static bool IsJump(Bytecode bytecode); 412 static bool IsJump(Bytecode bytecode);
474 413
475 // Returns true if the bytecode is a conditional jump, a jump, or a return. 414 // Returns true if the bytecode is a conditional jump, a jump, or a return.
476 static bool IsJumpOrReturn(Bytecode bytecode); 415 static bool IsJumpOrReturn(Bytecode bytecode);
477 416
478 // Returns true if the bytecode is a call or a constructor call. 417 // Returns true if the bytecode is a call or a constructor call.
479 static bool IsCallOrNew(Bytecode bytecode); 418 static bool IsCallOrNew(Bytecode bytecode);
480 419
481 // Returns true if the bytecode is a call to the runtime. 420 // Returns true if the bytecode is a call to the runtime.
482 static bool IsCallRuntime(Bytecode bytecode); 421 static bool IsCallRuntime(Bytecode bytecode);
483 422
484 // Returns true if the bytecode is a debug break. 423 // Returns true if the bytecode is a debug break.
485 static bool IsDebugBreak(Bytecode bytecode); 424 static bool IsDebugBreak(Bytecode bytecode);
486 425
487 // Returns true if |operand_type| is a register index operand (kIdx8/kIdx16). 426 // Returns true if the bytecode has wider operand forms.
427 static bool IsBytecodeWithScalableOperands(Bytecode bytecode);
428
429 // Returns true if |operand_type| is a register index operand (kFlag8).
430 static bool IsFlagOperandType(OperandType operand_type);
431
432 // Returns true if |operand_type| is a register index operand (kIdx).
488 static bool IsIndexOperandType(OperandType operand_type); 433 static bool IsIndexOperandType(OperandType operand_type);
489 434
490 // Returns true if |operand_type| represents an immediate. 435 // Returns true if |operand_type| represents an immediate.
491 static bool IsImmediateOperandType(OperandType operand_type); 436 static bool IsImmediateOperandType(OperandType operand_type);
492 437
493 // Returns true if |operand_type| is a register count operand 438 // Returns true if |operand_type| is a register count operand
494 // (kRegCount8/kRegCount16). 439 // (kRegCount).
495 static bool IsRegisterCountOperandType(OperandType operand_type); 440 static bool IsRegisterCountOperandType(OperandType operand_type);
496 441
497 // Returns true if |operand_type| is any type of register operand. 442 // Returns true if |operand_type| is any type of register operand.
498 static bool IsRegisterOperandType(OperandType operand_type); 443 static bool IsRegisterOperandType(OperandType operand_type);
499 444
500 // Returns true if |operand_type| represents a register used as an input. 445 // Returns true if |operand_type| represents a register used as an input.
501 static bool IsRegisterInputOperandType(OperandType operand_type); 446 static bool IsRegisterInputOperandType(OperandType operand_type);
502 447
503 // Returns true if |operand_type| represents a register used as an output. 448 // Returns true if |operand_type| represents a register used as an output.
504 static bool IsRegisterOutputOperandType(OperandType operand_type); 449 static bool IsRegisterOutputOperandType(OperandType operand_type);
505 450
506 // Returns true if |operand_type| is a maybe register operand 451 // Returns true if |operand_type| is a maybe register operand
507 // (kMaybeReg8/kMaybeReg16). 452 // (kMaybeReg).
508 static bool IsMaybeRegisterOperandType(OperandType operand_type); 453 static bool IsMaybeRegisterOperandType(OperandType operand_type);
509 454
455 // Returns true if |operand_type| is a runtime-id id operand (kRuntimeId).
rmcilroy 2016/03/10 16:45:37 remove second "id"
oth 2016/03/11 16:26:12 Done.
456 static bool IsRuntimeIdOperandType(OperandType operand_type);
457
510 // Decode a single bytecode and operands to |os|. 458 // Decode a single bytecode and operands to |os|.
511 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start, 459 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start,
512 int number_of_parameters); 460 int number_of_parameters);
513 461
514 private: 462 private:
515 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); 463 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes);
516 }; 464 };
517 465
518 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); 466 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode);
519 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); 467 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type);
520 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); 468 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type);
521 469
522 } // namespace interpreter 470 } // namespace interpreter
523 } // namespace internal 471 } // namespace internal
524 } // namespace v8 472 } // namespace v8
525 473
526 #endif // V8_INTERPRETER_BYTECODES_H_ 474 #endif // V8_INTERPRETER_BYTECODES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698