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/interpreter.h" | 5 #include "src/interpreter/interpreter.h" |
6 | 6 |
7 #include <fstream> | 7 #include <fstream> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 compiler::Node* Interpreter::BuildLoadContextSlot( | 537 compiler::Node* Interpreter::BuildLoadContextSlot( |
538 InterpreterAssembler* assembler) { | 538 InterpreterAssembler* assembler) { |
539 Node* reg_index = __ BytecodeOperandReg(0); | 539 Node* reg_index = __ BytecodeOperandReg(0); |
540 Node* context = __ LoadRegister(reg_index); | 540 Node* context = __ LoadRegister(reg_index); |
541 Node* slot_index = __ BytecodeOperandIdx(1); | 541 Node* slot_index = __ BytecodeOperandIdx(1); |
542 Node* depth = __ BytecodeOperandUImm(2); | 542 Node* depth = __ BytecodeOperandUImm(2); |
543 Node* slot_context = __ GetContextAtDepth(context, depth); | 543 Node* slot_context = __ GetContextAtDepth(context, depth); |
544 return __ LoadContextSlot(slot_context, slot_index); | 544 return __ LoadContextSlot(slot_context, slot_index); |
545 } | 545 } |
546 | 546 |
| 547 compiler::Node* Interpreter::BuildLoadCurrentContextSlot( |
| 548 InterpreterAssembler* assembler) { |
| 549 Node* slot_index = __ BytecodeOperandIdx(0); |
| 550 Node* slot_context = __ GetContext(); |
| 551 return __ LoadContextSlot(slot_context, slot_index); |
| 552 } |
| 553 |
547 // LdaContextSlot <context> <slot_index> <depth> | 554 // LdaContextSlot <context> <slot_index> <depth> |
548 // | 555 // |
549 // Load the object in |slot_index| of the context at |depth| in the context | 556 // Load the object in |slot_index| of the context at |depth| in the context |
550 // chain starting at |context| into the accumulator. | 557 // chain starting at |context| into the accumulator. |
551 void Interpreter::DoLdaContextSlot(InterpreterAssembler* assembler) { | 558 void Interpreter::DoLdaContextSlot(InterpreterAssembler* assembler) { |
552 Node* result = BuildLoadContextSlot(assembler); | 559 Node* result = BuildLoadContextSlot(assembler); |
553 __ SetAccumulator(result); | 560 __ SetAccumulator(result); |
554 __ Dispatch(); | 561 __ Dispatch(); |
555 } | 562 } |
556 | 563 |
| 564 // LdaCurrentContextSlot <slot_index> |
| 565 // |
| 566 // Load the object in |slot_index| of the current context into the accumulator. |
| 567 void Interpreter::DoLdaCurrentContextSlot(InterpreterAssembler* assembler) { |
| 568 Node* result = BuildLoadCurrentContextSlot(assembler); |
| 569 __ SetAccumulator(result); |
| 570 __ Dispatch(); |
| 571 } |
| 572 |
557 // LdrContextSlot <context> <slot_index> <depth> <reg> | 573 // LdrContextSlot <context> <slot_index> <depth> <reg> |
558 // | 574 // |
559 // Load the object in |slot_index| of the context at |depth| in the context | 575 // Load the object in |slot_index| of the context at |depth| in the context |
560 // chain of |context| into register |reg|. | 576 // chain of |context| into register |reg|. |
561 void Interpreter::DoLdrContextSlot(InterpreterAssembler* assembler) { | 577 void Interpreter::DoLdrContextSlot(InterpreterAssembler* assembler) { |
562 Node* result = BuildLoadContextSlot(assembler); | 578 Node* result = BuildLoadContextSlot(assembler); |
563 Node* destination = __ BytecodeOperandReg(3); | 579 Node* destination = __ BytecodeOperandReg(3); |
564 __ StoreRegister(result, destination); | 580 __ StoreRegister(result, destination); |
565 __ Dispatch(); | 581 __ Dispatch(); |
566 } | 582 } |
567 | 583 |
| 584 // LdrCurrentContextSlot <slot_index> <reg> |
| 585 // |
| 586 // Load the object in |slot_index| of the current context into register |reg|. |
| 587 void Interpreter::DoLdrCurrentContextSlot(InterpreterAssembler* assembler) { |
| 588 Node* result = BuildLoadCurrentContextSlot(assembler); |
| 589 Node* destination = __ BytecodeOperandReg(1); |
| 590 __ StoreRegister(result, destination); |
| 591 __ Dispatch(); |
| 592 } |
| 593 |
568 // StaContextSlot <context> <slot_index> <depth> | 594 // StaContextSlot <context> <slot_index> <depth> |
569 // | 595 // |
570 // Stores the object in the accumulator into |slot_index| of the context at | 596 // Stores the object in the accumulator into |slot_index| of the context at |
571 // |depth| in the context chain starting at |context|. | 597 // |depth| in the context chain starting at |context|. |
572 void Interpreter::DoStaContextSlot(InterpreterAssembler* assembler) { | 598 void Interpreter::DoStaContextSlot(InterpreterAssembler* assembler) { |
573 Node* value = __ GetAccumulator(); | 599 Node* value = __ GetAccumulator(); |
574 Node* reg_index = __ BytecodeOperandReg(0); | 600 Node* reg_index = __ BytecodeOperandReg(0); |
575 Node* context = __ LoadRegister(reg_index); | 601 Node* context = __ LoadRegister(reg_index); |
576 Node* slot_index = __ BytecodeOperandIdx(1); | 602 Node* slot_index = __ BytecodeOperandIdx(1); |
577 Node* depth = __ BytecodeOperandUImm(2); | 603 Node* depth = __ BytecodeOperandUImm(2); |
578 Node* slot_context = __ GetContextAtDepth(context, depth); | 604 Node* slot_context = __ GetContextAtDepth(context, depth); |
579 __ StoreContextSlot(slot_context, slot_index, value); | 605 __ StoreContextSlot(slot_context, slot_index, value); |
580 __ Dispatch(); | 606 __ Dispatch(); |
581 } | 607 } |
582 | 608 |
| 609 // StaCurrentContextSlot <slot_index> |
| 610 // |
| 611 // Stores the object in the accumulator into |slot_index| of the current |
| 612 // context. |
| 613 void Interpreter::DoStaCurrentContextSlot(InterpreterAssembler* assembler) { |
| 614 Node* value = __ GetAccumulator(); |
| 615 Node* slot_index = __ BytecodeOperandIdx(0); |
| 616 Node* slot_context = __ GetContext(); |
| 617 __ StoreContextSlot(slot_context, slot_index, value); |
| 618 __ Dispatch(); |
| 619 } |
| 620 |
583 void Interpreter::DoLdaLookupSlot(Runtime::FunctionId function_id, | 621 void Interpreter::DoLdaLookupSlot(Runtime::FunctionId function_id, |
584 InterpreterAssembler* assembler) { | 622 InterpreterAssembler* assembler) { |
585 Node* name_index = __ BytecodeOperandIdx(0); | 623 Node* name_index = __ BytecodeOperandIdx(0); |
586 Node* name = __ LoadConstantPoolEntry(name_index); | 624 Node* name = __ LoadConstantPoolEntry(name_index); |
587 Node* context = __ GetContext(); | 625 Node* context = __ GetContext(); |
588 Node* result = __ CallRuntime(function_id, context, name); | 626 Node* result = __ CallRuntime(function_id, context, name); |
589 __ SetAccumulator(result); | 627 __ SetAccumulator(result); |
590 __ Dispatch(); | 628 __ Dispatch(); |
591 } | 629 } |
592 | 630 |
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2695 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
2658 __ SmiTag(new_state)); | 2696 __ SmiTag(new_state)); |
2659 __ SetAccumulator(old_state); | 2697 __ SetAccumulator(old_state); |
2660 | 2698 |
2661 __ Dispatch(); | 2699 __ Dispatch(); |
2662 } | 2700 } |
2663 | 2701 |
2664 } // namespace interpreter | 2702 } // namespace interpreter |
2665 } // namespace internal | 2703 } // namespace internal |
2666 } // namespace v8 | 2704 } // namespace v8 |
OLD | NEW |