| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/execution.h" | 7 #include "src/execution.h" |
| 8 #include "src/handles.h" | 8 #include "src/handles.h" |
| 9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
| 10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 584 |
| 585 Handle<Object> return_val = callable().ToHandleChecked(); | 585 Handle<Object> return_val = callable().ToHandleChecked(); |
| 586 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(15)); | 586 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(15)); |
| 587 } | 587 } |
| 588 | 588 |
| 589 | 589 |
| 590 TEST(InterpreterLoadNamedProperty) { | 590 TEST(InterpreterLoadNamedProperty) { |
| 591 HandleAndZoneScope handles; | 591 HandleAndZoneScope handles; |
| 592 i::Isolate* isolate = handles.main_isolate(); | 592 i::Isolate* isolate = handles.main_isolate(); |
| 593 i::Factory* factory = isolate->factory(); | 593 i::Factory* factory = isolate->factory(); |
| 594 i::Zone zone; |
| 594 | 595 |
| 595 i::FeedbackVectorSlotKind ic_kinds[] = {i::FeedbackVectorSlotKind::LOAD_IC}; | 596 i::FeedbackVectorSpec feedback_spec(&zone); |
| 596 i::StaticFeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 597 i::FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); |
| 598 |
| 597 Handle<i::TypeFeedbackVector> vector = | 599 Handle<i::TypeFeedbackVector> vector = |
| 598 factory->NewTypeFeedbackVector(&feedback_spec); | 600 i::TypeFeedbackVector::New(isolate, &feedback_spec); |
| 599 | 601 |
| 600 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); | 602 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); |
| 601 name = factory->string_table()->LookupString(isolate, name); | 603 name = factory->string_table()->LookupString(isolate, name); |
| 602 | 604 |
| 603 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 605 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 604 builder.set_locals_count(0); | 606 builder.set_locals_count(0); |
| 605 builder.set_parameter_count(1); | 607 builder.set_parameter_count(1); |
| 606 builder.LoadLiteral(name) | 608 builder.LoadLiteral(name) |
| 607 .LoadNamedProperty(builder.Parameter(0), vector->first_ic_slot_index(), | 609 .LoadNamedProperty(builder.Parameter(0), vector->GetIndex(slot), |
| 608 i::SLOPPY) | 610 i::SLOPPY) |
| 609 .Return(); | 611 .Return(); |
| 610 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 612 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 611 | 613 |
| 612 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 614 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 613 auto callable = tester.GetCallable<Handle<Object>>(); | 615 auto callable = tester.GetCallable<Handle<Object>>(); |
| 614 | 616 |
| 615 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); | 617 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); |
| 616 // Test IC miss. | 618 // Test IC miss. |
| 617 Handle<Object> return_val = callable(object).ToHandleChecked(); | 619 Handle<Object> return_val = callable(object).ToHandleChecked(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 638 InterpreterTester::NewObject("({ val : 789, val4 : 123 })"); | 640 InterpreterTester::NewObject("({ val : 789, val4 : 123 })"); |
| 639 return_val = callable(object5).ToHandleChecked(); | 641 return_val = callable(object5).ToHandleChecked(); |
| 640 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(789)); | 642 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(789)); |
| 641 } | 643 } |
| 642 | 644 |
| 643 | 645 |
| 644 TEST(InterpreterLoadKeyedProperty) { | 646 TEST(InterpreterLoadKeyedProperty) { |
| 645 HandleAndZoneScope handles; | 647 HandleAndZoneScope handles; |
| 646 i::Isolate* isolate = handles.main_isolate(); | 648 i::Isolate* isolate = handles.main_isolate(); |
| 647 i::Factory* factory = isolate->factory(); | 649 i::Factory* factory = isolate->factory(); |
| 650 i::Zone zone; |
| 648 | 651 |
| 649 i::FeedbackVectorSlotKind ic_kinds[] = { | 652 i::FeedbackVectorSpec feedback_spec(&zone); |
| 650 i::FeedbackVectorSlotKind::KEYED_LOAD_IC}; | 653 i::FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); |
| 651 i::StaticFeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 654 |
| 652 Handle<i::TypeFeedbackVector> vector = | 655 Handle<i::TypeFeedbackVector> vector = |
| 653 factory->NewTypeFeedbackVector(&feedback_spec); | 656 i::TypeFeedbackVector::New(isolate, &feedback_spec); |
| 654 | 657 |
| 655 Handle<i::String> key = factory->NewStringFromAsciiChecked("key"); | 658 Handle<i::String> key = factory->NewStringFromAsciiChecked("key"); |
| 656 key = factory->string_table()->LookupString(isolate, key); | 659 key = factory->string_table()->LookupString(isolate, key); |
| 657 | 660 |
| 658 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 661 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 659 builder.set_locals_count(1); | 662 builder.set_locals_count(1); |
| 660 builder.set_parameter_count(1); | 663 builder.set_parameter_count(1); |
| 661 builder.LoadLiteral(key) | 664 builder.LoadLiteral(key) |
| 662 .LoadKeyedProperty(builder.Parameter(0), vector->first_ic_slot_index(), | 665 .LoadKeyedProperty(builder.Parameter(0), vector->GetIndex(slot), |
| 663 i::SLOPPY) | 666 i::SLOPPY) |
| 664 .Return(); | 667 .Return(); |
| 665 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 668 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 666 | 669 |
| 667 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 670 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 668 auto callable = tester.GetCallable<Handle<Object>>(); | 671 auto callable = tester.GetCallable<Handle<Object>>(); |
| 669 | 672 |
| 670 Handle<Object> object = InterpreterTester::NewObject("({ key : 123 })"); | 673 Handle<Object> object = InterpreterTester::NewObject("({ key : 123 })"); |
| 671 // Test IC miss. | 674 // Test IC miss. |
| 672 Handle<Object> return_val = callable(object).ToHandleChecked(); | 675 Handle<Object> return_val = callable(object).ToHandleChecked(); |
| 673 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(123)); | 676 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(123)); |
| 674 | 677 |
| 675 // Test transition to monomorphic IC. | 678 // Test transition to monomorphic IC. |
| 676 return_val = callable(object).ToHandleChecked(); | 679 return_val = callable(object).ToHandleChecked(); |
| 677 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(123)); | 680 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(123)); |
| 678 | 681 |
| 679 // Test transition to megamorphic IC. | 682 // Test transition to megamorphic IC. |
| 680 Handle<Object> object3 = | 683 Handle<Object> object3 = |
| 681 InterpreterTester::NewObject("({ key : 789, val2 : 123 })"); | 684 InterpreterTester::NewObject("({ key : 789, val2 : 123 })"); |
| 682 return_val = callable(object3).ToHandleChecked(); | 685 return_val = callable(object3).ToHandleChecked(); |
| 683 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(789)); | 686 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(789)); |
| 684 } | 687 } |
| 685 | 688 |
| 686 | 689 |
| 687 TEST(InterpreterStoreNamedProperty) { | 690 TEST(InterpreterStoreNamedProperty) { |
| 688 HandleAndZoneScope handles; | 691 HandleAndZoneScope handles; |
| 689 i::Isolate* isolate = handles.main_isolate(); | 692 i::Isolate* isolate = handles.main_isolate(); |
| 690 i::Factory* factory = isolate->factory(); | 693 i::Factory* factory = isolate->factory(); |
| 694 i::Zone zone; |
| 691 | 695 |
| 692 i::FeedbackVectorSlotKind ic_kinds[] = {i::FeedbackVectorSlotKind::STORE_IC}; | 696 i::FeedbackVectorSpec feedback_spec(&zone); |
| 693 i::StaticFeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 697 i::FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot(); |
| 698 |
| 694 Handle<i::TypeFeedbackVector> vector = | 699 Handle<i::TypeFeedbackVector> vector = |
| 695 factory->NewTypeFeedbackVector(&feedback_spec); | 700 i::TypeFeedbackVector::New(isolate, &feedback_spec); |
| 696 | 701 |
| 697 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); | 702 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); |
| 698 name = factory->string_table()->LookupString(isolate, name); | 703 name = factory->string_table()->LookupString(isolate, name); |
| 699 | 704 |
| 700 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 705 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 701 builder.set_locals_count(1); | 706 builder.set_locals_count(1); |
| 702 builder.set_parameter_count(1); | 707 builder.set_parameter_count(1); |
| 703 builder.LoadLiteral(name) | 708 builder.LoadLiteral(name) |
| 704 .StoreAccumulatorInRegister(Register(0)) | 709 .StoreAccumulatorInRegister(Register(0)) |
| 705 .LoadLiteral(Smi::FromInt(999)) | 710 .LoadLiteral(Smi::FromInt(999)) |
| 706 .StoreNamedProperty(builder.Parameter(0), Register(0), | 711 .StoreNamedProperty(builder.Parameter(0), Register(0), |
| 707 vector->first_ic_slot_index(), i::SLOPPY) | 712 vector->GetIndex(slot), i::SLOPPY) |
| 708 .Return(); | 713 .Return(); |
| 709 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 714 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 710 | 715 |
| 711 InterpreterTester tester(isolate, bytecode_array, vector); | 716 InterpreterTester tester(isolate, bytecode_array, vector); |
| 712 auto callable = tester.GetCallable<Handle<Object>>(); | 717 auto callable = tester.GetCallable<Handle<Object>>(); |
| 713 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); | 718 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); |
| 714 // Test IC miss. | 719 // Test IC miss. |
| 715 Handle<Object> result; | 720 Handle<Object> result; |
| 716 callable(object).ToHandleChecked(); | 721 callable(object).ToHandleChecked(); |
| 717 CHECK(Runtime::GetObjectProperty(isolate, object, name).ToHandle(&result)); | 722 CHECK(Runtime::GetObjectProperty(isolate, object, name).ToHandle(&result)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 741 callable(object5).ToHandleChecked(); | 746 callable(object5).ToHandleChecked(); |
| 742 CHECK(Runtime::GetObjectProperty(isolate, object5, name).ToHandle(&result)); | 747 CHECK(Runtime::GetObjectProperty(isolate, object5, name).ToHandle(&result)); |
| 743 CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); | 748 CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); |
| 744 } | 749 } |
| 745 | 750 |
| 746 | 751 |
| 747 TEST(InterpreterStoreKeyedProperty) { | 752 TEST(InterpreterStoreKeyedProperty) { |
| 748 HandleAndZoneScope handles; | 753 HandleAndZoneScope handles; |
| 749 i::Isolate* isolate = handles.main_isolate(); | 754 i::Isolate* isolate = handles.main_isolate(); |
| 750 i::Factory* factory = isolate->factory(); | 755 i::Factory* factory = isolate->factory(); |
| 756 i::Zone zone; |
| 751 | 757 |
| 752 i::FeedbackVectorSlotKind ic_kinds[] = { | 758 i::FeedbackVectorSpec feedback_spec(&zone); |
| 753 i::FeedbackVectorSlotKind::KEYED_STORE_IC}; | 759 i::FeedbackVectorSlot slot = feedback_spec.AddKeyedStoreICSlot(); |
| 754 i::StaticFeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 760 |
| 755 Handle<i::TypeFeedbackVector> vector = | 761 Handle<i::TypeFeedbackVector> vector = |
| 756 factory->NewTypeFeedbackVector(&feedback_spec); | 762 i::TypeFeedbackVector::New(isolate, &feedback_spec); |
| 757 | 763 |
| 758 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); | 764 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); |
| 759 name = factory->string_table()->LookupString(isolate, name); | 765 name = factory->string_table()->LookupString(isolate, name); |
| 760 | 766 |
| 761 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 767 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 762 builder.set_locals_count(1); | 768 builder.set_locals_count(1); |
| 763 builder.set_parameter_count(1); | 769 builder.set_parameter_count(1); |
| 764 builder.LoadLiteral(name) | 770 builder.LoadLiteral(name) |
| 765 .StoreAccumulatorInRegister(Register(0)) | 771 .StoreAccumulatorInRegister(Register(0)) |
| 766 .LoadLiteral(Smi::FromInt(999)) | 772 .LoadLiteral(Smi::FromInt(999)) |
| 767 .StoreKeyedProperty(builder.Parameter(0), Register(0), | 773 .StoreKeyedProperty(builder.Parameter(0), Register(0), |
| 768 vector->first_ic_slot_index(), i::SLOPPY) | 774 vector->GetIndex(slot), i::SLOPPY) |
| 769 .Return(); | 775 .Return(); |
| 770 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 776 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 771 | 777 |
| 772 InterpreterTester tester(isolate, bytecode_array, vector); | 778 InterpreterTester tester(isolate, bytecode_array, vector); |
| 773 auto callable = tester.GetCallable<Handle<Object>>(); | 779 auto callable = tester.GetCallable<Handle<Object>>(); |
| 774 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); | 780 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); |
| 775 // Test IC miss. | 781 // Test IC miss. |
| 776 Handle<Object> result; | 782 Handle<Object> result; |
| 777 callable(object).ToHandleChecked(); | 783 callable(object).ToHandleChecked(); |
| 778 CHECK(Runtime::GetObjectProperty(isolate, object, name).ToHandle(&result)); | 784 CHECK(Runtime::GetObjectProperty(isolate, object, name).ToHandle(&result)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 789 callable(object2).ToHandleChecked(); | 795 callable(object2).ToHandleChecked(); |
| 790 CHECK(Runtime::GetObjectProperty(isolate, object2, name).ToHandle(&result)); | 796 CHECK(Runtime::GetObjectProperty(isolate, object2, name).ToHandle(&result)); |
| 791 CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); | 797 CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); |
| 792 } | 798 } |
| 793 | 799 |
| 794 | 800 |
| 795 TEST(InterpreterCall) { | 801 TEST(InterpreterCall) { |
| 796 HandleAndZoneScope handles; | 802 HandleAndZoneScope handles; |
| 797 i::Isolate* isolate = handles.main_isolate(); | 803 i::Isolate* isolate = handles.main_isolate(); |
| 798 i::Factory* factory = isolate->factory(); | 804 i::Factory* factory = isolate->factory(); |
| 805 i::Zone zone; |
| 799 | 806 |
| 800 i::FeedbackVectorSlotKind ic_kinds[] = {i::FeedbackVectorSlotKind::LOAD_IC}; | 807 i::FeedbackVectorSpec feedback_spec(&zone); |
| 801 i::StaticFeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 808 i::FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); |
| 809 |
| 802 Handle<i::TypeFeedbackVector> vector = | 810 Handle<i::TypeFeedbackVector> vector = |
| 803 factory->NewTypeFeedbackVector(&feedback_spec); | 811 i::TypeFeedbackVector::New(isolate, &feedback_spec); |
| 812 int slot_index = vector->GetIndex(slot); |
| 804 | 813 |
| 805 Handle<i::String> name = factory->NewStringFromAsciiChecked("func"); | 814 Handle<i::String> name = factory->NewStringFromAsciiChecked("func"); |
| 806 name = factory->string_table()->LookupString(isolate, name); | 815 name = factory->string_table()->LookupString(isolate, name); |
| 807 | 816 |
| 808 // Check with no args. | 817 // Check with no args. |
| 809 { | 818 { |
| 810 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 819 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 811 builder.set_locals_count(1); | 820 builder.set_locals_count(1); |
| 812 builder.set_parameter_count(1); | 821 builder.set_parameter_count(1); |
| 813 builder.LoadLiteral(name) | 822 builder.LoadLiteral(name) |
| 814 .LoadNamedProperty(builder.Parameter(0), vector->first_ic_slot_index(), | 823 .LoadNamedProperty(builder.Parameter(0), slot_index, i::SLOPPY) |
| 815 i::SLOPPY) | |
| 816 .StoreAccumulatorInRegister(Register(0)) | 824 .StoreAccumulatorInRegister(Register(0)) |
| 817 .Call(Register(0), builder.Parameter(0), 0) | 825 .Call(Register(0), builder.Parameter(0), 0) |
| 818 .Return(); | 826 .Return(); |
| 819 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 827 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 820 | 828 |
| 821 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 829 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 822 auto callable = tester.GetCallable<Handle<Object>>(); | 830 auto callable = tester.GetCallable<Handle<Object>>(); |
| 823 | 831 |
| 824 Handle<Object> object = InterpreterTester::NewObject( | 832 Handle<Object> object = InterpreterTester::NewObject( |
| 825 "new (function Obj() { this.func = function() { return 0x265; }})()"); | 833 "new (function Obj() { this.func = function() { return 0x265; }})()"); |
| 826 Handle<Object> return_val = callable(object).ToHandleChecked(); | 834 Handle<Object> return_val = callable(object).ToHandleChecked(); |
| 827 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); | 835 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); |
| 828 } | 836 } |
| 829 | 837 |
| 830 // Check that receiver is passed properly. | 838 // Check that receiver is passed properly. |
| 831 { | 839 { |
| 832 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 840 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 833 builder.set_locals_count(1); | 841 builder.set_locals_count(1); |
| 834 builder.set_parameter_count(1); | 842 builder.set_parameter_count(1); |
| 835 builder.LoadLiteral(name) | 843 builder.LoadLiteral(name) |
| 836 .LoadNamedProperty(builder.Parameter(0), vector->first_ic_slot_index(), | 844 .LoadNamedProperty(builder.Parameter(0), slot_index, i::SLOPPY) |
| 837 i::SLOPPY) | |
| 838 .StoreAccumulatorInRegister(Register(0)) | 845 .StoreAccumulatorInRegister(Register(0)) |
| 839 .Call(Register(0), builder.Parameter(0), 0) | 846 .Call(Register(0), builder.Parameter(0), 0) |
| 840 .Return(); | 847 .Return(); |
| 841 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 848 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 842 | 849 |
| 843 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 850 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 844 auto callable = tester.GetCallable<Handle<Object>>(); | 851 auto callable = tester.GetCallable<Handle<Object>>(); |
| 845 | 852 |
| 846 Handle<Object> object = InterpreterTester::NewObject( | 853 Handle<Object> object = InterpreterTester::NewObject( |
| 847 "new (function Obj() {" | 854 "new (function Obj() {" |
| 848 " this.val = 1234;" | 855 " this.val = 1234;" |
| 849 " this.func = function() { return this.val; };" | 856 " this.func = function() { return this.val; };" |
| 850 "})()"); | 857 "})()"); |
| 851 Handle<Object> return_val = callable(object).ToHandleChecked(); | 858 Handle<Object> return_val = callable(object).ToHandleChecked(); |
| 852 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(1234)); | 859 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(1234)); |
| 853 } | 860 } |
| 854 | 861 |
| 855 // Check with two parameters (+ receiver). | 862 // Check with two parameters (+ receiver). |
| 856 { | 863 { |
| 857 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 864 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 858 builder.set_locals_count(4); | 865 builder.set_locals_count(4); |
| 859 builder.set_parameter_count(1); | 866 builder.set_parameter_count(1); |
| 860 builder.LoadLiteral(name) | 867 builder.LoadLiteral(name) |
| 861 .LoadNamedProperty(builder.Parameter(0), vector->first_ic_slot_index(), | 868 .LoadNamedProperty(builder.Parameter(0), slot_index, i::SLOPPY) |
| 862 i::SLOPPY) | |
| 863 .StoreAccumulatorInRegister(Register(0)) | 869 .StoreAccumulatorInRegister(Register(0)) |
| 864 .LoadAccumulatorWithRegister(builder.Parameter(0)) | 870 .LoadAccumulatorWithRegister(builder.Parameter(0)) |
| 865 .StoreAccumulatorInRegister(Register(1)) | 871 .StoreAccumulatorInRegister(Register(1)) |
| 866 .LoadLiteral(Smi::FromInt(51)) | 872 .LoadLiteral(Smi::FromInt(51)) |
| 867 .StoreAccumulatorInRegister(Register(2)) | 873 .StoreAccumulatorInRegister(Register(2)) |
| 868 .LoadLiteral(Smi::FromInt(11)) | 874 .LoadLiteral(Smi::FromInt(11)) |
| 869 .StoreAccumulatorInRegister(Register(3)) | 875 .StoreAccumulatorInRegister(Register(3)) |
| 870 .Call(Register(0), Register(1), 2) | 876 .Call(Register(0), Register(1), 2) |
| 871 .Return(); | 877 .Return(); |
| 872 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 878 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 873 | 879 |
| 874 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 880 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 875 auto callable = tester.GetCallable<Handle<Object>>(); | 881 auto callable = tester.GetCallable<Handle<Object>>(); |
| 876 | 882 |
| 877 Handle<Object> object = InterpreterTester::NewObject( | 883 Handle<Object> object = InterpreterTester::NewObject( |
| 878 "new (function Obj() { " | 884 "new (function Obj() { " |
| 879 " this.func = function(a, b) { return a - b; }" | 885 " this.func = function(a, b) { return a - b; }" |
| 880 "})()"); | 886 "})()"); |
| 881 Handle<Object> return_val = callable(object).ToHandleChecked(); | 887 Handle<Object> return_val = callable(object).ToHandleChecked(); |
| 882 CHECK(return_val->SameValue(Smi::FromInt(40))); | 888 CHECK(return_val->SameValue(Smi::FromInt(40))); |
| 883 } | 889 } |
| 884 | 890 |
| 885 // Check with 10 parameters (+ receiver). | 891 // Check with 10 parameters (+ receiver). |
| 886 { | 892 { |
| 887 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 893 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 888 builder.set_locals_count(12); | 894 builder.set_locals_count(12); |
| 889 builder.set_parameter_count(1); | 895 builder.set_parameter_count(1); |
| 890 builder.LoadLiteral(name) | 896 builder.LoadLiteral(name) |
| 891 .LoadNamedProperty(builder.Parameter(0), vector->first_ic_slot_index(), | 897 .LoadNamedProperty(builder.Parameter(0), slot_index, i::SLOPPY) |
| 892 i::SLOPPY) | |
| 893 .StoreAccumulatorInRegister(Register(0)) | 898 .StoreAccumulatorInRegister(Register(0)) |
| 894 .LoadAccumulatorWithRegister(builder.Parameter(0)) | 899 .LoadAccumulatorWithRegister(builder.Parameter(0)) |
| 895 .StoreAccumulatorInRegister(Register(1)) | 900 .StoreAccumulatorInRegister(Register(1)) |
| 896 .LoadLiteral(factory->NewStringFromAsciiChecked("a")) | 901 .LoadLiteral(factory->NewStringFromAsciiChecked("a")) |
| 897 .StoreAccumulatorInRegister(Register(2)) | 902 .StoreAccumulatorInRegister(Register(2)) |
| 898 .LoadLiteral(factory->NewStringFromAsciiChecked("b")) | 903 .LoadLiteral(factory->NewStringFromAsciiChecked("b")) |
| 899 .StoreAccumulatorInRegister(Register(3)) | 904 .StoreAccumulatorInRegister(Register(3)) |
| 900 .LoadLiteral(factory->NewStringFromAsciiChecked("c")) | 905 .LoadLiteral(factory->NewStringFromAsciiChecked("c")) |
| 901 .StoreAccumulatorInRegister(Register(4)) | 906 .StoreAccumulatorInRegister(Register(4)) |
| 902 .LoadLiteral(factory->NewStringFromAsciiChecked("d")) | 907 .LoadLiteral(factory->NewStringFromAsciiChecked("d")) |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 .Return(); | 1282 .Return(); |
| 1278 | 1283 |
| 1279 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1284 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1280 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1285 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1281 auto callable = tester.GetCallable<>(); | 1286 auto callable = tester.GetCallable<>(); |
| 1282 Handle<Object> return_value = callable().ToHandleChecked(); | 1287 Handle<Object> return_value = callable().ToHandleChecked(); |
| 1283 CHECK(return_value->IsBoolean()); | 1288 CHECK(return_value->IsBoolean()); |
| 1284 CHECK_EQ(return_value->BooleanValue(), expected_value); | 1289 CHECK_EQ(return_value->BooleanValue(), expected_value); |
| 1285 } | 1290 } |
| 1286 } | 1291 } |
| OLD | NEW |