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

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: Rebase onto 3c1dc424d3f2f651ad 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) V(None, OperandTypeInfo::kNone)
19 V(None, OperandSize::kNone)
20 19
21 #define REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ 20 #define REGISTER_INPUT_OPERAND_TYPE_LIST(V) \
22 /* Byte operands. */ \ 21 V(MaybeReg, OperandTypeInfo::kScalableSignedByte) \
23 V(MaybeReg8, OperandSize::kByte) \ 22 V(Reg, OperandTypeInfo::kScalableSignedByte) \
24 V(Reg8, OperandSize::kByte) \ 23 V(RegPair, OperandTypeInfo::kScalableSignedByte)
25 V(RegPair8, OperandSize::kByte) \
26 /* Short operands. */ \
27 V(MaybeReg16, OperandSize::kShort) \
28 V(Reg16, OperandSize::kShort) \
29 V(RegPair16, OperandSize::kShort)
30 24
31 #define REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) \ 25 #define REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) \
32 /* Byte operands. */ \ 26 V(RegOut, OperandTypeInfo::kScalableSignedByte) \
33 V(RegOut8, OperandSize::kByte) \ 27 V(RegOutPair, OperandTypeInfo::kScalableSignedByte) \
34 V(RegOutPair8, OperandSize::kByte) \ 28 V(RegOutTriple, OperandTypeInfo::kScalableSignedByte)
35 V(RegOutTriple8, OperandSize::kByte) \
36 /* Short operands. */ \
37 V(RegOut16, OperandSize::kShort) \
38 V(RegOutPair16, OperandSize::kShort) \
39 V(RegOutTriple16, OperandSize::kShort)
40 29
41 #define SCALAR_OPERAND_TYPE_LIST(V) \ 30 #define SCALAR_OPERAND_TYPE_LIST(V) \
42 /* Byte operands. */ \ 31 V(Flag8, OperandTypeInfo::kFixedUnsignedByte) \
43 V(Idx8, OperandSize::kByte) \ 32 V(Idx, OperandTypeInfo::kScalableUnsignedByte) \
44 V(Imm8, OperandSize::kByte) \ 33 V(Imm, OperandTypeInfo::kScalableSignedByte) \
45 V(RegCount8, OperandSize::kByte) \ 34 V(RegCount, OperandTypeInfo::kScalableUnsignedByte) \
46 /* Short operands. */ \ 35 V(RuntimeId, OperandTypeInfo::kFixedUnsignedShort)
47 V(Idx16, OperandSize::kShort) \
48 V(RegCount16, OperandSize::kShort)
49 36
50 #define REGISTER_OPERAND_TYPE_LIST(V) \ 37 #define REGISTER_OPERAND_TYPE_LIST(V) \
51 REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ 38 REGISTER_INPUT_OPERAND_TYPE_LIST(V) \
52 REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) 39 REGISTER_OUTPUT_OPERAND_TYPE_LIST(V)
53 40
54 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \ 41 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \
55 INVALID_OPERAND_TYPE_LIST(V) \ 42 INVALID_OPERAND_TYPE_LIST(V) \
56 SCALAR_OPERAND_TYPE_LIST(V) 43 SCALAR_OPERAND_TYPE_LIST(V)
57 44
58 // The list of operand types used by bytecodes. 45 // The list of operand types used by bytecodes.
59 #define OPERAND_TYPE_LIST(V) \ 46 #define OPERAND_TYPE_LIST(V) \
60 NON_REGISTER_OPERAND_TYPE_LIST(V) \ 47 NON_REGISTER_OPERAND_TYPE_LIST(V) \
61 REGISTER_OPERAND_TYPE_LIST(V) 48 REGISTER_OPERAND_TYPE_LIST(V)
62 49
63 // Define one debug break bytecode for each operands size. 50 // Define one debug break bytecode for each operands size.
64 #define DEBUG_BREAK_BYTECODE_LIST(V) \ 51 #define DEBUG_BREAK_BYTECODE_LIST(V) \
65 V(DebugBreak0, OperandType::kNone) \ 52 V(DebugBreak0, OperandType::kNone) \
66 V(DebugBreak1, OperandType::kReg8) \ 53 V(DebugBreak1, OperandType::kReg) \
67 V(DebugBreak2, OperandType::kReg16) \ 54 V(DebugBreak2, OperandType::kReg, OperandType::kReg) \
68 V(DebugBreak3, OperandType::kReg16, OperandType::kReg8) \ 55 V(DebugBreak3, OperandType::kReg, OperandType::kReg, OperandType::kReg) \
69 V(DebugBreak4, OperandType::kReg16, OperandType::kReg16) \ 56 V(DebugBreak4, OperandType::kReg, OperandType::kReg, OperandType::kReg, \
70 V(DebugBreak5, OperandType::kReg16, OperandType::kReg16, OperandType::kReg8) \ 57 OperandType::kReg) \
71 V(DebugBreak6, OperandType::kReg16, OperandType::kReg16, \ 58 V(DebugBreak5, OperandType::kRuntimeId, OperandType::kReg, \
72 OperandType::kReg16) \ 59 OperandType::kReg) \
73 V(DebugBreak7, OperandType::kReg16, OperandType::kReg16, \ 60 V(DebugBreak6, OperandType::kRuntimeId, OperandType::kReg, \
74 OperandType::kReg16, OperandType::kReg8) \ 61 OperandType::kReg, OperandType::kReg) \
75 V(DebugBreak8, OperandType::kReg16, OperandType::kReg16, \ 62 V(DebugBreak7, OperandType::kIdx, OperandType::kFlag8) \
76 OperandType::kReg16, OperandType::kReg16) 63 V(DebugBreak8, OperandType::kIdx, OperandType::kIdx, OperandType::kFlag8)
77 64
78 // The list of bytecodes which are interpreted by the interpreter. 65 // The list of bytecodes which are interpreted by the interpreter.
79 #define BYTECODE_LIST(V) \ 66 #define BYTECODE_LIST(V) \
80 \ 67 /* Extended width operands */ \
81 /* Loading the accumulator */ \ 68 V(Wide, OperandType::kNone) \
82 V(LdaZero, OperandType::kNone) \ 69 V(ExtraWide, OperandType::kNone) \
83 V(LdaSmi8, OperandType::kImm8) \ 70 \
84 V(LdaUndefined, OperandType::kNone) \ 71 /* Loading the accumulator */ \
85 V(LdaNull, OperandType::kNone) \ 72 V(LdaZero, OperandType::kNone) \
86 V(LdaTheHole, OperandType::kNone) \ 73 V(LdaSmi, OperandType::kImm) \
87 V(LdaTrue, OperandType::kNone) \ 74 V(LdaUndefined, OperandType::kNone) \
88 V(LdaFalse, OperandType::kNone) \ 75 V(LdaNull, OperandType::kNone) \
89 V(LdaConstant, OperandType::kIdx8) \ 76 V(LdaTheHole, OperandType::kNone) \
90 V(LdaConstantWide, OperandType::kIdx16) \ 77 V(LdaTrue, OperandType::kNone) \
91 \ 78 V(LdaFalse, OperandType::kNone) \
92 /* Globals */ \ 79 V(LdaConstant, OperandType::kIdx) \
93 V(LdaGlobal, OperandType::kIdx8, OperandType::kIdx8) \ 80 \
94 V(LdaGlobalInsideTypeof, OperandType::kIdx8, OperandType::kIdx8) \ 81 /* Globals */ \
95 V(LdaGlobalWide, OperandType::kIdx16, OperandType::kIdx16) \ 82 V(LdaGlobal, OperandType::kIdx, OperandType::kIdx) \
96 V(LdaGlobalInsideTypeofWide, OperandType::kIdx16, OperandType::kIdx16) \ 83 V(LdaGlobalInsideTypeof, OperandType::kIdx, OperandType::kIdx) \
97 V(StaGlobalSloppy, OperandType::kIdx8, OperandType::kIdx8) \ 84 V(StaGlobalSloppy, OperandType::kIdx, OperandType::kIdx) \
98 V(StaGlobalStrict, OperandType::kIdx8, OperandType::kIdx8) \ 85 V(StaGlobalStrict, OperandType::kIdx, OperandType::kIdx) \
99 V(StaGlobalSloppyWide, OperandType::kIdx16, OperandType::kIdx16) \ 86 \
100 V(StaGlobalStrictWide, OperandType::kIdx16, OperandType::kIdx16) \ 87 /* Context operations */ \
101 \ 88 V(PushContext, OperandType::kReg) \
102 /* Context operations */ \ 89 V(PopContext, OperandType::kReg) \
103 V(PushContext, OperandType::kReg8) \ 90 V(LdaContextSlot, OperandType::kReg, OperandType::kIdx) \
104 V(PopContext, OperandType::kReg8) \ 91 V(StaContextSlot, OperandType::kReg, OperandType::kIdx) \
105 V(LdaContextSlot, OperandType::kReg8, OperandType::kIdx8) \ 92 \
106 V(StaContextSlot, OperandType::kReg8, OperandType::kIdx8) \ 93 /* Load-Store lookup slots */ \
107 V(LdaContextSlotWide, OperandType::kReg8, OperandType::kIdx16) \ 94 V(LdaLookupSlot, OperandType::kIdx) \
108 V(StaContextSlotWide, OperandType::kReg8, OperandType::kIdx16) \ 95 V(LdaLookupSlotInsideTypeof, OperandType::kIdx) \
109 \ 96 V(StaLookupSlotSloppy, OperandType::kIdx) \
110 /* Load-Store lookup slots */ \ 97 V(StaLookupSlotStrict, OperandType::kIdx) \
111 V(LdaLookupSlot, OperandType::kIdx8) \ 98 \
112 V(LdaLookupSlotInsideTypeof, OperandType::kIdx8) \ 99 /* Register-accumulator transfers */ \
113 V(LdaLookupSlotWide, OperandType::kIdx16) \ 100 V(Ldar, OperandType::kReg) \
114 V(LdaLookupSlotInsideTypeofWide, OperandType::kIdx16) \ 101 V(Star, OperandType::kRegOut) \
115 V(StaLookupSlotSloppy, OperandType::kIdx8) \ 102 \
116 V(StaLookupSlotStrict, OperandType::kIdx8) \ 103 /* Register-register transfers */ \
117 V(StaLookupSlotSloppyWide, OperandType::kIdx16) \ 104 V(Mov, OperandType::kReg, OperandType::kRegOut) \
118 V(StaLookupSlotStrictWide, OperandType::kIdx16) \ 105 \
119 \ 106 /* LoadIC operations */ \
120 /* Register-accumulator transfers */ \ 107 V(LoadIC, OperandType::kReg, OperandType::kIdx, OperandType::kIdx) \
121 V(Ldar, OperandType::kReg8) \ 108 V(KeyedLoadIC, OperandType::kReg, OperandType::kIdx) \
122 V(Star, OperandType::kRegOut8) \ 109 \
123 \ 110 /* StoreIC operations */ \
124 /* Register-register transfers */ \ 111 V(StoreICSloppy, OperandType::kReg, OperandType::kIdx, OperandType::kIdx) \
125 V(Mov, OperandType::kReg8, OperandType::kRegOut8) \ 112 V(StoreICStrict, OperandType::kReg, OperandType::kIdx, OperandType::kIdx) \
126 V(MovWide, OperandType::kReg16, OperandType::kRegOut16) \ 113 V(KeyedStoreICSloppy, OperandType::kReg, OperandType::kReg, \
127 \ 114 OperandType::kIdx) \
128 /* LoadIC operations */ \ 115 V(KeyedStoreICStrict, OperandType::kReg, OperandType::kReg, \
129 V(LoadIC, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 116 OperandType::kIdx) \
130 V(KeyedLoadIC, OperandType::kReg8, OperandType::kIdx8) \ 117 \
131 V(LoadICWide, OperandType::kReg8, OperandType::kIdx16, OperandType::kIdx16) \ 118 /* Binary Operators */ \
132 V(KeyedLoadICWide, OperandType::kReg8, OperandType::kIdx16) \ 119 V(Add, OperandType::kReg) \
133 \ 120 V(Sub, OperandType::kReg) \
134 /* StoreIC operations */ \ 121 V(Mul, OperandType::kReg) \
135 V(StoreICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 122 V(Div, OperandType::kReg) \
136 V(StoreICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 123 V(Mod, OperandType::kReg) \
137 V(KeyedStoreICSloppy, OperandType::kReg8, OperandType::kReg8, \ 124 V(BitwiseOr, OperandType::kReg) \
138 OperandType::kIdx8) \ 125 V(BitwiseXor, OperandType::kReg) \
139 V(KeyedStoreICStrict, OperandType::kReg8, OperandType::kReg8, \ 126 V(BitwiseAnd, OperandType::kReg) \
140 OperandType::kIdx8) \ 127 V(ShiftLeft, OperandType::kReg) \
141 V(StoreICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ 128 V(ShiftRight, OperandType::kReg) \
142 OperandType::kIdx16) \ 129 V(ShiftRightLogical, OperandType::kReg) \
143 V(StoreICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ 130 \
144 OperandType::kIdx16) \ 131 /* Unary Operators */ \
145 V(KeyedStoreICSloppyWide, OperandType::kReg8, OperandType::kReg8, \ 132 V(Inc, OperandType::kNone) \
146 OperandType::kIdx16) \ 133 V(Dec, OperandType::kNone) \
147 V(KeyedStoreICStrictWide, OperandType::kReg8, OperandType::kReg8, \ 134 V(LogicalNot, OperandType::kNone) \
148 OperandType::kIdx16) \ 135 V(TypeOf, OperandType::kNone) \
149 \ 136 V(DeletePropertyStrict, OperandType::kReg) \
150 /* Binary Operators */ \ 137 V(DeletePropertySloppy, OperandType::kReg) \
151 V(Add, OperandType::kReg8) \ 138 \
152 V(Sub, OperandType::kReg8) \ 139 /* Call operations */ \
153 V(Mul, OperandType::kReg8) \ 140 V(Call, OperandType::kReg, OperandType::kReg, OperandType::kRegCount, \
154 V(Div, OperandType::kReg8) \ 141 OperandType::kIdx) \
155 V(Mod, OperandType::kReg8) \ 142 V(TailCall, OperandType::kReg, OperandType::kReg, OperandType::kRegCount, \
156 V(BitwiseOr, OperandType::kReg8) \ 143 OperandType::kIdx) \
157 V(BitwiseXor, OperandType::kReg8) \ 144 V(CallRuntime, OperandType::kRuntimeId, OperandType::kMaybeReg, \
158 V(BitwiseAnd, OperandType::kReg8) \ 145 OperandType::kRegCount) \
159 V(ShiftLeft, OperandType::kReg8) \ 146 V(CallRuntimeForPair, OperandType::kRuntimeId, OperandType::kMaybeReg, \
160 V(ShiftRight, OperandType::kReg8) \ 147 OperandType::kRegCount, OperandType::kRegOutPair) \
161 V(ShiftRightLogical, OperandType::kReg8) \ 148 V(CallJSRuntime, OperandType::kIdx, OperandType::kReg, \
162 \ 149 OperandType::kRegCount) \
163 /* Unary Operators */ \ 150 \
164 V(Inc, OperandType::kNone) \ 151 /* New operator */ \
165 V(Dec, OperandType::kNone) \ 152 V(New, OperandType::kReg, OperandType::kMaybeReg, OperandType::kRegCount) \
166 V(LogicalNot, OperandType::kNone) \ 153 \
167 V(TypeOf, OperandType::kNone) \ 154 /* Test Operators */ \
168 V(DeletePropertyStrict, OperandType::kReg8) \ 155 V(TestEqual, OperandType::kReg) \
169 V(DeletePropertySloppy, OperandType::kReg8) \ 156 V(TestNotEqual, OperandType::kReg) \
170 \ 157 V(TestEqualStrict, OperandType::kReg) \
171 /* Call operations */ \ 158 V(TestLessThan, OperandType::kReg) \
172 V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kRegCount8, \ 159 V(TestGreaterThan, OperandType::kReg) \
173 OperandType::kIdx8) \ 160 V(TestLessThanOrEqual, OperandType::kReg) \
174 V(CallWide, OperandType::kReg16, OperandType::kReg16, \ 161 V(TestGreaterThanOrEqual, OperandType::kReg) \
175 OperandType::kRegCount16, OperandType::kIdx16) \ 162 V(TestInstanceOf, OperandType::kReg) \
176 V(TailCall, OperandType::kReg8, OperandType::kReg8, OperandType::kRegCount8, \ 163 V(TestIn, OperandType::kReg) \
177 OperandType::kIdx8) \ 164 \
178 V(TailCallWide, OperandType::kReg16, OperandType::kReg16, \ 165 /* Cast operators */ \
179 OperandType::kRegCount16, OperandType::kIdx16) \ 166 V(ToName, OperandType::kNone) \
180 V(CallRuntime, OperandType::kIdx16, OperandType::kMaybeReg8, \ 167 V(ToNumber, OperandType::kNone) \
181 OperandType::kRegCount8) \ 168 V(ToObject, OperandType::kNone) \
182 V(CallRuntimeWide, OperandType::kIdx16, OperandType::kMaybeReg16, \ 169 \
183 OperandType::kRegCount8) \ 170 /* Literals */ \
184 V(CallRuntimeForPair, OperandType::kIdx16, OperandType::kMaybeReg8, \ 171 V(CreateRegExpLiteral, OperandType::kIdx, OperandType::kIdx, \
185 OperandType::kRegCount8, OperandType::kRegOutPair8) \ 172 OperandType::kFlag8) \
186 V(CallRuntimeForPairWide, OperandType::kIdx16, OperandType::kMaybeReg16, \ 173 V(CreateArrayLiteral, OperandType::kIdx, OperandType::kIdx, \
187 OperandType::kRegCount8, OperandType::kRegOutPair16) \ 174 OperandType::kFlag8) \
188 V(CallJSRuntime, OperandType::kIdx16, OperandType::kReg8, \ 175 V(CreateObjectLiteral, OperandType::kIdx, OperandType::kIdx, \
189 OperandType::kRegCount8) \ 176 OperandType::kFlag8) \
190 V(CallJSRuntimeWide, OperandType::kIdx16, OperandType::kReg16, \ 177 \
191 OperandType::kRegCount16) \ 178 /* Closure allocation */ \
192 \ 179 V(CreateClosure, OperandType::kIdx, OperandType::kFlag8) \
193 /* New operator */ \ 180 \
194 V(New, OperandType::kReg8, OperandType::kMaybeReg8, OperandType::kRegCount8) \ 181 /* Arguments allocation */ \
195 V(NewWide, OperandType::kReg16, OperandType::kMaybeReg16, \ 182 V(CreateMappedArguments, OperandType::kNone) \
196 OperandType::kRegCount16) \ 183 V(CreateUnmappedArguments, OperandType::kNone) \
197 \ 184 V(CreateRestParameter, OperandType::kNone) \
198 /* Test Operators */ \ 185 \
199 V(TestEqual, OperandType::kReg8) \ 186 /* Control Flow */ \
200 V(TestNotEqual, OperandType::kReg8) \ 187 V(Jump, OperandType::kImm) \
201 V(TestEqualStrict, OperandType::kReg8) \ 188 V(JumpConstant, OperandType::kIdx) \
202 V(TestLessThan, OperandType::kReg8) \ 189 V(JumpIfTrue, OperandType::kImm) \
203 V(TestGreaterThan, OperandType::kReg8) \ 190 V(JumpIfTrueConstant, OperandType::kIdx) \
204 V(TestLessThanOrEqual, OperandType::kReg8) \ 191 V(JumpIfFalse, OperandType::kImm) \
205 V(TestGreaterThanOrEqual, OperandType::kReg8) \ 192 V(JumpIfFalseConstant, OperandType::kIdx) \
206 V(TestInstanceOf, OperandType::kReg8) \ 193 V(JumpIfToBooleanTrue, OperandType::kImm) \
207 V(TestIn, OperandType::kReg8) \ 194 V(JumpIfToBooleanTrueConstant, OperandType::kIdx) \
208 \ 195 V(JumpIfToBooleanFalse, OperandType::kImm) \
209 /* Cast operators */ \ 196 V(JumpIfToBooleanFalseConstant, OperandType::kIdx) \
210 V(ToName, OperandType::kNone) \ 197 V(JumpIfNull, OperandType::kImm) \
211 V(ToNumber, OperandType::kNone) \ 198 V(JumpIfNullConstant, OperandType::kIdx) \
212 V(ToObject, OperandType::kNone) \ 199 V(JumpIfUndefined, OperandType::kImm) \
213 \ 200 V(JumpIfUndefinedConstant, OperandType::kIdx) \
214 /* Literals */ \ 201 V(JumpIfNotHole, OperandType::kImm) \
215 V(CreateRegExpLiteral, OperandType::kIdx8, OperandType::kIdx8, \ 202 V(JumpIfNotHoleConstant, OperandType::kIdx) \
216 OperandType::kImm8) \ 203 \
217 V(CreateArrayLiteral, OperandType::kIdx8, OperandType::kIdx8, \ 204 /* Complex flow control For..in */ \
218 OperandType::kImm8) \ 205 V(ForInPrepare, OperandType::kRegOutTriple) \
219 V(CreateObjectLiteral, OperandType::kIdx8, OperandType::kIdx8, \ 206 V(ForInDone, OperandType::kReg, OperandType::kReg) \
220 OperandType::kImm8) \ 207 V(ForInNext, OperandType::kReg, OperandType::kReg, OperandType::kRegPair, \
221 V(CreateRegExpLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \ 208 OperandType::kIdx) \
222 OperandType::kImm8) \ 209 V(ForInStep, OperandType::kReg) \
223 V(CreateArrayLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \ 210 \
224 OperandType::kImm8) \ 211 /* Perform a stack guard check */ \
225 V(CreateObjectLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \ 212 V(StackCheck, OperandType::kNone) \
226 OperandType::kImm8) \ 213 \
227 \ 214 /* Non-local flow control */ \
228 /* Closure allocation */ \ 215 V(Throw, OperandType::kNone) \
229 V(CreateClosure, OperandType::kIdx8, OperandType::kImm8) \ 216 V(ReThrow, OperandType::kNone) \
230 V(CreateClosureWide, OperandType::kIdx16, OperandType::kImm8) \ 217 V(Return, OperandType::kNone) \
231 \ 218 \
232 /* Arguments allocation */ \ 219 /* Debugger */ \
233 V(CreateMappedArguments, OperandType::kNone) \ 220 V(Debugger, OperandType::kNone) \
234 V(CreateUnmappedArguments, OperandType::kNone) \ 221 DEBUG_BREAK_BYTECODE_LIST(V) \
235 V(CreateRestParameter, OperandType::kNone) \ 222 \
236 \ 223 /* Illegal bytecode (terminates execution) */ \
237 /* Control Flow */ \ 224 V(Illegal, OperandType::kNone)
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)
284 225
285 // Enumeration of the size classes of operand types used by bytecodes. 226 // Enumeration of the size classes of operand types used by bytecodes.
286 enum class OperandSize : uint8_t { 227 enum class OperandSize : uint8_t {
287 kNone = 0, 228 kNone = 0,
288 kByte = 1, 229 kByte = 1,
289 kShort = 2, 230 kShort = 2,
231 kQuad = 4,
232 kLast = kQuad
290 }; 233 };
291 234
235 #define OPERAND_TYPE_INFO_LIST(V) \
236 V(None, false, false, OperandSize::kNone) \
237 V(ScalableSignedByte, true, false, OperandSize::kByte) \
238 V(ScalableUnsignedByte, true, true, OperandSize::kByte) \
239 V(FixedUnsignedByte, false, true, OperandSize::kByte) \
240 V(FixedUnsignedShort, false, true, OperandSize::kShort)
241
242 enum class OperandTypeInfo : uint8_t {
243 #define DECLARE_OPERAND_TYPE_INFO(Name, ...) k##Name,
244 OPERAND_TYPE_INFO_LIST(DECLARE_OPERAND_TYPE_INFO)
245 #undef DECLARE_OPERAND_TYPE_INFO
246 };
292 247
293 // Enumeration of operand types used by bytecodes. 248 // Enumeration of operand types used by bytecodes.
294 enum class OperandType : uint8_t { 249 enum class OperandType : uint8_t {
295 #define DECLARE_OPERAND_TYPE(Name, _) k##Name, 250 #define DECLARE_OPERAND_TYPE(Name, _) k##Name,
296 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE) 251 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE)
297 #undef DECLARE_OPERAND_TYPE 252 #undef DECLARE_OPERAND_TYPE
298 #define COUNT_OPERAND_TYPES(x, _) +1 253 #define COUNT_OPERAND_TYPES(x, _) +1
299 // The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will 254 // The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will
300 // evaluate to the same value as the last operand. 255 // evaluate to the same value as the last operand.
301 kLast = -1 OPERAND_TYPE_LIST(COUNT_OPERAND_TYPES) 256 kLast = -1 OPERAND_TYPE_LIST(COUNT_OPERAND_TYPES)
(...skipping 21 matching lines...) Expand all
323 explicit Register(int index = kInvalidIndex) : index_(index) {} 278 explicit Register(int index = kInvalidIndex) : index_(index) {}
324 279
325 int index() const { return index_; } 280 int index() const { return index_; }
326 bool is_parameter() const { return index() < 0; } 281 bool is_parameter() const { return index() < 0; }
327 bool is_valid() const { return index_ != kInvalidIndex; } 282 bool is_valid() const { return index_ != kInvalidIndex; }
328 bool is_byte_operand() const; 283 bool is_byte_operand() const;
329 bool is_short_operand() const; 284 bool is_short_operand() const;
330 285
331 static Register FromParameterIndex(int index, int parameter_count); 286 static Register FromParameterIndex(int index, int parameter_count);
332 int ToParameterIndex(int parameter_count) const; 287 int ToParameterIndex(int parameter_count) const;
333 static int MaxParameterIndex();
334 static int MaxRegisterIndex();
335 static int MaxRegisterIndexForByteOperand();
336 288
337 // Returns an invalid register. 289 // Returns an invalid register.
338 static Register invalid_value() { return Register(); } 290 static Register invalid_value() { return Register(); }
339 291
340 // Returns the register for the function's closure object. 292 // Returns the register for the function's closure object.
341 static Register function_closure(); 293 static Register function_closure();
342 bool is_function_closure() const; 294 bool is_function_closure() const;
343 295
344 // Returns the register which holds the current context object. 296 // Returns the register which holds the current context object.
345 static Register current_context(); 297 static Register current_context();
346 bool is_current_context() const; 298 bool is_current_context() const;
347 299
348 // Returns the register for the incoming new target value. 300 // Returns the register for the incoming new target value.
349 static Register new_target(); 301 static Register new_target();
350 bool is_new_target() const; 302 bool is_new_target() const;
351 303
352 static Register FromOperand(uint8_t operand); 304 int32_t ToOperand() const { return -index_; }
353 uint8_t ToOperand() const; 305 static Register FromOperand(int32_t operand) { return Register(-operand); }
354
355 static Register FromWideOperand(uint16_t operand);
356 uint16_t ToWideOperand() const;
357
358 static Register FromRawOperand(uint32_t raw_operand);
359 uint32_t ToRawOperand() const;
360 306
361 static bool AreContiguous(Register reg1, Register reg2, 307 static bool AreContiguous(Register reg1, Register reg2,
362 Register reg3 = Register(), 308 Register reg3 = Register(),
363 Register reg4 = Register(), 309 Register reg4 = Register(),
364 Register reg5 = Register()); 310 Register reg5 = Register());
365 311
366 std::string ToString(int parameter_count); 312 std::string ToString(int parameter_count);
367 313
368 bool operator==(const Register& other) const { 314 bool operator==(const Register& other) const {
369 return index() == other.index(); 315 return index() == other.index();
(...skipping 22 matching lines...) Expand all
392 338
393 int index_; 339 int index_;
394 }; 340 };
395 341
396 342
397 class Bytecodes { 343 class Bytecodes {
398 public: 344 public:
399 // Returns string representation of |bytecode|. 345 // Returns string representation of |bytecode|.
400 static const char* ToString(Bytecode bytecode); 346 static const char* ToString(Bytecode bytecode);
401 347
348 // Returns string representation of |bytecode|.
349 static std::string ToString(Bytecode bytecode, int operand_scale);
350
402 // Returns string representation of |operand_type|. 351 // Returns string representation of |operand_type|.
403 static const char* OperandTypeToString(OperandType operand_type); 352 static const char* OperandTypeToString(OperandType operand_type);
404 353
405 // Returns string representation of |operand_size|. 354 // Returns string representation of |operand_size|.
406 static const char* OperandSizeToString(OperandSize operand_size); 355 static const char* OperandSizeToString(OperandSize operand_size);
407 356
408 // Returns byte value of bytecode. 357 // Returns byte value of bytecode.
409 static uint8_t ToByte(Bytecode bytecode); 358 static uint8_t ToByte(Bytecode bytecode);
410 359
411 // Returns bytecode for |value|. 360 // Returns bytecode for |value|.
412 static Bytecode FromByte(uint8_t value); 361 static Bytecode FromByte(uint8_t value);
413 362
414 // Returns the number of operands expected by |bytecode|. 363 // Returns the number of operands expected by |bytecode|.
415 static int NumberOfOperands(Bytecode bytecode); 364 static int NumberOfOperands(Bytecode bytecode);
416 365
417 // Returns the number of register operands expected by |bytecode|. 366 // Returns the number of register operands expected by |bytecode|.
418 static int NumberOfRegisterOperands(Bytecode bytecode); 367 static int NumberOfRegisterOperands(Bytecode bytecode);
419 368
369 // Returns the scaling applied to scalable operands if bytecode is
370 // is a scaling prefix, returns 1 otherwise..
371 static int GetPrefixBytecodeScale(Bytecode bytecode);
372
420 // Returns the i-th operand of |bytecode|. 373 // Returns the i-th operand of |bytecode|.
421 static OperandType GetOperandType(Bytecode bytecode, int i); 374 static OperandType GetOperandType(Bytecode bytecode, int i);
422 375
423 // Returns the size of the i-th operand of |bytecode|. 376 // Returns the size of the i-th operand of |bytecode|.
424 static OperandSize GetOperandSize(Bytecode bytecode, int i); 377 static OperandSize GetOperandSize(Bytecode bytecode, int i, int scale);
425 378
426 // Returns the offset of the i-th operand of |bytecode| relative to the start 379 // Returns the offset of the i-th operand of |bytecode| relative to the start
427 // of the bytecode. 380 // of the bytecode.
428 static int GetOperandOffset(Bytecode bytecode, int i); 381 static int GetOperandOffset(Bytecode bytecode, int i, int scale);
429 382
430 // Returns a zero-based bitmap of the register operand positions of 383 // Returns a zero-based bitmap of the register operand positions of
431 // |bytecode|. 384 // |bytecode|.
432 static int GetRegisterOperandBitmap(Bytecode bytecode); 385 static int GetRegisterOperandBitmap(Bytecode bytecode);
433 386
434 // Returns a debug break bytecode with a matching operand size. 387 // Returns a debug break bytecode with a matching operand size.
435 static Bytecode GetDebugBreak(Bytecode bytecode); 388 static Bytecode GetDebugBreak(Bytecode bytecode, int scale);
436 389
437 // Returns the size of the bytecode including its operands. 390 // Returns the size of the bytecode including its operands and
438 static int Size(Bytecode bytecode); 391 // prefix byte when scaling active.
392 static int Size(Bytecode bytecode, int operand_scale);
439 393
440 // Returns the size of |operand|. 394 // Returns the size of |operand|.
441 static OperandSize SizeOfOperand(OperandType operand); 395 static OperandSize SizeOfOperand(OperandType operand, int scale);
442 396
443 // Returns true if the bytecode is a conditional jump taking 397 // Returns true if the bytecode is a conditional jump taking
444 // an immediate byte operand (OperandType::kImm8). 398 // an immediate byte operand (OperandType::kImm).
445 static bool IsConditionalJumpImmediate(Bytecode bytecode); 399 static bool IsConditionalJumpImmediate(Bytecode bytecode);
446 400
447 // Returns true if the bytecode is a conditional jump taking 401 // Returns true if the bytecode is a conditional jump taking
448 // a constant pool entry (OperandType::kIdx8). 402 // a constant pool entry (OperandType::kIdx).
449 static bool IsConditionalJumpConstant(Bytecode bytecode); 403 static bool IsConditionalJumpConstant(Bytecode bytecode);
450 404
451 // Returns true if the bytecode is a conditional jump taking 405 // 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. 406 // any kind of operand.
457 static bool IsConditionalJump(Bytecode bytecode); 407 static bool IsConditionalJump(Bytecode bytecode);
458 408
459 // Returns true if the bytecode is a jump or a conditional jump taking 409 // Returns true if the bytecode is a jump or a conditional jump taking
460 // an immediate byte operand (OperandType::kImm8). 410 // an immediate byte operand (OperandType::kImm).
461 static bool IsJumpImmediate(Bytecode bytecode); 411 static bool IsJumpImmediate(Bytecode bytecode);
462 412
463 // Returns true if the bytecode is a jump or conditional jump taking a 413 // Returns true if the bytecode is a jump or conditional jump taking a
464 // constant pool entry (OperandType::kIdx8). 414 // constant pool entry (OperandType::kIdx).
465 static bool IsJumpConstant(Bytecode bytecode); 415 static bool IsJumpConstant(Bytecode bytecode);
466 416
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 417 // Returns true if the bytecode is a jump or conditional jump taking
472 // any kind of operand. 418 // any kind of operand.
473 static bool IsJump(Bytecode bytecode); 419 static bool IsJump(Bytecode bytecode);
474 420
475 // Returns true if the bytecode is a conditional jump, a jump, or a return. 421 // Returns true if the bytecode is a conditional jump, a jump, or a return.
476 static bool IsJumpOrReturn(Bytecode bytecode); 422 static bool IsJumpOrReturn(Bytecode bytecode);
477 423
478 // Returns true if the bytecode is a call or a constructor call. 424 // Returns true if the bytecode is a call or a constructor call.
479 static bool IsCallOrNew(Bytecode bytecode); 425 static bool IsCallOrNew(Bytecode bytecode);
480 426
481 // Returns true if the bytecode is a call to the runtime. 427 // Returns true if the bytecode is a call to the runtime.
482 static bool IsCallRuntime(Bytecode bytecode); 428 static bool IsCallRuntime(Bytecode bytecode);
483 429
484 // Returns true if the bytecode is a debug break. 430 // Returns true if the bytecode is a debug break.
485 static bool IsDebugBreak(Bytecode bytecode); 431 static bool IsDebugBreak(Bytecode bytecode);
486 432
487 // Returns true if |operand_type| is a register index operand (kIdx8/kIdx16). 433 // Returns true if the bytecode has wider operand forms.
488 static bool IsIndexOperandType(OperandType operand_type); 434 static bool IsBytecodeWithScalableOperands(Bytecode bytecode);
489 435
490 // Returns true if |operand_type| represents an immediate. 436 // Returns true if the bytecode is an scaling prefix bytecode.
491 static bool IsImmediateOperandType(OperandType operand_type); 437 static bool IsPrefixScalingBytecode(Bytecode bytecode);
492
493 // Returns true if |operand_type| is a register count operand
494 // (kRegCount8/kRegCount16).
495 static bool IsRegisterCountOperandType(OperandType operand_type);
496 438
497 // Returns true if |operand_type| is any type of register operand. 439 // Returns true if |operand_type| is any type of register operand.
498 static bool IsRegisterOperandType(OperandType operand_type); 440 static bool IsRegisterOperandType(OperandType operand_type);
499 441
500 // Returns true if |operand_type| represents a register used as an input. 442 // Returns true if |operand_type| represents a register used as an input.
501 static bool IsRegisterInputOperandType(OperandType operand_type); 443 static bool IsRegisterInputOperandType(OperandType operand_type);
502 444
503 // Returns true if |operand_type| represents a register used as an output. 445 // Returns true if |operand_type| represents a register used as an output.
504 static bool IsRegisterOutputOperandType(OperandType operand_type); 446 static bool IsRegisterOutputOperandType(OperandType operand_type);
505 447
506 // Returns true if |operand_type| is a maybe register operand 448 // Returns true if |operand_type| is a maybe register operand
507 // (kMaybeReg8/kMaybeReg16). 449 // (kMaybeReg).
508 static bool IsMaybeRegisterOperandType(OperandType operand_type); 450 static bool IsMaybeRegisterOperandType(OperandType operand_type);
509 451
452 // Returns true if |operand_type| is a runtime-id operand (kRuntimeId).
453 static bool IsRuntimeIdOperandType(OperandType operand_type);
454
455 // Returns true if |operand_type| is unsigned, false if signed.
456 static bool IsUnsignedOperandType(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