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

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

Issue 1700993002: Remove strong mode support from property loads. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comment. Created 4 years, 10 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/interpreter/test-bytecode-generator.cc ('k') | test/mjsunit/mjsunit.status » ('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/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 i::FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); 737 i::FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
738 738
739 Handle<i::TypeFeedbackVector> vector = 739 Handle<i::TypeFeedbackVector> vector =
740 i::NewTypeFeedbackVector(isolate, &feedback_spec); 740 i::NewTypeFeedbackVector(isolate, &feedback_spec);
741 741
742 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); 742 Handle<i::String> name = factory->NewStringFromAsciiChecked("val");
743 name = factory->string_table()->LookupString(isolate, name); 743 name = factory->string_table()->LookupString(isolate, name);
744 744
745 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 745 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
746 0, 0); 746 0, 0);
747 builder.LoadNamedProperty(builder.Parameter(0), name, vector->GetIndex(slot), 747 builder.LoadNamedProperty(builder.Parameter(0), name, vector->GetIndex(slot))
748 i::SLOPPY)
749 .Return(); 748 .Return();
750 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 749 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
751 750
752 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); 751 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector);
753 auto callable = tester.GetCallable<Handle<Object>>(); 752 auto callable = tester.GetCallable<Handle<Object>>();
754 753
755 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); 754 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })");
756 // Test IC miss. 755 // Test IC miss.
757 Handle<Object> return_val = callable(object).ToHandleChecked(); 756 Handle<Object> return_val = callable(object).ToHandleChecked();
758 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(123)); 757 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(123));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 791
793 Handle<i::TypeFeedbackVector> vector = 792 Handle<i::TypeFeedbackVector> vector =
794 i::NewTypeFeedbackVector(isolate, &feedback_spec); 793 i::NewTypeFeedbackVector(isolate, &feedback_spec);
795 794
796 Handle<i::String> key = factory->NewStringFromAsciiChecked("key"); 795 Handle<i::String> key = factory->NewStringFromAsciiChecked("key");
797 key = factory->string_table()->LookupString(isolate, key); 796 key = factory->string_table()->LookupString(isolate, key);
798 797
799 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 798 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
800 0, 1); 799 0, 1);
801 builder.LoadLiteral(key) 800 builder.LoadLiteral(key)
802 .LoadKeyedProperty(builder.Parameter(0), vector->GetIndex(slot), 801 .LoadKeyedProperty(builder.Parameter(0), vector->GetIndex(slot))
803 i::STRICT)
804 .Return(); 802 .Return();
805 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 803 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
806 804
807 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); 805 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector);
808 auto callable = tester.GetCallable<Handle<Object>>(); 806 auto callable = tester.GetCallable<Handle<Object>>();
809 807
810 Handle<Object> object = InterpreterTester::NewObject("({ key : 123 })"); 808 Handle<Object> object = InterpreterTester::NewObject("({ key : 123 })");
811 // Test IC miss. 809 // Test IC miss.
812 Handle<Object> return_val = callable(object).ToHandleChecked(); 810 Handle<Object> return_val = callable(object).ToHandleChecked();
813 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(123)); 811 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(123));
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 i::NewTypeFeedbackVector(isolate, &feedback_spec); 942 i::NewTypeFeedbackVector(isolate, &feedback_spec);
945 int slot_index = vector->GetIndex(slot); 943 int slot_index = vector->GetIndex(slot);
946 944
947 Handle<i::String> name = factory->NewStringFromAsciiChecked("func"); 945 Handle<i::String> name = factory->NewStringFromAsciiChecked("func");
948 name = factory->string_table()->LookupString(isolate, name); 946 name = factory->string_table()->LookupString(isolate, name);
949 947
950 // Check with no args. 948 // Check with no args.
951 { 949 {
952 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 950 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
953 0, 1); 951 0, 1);
954 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) 952 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index)
955 .StoreAccumulatorInRegister(Register(0)) 953 .StoreAccumulatorInRegister(Register(0))
956 .Call(Register(0), builder.Parameter(0), 1, 0) 954 .Call(Register(0), builder.Parameter(0), 1, 0)
957 .Return(); 955 .Return();
958 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 956 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
959 957
960 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); 958 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector);
961 auto callable = tester.GetCallable<Handle<Object>>(); 959 auto callable = tester.GetCallable<Handle<Object>>();
962 960
963 Handle<Object> object = InterpreterTester::NewObject( 961 Handle<Object> object = InterpreterTester::NewObject(
964 "new (function Obj() { this.func = function() { return 0x265; }})()"); 962 "new (function Obj() { this.func = function() { return 0x265; }})()");
965 Handle<Object> return_val = callable(object).ToHandleChecked(); 963 Handle<Object> return_val = callable(object).ToHandleChecked();
966 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); 964 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265));
967 } 965 }
968 966
969 // Check that receiver is passed properly. 967 // Check that receiver is passed properly.
970 { 968 {
971 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 969 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
972 0, 1); 970 0, 1);
973 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) 971 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index)
974 .StoreAccumulatorInRegister(Register(0)) 972 .StoreAccumulatorInRegister(Register(0))
975 .Call(Register(0), builder.Parameter(0), 1, 0) 973 .Call(Register(0), builder.Parameter(0), 1, 0)
976 .Return(); 974 .Return();
977 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 975 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
978 976
979 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); 977 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector);
980 auto callable = tester.GetCallable<Handle<Object>>(); 978 auto callable = tester.GetCallable<Handle<Object>>();
981 979
982 Handle<Object> object = InterpreterTester::NewObject( 980 Handle<Object> object = InterpreterTester::NewObject(
983 "new (function Obj() {" 981 "new (function Obj() {"
984 " this.val = 1234;" 982 " this.val = 1234;"
985 " this.func = function() { return this.val; };" 983 " this.func = function() { return this.val; };"
986 "})()"); 984 "})()");
987 Handle<Object> return_val = callable(object).ToHandleChecked(); 985 Handle<Object> return_val = callable(object).ToHandleChecked();
988 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(1234)); 986 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(1234));
989 } 987 }
990 988
991 // Check with two parameters (+ receiver). 989 // Check with two parameters (+ receiver).
992 { 990 {
993 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 991 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
994 0, 4); 992 0, 4);
995 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) 993 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index)
996 .StoreAccumulatorInRegister(Register(0)) 994 .StoreAccumulatorInRegister(Register(0))
997 .LoadAccumulatorWithRegister(builder.Parameter(0)) 995 .LoadAccumulatorWithRegister(builder.Parameter(0))
998 .StoreAccumulatorInRegister(Register(1)) 996 .StoreAccumulatorInRegister(Register(1))
999 .LoadLiteral(Smi::FromInt(51)) 997 .LoadLiteral(Smi::FromInt(51))
1000 .StoreAccumulatorInRegister(Register(2)) 998 .StoreAccumulatorInRegister(Register(2))
1001 .LoadLiteral(Smi::FromInt(11)) 999 .LoadLiteral(Smi::FromInt(11))
1002 .StoreAccumulatorInRegister(Register(3)) 1000 .StoreAccumulatorInRegister(Register(3))
1003 .Call(Register(0), Register(1), 3, 0) 1001 .Call(Register(0), Register(1), 3, 0)
1004 .Return(); 1002 .Return();
1005 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1003 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1006 1004
1007 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); 1005 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector);
1008 auto callable = tester.GetCallable<Handle<Object>>(); 1006 auto callable = tester.GetCallable<Handle<Object>>();
1009 1007
1010 Handle<Object> object = InterpreterTester::NewObject( 1008 Handle<Object> object = InterpreterTester::NewObject(
1011 "new (function Obj() { " 1009 "new (function Obj() { "
1012 " this.func = function(a, b) { return a - b; }" 1010 " this.func = function(a, b) { return a - b; }"
1013 "})()"); 1011 "})()");
1014 Handle<Object> return_val = callable(object).ToHandleChecked(); 1012 Handle<Object> return_val = callable(object).ToHandleChecked();
1015 CHECK(return_val->SameValue(Smi::FromInt(40))); 1013 CHECK(return_val->SameValue(Smi::FromInt(40)));
1016 } 1014 }
1017 1015
1018 // Check with 10 parameters (+ receiver). 1016 // Check with 10 parameters (+ receiver).
1019 { 1017 {
1020 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 1018 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
1021 0, 12); 1019 0, 12);
1022 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) 1020 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index)
1023 .StoreAccumulatorInRegister(Register(0)) 1021 .StoreAccumulatorInRegister(Register(0))
1024 .LoadAccumulatorWithRegister(builder.Parameter(0)) 1022 .LoadAccumulatorWithRegister(builder.Parameter(0))
1025 .StoreAccumulatorInRegister(Register(1)) 1023 .StoreAccumulatorInRegister(Register(1))
1026 .LoadLiteral(factory->NewStringFromAsciiChecked("a")) 1024 .LoadLiteral(factory->NewStringFromAsciiChecked("a"))
1027 .StoreAccumulatorInRegister(Register(2)) 1025 .StoreAccumulatorInRegister(Register(2))
1028 .LoadLiteral(factory->NewStringFromAsciiChecked("b")) 1026 .LoadLiteral(factory->NewStringFromAsciiChecked("b"))
1029 .StoreAccumulatorInRegister(Register(3)) 1027 .StoreAccumulatorInRegister(Register(3))
1030 .LoadLiteral(factory->NewStringFromAsciiChecked("c")) 1028 .LoadLiteral(factory->NewStringFromAsciiChecked("c"))
1031 .StoreAccumulatorInRegister(Register(4)) 1029 .StoreAccumulatorInRegister(Register(4))
1032 .LoadLiteral(factory->NewStringFromAsciiChecked("d")) 1030 .LoadLiteral(factory->NewStringFromAsciiChecked("d"))
(...skipping 3125 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 Handle<i::Object> return_value = callable().ToHandleChecked(); 4156 Handle<i::Object> return_value = callable().ToHandleChecked();
4159 CHECK(return_value->SameValue(*const_decl[i].second)); 4157 CHECK(return_value->SameValue(*const_decl[i].second));
4160 } 4158 }
4161 4159
4162 FLAG_legacy_const = old_flag_legacy_const; 4160 FLAG_legacy_const = old_flag_legacy_const;
4163 } 4161 }
4164 4162
4165 } // namespace interpreter 4163 } // namespace interpreter
4166 } // namespace internal 4164 } // namespace internal
4167 } // namespace v8 4165 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698