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

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

Issue 1595103006: [Interpreter] Preparation for wide registers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 11 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
« no previous file with comments | « src/interpreter/bytecode-array-iterator.cc ('k') | src/interpreter/bytecodes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) \
19 V(None, OperandSize::kNone)
20
21 #define REGISTER_OPERAND_TYPE_LIST(V) \
22 /* Byte operands. */ \
23 V(MaybeReg8, OperandSize::kByte) \
24 V(Reg8, OperandSize::kByte) \
25 V(RegPair8, OperandSize::kByte) \
26 V(RegTriple8, OperandSize::kByte) \
27 /* Short operands. */ \
28 V(MaybeReg16, OperandSize::kShort) \
29 V(Reg16, OperandSize::kShort) \
30 V(RegPair16, OperandSize::kShort) \
31 V(RegTriple16, OperandSize::kShort)
32
33 #define SCALAR_OPERAND_TYPE_LIST(V) \
34 /* Byte operands. */ \
35 V(Idx8, OperandSize::kByte) \
36 V(Imm8, OperandSize::kByte) \
37 V(RegCount8, OperandSize::kByte) \
38 /* Short operands. */ \
39 V(Idx16, OperandSize::kShort) \
40 V(RegCount16, OperandSize::kShort)
41
18 // The list of operand types used by bytecodes. 42 // The list of operand types used by bytecodes.
19 #define OPERAND_TYPE_LIST(V) \ 43 #define OPERAND_TYPE_LIST(V) \
20 \ 44 INVALID_OPERAND_TYPE_LIST(V) \
21 /* None operand. */ \ 45 REGISTER_OPERAND_TYPE_LIST(V) \
22 V(None, OperandSize::kNone) \ 46 SCALAR_OPERAND_TYPE_LIST(V)
23 \
24 /* Byte operands. */ \
25 V(Count8, OperandSize::kByte) \
26 V(Imm8, OperandSize::kByte) \
27 V(Idx8, OperandSize::kByte) \
28 V(MaybeReg8, OperandSize::kByte) \
29 V(Reg8, OperandSize::kByte) \
30 V(RegPair8, OperandSize::kByte) \
31 V(RegTriple8, OperandSize::kByte) \
32 \
33 /* Short operands. */ \
34 V(Count16, OperandSize::kShort) \
35 V(Idx16, OperandSize::kShort) \
36 V(Reg16, OperandSize::kShort)
37 47
38 // The list of bytecodes which are interpreted by the interpreter. 48 // The list of bytecodes which are interpreted by the interpreter.
39 #define BYTECODE_LIST(V) \ 49 #define BYTECODE_LIST(V) \
40 \ 50 \
41 /* Loading the accumulator */ \ 51 /* Loading the accumulator */ \
42 V(LdaZero, OperandType::kNone) \ 52 V(LdaZero, OperandType::kNone) \
43 V(LdaSmi8, OperandType::kImm8) \ 53 V(LdaSmi8, OperandType::kImm8) \
44 V(LdaUndefined, OperandType::kNone) \ 54 V(LdaUndefined, OperandType::kNone) \
45 V(LdaNull, OperandType::kNone) \ 55 V(LdaNull, OperandType::kNone) \
46 V(LdaTheHole, OperandType::kNone) \ 56 V(LdaTheHole, OperandType::kNone) \
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 V(StaLookupSlotStrict, OperandType::kIdx8) \ 90 V(StaLookupSlotStrict, OperandType::kIdx8) \
81 V(StaLookupSlotSloppyWide, OperandType::kIdx16) \ 91 V(StaLookupSlotSloppyWide, OperandType::kIdx16) \
82 V(StaLookupSlotStrictWide, OperandType::kIdx16) \ 92 V(StaLookupSlotStrictWide, OperandType::kIdx16) \
83 \ 93 \
84 /* Register-accumulator transfers */ \ 94 /* Register-accumulator transfers */ \
85 V(Ldar, OperandType::kReg8) \ 95 V(Ldar, OperandType::kReg8) \
86 V(Star, OperandType::kReg8) \ 96 V(Star, OperandType::kReg8) \
87 \ 97 \
88 /* Register-register transfers */ \ 98 /* Register-register transfers */ \
89 V(Mov, OperandType::kReg8, OperandType::kReg8) \ 99 V(Mov, OperandType::kReg8, OperandType::kReg8) \
90 V(Exchange, OperandType::kReg8, OperandType::kReg16) \ 100 V(MovWide, OperandType::kReg16, OperandType::kReg16) \
91 V(ExchangeWide, OperandType::kReg16, OperandType::kReg16) \
92 \ 101 \
93 /* LoadIC operations */ \ 102 /* LoadIC operations */ \
94 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 103 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \
95 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 104 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \
96 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \ 105 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \
97 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \ 106 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \
98 /* TODO(rmcilroy): Wide register operands too? */ \ 107 /* TODO(rmcilroy): Wide register operands too? */ \
99 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ 108 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \
100 OperandType::kIdx16) \ 109 OperandType::kIdx16) \
101 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ 110 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 /* Unary Operators */ \ 145 /* Unary Operators */ \
137 V(Inc, OperandType::kNone) \ 146 V(Inc, OperandType::kNone) \
138 V(Dec, OperandType::kNone) \ 147 V(Dec, OperandType::kNone) \
139 V(LogicalNot, OperandType::kNone) \ 148 V(LogicalNot, OperandType::kNone) \
140 V(TypeOf, OperandType::kNone) \ 149 V(TypeOf, OperandType::kNone) \
141 V(DeletePropertyStrict, OperandType::kReg8) \ 150 V(DeletePropertyStrict, OperandType::kReg8) \
142 V(DeletePropertySloppy, OperandType::kReg8) \ 151 V(DeletePropertySloppy, OperandType::kReg8) \
143 V(DeleteLookupSlot, OperandType::kNone) \ 152 V(DeleteLookupSlot, OperandType::kNone) \
144 \ 153 \
145 /* Call operations */ \ 154 /* Call operations */ \
146 V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kCount8, \ 155 V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kRegCount8, \
147 OperandType::kIdx8) \ 156 OperandType::kIdx8) \
148 V(CallWide, OperandType::kReg8, OperandType::kReg8, OperandType::kCount16, \ 157 V(CallWide, OperandType::kReg16, OperandType::kReg16, \
149 OperandType::kIdx16) \ 158 OperandType::kRegCount16, OperandType::kIdx16) \
150 V(CallRuntime, OperandType::kIdx16, OperandType::kMaybeReg8, \ 159 V(CallRuntime, OperandType::kIdx16, OperandType::kMaybeReg8, \
151 OperandType::kCount8) \ 160 OperandType::kRegCount8) \
161 V(CallRuntimeWide, OperandType::kIdx16, OperandType::kMaybeReg16, \
162 OperandType::kRegCount8) \
152 V(CallRuntimeForPair, OperandType::kIdx16, OperandType::kMaybeReg8, \ 163 V(CallRuntimeForPair, OperandType::kIdx16, OperandType::kMaybeReg8, \
153 OperandType::kCount8, OperandType::kRegPair8) \ 164 OperandType::kRegCount8, OperandType::kRegPair8) \
165 V(CallRuntimeForPairWide, OperandType::kIdx16, OperandType::kMaybeReg16, \
166 OperandType::kRegCount8, OperandType::kRegPair16) \
154 V(CallJSRuntime, OperandType::kIdx16, OperandType::kReg8, \ 167 V(CallJSRuntime, OperandType::kIdx16, OperandType::kReg8, \
155 OperandType::kCount8) \ 168 OperandType::kRegCount8) \
169 V(CallJSRuntimeWide, OperandType::kIdx16, OperandType::kReg16, \
170 OperandType::kRegCount16) \
156 \ 171 \
157 /* New operator */ \ 172 /* New operator */ \
158 V(New, OperandType::kReg8, OperandType::kMaybeReg8, OperandType::kCount8) \ 173 V(New, OperandType::kReg8, OperandType::kMaybeReg8, OperandType::kRegCount8) \
174 V(NewWide, OperandType::kReg16, OperandType::kMaybeReg16, \
175 OperandType::kRegCount16) \
159 \ 176 \
160 /* Test Operators */ \ 177 /* Test Operators */ \
161 V(TestEqual, OperandType::kReg8) \ 178 V(TestEqual, OperandType::kReg8) \
162 V(TestNotEqual, OperandType::kReg8) \ 179 V(TestNotEqual, OperandType::kReg8) \
163 V(TestEqualStrict, OperandType::kReg8) \ 180 V(TestEqualStrict, OperandType::kReg8) \
164 V(TestNotEqualStrict, OperandType::kReg8) \ 181 V(TestNotEqualStrict, OperandType::kReg8) \
165 V(TestLessThan, OperandType::kReg8) \ 182 V(TestLessThan, OperandType::kReg8) \
166 V(TestGreaterThan, OperandType::kReg8) \ 183 V(TestGreaterThan, OperandType::kReg8) \
167 V(TestLessThanOrEqual, OperandType::kReg8) \ 184 V(TestLessThanOrEqual, OperandType::kReg8) \
168 V(TestGreaterThanOrEqual, OperandType::kReg8) \ 185 V(TestGreaterThanOrEqual, OperandType::kReg8) \
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 V(JumpIfToBooleanFalseConstantWide, OperandType::kIdx16) \ 231 V(JumpIfToBooleanFalseConstantWide, OperandType::kIdx16) \
215 V(JumpIfNull, OperandType::kImm8) \ 232 V(JumpIfNull, OperandType::kImm8) \
216 V(JumpIfNullConstant, OperandType::kIdx8) \ 233 V(JumpIfNullConstant, OperandType::kIdx8) \
217 V(JumpIfNullConstantWide, OperandType::kIdx16) \ 234 V(JumpIfNullConstantWide, OperandType::kIdx16) \
218 V(JumpIfUndefined, OperandType::kImm8) \ 235 V(JumpIfUndefined, OperandType::kImm8) \
219 V(JumpIfUndefinedConstant, OperandType::kIdx8) \ 236 V(JumpIfUndefinedConstant, OperandType::kIdx8) \
220 V(JumpIfUndefinedConstantWide, OperandType::kIdx16) \ 237 V(JumpIfUndefinedConstantWide, OperandType::kIdx16) \
221 \ 238 \
222 /* Complex flow control For..in */ \ 239 /* Complex flow control For..in */ \
223 V(ForInPrepare, OperandType::kRegTriple8) \ 240 V(ForInPrepare, OperandType::kRegTriple8) \
241 V(ForInPrepareWide, OperandType::kRegTriple16) \
224 V(ForInDone, OperandType::kReg8, OperandType::kReg8) \ 242 V(ForInDone, OperandType::kReg8, OperandType::kReg8) \
225 V(ForInNext, OperandType::kReg8, OperandType::kReg8, OperandType::kRegPair8) \ 243 V(ForInNext, OperandType::kReg8, OperandType::kReg8, OperandType::kRegPair8) \
244 V(ForInNextWide, OperandType::kReg16, OperandType::kReg16, \
245 OperandType::kRegPair16) \
226 V(ForInStep, OperandType::kReg8) \ 246 V(ForInStep, OperandType::kReg8) \
227 \ 247 \
228 /* Non-local flow control */ \ 248 /* Non-local flow control */ \
229 V(Throw, OperandType::kNone) \ 249 V(Throw, OperandType::kNone) \
230 V(Return, OperandType::kNone) 250 V(Return, OperandType::kNone)
231 251
232 252
233 // Enumeration of the size classes of operand types used by bytecodes. 253 // Enumeration of the size classes of operand types used by bytecodes.
234 enum class OperandSize : uint8_t { 254 enum class OperandSize : uint8_t {
235 kNone = 0, 255 kNone = 0,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // Returns the register for the incoming new target value. 314 // Returns the register for the incoming new target value.
295 static Register new_target(); 315 static Register new_target();
296 bool is_new_target() const; 316 bool is_new_target() const;
297 317
298 static Register FromOperand(uint8_t operand); 318 static Register FromOperand(uint8_t operand);
299 uint8_t ToOperand() const; 319 uint8_t ToOperand() const;
300 320
301 static Register FromWideOperand(uint16_t operand); 321 static Register FromWideOperand(uint16_t operand);
302 uint16_t ToWideOperand() const; 322 uint16_t ToWideOperand() const;
303 323
324 static Register FromRawOperand(uint32_t raw_operand);
325 uint32_t ToRawOperand() const;
326
304 static bool AreContiguous(Register reg1, Register reg2, 327 static bool AreContiguous(Register reg1, Register reg2,
305 Register reg3 = Register(), 328 Register reg3 = Register(),
306 Register reg4 = Register(), 329 Register reg4 = Register(),
307 Register reg5 = Register()); 330 Register reg5 = Register());
308 331
309 bool operator==(const Register& other) const { 332 bool operator==(const Register& other) const {
310 return index() == other.index(); 333 return index() == other.index();
311 } 334 }
312 bool operator!=(const Register& other) const { 335 bool operator!=(const Register& other) const {
313 return index() != other.index(); 336 return index() != other.index();
314 } 337 }
315 bool operator<(const Register& other) const { 338 bool operator<(const Register& other) const {
316 return index() < other.index(); 339 return index() < other.index();
317 } 340 }
318 bool operator<=(const Register& other) const { 341 bool operator<=(const Register& other) const {
319 return index() <= other.index(); 342 return index() <= other.index();
320 } 343 }
344 bool operator>(const Register& other) const {
345 return index() > other.index();
346 }
347 bool operator>=(const Register& other) const {
348 return index() >= other.index();
349 }
321 350
322 private: 351 private:
323 static const int kIllegalIndex = kMaxInt; 352 static const int kIllegalIndex = kMaxInt;
324 353
325 void* operator new(size_t size); 354 void* operator new(size_t size);
326 void operator delete(void* p); 355 void operator delete(void* p);
327 356
328 int index_; 357 int index_;
329 }; 358 };
330 359
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 439
411 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); 440 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode);
412 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); 441 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type);
413 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); 442 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type);
414 443
415 } // namespace interpreter 444 } // namespace interpreter
416 } // namespace internal 445 } // namespace internal
417 } // namespace v8 446 } // namespace v8
418 447
419 #endif // V8_INTERPRETER_BYTECODES_H_ 448 #endif // V8_INTERPRETER_BYTECODES_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-iterator.cc ('k') | src/interpreter/bytecodes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698