| 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/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace interpreter { | 9 namespace interpreter { |
| 10 | 10 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 BytecodeArrayBuilder& BytecodeArrayBuilder::MoveRegister(Register from, | 374 BytecodeArrayBuilder& BytecodeArrayBuilder::MoveRegister(Register from, |
| 375 Register to) { | 375 Register to) { |
| 376 DCHECK(from != to); | 376 DCHECK(from != to); |
| 377 Output(Bytecode::kMov, from.ToOperand(), to.ToOperand()); | 377 Output(Bytecode::kMov, from.ToOperand(), to.ToOperand()); |
| 378 return *this; | 378 return *this; |
| 379 } | 379 } |
| 380 | 380 |
| 381 | 381 |
| 382 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( | 382 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( |
| 383 size_t name_index, int feedback_slot, LanguageMode language_mode, | 383 const Handle<String> name, int feedback_slot, LanguageMode language_mode, |
| 384 TypeofMode typeof_mode) { | 384 TypeofMode typeof_mode) { |
| 385 // TODO(rmcilroy): Potentially store language and typeof information in an | 385 // TODO(rmcilroy): Potentially store language and typeof information in an |
| 386 // operand rather than having extra bytecodes. | 386 // operand rather than having extra bytecodes. |
| 387 Bytecode bytecode = BytecodeForLoadGlobal(language_mode, typeof_mode); | 387 Bytecode bytecode = BytecodeForLoadGlobal(language_mode, typeof_mode); |
| 388 size_t name_index = GetConstantPoolEntry(name); |
| 388 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { | 389 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
| 389 Output(bytecode, static_cast<uint8_t>(name_index), | 390 Output(bytecode, static_cast<uint8_t>(name_index), |
| 390 static_cast<uint8_t>(feedback_slot)); | 391 static_cast<uint8_t>(feedback_slot)); |
| 391 } else if (FitsInIdx16Operand(name_index) && | 392 } else if (FitsInIdx16Operand(name_index) && |
| 392 FitsInIdx16Operand(feedback_slot)) { | 393 FitsInIdx16Operand(feedback_slot)) { |
| 393 Output(BytecodeForWideOperands(bytecode), static_cast<uint16_t>(name_index), | 394 Output(BytecodeForWideOperands(bytecode), static_cast<uint16_t>(name_index), |
| 394 static_cast<uint16_t>(feedback_slot)); | 395 static_cast<uint16_t>(feedback_slot)); |
| 395 } else { | 396 } else { |
| 396 UNIMPLEMENTED(); | 397 UNIMPLEMENTED(); |
| 397 } | 398 } |
| 398 return *this; | 399 return *this; |
| 399 } | 400 } |
| 400 | 401 |
| 401 | 402 |
| 402 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal( | 403 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal( |
| 403 size_t name_index, int feedback_slot, LanguageMode language_mode) { | 404 const Handle<String> name, int feedback_slot, LanguageMode language_mode) { |
| 404 Bytecode bytecode = BytecodeForStoreGlobal(language_mode); | 405 Bytecode bytecode = BytecodeForStoreGlobal(language_mode); |
| 406 size_t name_index = GetConstantPoolEntry(name); |
| 405 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { | 407 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
| 406 Output(bytecode, static_cast<uint8_t>(name_index), | 408 Output(bytecode, static_cast<uint8_t>(name_index), |
| 407 static_cast<uint8_t>(feedback_slot)); | 409 static_cast<uint8_t>(feedback_slot)); |
| 408 } else if (FitsInIdx16Operand(name_index) && | 410 } else if (FitsInIdx16Operand(name_index) && |
| 409 FitsInIdx16Operand(feedback_slot)) { | 411 FitsInIdx16Operand(feedback_slot)) { |
| 410 Output(BytecodeForWideOperands(bytecode), static_cast<uint16_t>(name_index), | 412 Output(BytecodeForWideOperands(bytecode), static_cast<uint16_t>(name_index), |
| 411 static_cast<uint16_t>(feedback_slot)); | 413 static_cast<uint16_t>(feedback_slot)); |
| 412 } else { | 414 } else { |
| 413 UNIMPLEMENTED(); | 415 UNIMPLEMENTED(); |
| 414 } | 416 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 if (FitsInIdx8Operand(name_index)) { | 466 if (FitsInIdx8Operand(name_index)) { |
| 465 Output(bytecode, static_cast<uint8_t>(name_index)); | 467 Output(bytecode, static_cast<uint8_t>(name_index)); |
| 466 } else { | 468 } else { |
| 467 UNIMPLEMENTED(); | 469 UNIMPLEMENTED(); |
| 468 } | 470 } |
| 469 return *this; | 471 return *this; |
| 470 } | 472 } |
| 471 | 473 |
| 472 | 474 |
| 473 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( | 475 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( |
| 474 Register object, size_t name_index, int feedback_slot, | 476 Register object, const Handle<String> name, int feedback_slot, |
| 475 LanguageMode language_mode) { | 477 LanguageMode language_mode) { |
| 476 Bytecode bytecode = BytecodeForLoadIC(language_mode); | 478 Bytecode bytecode = BytecodeForLoadIC(language_mode); |
| 479 size_t name_index = GetConstantPoolEntry(name); |
| 477 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { | 480 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
| 478 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(name_index), | 481 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(name_index), |
| 479 static_cast<uint8_t>(feedback_slot)); | 482 static_cast<uint8_t>(feedback_slot)); |
| 480 } else if (FitsInIdx16Operand(name_index) && | 483 } else if (FitsInIdx16Operand(name_index) && |
| 481 FitsInIdx16Operand(feedback_slot)) { | 484 FitsInIdx16Operand(feedback_slot)) { |
| 482 Output(BytecodeForWideOperands(bytecode), object.ToOperand(), | 485 Output(BytecodeForWideOperands(bytecode), object.ToOperand(), |
| 483 static_cast<uint16_t>(name_index), | 486 static_cast<uint16_t>(name_index), |
| 484 static_cast<uint16_t>(feedback_slot)); | 487 static_cast<uint16_t>(feedback_slot)); |
| 485 } else { | 488 } else { |
| 486 UNIMPLEMENTED(); | 489 UNIMPLEMENTED(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 498 Output(BytecodeForWideOperands(bytecode), object.ToOperand(), | 501 Output(BytecodeForWideOperands(bytecode), object.ToOperand(), |
| 499 static_cast<uint16_t>(feedback_slot)); | 502 static_cast<uint16_t>(feedback_slot)); |
| 500 } else { | 503 } else { |
| 501 UNIMPLEMENTED(); | 504 UNIMPLEMENTED(); |
| 502 } | 505 } |
| 503 return *this; | 506 return *this; |
| 504 } | 507 } |
| 505 | 508 |
| 506 | 509 |
| 507 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( | 510 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( |
| 508 Register object, size_t name_index, int feedback_slot, | 511 Register object, const Handle<String> name, int feedback_slot, |
| 509 LanguageMode language_mode) { | 512 LanguageMode language_mode) { |
| 510 Bytecode bytecode = BytecodeForStoreIC(language_mode); | 513 Bytecode bytecode = BytecodeForStoreIC(language_mode); |
| 514 size_t name_index = GetConstantPoolEntry(name); |
| 511 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { | 515 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
| 512 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(name_index), | 516 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(name_index), |
| 513 static_cast<uint8_t>(feedback_slot)); | 517 static_cast<uint8_t>(feedback_slot)); |
| 514 } else if (FitsInIdx16Operand(name_index) && | 518 } else if (FitsInIdx16Operand(name_index) && |
| 515 FitsInIdx16Operand(feedback_slot)) { | 519 FitsInIdx16Operand(feedback_slot)) { |
| 516 Output(BytecodeForWideOperands(bytecode), object.ToOperand(), | 520 Output(BytecodeForWideOperands(bytecode), object.ToOperand(), |
| 517 static_cast<uint16_t>(name_index), | 521 static_cast<uint16_t>(name_index), |
| 518 static_cast<uint16_t>(feedback_slot)); | 522 static_cast<uint16_t>(feedback_slot)); |
| 519 } else { | 523 } else { |
| 520 UNIMPLEMENTED(); | 524 UNIMPLEMENTED(); |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 DCHECK_GT(next_consecutive_count_, 0); | 1537 DCHECK_GT(next_consecutive_count_, 0); |
| 1534 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); | 1538 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); |
| 1535 allocated_.push_back(next_consecutive_register_); | 1539 allocated_.push_back(next_consecutive_register_); |
| 1536 next_consecutive_count_--; | 1540 next_consecutive_count_--; |
| 1537 return Register(next_consecutive_register_++); | 1541 return Register(next_consecutive_register_++); |
| 1538 } | 1542 } |
| 1539 | 1543 |
| 1540 } // namespace interpreter | 1544 } // namespace interpreter |
| 1541 } // namespace internal | 1545 } // namespace internal |
| 1542 } // namespace v8 | 1546 } // namespace v8 |
| OLD | NEW |