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

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

Issue 1546643002: [Interpreter] Updates load/store global and named property to accept variable name. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 12 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 | « src/interpreter/bytecode-generator.cc ('k') | test/cctest/interpreter/test-interpreter.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/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-generator.h" 9 #include "src/interpreter/bytecode-generator.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 int wide_idx_2 = vector->GetIndex(slot1) - 2; 1019 int wide_idx_2 = vector->GetIndex(slot1) - 2;
1020 int wide_idx_3 = vector->GetIndex(slot1) - 2; 1020 int wide_idx_3 = vector->GetIndex(slot1) - 2;
1021 int wide_idx_4 = vector->GetIndex(slot1) - 2; 1021 int wide_idx_4 = vector->GetIndex(slot1) - 2;
1022 1022
1023 ExpectedSnippet<const char*> snippets[] = { 1023 ExpectedSnippet<const char*> snippets[] = {
1024 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})", 1024 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})",
1025 0, 1025 0,
1026 2, 1026 2,
1027 8, 1027 8,
1028 { 1028 {
1029 B(LdaConstant), U8(1), // 1029 B(LdaConstant), U8(0), //
1030 B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // 1030 B(StoreICSloppy), A(1, 2), U8(1), U8(vector->GetIndex(slot1)), //
1031 B(LdaUndefined), // 1031 B(LdaUndefined), //
1032 B(Return), // 1032 B(Return), //
1033 }, 1033 },
1034 2, 1034 2,
1035 {"name", "val"}}, 1035 {"val", "name"}},
1036 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})", 1036 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})",
1037 0, 1037 0,
1038 2, 1038 2,
1039 8, 1039 8,
1040 { 1040 {
1041 B(LdaConstant), U8(1), // 1041 B(LdaConstant), U8(0), //
1042 B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // 1042 B(StoreICSloppy), A(1, 2), U8(1), U8(vector->GetIndex(slot1)), //
1043 B(LdaUndefined), // 1043 B(LdaUndefined), //
1044 B(Return), // 1044 B(Return), //
1045 }, 1045 },
1046 2, 1046 2,
1047 {"key", "val"}}, 1047 {"val", "key"}},
1048 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})", 1048 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})",
1049 kPointerSize, 1049 kPointerSize,
1050 2, 1050 2,
1051 12, 1051 12,
1052 { 1052 {
1053 B(LdaSmi8), U8(100), // 1053 B(LdaSmi8), U8(100), //
1054 B(Star), R(0), // 1054 B(Star), R(0), //
1055 B(LdaConstant), U8(0), // 1055 B(LdaConstant), U8(0), //
1056 B(KeyedStoreICSloppy), A(1, 2), R(0), // 1056 B(KeyedStoreICSloppy), A(1, 2), R(0), //
1057 U8(vector->GetIndex(slot1)), // 1057 U8(vector->GetIndex(slot1)), //
(...skipping 28 matching lines...) Expand all
1086 B(Return), // 1086 B(Return), //
1087 }, 1087 },
1088 1, 1088 1,
1089 {"name"}}, 1089 {"name"}},
1090 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n" 1090 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n"
1091 "f({name : \"test\"})", 1091 "f({name : \"test\"})",
1092 0, 1092 0,
1093 2, 1093 2,
1094 8, 1094 8,
1095 { 1095 {
1096 B(LdaConstant), U8(1), // 1096 B(LdaConstant), U8(0), //
1097 B(StoreICStrict), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // 1097 B(StoreICStrict), A(1, 2), U8(1), U8(vector->GetIndex(slot1)), //
1098 B(LdaUndefined), // 1098 B(LdaUndefined), //
1099 B(Return), // 1099 B(Return), //
1100 }, 1100 },
1101 2, 1101 2,
1102 {"name", "val"}}, 1102 {"val", "name"}},
1103 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n" 1103 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n"
1104 "f({arg : \"test\"}, \"arg\")", 1104 "f({arg : \"test\"}, \"arg\")",
1105 0, 1105 0,
1106 3, 1106 3,
1107 8, 1107 8,
1108 { 1108 {
1109 B(LdaConstant), U8(0), // 1109 B(LdaConstant), U8(0), //
1110 B(KeyedStoreICStrict), A(1, 3), A(2, 3), // 1110 B(KeyedStoreICStrict), A(1, 3), A(2, 3), //
1111 U8(vector->GetIndex(slot1)), // 1111 U8(vector->GetIndex(slot1)), //
1112 B(LdaUndefined), // 1112 B(LdaUndefined), //
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 2, 3327 2,
3328 {InstanceType::FIXED_ARRAY_TYPE, 3328 {InstanceType::FIXED_ARRAY_TYPE,
3329 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 3329 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
3330 {"return { func: function() { } };", 3330 {"return { func: function() { } };",
3331 1 * kPointerSize, 3331 1 * kPointerSize,
3332 1, 3332 1,
3333 16, 3333 16,
3334 { 3334 {
3335 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // 3335 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3336 B(Star), R(0), // 3336 B(Star), R(0), //
3337 B(CreateClosure), U8(2), U8(0), // 3337 B(CreateClosure), U8(1), U8(0), //
3338 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), // 3338 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot1)), //
3339 B(Ldar), R(0), // 3339 B(Ldar), R(0), //
3340 B(Return), // 3340 B(Return), //
3341 }, 3341 },
3342 3, 3342 3,
3343 {InstanceType::FIXED_ARRAY_TYPE, 3343 {InstanceType::FIXED_ARRAY_TYPE,
3344 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3344 InstanceType::SHARED_FUNCTION_INFO_TYPE,
3345 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3345 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
3346 {"return { func(a) { return a; } };", 3346 {"return { func(a) { return a; } };",
3347 1 * kPointerSize, 3347 1 * kPointerSize,
3348 1, 3348 1,
3349 16, 3349 16,
3350 { 3350 {
3351 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // 3351 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3352 B(Star), R(0), // 3352 B(Star), R(0), //
3353 B(CreateClosure), U8(2), U8(0), // 3353 B(CreateClosure), U8(1), U8(0), //
3354 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), // 3354 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot1)), //
3355 B(Ldar), R(0), // 3355 B(Ldar), R(0), //
3356 B(Return), // 3356 B(Return), //
3357 }, 3357 },
3358 3, 3358 3,
3359 {InstanceType::FIXED_ARRAY_TYPE, 3359 {InstanceType::FIXED_ARRAY_TYPE,
3360 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3360 InstanceType::SHARED_FUNCTION_INFO_TYPE,
3361 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3361 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
3362 {"return { get a() { return 2; } };", 3362 {"return { get a() { return 2; } };",
3363 5 * kPointerSize, 3363 5 * kPointerSize,
3364 1, 3364 1,
3365 29, 3365 29,
3366 { 3366 {
3367 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // 3367 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3368 B(Star), R(0), // 3368 B(Star), R(0), //
3369 B(LdaConstant), U8(1), // 3369 B(LdaConstant), U8(1), //
3370 B(Star), R(1), // 3370 B(Star), R(1), //
3371 B(CreateClosure), U8(2), U8(0), // 3371 B(CreateClosure), U8(2), U8(0), //
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3652 B(Star), R(1), // 3652 B(Star), R(1), //
3653 B(LdaZero), // 3653 B(LdaZero), //
3654 B(Star), R(2), // 3654 B(Star), R(2), //
3655 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 3655 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
3656 B(LdaConstant), U8(1), // 3656 B(LdaConstant), U8(1), //
3657 B(Star), R(1), // 3657 B(Star), R(1), //
3658 B(LdaZero), // 3658 B(LdaZero), //
3659 B(Star), R(2), // 3659 B(Star), R(2), //
3660 B(CreateObjectLiteral), U8(2), U8(0), U8(has_function_flags), // 3660 B(CreateObjectLiteral), U8(2), U8(0), U8(has_function_flags), //
3661 B(Star), R(4), // 3661 B(Star), R(4), //
3662 B(CreateClosure), U8(4), U8(1), // 3662 B(CreateClosure), U8(3), U8(1), //
3663 B(StoreICSloppy), R(4), U8(3), U8(3), // 3663 B(StoreICSloppy), R(4), U8(4), U8(3), //
3664 B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), // 3664 B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), //
3665 B(Ldar), R(4), // 3665 B(Ldar), R(4), //
3666 B(Star), R(3), // 3666 B(Star), R(3), //
3667 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // 3667 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), //
3668 B(LdaUndefined), // 3668 B(LdaUndefined), //
3669 B(Return), // 3669 B(Return), //
3670 }, 3670 },
3671 5, 3671 5,
3672 {InstanceType::FIXED_ARRAY_TYPE, 3672 {InstanceType::FIXED_ARRAY_TYPE,
3673 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3673 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
3674 InstanceType::FIXED_ARRAY_TYPE, 3674 InstanceType::FIXED_ARRAY_TYPE,
3675 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3675 InstanceType::SHARED_FUNCTION_INFO_TYPE,
3676 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3676 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
3677 }; 3677 };
3678 3678
3679 for (size_t i = 0; i < arraysize(snippets); i++) { 3679 for (size_t i = 0; i < arraysize(snippets); i++) {
3680 Handle<BytecodeArray> bytecode_array = 3680 Handle<BytecodeArray> bytecode_array =
3681 helper.MakeTopLevelBytecode(snippets[i].code_snippet); 3681 helper.MakeTopLevelBytecode(snippets[i].code_snippet);
3682 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 3682 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3683 } 3683 }
3684 } 3684 }
3685 3685
3686 3686
(...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after
5790 // inside eval. 5790 // inside eval.
5791 Handle<BytecodeArray> bytecode_array = 5791 Handle<BytecodeArray> bytecode_array =
5792 helper.MakeBytecode(script.c_str(), "t", "f"); 5792 helper.MakeBytecode(script.c_str(), "t", "f");
5793 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 5793 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5794 } 5794 }
5795 } 5795 }
5796 5796
5797 } // namespace interpreter 5797 } // namespace interpreter
5798 } // namespace internal 5798 } // namespace internal
5799 } // namespace v8 5799 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698