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

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: Additional test for debugger stepping and wider constant array builder test. 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_PLAIN_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)
rmcilroy 2016/03/17 17:30:50 I don't think you need as many of these any more d
oth 2016/03/21 09:16:54 Good spot. We need both of the breaks with the kRu
64
65 // Define one debug break for each widening prefix
66 #define DEBUG_BREAK_PREFIX_BYTECODE_LIST(V) \
67 V(DebugBreakWide, OperandType::kNone) \
68 V(DebugBreakExtraWide, OperandType::kNone)
69
70 #define DEBUG_BREAK_BYTECODE_LIST(V) \
71 DEBUG_BREAK_PLAIN_BYTECODE_LIST(V) \
72 DEBUG_BREAK_PREFIX_BYTECODE_LIST(V)
77 73
78 // The list of bytecodes which are interpreted by the interpreter. 74 // The list of bytecodes which are interpreted by the interpreter.
79 #define BYTECODE_LIST(V) \ 75 #define BYTECODE_LIST(V) \
80 \ 76 /* Extended width operands */ \
81 /* Loading the accumulator */ \ 77 V(Wide, OperandType::kNone) \
82 V(LdaZero, OperandType::kNone) \ 78 V(ExtraWide, OperandType::kNone) \
83 V(LdaSmi8, OperandType::kImm8) \ 79 \
84 V(LdaUndefined, OperandType::kNone) \ 80 /* Loading the accumulator */ \
85 V(LdaNull, OperandType::kNone) \ 81 V(LdaZero, OperandType::kNone) \
86 V(LdaTheHole, OperandType::kNone) \ 82 V(LdaSmi, OperandType::kImm) \
87 V(LdaTrue, OperandType::kNone) \ 83 V(LdaUndefined, OperandType::kNone) \
88 V(LdaFalse, OperandType::kNone) \ 84 V(LdaNull, OperandType::kNone) \
89 V(LdaConstant, OperandType::kIdx8) \ 85 V(LdaTheHole, OperandType::kNone) \
90 V(LdaConstantWide, OperandType::kIdx16) \ 86 V(LdaTrue, OperandType::kNone) \
91 \ 87 V(LdaFalse, OperandType::kNone) \
92 /* Globals */ \ 88 V(LdaConstant, OperandType::kIdx) \
93 V(LdaGlobal, OperandType::kIdx8, OperandType::kIdx8) \ 89 \
94 V(LdaGlobalInsideTypeof, OperandType::kIdx8, OperandType::kIdx8) \ 90 /* Globals */ \
95 V(LdaGlobalWide, OperandType::kIdx16, OperandType::kIdx16) \ 91 V(LdaGlobal, OperandType::kIdx, OperandType::kIdx) \
96 V(LdaGlobalInsideTypeofWide, OperandType::kIdx16, OperandType::kIdx16) \ 92 V(LdaGlobalInsideTypeof, OperandType::kIdx, OperandType::kIdx) \
97 V(StaGlobalSloppy, OperandType::kIdx8, OperandType::kIdx8) \ 93 V(StaGlobalSloppy, OperandType::kIdx, OperandType::kIdx) \
98 V(StaGlobalStrict, OperandType::kIdx8, OperandType::kIdx8) \ 94 V(StaGlobalStrict, OperandType::kIdx, OperandType::kIdx) \
99 V(StaGlobalSloppyWide, OperandType::kIdx16, OperandType::kIdx16) \ 95 \
100 V(StaGlobalStrictWide, OperandType::kIdx16, OperandType::kIdx16) \ 96 /* Context operations */ \
101 \ 97 V(PushContext, OperandType::kReg) \
102 /* Context operations */ \ 98 V(PopContext, OperandType::kReg) \
103 V(PushContext, OperandType::kReg8) \ 99 V(LdaContextSlot, OperandType::kReg, OperandType::kIdx) \
104 V(PopContext, OperandType::kReg8) \ 100 V(StaContextSlot, OperandType::kReg, OperandType::kIdx) \
105 V(LdaContextSlot, OperandType::kReg8, OperandType::kIdx8) \ 101 \
106 V(StaContextSlot, OperandType::kReg8, OperandType::kIdx8) \ 102 /* Load-Store lookup slots */ \
107 V(LdaContextSlotWide, OperandType::kReg8, OperandType::kIdx16) \ 103 V(LdaLookupSlot, OperandType::kIdx) \
108 V(StaContextSlotWide, OperandType::kReg8, OperandType::kIdx16) \ 104 V(LdaLookupSlotInsideTypeof, OperandType::kIdx) \
109 \ 105 V(StaLookupSlotSloppy, OperandType::kIdx) \
110 /* Load-Store lookup slots */ \ 106 V(StaLookupSlotStrict, OperandType::kIdx) \
111 V(LdaLookupSlot, OperandType::kIdx8) \ 107 \
112 V(LdaLookupSlotInsideTypeof, OperandType::kIdx8) \ 108 /* Register-accumulator transfers */ \
113 V(LdaLookupSlotWide, OperandType::kIdx16) \ 109 V(Ldar, OperandType::kReg) \
114 V(LdaLookupSlotInsideTypeofWide, OperandType::kIdx16) \ 110 V(Star, OperandType::kRegOut) \
115 V(StaLookupSlotSloppy, OperandType::kIdx8) \ 111 \
116 V(StaLookupSlotStrict, OperandType::kIdx8) \ 112 /* Register-register transfers */ \
117 V(StaLookupSlotSloppyWide, OperandType::kIdx16) \ 113 V(Mov, OperandType::kReg, OperandType::kRegOut) \
118 V(StaLookupSlotStrictWide, OperandType::kIdx16) \ 114 \
119 \ 115 /* LoadIC operations */ \
120 /* Register-accumulator transfers */ \ 116 V(LoadIC, OperandType::kReg, OperandType::kIdx, OperandType::kIdx) \
121 V(Ldar, OperandType::kReg8) \ 117 V(KeyedLoadIC, OperandType::kReg, OperandType::kIdx) \
122 V(Star, OperandType::kRegOut8) \ 118 \
123 \ 119 /* StoreIC operations */ \
124 /* Register-register transfers */ \ 120 V(StoreICSloppy, OperandType::kReg, OperandType::kIdx, OperandType::kIdx) \
125 V(Mov, OperandType::kReg8, OperandType::kRegOut8) \ 121 V(StoreICStrict, OperandType::kReg, OperandType::kIdx, OperandType::kIdx) \
126 V(MovWide, OperandType::kReg16, OperandType::kRegOut16) \ 122 V(KeyedStoreICSloppy, OperandType::kReg, OperandType::kReg, \
127 \ 123 OperandType::kIdx) \
128 /* LoadIC operations */ \ 124 V(KeyedStoreICStrict, OperandType::kReg, OperandType::kReg, \
129 V(LoadIC, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 125 OperandType::kIdx) \
130 V(KeyedLoadIC, OperandType::kReg8, OperandType::kIdx8) \ 126 \
131 V(LoadICWide, OperandType::kReg8, OperandType::kIdx16, OperandType::kIdx16) \ 127 /* Binary Operators */ \
132 V(KeyedLoadICWide, OperandType::kReg8, OperandType::kIdx16) \ 128 V(Add, OperandType::kReg) \
133 \ 129 V(Sub, OperandType::kReg) \
134 /* StoreIC operations */ \ 130 V(Mul, OperandType::kReg) \
135 V(StoreICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 131 V(Div, OperandType::kReg) \
136 V(StoreICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 132 V(Mod, OperandType::kReg) \
137 V(KeyedStoreICSloppy, OperandType::kReg8, OperandType::kReg8, \ 133 V(BitwiseOr, OperandType::kReg) \
138 OperandType::kIdx8) \ 134 V(BitwiseXor, OperandType::kReg) \
139 V(KeyedStoreICStrict, OperandType::kReg8, OperandType::kReg8, \ 135 V(BitwiseAnd, OperandType::kReg) \
140 OperandType::kIdx8) \ 136 V(ShiftLeft, OperandType::kReg) \
141 V(StoreICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ 137 V(ShiftRight, OperandType::kReg) \
142 OperandType::kIdx16) \ 138 V(ShiftRightLogical, OperandType::kReg) \
143 V(StoreICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ 139 \
144 OperandType::kIdx16) \ 140 /* Unary Operators */ \
145 V(KeyedStoreICSloppyWide, OperandType::kReg8, OperandType::kReg8, \ 141 V(Inc, OperandType::kNone) \
146 OperandType::kIdx16) \ 142 V(Dec, OperandType::kNone) \
147 V(KeyedStoreICStrictWide, OperandType::kReg8, OperandType::kReg8, \ 143 V(LogicalNot, OperandType::kNone) \
148 OperandType::kIdx16) \ 144 V(TypeOf, OperandType::kNone) \
149 \ 145 V(DeletePropertyStrict, OperandType::kReg) \
150 /* Binary Operators */ \ 146 V(DeletePropertySloppy, OperandType::kReg) \
151 V(Add, OperandType::kReg8) \ 147 \
152 V(Sub, OperandType::kReg8) \ 148 /* Call operations */ \
153 V(Mul, OperandType::kReg8) \ 149 V(Call, OperandType::kReg, OperandType::kReg, OperandType::kRegCount, \
154 V(Div, OperandType::kReg8) \ 150 OperandType::kIdx) \
155 V(Mod, OperandType::kReg8) \ 151 V(TailCall, OperandType::kReg, OperandType::kReg, OperandType::kRegCount, \
156 V(BitwiseOr, OperandType::kReg8) \ 152 OperandType::kIdx) \
157 V(BitwiseXor, OperandType::kReg8) \ 153 V(CallRuntime, OperandType::kRuntimeId, OperandType::kMaybeReg, \
158 V(BitwiseAnd, OperandType::kReg8) \ 154 OperandType::kRegCount) \
159 V(ShiftLeft, OperandType::kReg8) \ 155 V(CallRuntimeForPair, OperandType::kRuntimeId, OperandType::kMaybeReg, \
160 V(ShiftRight, OperandType::kReg8) \ 156 OperandType::kRegCount, OperandType::kRegOutPair) \
161 V(ShiftRightLogical, OperandType::kReg8) \ 157 V(CallJSRuntime, OperandType::kIdx, OperandType::kReg, \
162 \ 158 OperandType::kRegCount) \
163 /* Unary Operators */ \ 159 \
164 V(Inc, OperandType::kNone) \ 160 /* New operator */ \
165 V(Dec, OperandType::kNone) \ 161 V(New, OperandType::kReg, OperandType::kMaybeReg, OperandType::kRegCount) \
166 V(LogicalNot, OperandType::kNone) \ 162 \
167 V(TypeOf, OperandType::kNone) \ 163 /* Test Operators */ \
168 V(DeletePropertyStrict, OperandType::kReg8) \ 164 V(TestEqual, OperandType::kReg) \
169 V(DeletePropertySloppy, OperandType::kReg8) \ 165 V(TestNotEqual, OperandType::kReg) \
170 \ 166 V(TestEqualStrict, OperandType::kReg) \
171 /* Call operations */ \ 167 V(TestLessThan, OperandType::kReg) \
172 V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kRegCount8, \ 168 V(TestGreaterThan, OperandType::kReg) \
173 OperandType::kIdx8) \ 169 V(TestLessThanOrEqual, OperandType::kReg) \
174 V(CallWide, OperandType::kReg16, OperandType::kReg16, \ 170 V(TestGreaterThanOrEqual, OperandType::kReg) \
175 OperandType::kRegCount16, OperandType::kIdx16) \ 171 V(TestInstanceOf, OperandType::kReg) \
176 V(TailCall, OperandType::kReg8, OperandType::kReg8, OperandType::kRegCount8, \ 172 V(TestIn, OperandType::kReg) \
177 OperandType::kIdx8) \ 173 \
178 V(TailCallWide, OperandType::kReg16, OperandType::kReg16, \ 174 /* Cast operators */ \
179 OperandType::kRegCount16, OperandType::kIdx16) \ 175 V(ToName, OperandType::kNone) \
180 V(CallRuntime, OperandType::kIdx16, OperandType::kMaybeReg8, \ 176 V(ToNumber, OperandType::kNone) \
181 OperandType::kRegCount8) \ 177 V(ToObject, OperandType::kNone) \
182 V(CallRuntimeWide, OperandType::kIdx16, OperandType::kMaybeReg16, \ 178 \
183 OperandType::kRegCount8) \ 179 /* Literals */ \
184 V(CallRuntimeForPair, OperandType::kIdx16, OperandType::kMaybeReg8, \ 180 V(CreateRegExpLiteral, OperandType::kIdx, OperandType::kIdx, \
185 OperandType::kRegCount8, OperandType::kRegOutPair8) \ 181 OperandType::kFlag8) \
186 V(CallRuntimeForPairWide, OperandType::kIdx16, OperandType::kMaybeReg16, \ 182 V(CreateArrayLiteral, OperandType::kIdx, OperandType::kIdx, \
187 OperandType::kRegCount8, OperandType::kRegOutPair16) \ 183 OperandType::kFlag8) \
188 V(CallJSRuntime, OperandType::kIdx16, OperandType::kReg8, \ 184 V(CreateObjectLiteral, OperandType::kIdx, OperandType::kIdx, \
189 OperandType::kRegCount8) \ 185 OperandType::kFlag8) \
190 V(CallJSRuntimeWide, OperandType::kIdx16, OperandType::kReg16, \ 186 \
191 OperandType::kRegCount16) \ 187 /* Closure allocation */ \
192 \ 188 V(CreateClosure, OperandType::kIdx, OperandType::kFlag8) \
193 /* New operator */ \ 189 \
194 V(New, OperandType::kReg8, OperandType::kMaybeReg8, OperandType::kRegCount8) \ 190 /* Arguments allocation */ \
195 V(NewWide, OperandType::kReg16, OperandType::kMaybeReg16, \ 191 V(CreateMappedArguments, OperandType::kNone) \
196 OperandType::kRegCount16) \ 192 V(CreateUnmappedArguments, OperandType::kNone) \
197 \ 193 V(CreateRestParameter, OperandType::kNone) \
198 /* Test Operators */ \ 194 \
199 V(TestEqual, OperandType::kReg8) \ 195 /* Control Flow */ \
200 V(TestNotEqual, OperandType::kReg8) \ 196 V(Jump, OperandType::kImm) \
201 V(TestEqualStrict, OperandType::kReg8) \ 197 V(JumpConstant, OperandType::kIdx) \
202 V(TestLessThan, OperandType::kReg8) \ 198 V(JumpIfTrue, OperandType::kImm) \
203 V(TestGreaterThan, OperandType::kReg8) \ 199 V(JumpIfTrueConstant, OperandType::kIdx) \
204 V(TestLessThanOrEqual, OperandType::kReg8) \ 200 V(JumpIfFalse, OperandType::kImm) \
205 V(TestGreaterThanOrEqual, OperandType::kReg8) \ 201 V(JumpIfFalseConstant, OperandType::kIdx) \
206 V(TestInstanceOf, OperandType::kReg8) \ 202 V(JumpIfToBooleanTrue, OperandType::kImm) \
207 V(TestIn, OperandType::kReg8) \ 203 V(JumpIfToBooleanTrueConstant, OperandType::kIdx) \
208 \ 204 V(JumpIfToBooleanFalse, OperandType::kImm) \
209 /* Cast operators */ \ 205 V(JumpIfToBooleanFalseConstant, OperandType::kIdx) \
210 V(ToName, OperandType::kNone) \ 206 V(JumpIfNull, OperandType::kImm) \
211 V(ToNumber, OperandType::kNone) \ 207 V(JumpIfNullConstant, OperandType::kIdx) \
212 V(ToObject, OperandType::kNone) \ 208 V(JumpIfUndefined, OperandType::kImm) \
213 \ 209 V(JumpIfUndefinedConstant, OperandType::kIdx) \
214 /* Literals */ \ 210 V(JumpIfNotHole, OperandType::kImm) \
215 V(CreateRegExpLiteral, OperandType::kIdx8, OperandType::kIdx8, \ 211 V(JumpIfNotHoleConstant, OperandType::kIdx) \
216 OperandType::kImm8) \ 212 \
217 V(CreateArrayLiteral, OperandType::kIdx8, OperandType::kIdx8, \ 213 /* Complex flow control For..in */ \
218 OperandType::kImm8) \ 214 V(ForInPrepare, OperandType::kRegOutTriple) \
219 V(CreateObjectLiteral, OperandType::kIdx8, OperandType::kIdx8, \ 215 V(ForInDone, OperandType::kReg, OperandType::kReg) \
220 OperandType::kImm8) \ 216 V(ForInNext, OperandType::kReg, OperandType::kReg, OperandType::kRegPair, \
221 V(CreateRegExpLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \ 217 OperandType::kIdx) \
222 OperandType::kImm8) \ 218 V(ForInStep, OperandType::kReg) \
223 V(CreateArrayLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \ 219 \
224 OperandType::kImm8) \ 220 /* Perform a stack guard check */ \
225 V(CreateObjectLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \ 221 V(StackCheck, OperandType::kNone) \
226 OperandType::kImm8) \ 222 \
227 \ 223 /* Non-local flow control */ \
228 /* Closure allocation */ \ 224 V(Throw, OperandType::kNone) \
229 V(CreateClosure, OperandType::kIdx8, OperandType::kImm8) \ 225 V(ReThrow, OperandType::kNone) \
230 V(CreateClosureWide, OperandType::kIdx16, OperandType::kImm8) \ 226 V(Return, OperandType::kNone) \
231 \ 227 \
232 /* Arguments allocation */ \ 228 /* Debugger */ \
233 V(CreateMappedArguments, OperandType::kNone) \ 229 V(Debugger, OperandType::kNone) \
234 V(CreateUnmappedArguments, OperandType::kNone) \ 230 DEBUG_BREAK_BYTECODE_LIST(V) \
235 V(CreateRestParameter, OperandType::kNone) \ 231 \
236 \ 232 /* Illegal bytecode (terminates execution) */ \
237 /* Control Flow */ \ 233 V(Illegal, OperandType::kNone)
238 V(Jump, OperandType::kImm8) \ 234
239 V(JumpConstant, OperandType::kIdx8) \ 235 // Enumeration of scaling factors applicable to scalable operands.
240 V(JumpConstantWide, OperandType::kIdx16) \ 236 enum class OperandScale : uint8_t {
241 V(JumpIfTrue, OperandType::kImm8) \ 237 k1X = 1,
rmcilroy 2016/03/17 17:30:50 These names aren't very easy for me to parse. How
oth 2016/03/21 09:16:54 Done. <Bikeshed> It might be better generally if
242 V(JumpIfTrueConstant, OperandType::kIdx8) \ 238 k2X = 2,
243 V(JumpIfTrueConstantWide, OperandType::kIdx16) \ 239 k4X = 4,
244 V(JumpIfFalse, OperandType::kImm8) \ 240 kMaxValid = k4X,
245 V(JumpIfFalseConstant, OperandType::kIdx8) \ 241 kInvalid = 8,
246 V(JumpIfFalseConstantWide, OperandType::kIdx16) \ 242 };
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 243
285 // Enumeration of the size classes of operand types used by bytecodes. 244 // Enumeration of the size classes of operand types used by bytecodes.
286 enum class OperandSize : uint8_t { 245 enum class OperandSize : uint8_t {
287 kNone = 0, 246 kNone = 0,
288 kByte = 1, 247 kByte = 1,
289 kShort = 2, 248 kShort = 2,
249 kQuad = 4,
250 kLast = kQuad
290 }; 251 };
291 252
253 #define OPERAND_TYPE_INFO_LIST(V) \
254 V(None, false, false, OperandSize::kNone) \
rmcilroy 2016/03/17 17:30:50 Could you add a comment describing what each of th
oth 2016/03/21 09:16:54 Done.
255 V(ScalableSignedByte, true, false, OperandSize::kByte) \
256 V(ScalableUnsignedByte, true, true, OperandSize::kByte) \
257 V(FixedUnsignedByte, false, true, OperandSize::kByte) \
258 V(FixedUnsignedShort, false, true, OperandSize::kShort)
259
260 enum class OperandTypeInfo : uint8_t {
261 #define DECLARE_OPERAND_TYPE_INFO(Name, ...) k##Name,
262 OPERAND_TYPE_INFO_LIST(DECLARE_OPERAND_TYPE_INFO)
263 #undef DECLARE_OPERAND_TYPE_INFO
264 };
292 265
293 // Enumeration of operand types used by bytecodes. 266 // Enumeration of operand types used by bytecodes.
294 enum class OperandType : uint8_t { 267 enum class OperandType : uint8_t {
295 #define DECLARE_OPERAND_TYPE(Name, _) k##Name, 268 #define DECLARE_OPERAND_TYPE(Name, _) k##Name,
296 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE) 269 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE)
297 #undef DECLARE_OPERAND_TYPE 270 #undef DECLARE_OPERAND_TYPE
298 #define COUNT_OPERAND_TYPES(x, _) +1 271 #define COUNT_OPERAND_TYPES(x, _) +1
299 // The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will 272 // The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will
300 // evaluate to the same value as the last operand. 273 // evaluate to the same value as the last operand.
301 kLast = -1 OPERAND_TYPE_LIST(COUNT_OPERAND_TYPES) 274 kLast = -1 OPERAND_TYPE_LIST(COUNT_OPERAND_TYPES)
(...skipping 21 matching lines...) Expand all
323 explicit Register(int index = kInvalidIndex) : index_(index) {} 296 explicit Register(int index = kInvalidIndex) : index_(index) {}
324 297
325 int index() const { return index_; } 298 int index() const { return index_; }
326 bool is_parameter() const { return index() < 0; } 299 bool is_parameter() const { return index() < 0; }
327 bool is_valid() const { return index_ != kInvalidIndex; } 300 bool is_valid() const { return index_ != kInvalidIndex; }
328 bool is_byte_operand() const; 301 bool is_byte_operand() const;
329 bool is_short_operand() const; 302 bool is_short_operand() const;
330 303
331 static Register FromParameterIndex(int index, int parameter_count); 304 static Register FromParameterIndex(int index, int parameter_count);
332 int ToParameterIndex(int parameter_count) const; 305 int ToParameterIndex(int parameter_count) const;
333 static int MaxParameterIndex();
334 static int MaxRegisterIndex();
335 static int MaxRegisterIndexForByteOperand();
336 306
337 // Returns an invalid register. 307 // Returns an invalid register.
338 static Register invalid_value() { return Register(); } 308 static Register invalid_value() { return Register(); }
339 309
340 // Returns the register for the function's closure object. 310 // Returns the register for the function's closure object.
341 static Register function_closure(); 311 static Register function_closure();
342 bool is_function_closure() const; 312 bool is_function_closure() const;
343 313
344 // Returns the register which holds the current context object. 314 // Returns the register which holds the current context object.
345 static Register current_context(); 315 static Register current_context();
346 bool is_current_context() const; 316 bool is_current_context() const;
347 317
348 // Returns the register for the incoming new target value. 318 // Returns the register for the incoming new target value.
349 static Register new_target(); 319 static Register new_target();
350 bool is_new_target() const; 320 bool is_new_target() const;
351 321
352 static Register FromOperand(uint8_t operand); 322 int32_t ToOperand() const { return -index_; }
353 uint8_t ToOperand() const; 323 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 324
361 static bool AreContiguous(Register reg1, Register reg2, 325 static bool AreContiguous(Register reg1, Register reg2,
362 Register reg3 = Register(), 326 Register reg3 = Register(),
363 Register reg4 = Register(), 327 Register reg4 = Register(),
364 Register reg5 = Register()); 328 Register reg5 = Register());
365 329
366 std::string ToString(int parameter_count); 330 std::string ToString(int parameter_count);
367 331
368 bool operator==(const Register& other) const { 332 bool operator==(const Register& other) const {
369 return index() == other.index(); 333 return index() == other.index();
(...skipping 22 matching lines...) Expand all
392 356
393 int index_; 357 int index_;
394 }; 358 };
395 359
396 360
397 class Bytecodes { 361 class Bytecodes {
398 public: 362 public:
399 // Returns string representation of |bytecode|. 363 // Returns string representation of |bytecode|.
400 static const char* ToString(Bytecode bytecode); 364 static const char* ToString(Bytecode bytecode);
401 365
366 // Returns string representation of |bytecode|.
367 static std::string ToString(Bytecode bytecode, OperandScale operand_scale);
368
402 // Returns string representation of |operand_type|. 369 // Returns string representation of |operand_type|.
403 static const char* OperandTypeToString(OperandType operand_type); 370 static const char* OperandTypeToString(OperandType operand_type);
404 371
372 // Returns string representation of |operand_scale|.
373 static const char* OperandScaleToString(OperandScale operand_scale);
374
405 // Returns string representation of |operand_size|. 375 // Returns string representation of |operand_size|.
406 static const char* OperandSizeToString(OperandSize operand_size); 376 static const char* OperandSizeToString(OperandSize operand_size);
407 377
408 // Returns byte value of bytecode. 378 // Returns byte value of bytecode.
409 static uint8_t ToByte(Bytecode bytecode); 379 static uint8_t ToByte(Bytecode bytecode);
410 380
411 // Returns bytecode for |value|. 381 // Returns bytecode for |value|.
412 static Bytecode FromByte(uint8_t value); 382 static Bytecode FromByte(uint8_t value);
413 383
414 // Returns the number of operands expected by |bytecode|. 384 // Returns the number of operands expected by |bytecode|.
415 static int NumberOfOperands(Bytecode bytecode); 385 static int NumberOfOperands(Bytecode bytecode);
416 386
417 // Returns the number of register operands expected by |bytecode|. 387 // Returns the number of register operands expected by |bytecode|.
418 static int NumberOfRegisterOperands(Bytecode bytecode); 388 static int NumberOfRegisterOperands(Bytecode bytecode);
419 389
390 // Returns the prefix bytecode representing an operand scale to be
391 // applied to a a bytecode.
392 static Bytecode OperandScaleToPrefixBytecode(OperandScale operand_scale);
393
394 // Returns true if the operand scale requires a prefix bytecode.
395 static bool OperandScaleRequiresPrefixBytecode(OperandScale operand_scale);
396
397 // Returns the scaling applied to scalable operands if bytecode is
398 // is a scaling prefix.
399 static OperandScale PrefixBytecodeToOperandScale(Bytecode bytecode);
400
420 // Returns the i-th operand of |bytecode|. 401 // Returns the i-th operand of |bytecode|.
421 static OperandType GetOperandType(Bytecode bytecode, int i); 402 static OperandType GetOperandType(Bytecode bytecode, int i);
422 403
423 // Returns the size of the i-th operand of |bytecode|. 404 // Returns the size of the i-th operand of |bytecode|.
424 static OperandSize GetOperandSize(Bytecode bytecode, int i); 405 static OperandSize GetOperandSize(Bytecode bytecode, int i,
406 OperandScale operand_scale);
425 407
426 // Returns the offset of the i-th operand of |bytecode| relative to the start 408 // Returns the offset of the i-th operand of |bytecode| relative to the start
427 // of the bytecode. 409 // of the bytecode.
428 static int GetOperandOffset(Bytecode bytecode, int i); 410 static int GetOperandOffset(Bytecode bytecode, int i,
411 OperandScale operand_scale);
429 412
430 // Returns a zero-based bitmap of the register operand positions of 413 // Returns a zero-based bitmap of the register operand positions of
431 // |bytecode|. 414 // |bytecode|.
432 static int GetRegisterOperandBitmap(Bytecode bytecode); 415 static int GetRegisterOperandBitmap(Bytecode bytecode);
433 416
434 // Returns a debug break bytecode with a matching operand size. 417 // Returns a debug break bytecode to replace |bytecode|.
435 static Bytecode GetDebugBreak(Bytecode bytecode); 418 static Bytecode GetDebugBreak(Bytecode bytecode);
436 419
437 // Returns the size of the bytecode including its operands. 420 // Returns the size of the bytecode including its operands and
438 static int Size(Bytecode bytecode); 421 // prefix byte when scaling active.
rmcilroy 2016/03/17 17:30:50 I don't think this includes the prefix byte does i
oth 2016/03/21 09:16:54 Done. This was really stale, true many revisions b
422 static int Size(Bytecode bytecode, OperandScale operand_scale);
439 423
440 // Returns the size of |operand|. 424 // Returns the size of |operand|.
441 static OperandSize SizeOfOperand(OperandType operand); 425 static OperandSize SizeOfOperand(OperandType operand, OperandScale scale);
442 426
443 // Returns true if the bytecode is a conditional jump taking 427 // Returns true if the bytecode is a conditional jump taking
444 // an immediate byte operand (OperandType::kImm8). 428 // an immediate byte operand (OperandType::kImm).
445 static bool IsConditionalJumpImmediate(Bytecode bytecode); 429 static bool IsConditionalJumpImmediate(Bytecode bytecode);
446 430
447 // Returns true if the bytecode is a conditional jump taking 431 // Returns true if the bytecode is a conditional jump taking
448 // a constant pool entry (OperandType::kIdx8). 432 // a constant pool entry (OperandType::kIdx).
449 static bool IsConditionalJumpConstant(Bytecode bytecode); 433 static bool IsConditionalJumpConstant(Bytecode bytecode);
450 434
451 // Returns true if the bytecode is a conditional jump taking 435 // 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. 436 // any kind of operand.
457 static bool IsConditionalJump(Bytecode bytecode); 437 static bool IsConditionalJump(Bytecode bytecode);
458 438
459 // Returns true if the bytecode is a jump or a conditional jump taking 439 // Returns true if the bytecode is a jump or a conditional jump taking
460 // an immediate byte operand (OperandType::kImm8). 440 // an immediate byte operand (OperandType::kImm).
461 static bool IsJumpImmediate(Bytecode bytecode); 441 static bool IsJumpImmediate(Bytecode bytecode);
462 442
463 // Returns true if the bytecode is a jump or conditional jump taking a 443 // Returns true if the bytecode is a jump or conditional jump taking a
464 // constant pool entry (OperandType::kIdx8). 444 // constant pool entry (OperandType::kIdx).
465 static bool IsJumpConstant(Bytecode bytecode); 445 static bool IsJumpConstant(Bytecode bytecode);
466 446
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 447 // Returns true if the bytecode is a jump or conditional jump taking
472 // any kind of operand. 448 // any kind of operand.
473 static bool IsJump(Bytecode bytecode); 449 static bool IsJump(Bytecode bytecode);
474 450
475 // Returns true if the bytecode is a conditional jump, a jump, or a return. 451 // Returns true if the bytecode is a conditional jump, a jump, or a return.
476 static bool IsJumpOrReturn(Bytecode bytecode); 452 static bool IsJumpOrReturn(Bytecode bytecode);
477 453
478 // Returns true if the bytecode is a call or a constructor call. 454 // Returns true if the bytecode is a call or a constructor call.
479 static bool IsCallOrNew(Bytecode bytecode); 455 static bool IsCallOrNew(Bytecode bytecode);
480 456
481 // Returns true if the bytecode is a call to the runtime. 457 // Returns true if the bytecode is a call to the runtime.
482 static bool IsCallRuntime(Bytecode bytecode); 458 static bool IsCallRuntime(Bytecode bytecode);
483 459
484 // Returns true if the bytecode is a debug break. 460 // Returns true if the bytecode is a debug break.
485 static bool IsDebugBreak(Bytecode bytecode); 461 static bool IsDebugBreak(Bytecode bytecode);
486 462
487 // Returns true if |operand_type| is a register index operand (kIdx8/kIdx16). 463 // Returns true if the bytecode has wider operand forms.
488 static bool IsIndexOperandType(OperandType operand_type); 464 static bool IsBytecodeWithScalableOperands(Bytecode bytecode);
489 465
490 // Returns true if |operand_type| represents an immediate. 466 // Returns true if the bytecode is an scaling prefix bytecode.
rmcilroy 2016/03/17 17:30:50 /s/an/a
oth 2016/03/21 09:16:54 Done.
491 static bool IsImmediateOperandType(OperandType operand_type); 467 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 468
497 // Returns true if |operand_type| is any type of register operand. 469 // Returns true if |operand_type| is any type of register operand.
498 static bool IsRegisterOperandType(OperandType operand_type); 470 static bool IsRegisterOperandType(OperandType operand_type);
499 471
500 // Returns true if |operand_type| represents a register used as an input. 472 // Returns true if |operand_type| represents a register used as an input.
501 static bool IsRegisterInputOperandType(OperandType operand_type); 473 static bool IsRegisterInputOperandType(OperandType operand_type);
502 474
503 // Returns true if |operand_type| represents a register used as an output. 475 // Returns true if |operand_type| represents a register used as an output.
504 static bool IsRegisterOutputOperandType(OperandType operand_type); 476 static bool IsRegisterOutputOperandType(OperandType operand_type);
505 477
506 // Returns true if |operand_type| is a maybe register operand 478 // Returns true if |operand_type| is a maybe register operand
507 // (kMaybeReg8/kMaybeReg16). 479 // (kMaybeReg).
508 static bool IsMaybeRegisterOperandType(OperandType operand_type); 480 static bool IsMaybeRegisterOperandType(OperandType operand_type);
509 481
482 // Returns true if |operand_type| is a runtime-id operand (kRuntimeId).
483 static bool IsRuntimeIdOperandType(OperandType operand_type);
484
485 // Returns true if |operand_type| is unsigned, false if signed.
486 static bool IsUnsignedOperandType(OperandType operand_type);
487
510 // Decode a single bytecode and operands to |os|. 488 // Decode a single bytecode and operands to |os|.
511 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start, 489 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start,
512 int number_of_parameters); 490 int number_of_parameters);
513 491
492 // Return the next larger operand scale.
493 static OperandScale NextOperandScale(OperandScale operand_scale);
494
514 private: 495 private:
515 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); 496 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes);
516 }; 497 };
517 498
518 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); 499 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode);
500 std::ostream& operator<<(std::ostream& os, const OperandScale& operand_scale);
501 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size);
519 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); 502 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type);
520 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type);
521 503
522 } // namespace interpreter 504 } // namespace interpreter
523 } // namespace internal 505 } // namespace internal
524 } // namespace v8 506 } // namespace v8
525 507
526 #endif // V8_INTERPRETER_BYTECODES_H_ 508 #endif // V8_INTERPRETER_BYTECODES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698