| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 if (FitsInIdx8Operand(literal_index)) { | 367 if (FitsInIdx8Operand(literal_index)) { |
| 368 Output(Bytecode::kCreateArrayLiteral, static_cast<uint8_t>(literal_index), | 368 Output(Bytecode::kCreateArrayLiteral, static_cast<uint8_t>(literal_index), |
| 369 static_cast<uint8_t>(flags)); | 369 static_cast<uint8_t>(flags)); |
| 370 } else { | 370 } else { |
| 371 UNIMPLEMENTED(); | 371 UNIMPLEMENTED(); |
| 372 } | 372 } |
| 373 return *this; | 373 return *this; |
| 374 } | 374 } |
| 375 | 375 |
| 376 | 376 |
| 377 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateObjectLiteral( |
| 378 int literal_index, int flags) { |
| 379 DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bytes. |
| 380 if (FitsInIdx8Operand(literal_index)) { |
| 381 Output(Bytecode::kCreateObjectLiteral, static_cast<uint8_t>(literal_index), |
| 382 static_cast<uint8_t>(flags)); |
| 383 } else { |
| 384 UNIMPLEMENTED(); |
| 385 } |
| 386 return *this; |
| 387 } |
| 388 |
| 389 |
| 377 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateClosure( | 390 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateClosure( |
| 378 PretenureFlag tenured) { | 391 PretenureFlag tenured) { |
| 379 DCHECK(FitsInImm8Operand(tenured)); | 392 DCHECK(FitsInImm8Operand(tenured)); |
| 380 Output(Bytecode::kCreateClosure, static_cast<uint8_t>(tenured)); | 393 Output(Bytecode::kCreateClosure, static_cast<uint8_t>(tenured)); |
| 381 return *this; | 394 return *this; |
| 382 } | 395 } |
| 383 | 396 |
| 384 | 397 |
| 385 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToBoolean() { | 398 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToBoolean() { |
| 386 if (LastBytecodeInSameBlock()) { | 399 if (LastBytecodeInSameBlock()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 406 default: | 419 default: |
| 407 // Fall through to output kToBoolean. | 420 // Fall through to output kToBoolean. |
| 408 break; | 421 break; |
| 409 } | 422 } |
| 410 } | 423 } |
| 411 Output(Bytecode::kToBoolean); | 424 Output(Bytecode::kToBoolean); |
| 412 return *this; | 425 return *this; |
| 413 } | 426 } |
| 414 | 427 |
| 415 | 428 |
| 429 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToName() { |
| 430 Output(Bytecode::kToName); |
| 431 return *this; |
| 432 } |
| 433 |
| 434 |
| 416 BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(BytecodeLabel* label) { | 435 BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(BytecodeLabel* label) { |
| 417 if (label->is_forward_target()) { | 436 if (label->is_forward_target()) { |
| 418 // An earlier jump instruction refers to this label. Update it's location. | 437 // An earlier jump instruction refers to this label. Update it's location. |
| 419 PatchJump(bytecodes()->end(), bytecodes()->begin() + label->offset()); | 438 PatchJump(bytecodes()->end(), bytecodes()->begin() + label->offset()); |
| 420 // Now treat as if the label will only be back referred to. | 439 // Now treat as if the label will only be back referred to. |
| 421 } | 440 } |
| 422 label->bind_to(bytecodes()->size()); | 441 label->bind_to(bytecodes()->size()); |
| 423 return *this; | 442 return *this; |
| 424 } | 443 } |
| 425 | 444 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 | 823 |
| 805 Register TemporaryRegisterScope::NewRegister() { | 824 Register TemporaryRegisterScope::NewRegister() { |
| 806 count_++; | 825 count_++; |
| 807 last_register_index_ = builder_->BorrowTemporaryRegister(); | 826 last_register_index_ = builder_->BorrowTemporaryRegister(); |
| 808 return Register(last_register_index_); | 827 return Register(last_register_index_); |
| 809 } | 828 } |
| 810 | 829 |
| 811 } // namespace interpreter | 830 } // namespace interpreter |
| 812 } // namespace internal | 831 } // namespace internal |
| 813 } // namespace v8 | 832 } // namespace v8 |
| OLD | NEW |