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 #include "src/interpreter/bytecodes.h" | 5 #include "src/interpreter/bytecodes.h" |
| 6 | 6 |
| 7 #include "src/frames.h" | 7 #include "src/frames.h" |
| 8 #include "src/interpreter/bytecode-traits.h" | 8 #include "src/interpreter/bytecode-traits.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 return IsJumpImmediate(bytecode) || IsJumpConstant(bytecode) || | 255 return IsJumpImmediate(bytecode) || IsJumpConstant(bytecode) || |
| 256 IsJumpConstantWide(bytecode); | 256 IsJumpConstantWide(bytecode); |
| 257 } | 257 } |
| 258 | 258 |
| 259 | 259 |
| 260 // static | 260 // static |
| 261 bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) { | 261 bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) { |
| 262 return bytecode == Bytecode::kReturn || IsJump(bytecode); | 262 return bytecode == Bytecode::kReturn || IsJump(bytecode); |
| 263 } | 263 } |
| 264 | 264 |
| 265 // static | |
| 266 bool Bytecodes::IsRegisterOperandType(OperandType operand_type) { | |
| 267 switch (operand_type) { | |
| 268 #define CASE(Name, _) \ | |
| 269 case OperandType::k##Name: \ | |
| 270 return true; | |
| 271 REGISTER_OPERAND_TYPE_LIST(CASE) | |
| 272 #undef CASE | |
| 273 #define CASE(Name, _) \ | |
| 274 case OperandType::k##Name: \ | |
| 275 break; | |
| 276 NON_REGISTER_OPERAND_TYPE_LIST(CASE) | |
| 277 #undef CASE | |
| 278 } | |
| 279 return false; | |
| 280 } | |
| 281 | |
| 282 // static | |
| 283 bool Bytecodes::IsRegisterInputOperandType(OperandType operand_type) { | |
| 284 switch (operand_type) { | |
| 285 #define CASE(Name, _) \ | |
| 286 case OperandType::k##Name: \ | |
| 287 return true; | |
| 288 REGISTER_INPUT_OPERAND_TYPE_LIST(CASE) | |
| 289 #undef CASE | |
| 290 #define CASE(Name, _) \ | |
| 291 case OperandType::k##Name: \ | |
| 292 break; | |
| 293 NON_REGISTER_OPERAND_TYPE_LIST(CASE) | |
| 294 REGISTER_OUTPUT_OPERAND_TYPE_LIST(CASE) | |
| 295 #undef CASE | |
| 296 } | |
| 297 return false; | |
| 298 } | |
| 299 | |
| 300 // static | |
| 301 bool Bytecodes::IsRegisterOutputOperandType(OperandType operand_type) { | |
| 302 switch (operand_type) { | |
| 303 #define CASE(Name, _) \ | |
| 304 case OperandType::k##Name: \ | |
| 305 return true; | |
| 306 REGISTER_OUTPUT_OPERAND_TYPE_LIST(CASE) | |
| 307 #undef CASE | |
| 308 #define CASE(Name, _) \ | |
| 309 case OperandType::k##Name: \ | |
| 310 break; | |
| 311 NON_REGISTER_OPERAND_TYPE_LIST(CASE) | |
| 312 REGISTER_INPUT_OPERAND_TYPE_LIST(CASE) | |
| 313 #undef CASE | |
| 314 } | |
| 315 return false; | |
| 316 } | |
| 265 | 317 |
| 266 namespace { | 318 namespace { |
| 267 static Register DecodeRegister(const uint8_t* operand_start, | 319 static Register DecodeRegister(const uint8_t* operand_start, |
| 268 OperandType operand_type) { | 320 OperandType operand_type) { |
| 269 switch (Bytecodes::SizeOfOperand(operand_type)) { | 321 switch (Bytecodes::SizeOfOperand(operand_type)) { |
| 270 case OperandSize::kByte: | 322 case OperandSize::kByte: |
| 271 return Register::FromOperand(*operand_start); | 323 return Register::FromOperand(*operand_start); |
| 272 case OperandSize::kShort: | 324 case OperandSize::kShort: |
| 273 return Register::FromWideOperand(ReadUnalignedUInt16(operand_start)); | 325 return Register::FromWideOperand(ReadUnalignedUInt16(operand_start)); |
| 274 case OperandSize::kNone: { | 326 case OperandSize::kNone: { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 break; | 368 break; |
| 317 case interpreter::OperandType::kIdx16: | 369 case interpreter::OperandType::kIdx16: |
| 318 os << "[" << ReadUnalignedUInt16(operand_start) << "]"; | 370 os << "[" << ReadUnalignedUInt16(operand_start) << "]"; |
| 319 break; | 371 break; |
| 320 case interpreter::OperandType::kImm8: | 372 case interpreter::OperandType::kImm8: |
| 321 os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start)); | 373 os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start)); |
| 322 break; | 374 break; |
| 323 case interpreter::OperandType::kMaybeReg8: | 375 case interpreter::OperandType::kMaybeReg8: |
| 324 case interpreter::OperandType::kMaybeReg16: | 376 case interpreter::OperandType::kMaybeReg16: |
| 325 case interpreter::OperandType::kReg8: | 377 case interpreter::OperandType::kReg8: |
| 326 case interpreter::OperandType::kReg16: { | 378 case interpreter::OperandType::kReg16: |
| 379 case interpreter::OperandType::kRegOut8: | |
| 380 case interpreter::OperandType::kRegOut16: { | |
| 327 Register reg = DecodeRegister(operand_start, op_type); | 381 Register reg = DecodeRegister(operand_start, op_type); |
| 328 if (reg.is_current_context()) { | 382 if (reg.is_current_context()) { |
| 329 os << "<context>"; | 383 os << "<context>"; |
| 330 } else if (reg.is_function_closure()) { | 384 } else if (reg.is_function_closure()) { |
| 331 os << "<closure>"; | 385 os << "<closure>"; |
| 332 } else if (reg.is_new_target()) { | 386 } else if (reg.is_new_target()) { |
| 333 os << "<new.target>"; | 387 os << "<new.target>"; |
| 334 } else if (reg.is_parameter()) { | 388 } else if (reg.is_parameter()) { |
| 335 int parameter_index = reg.ToParameterIndex(parameter_count); | 389 int parameter_index = reg.ToParameterIndex(parameter_count); |
| 336 if (parameter_index == 0) { | 390 if (parameter_index == 0) { |
| 337 os << "<this>"; | 391 os << "<this>"; |
| 338 } else { | 392 } else { |
| 339 os << "a" << parameter_index - 1; | 393 os << "a" << parameter_index - 1; |
| 340 } | 394 } |
| 341 } else { | 395 } else { |
| 342 os << "r" << reg.index(); | 396 os << "r" << reg.index(); |
| 343 } | 397 } |
| 344 break; | 398 break; |
| 345 } | 399 } |
| 400 case interpreter::OperandType::kRegOutPair8: | |
| 401 case interpreter::OperandType::kRegOutPair16: | |
| 402 case interpreter::OperandType::kRegOutTriple8: | |
| 403 case interpreter::OperandType::kRegOutTriple16: | |
| 346 case interpreter::OperandType::kRegPair8: | 404 case interpreter::OperandType::kRegPair8: |
| 347 case interpreter::OperandType::kRegTriple8: | 405 case interpreter::OperandType::kRegPair16: { |
| 348 case interpreter::OperandType::kRegPair16: | |
| 349 case interpreter::OperandType::kRegTriple16: { | |
| 350 Register reg = DecodeRegister(operand_start, op_type); | 406 Register reg = DecodeRegister(operand_start, op_type); |
| 351 int range = op_type == interpreter::OperandType::kRegPair8 ? 1 : 2; | 407 int range = op_type == interpreter::OperandType::kRegPair8 ? 1 : 2; |
|
rmcilroy
2016/01/26 16:49:51
Need to fix this line to deal with new output type
oth
2016/01/26 17:55:53
Done.
| |
| 352 if (reg.is_parameter()) { | 408 if (reg.is_parameter()) { |
| 353 int parameter_index = reg.ToParameterIndex(parameter_count); | 409 int parameter_index = reg.ToParameterIndex(parameter_count); |
| 354 DCHECK_GT(parameter_index, 0); | 410 DCHECK_GT(parameter_index, 0); |
| 355 os << "a" << parameter_index - range << "-" << parameter_index; | 411 os << "a" << parameter_index - range << "-" << parameter_index; |
| 356 } else { | 412 } else { |
| 357 os << "r" << reg.index() << "-" << reg.index() + range; | 413 os << "r" << reg.index() << "-" << reg.index() + range; |
| 358 } | 414 } |
| 359 break; | 415 break; |
| 360 } | 416 } |
| 361 case interpreter::OperandType::kNone: | 417 case interpreter::OperandType::kNone: |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 } | 505 } |
| 450 | 506 |
| 451 | 507 |
| 452 Register Register::new_target() { return Register(kNewTargetRegisterIndex); } | 508 Register Register::new_target() { return Register(kNewTargetRegisterIndex); } |
| 453 | 509 |
| 454 | 510 |
| 455 bool Register::is_new_target() const { | 511 bool Register::is_new_target() const { |
| 456 return index() == kNewTargetRegisterIndex; | 512 return index() == kNewTargetRegisterIndex; |
| 457 } | 513 } |
| 458 | 514 |
| 459 | |
| 460 int Register::MaxParameterIndex() { return kMaxParameterIndex; } | 515 int Register::MaxParameterIndex() { return kMaxParameterIndex; } |
| 461 | 516 |
| 462 int Register::MaxRegisterIndex() { return kMaxRegisterIndex; } | 517 int Register::MaxRegisterIndex() { return kMaxRegisterIndex; } |
| 463 | 518 |
| 464 int Register::MaxRegisterIndexForByteOperand() { return kMaxReg8Index; } | 519 int Register::MaxRegisterIndexForByteOperand() { return kMaxReg8Index; } |
| 465 | 520 |
| 466 uint8_t Register::ToOperand() const { | 521 uint8_t Register::ToOperand() const { |
| 467 DCHECK(is_byte_operand()); | 522 DCHECK(is_byte_operand()); |
| 468 return static_cast<uint8_t>(-index_); | 523 return static_cast<uint8_t>(-index_); |
| 469 } | 524 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 } | 563 } |
| 509 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) { | 564 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) { |
| 510 return false; | 565 return false; |
| 511 } | 566 } |
| 512 return true; | 567 return true; |
| 513 } | 568 } |
| 514 | 569 |
| 515 } // namespace interpreter | 570 } // namespace interpreter |
| 516 } // namespace internal | 571 } // namespace internal |
| 517 } // namespace v8 | 572 } // namespace v8 |
| OLD | NEW |