Chromium Code Reviews| OLD | NEW |
|---|---|
| 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. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 V(None, OperandSize::kNone) \ | 22 V(None, OperandSize::kNone) \ |
| 23 \ | 23 \ |
| 24 /* Byte operands. */ \ | 24 /* Byte operands. */ \ |
| 25 V(Count8, OperandSize::kByte) \ | 25 V(Count8, OperandSize::kByte) \ |
| 26 V(Imm8, OperandSize::kByte) \ | 26 V(Imm8, OperandSize::kByte) \ |
| 27 V(Idx8, OperandSize::kByte) \ | 27 V(Idx8, OperandSize::kByte) \ |
| 28 V(Reg8, OperandSize::kByte) \ | 28 V(Reg8, OperandSize::kByte) \ |
| 29 V(MaybeReg8, OperandSize::kByte) \ | 29 V(MaybeReg8, OperandSize::kByte) \ |
| 30 \ | 30 \ |
| 31 /* Short operands. */ \ | 31 /* Short operands. */ \ |
| 32 V(Idx16, OperandSize::kShort) \ | |
|
rmcilroy
2016/01/04 11:54:54
nit - alphabetical ordering?
oth
2016/01/04 14:01:42
Done.
| |
| 32 V(Count16, OperandSize::kShort) \ | 33 V(Count16, OperandSize::kShort) \ |
| 33 V(Idx16, OperandSize::kShort) | 34 V(Reg16, OperandSize::kShort) |
| 34 | 35 |
| 35 // The list of bytecodes which are interpreted by the interpreter. | 36 // The list of bytecodes which are interpreted by the interpreter. |
| 36 #define BYTECODE_LIST(V) \ | 37 #define BYTECODE_LIST(V) \ |
| 37 \ | 38 \ |
| 38 /* Loading the accumulator */ \ | 39 /* Loading the accumulator */ \ |
| 39 V(LdaZero, OperandType::kNone) \ | 40 V(LdaZero, OperandType::kNone) \ |
| 40 V(LdaSmi8, OperandType::kImm8) \ | 41 V(LdaSmi8, OperandType::kImm8) \ |
| 41 V(LdaUndefined, OperandType::kNone) \ | 42 V(LdaUndefined, OperandType::kNone) \ |
| 42 V(LdaNull, OperandType::kNone) \ | 43 V(LdaNull, OperandType::kNone) \ |
| 43 V(LdaTheHole, OperandType::kNone) \ | 44 V(LdaTheHole, OperandType::kNone) \ |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 71 V(LdaLookupSlotInsideTypeof, OperandType::kIdx8) \ | 72 V(LdaLookupSlotInsideTypeof, OperandType::kIdx8) \ |
| 72 V(StaLookupSlotSloppy, OperandType::kIdx8) \ | 73 V(StaLookupSlotSloppy, OperandType::kIdx8) \ |
| 73 V(StaLookupSlotStrict, OperandType::kIdx8) \ | 74 V(StaLookupSlotStrict, OperandType::kIdx8) \ |
| 74 \ | 75 \ |
| 75 /* Register-accumulator transfers */ \ | 76 /* Register-accumulator transfers */ \ |
| 76 V(Ldar, OperandType::kReg8) \ | 77 V(Ldar, OperandType::kReg8) \ |
| 77 V(Star, OperandType::kReg8) \ | 78 V(Star, OperandType::kReg8) \ |
| 78 \ | 79 \ |
| 79 /* Register-register transfers */ \ | 80 /* Register-register transfers */ \ |
| 80 V(Mov, OperandType::kReg8, OperandType::kReg8) \ | 81 V(Mov, OperandType::kReg8, OperandType::kReg8) \ |
| 82 V(Exchange, OperandType::kReg8, OperandType::kReg16) \ | |
|
rmcilroy
2016/01/04 11:54:54
Is it worth having the non-wide version? It only s
oth
2016/01/04 14:01:42
I've not found a case that would need it in the ne
| |
| 83 V(ExchangeWide, OperandType::kReg16, OperandType::kReg16) \ | |
| 81 \ | 84 \ |
| 82 /* LoadIC operations */ \ | 85 /* LoadIC operations */ \ |
| 83 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ | 86 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ |
| 84 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ | 87 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ |
| 85 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \ | 88 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \ |
| 86 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \ | 89 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \ |
| 87 /* TODO(rmcilroy): Wide register operands too? */ \ | 90 /* TODO(rmcilroy): Wide register operands too? */ \ |
| 88 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ | 91 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ |
| 89 OperandType::kIdx16) \ | 92 OperandType::kIdx16) \ |
| 90 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ | 93 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) | 246 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) |
| 244 #undef COUNT_BYTECODE | 247 #undef COUNT_BYTECODE |
| 245 }; | 248 }; |
| 246 | 249 |
| 247 | 250 |
| 248 // An interpreter Register which is located in the function's Register file | 251 // An interpreter Register which is located in the function's Register file |
| 249 // in its stack-frame. Register hold parameters, this, and expression values. | 252 // in its stack-frame. Register hold parameters, this, and expression values. |
| 250 class Register { | 253 class Register { |
| 251 public: | 254 public: |
| 252 static const int kMaxRegisterIndex = 127; | 255 static const int kMaxRegisterIndex = 127; |
| 253 static const int kMinRegisterIndex = -128; | 256 static const int kMinRegisterIndex = -128; |
|
rmcilroy
2016/01/04 11:54:54
Can we get rid of these now? If not could we renam
oth
2016/01/04 14:01:42
Done.
| |
| 254 | 257 |
| 255 Register() : index_(kIllegalIndex) {} | 258 Register() : index_(kIllegalIndex) {} |
| 256 | 259 |
| 257 explicit Register(int index) : index_(index) { | 260 explicit Register(int index) : index_(index) {} |
| 258 DCHECK_LE(index_, kMaxRegisterIndex); | |
| 259 DCHECK_GE(index_, kMinRegisterIndex); | |
| 260 } | |
| 261 | 261 |
| 262 int index() const { | 262 int index() const { |
| 263 DCHECK(index_ != kIllegalIndex); | 263 DCHECK(index_ != kIllegalIndex); |
| 264 return index_; | 264 return index_; |
| 265 } | 265 } |
| 266 bool is_parameter() const { return index() < 0; } | 266 bool is_parameter() const { return index() < 0; } |
| 267 bool is_valid() const { return index_ != kIllegalIndex; } | 267 bool is_valid() const { return index_ != kIllegalIndex; } |
| 268 | 268 |
| 269 static Register FromParameterIndex(int index, int parameter_count); | 269 static Register FromParameterIndex(int index, int parameter_count); |
| 270 int ToParameterIndex(int parameter_count) const; | 270 int ToParameterIndex(int parameter_count) const; |
| 271 static int MaxParameterIndex(); | 271 static int MaxParameterIndex(); |
| 272 | 272 |
| 273 // Returns the register for the function's closure object. | 273 // Returns the register for the function's closure object. |
| 274 static Register function_closure(); | 274 static Register function_closure(); |
| 275 bool is_function_closure() const; | 275 bool is_function_closure() const; |
| 276 | 276 |
| 277 // Returns the register for the function's outer context. | 277 // Returns the register for the function's outer context. |
| 278 static Register function_context(); | 278 static Register function_context(); |
| 279 bool is_function_context() const; | 279 bool is_function_context() const; |
| 280 | 280 |
| 281 // Returns the register for the incoming new target value. | 281 // Returns the register for the incoming new target value. |
| 282 static Register new_target(); | 282 static Register new_target(); |
| 283 bool is_new_target() const; | 283 bool is_new_target() const; |
| 284 | 284 |
| 285 static Register FromOperand(uint8_t operand); | 285 static Register FromOperand(uint8_t operand); |
| 286 uint8_t ToOperand() const; | 286 uint8_t ToOperand() const; |
| 287 | 287 |
| 288 static Register FromWideOperand(uint16_t operand); | |
| 289 uint16_t ToWideOperand() const; | |
| 290 | |
| 288 static bool AreContiguous(Register reg1, Register reg2, | 291 static bool AreContiguous(Register reg1, Register reg2, |
| 289 Register reg3 = Register(), | 292 Register reg3 = Register(), |
| 290 Register reg4 = Register(), | 293 Register reg4 = Register(), |
| 291 Register reg5 = Register()); | 294 Register reg5 = Register()); |
| 292 | 295 |
| 293 bool operator==(const Register& other) const { | 296 bool operator==(const Register& other) const { |
| 294 return index() == other.index(); | 297 return index() == other.index(); |
| 295 } | 298 } |
| 296 bool operator!=(const Register& other) const { | 299 bool operator!=(const Register& other) const { |
| 297 return index() != other.index(); | 300 return index() != other.index(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 | 389 |
| 387 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); | 390 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); |
| 388 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); | 391 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); |
| 389 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); | 392 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); |
| 390 | 393 |
| 391 } // namespace interpreter | 394 } // namespace interpreter |
| 392 } // namespace internal | 395 } // namespace internal |
| 393 } // namespace v8 | 396 } // namespace v8 |
| 394 | 397 |
| 395 #endif // V8_INTERPRETER_BYTECODES_H_ | 398 #endif // V8_INTERPRETER_BYTECODES_H_ |
| OLD | NEW |