Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: test/cctest/interpreter/test-interpreter.cc

Issue 2122183002: [Interpreter] Collect type feedback for calls in the bytecode handler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updated cctest.status to mark the tests fail with ignition. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/cctest.status ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bytecode-array-iterator.h" 10 #include "src/interpreter/bytecode-array-iterator.h"
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 791 }
792 792
793 static void TestInterpreterCall(TailCallMode tail_call_mode) { 793 static void TestInterpreterCall(TailCallMode tail_call_mode) {
794 HandleAndZoneScope handles; 794 HandleAndZoneScope handles;
795 i::Isolate* isolate = handles.main_isolate(); 795 i::Isolate* isolate = handles.main_isolate();
796 i::Factory* factory = isolate->factory(); 796 i::Factory* factory = isolate->factory();
797 i::Zone zone(isolate->allocator()); 797 i::Zone zone(isolate->allocator());
798 798
799 i::FeedbackVectorSpec feedback_spec(&zone); 799 i::FeedbackVectorSpec feedback_spec(&zone);
800 i::FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); 800 i::FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
801 i::FeedbackVectorSlot call_slot = feedback_spec.AddCallICSlot();
801 802
802 Handle<i::TypeFeedbackVector> vector = 803 Handle<i::TypeFeedbackVector> vector =
803 i::NewTypeFeedbackVector(isolate, &feedback_spec); 804 i::NewTypeFeedbackVector(isolate, &feedback_spec);
804 int slot_index = vector->GetIndex(slot); 805 int slot_index = vector->GetIndex(slot);
806 int call_slot_index = -1;
807 call_slot_index = vector->GetIndex(call_slot);
805 808
806 Handle<i::String> name = factory->NewStringFromAsciiChecked("func"); 809 Handle<i::String> name = factory->NewStringFromAsciiChecked("func");
807 name = factory->string_table()->LookupString(isolate, name); 810 name = factory->string_table()->LookupString(isolate, name);
808 811
809 // Check with no args. 812 // Check with no args.
810 { 813 {
811 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 814 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
812 0, 1); 815 0, 1);
813 816
814 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) 817 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index)
815 .StoreAccumulatorInRegister(Register(0)) 818 .StoreAccumulatorInRegister(Register(0));
816 .Call(Register(0), builder.Parameter(0), 1, 0, tail_call_mode) 819
817 .Return(); 820 builder.Call(Register(0), builder.Parameter(0), 1, call_slot_index,
821 tail_call_mode);
822
823 builder.Return();
818 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 824 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
819 825
820 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); 826 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector);
821 auto callable = tester.GetCallable<Handle<Object>>(); 827 auto callable = tester.GetCallable<Handle<Object>>();
822 828
823 Handle<Object> object = InterpreterTester::NewObject( 829 Handle<Object> object = InterpreterTester::NewObject(
824 "new (function Obj() { this.func = function() { return 0x265; }})()"); 830 "new (function Obj() { this.func = function() { return 0x265; }})()");
825 Handle<Object> return_val = callable(object).ToHandleChecked(); 831 Handle<Object> return_val = callable(object).ToHandleChecked();
826 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); 832 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265));
827 } 833 }
828 834
829 // Check that receiver is passed properly. 835 // Check that receiver is passed properly.
830 { 836 {
831 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 837 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
832 0, 1); 838 0, 1);
833 839
834 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) 840 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index)
835 .StoreAccumulatorInRegister(Register(0)) 841 .StoreAccumulatorInRegister(Register(0));
836 .Call(Register(0), builder.Parameter(0), 1, 0, tail_call_mode) 842 builder.Call(Register(0), builder.Parameter(0), 1, call_slot_index,
837 .Return(); 843 tail_call_mode);
844 builder.Return();
838 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 845 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
839 846
840 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); 847 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector);
841 auto callable = tester.GetCallable<Handle<Object>>(); 848 auto callable = tester.GetCallable<Handle<Object>>();
842 849
843 Handle<Object> object = InterpreterTester::NewObject( 850 Handle<Object> object = InterpreterTester::NewObject(
844 "new (function Obj() {" 851 "new (function Obj() {"
845 " this.val = 1234;" 852 " this.val = 1234;"
846 " this.func = function() { return this.val; };" 853 " this.func = function() { return this.val; };"
847 "})()"); 854 "})()");
848 Handle<Object> return_val = callable(object).ToHandleChecked(); 855 Handle<Object> return_val = callable(object).ToHandleChecked();
849 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(1234)); 856 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(1234));
850 } 857 }
851 858
852 // Check with two parameters (+ receiver). 859 // Check with two parameters (+ receiver).
853 { 860 {
854 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 861 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
855 0, 4); 862 0, 4);
856 863
857 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) 864 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index)
858 .StoreAccumulatorInRegister(Register(0)) 865 .StoreAccumulatorInRegister(Register(0))
859 .LoadAccumulatorWithRegister(builder.Parameter(0)) 866 .LoadAccumulatorWithRegister(builder.Parameter(0))
860 .StoreAccumulatorInRegister(Register(1)) 867 .StoreAccumulatorInRegister(Register(1))
861 .LoadLiteral(Smi::FromInt(51)) 868 .LoadLiteral(Smi::FromInt(51))
862 .StoreAccumulatorInRegister(Register(2)) 869 .StoreAccumulatorInRegister(Register(2))
863 .LoadLiteral(Smi::FromInt(11)) 870 .LoadLiteral(Smi::FromInt(11))
864 .StoreAccumulatorInRegister(Register(3)) 871 .StoreAccumulatorInRegister(Register(3));
865 .Call(Register(0), Register(1), 3, 0, tail_call_mode) 872
866 .Return(); 873 builder.Call(Register(0), Register(1), 3, call_slot_index, tail_call_mode);
874
875 builder.Return();
876
867 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 877 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
868 878
869 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); 879 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector);
870 auto callable = tester.GetCallable<Handle<Object>>(); 880 auto callable = tester.GetCallable<Handle<Object>>();
871 881
872 Handle<Object> object = InterpreterTester::NewObject( 882 Handle<Object> object = InterpreterTester::NewObject(
873 "new (function Obj() { " 883 "new (function Obj() { "
874 " this.func = function(a, b) { return a - b; }" 884 " this.func = function(a, b) { return a - b; }"
875 "})()"); 885 "})()");
876 Handle<Object> return_val = callable(object).ToHandleChecked(); 886 Handle<Object> return_val = callable(object).ToHandleChecked();
(...skipping 21 matching lines...) Expand all
898 .StoreAccumulatorInRegister(Register(6)) 908 .StoreAccumulatorInRegister(Register(6))
899 .LoadLiteral(factory->NewStringFromAsciiChecked("f")) 909 .LoadLiteral(factory->NewStringFromAsciiChecked("f"))
900 .StoreAccumulatorInRegister(Register(7)) 910 .StoreAccumulatorInRegister(Register(7))
901 .LoadLiteral(factory->NewStringFromAsciiChecked("g")) 911 .LoadLiteral(factory->NewStringFromAsciiChecked("g"))
902 .StoreAccumulatorInRegister(Register(8)) 912 .StoreAccumulatorInRegister(Register(8))
903 .LoadLiteral(factory->NewStringFromAsciiChecked("h")) 913 .LoadLiteral(factory->NewStringFromAsciiChecked("h"))
904 .StoreAccumulatorInRegister(Register(9)) 914 .StoreAccumulatorInRegister(Register(9))
905 .LoadLiteral(factory->NewStringFromAsciiChecked("i")) 915 .LoadLiteral(factory->NewStringFromAsciiChecked("i"))
906 .StoreAccumulatorInRegister(Register(10)) 916 .StoreAccumulatorInRegister(Register(10))
907 .LoadLiteral(factory->NewStringFromAsciiChecked("j")) 917 .LoadLiteral(factory->NewStringFromAsciiChecked("j"))
908 .StoreAccumulatorInRegister(Register(11)) 918 .StoreAccumulatorInRegister(Register(11));
909 .Call(Register(0), Register(1), 11, 0, tail_call_mode) 919
910 .Return(); 920 builder.Call(Register(0), Register(1), 11, call_slot_index, tail_call_mode);
921
922 builder.Return();
923
911 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 924 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
912 925
913 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); 926 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector);
914 auto callable = tester.GetCallable<Handle<Object>>(); 927 auto callable = tester.GetCallable<Handle<Object>>();
915 928
916 Handle<Object> object = InterpreterTester::NewObject( 929 Handle<Object> object = InterpreterTester::NewObject(
917 "new (function Obj() { " 930 "new (function Obj() { "
918 " this.prefix = \"prefix_\";" 931 " this.prefix = \"prefix_\";"
919 " this.func = function(a, b, c, d, e, f, g, h, i, j) {" 932 " this.func = function(a, b, c, d, e, f, g, h, i, j) {"
920 " return this.prefix + a + b + c + d + e + f + g + h + i + j;" 933 " return this.prefix + a + b + c + d + e + f + g + h + i + j;"
(...skipping 3273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4194 Handle<i::Object> return_value = callable().ToHandleChecked(); 4207 Handle<i::Object> return_value = callable().ToHandleChecked();
4195 CHECK(return_value->SameValue(*tests[i].second)); 4208 CHECK(return_value->SameValue(*tests[i].second));
4196 } 4209 }
4197 4210
4198 FLAG_ignition_generators = old_flag; 4211 FLAG_ignition_generators = old_flag;
4199 } 4212 }
4200 4213
4201 } // namespace interpreter 4214 } // namespace interpreter
4202 } // namespace internal 4215 } // namespace internal
4203 } // namespace v8 4216 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698