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

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

Issue 1584813002: [Interpreter] Make ForInPrepare take a kRegTriple8 and ForInNext take kRegPair8 for cache state (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_forin
Patch Set: Created 4 years, 11 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
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 4886 matching lines...) Expand 10 before | Expand all | Expand 10 after
4897 {"for (var p in undefined) {}", 4897 {"for (var p in undefined) {}",
4898 2 * kPointerSize, 4898 2 * kPointerSize,
4899 1, 4899 1,
4900 2, 4900 2,
4901 {B(LdaUndefined), B(Return)}, 4901 {B(LdaUndefined), B(Return)},
4902 0}, 4902 0},
4903 {"var x = 'potatoes';\n" 4903 {"var x = 'potatoes';\n"
4904 "for (var p in x) { return p; }", 4904 "for (var p in x) { return p; }",
4905 8 * kPointerSize, 4905 8 * kPointerSize,
4906 1, 4906 1,
4907 45, 4907 42,
4908 { 4908 {
4909 B(LdaConstant), U8(0), // 4909 B(LdaConstant), U8(0), //
4910 B(Star), R(1), // 4910 B(Star), R(1), //
4911 B(JumpIfUndefined), U8(39), // 4911 B(JumpIfUndefined), U8(36), //
4912 B(JumpIfNull), U8(37), // 4912 B(JumpIfNull), U8(34), //
4913 B(ToObject), // 4913 B(ToObject), //
4914 B(JumpIfNull), U8(34), // 4914 B(JumpIfNull), U8(31), //
4915 B(Star), R(3), // 4915 B(Star), R(3), //
4916 B(ForInPrepare), R(4), R(5), R(6), // 4916 B(ForInPrepare), R(4), //
4917 B(LdaZero), // 4917 B(LdaZero), //
4918 B(Star), R(7), // 4918 B(Star), R(7), //
4919 B(ForInDone), R(7), R(6), // 4919 B(ForInDone), R(7), R(6), //
4920 B(JumpIfTrue), U8(20), // 4920 B(JumpIfTrue), U8(19), //
4921 B(ForInNext), R(3), R(4), R(5), R(7), // 4921 B(ForInNext), R(3), R(7), R(4), //
4922 B(JumpIfUndefined), U8(7), // 4922 B(JumpIfUndefined), U8(7), //
4923 B(Star), R(0), // 4923 B(Star), R(0), //
4924 B(Star), R(2), // 4924 B(Star), R(2), //
4925 B(Return), // 4925 B(Return), //
4926 B(ForInStep), R(7), // 4926 B(ForInStep), R(7), //
4927 B(Star), R(7), // 4927 B(Star), R(7), //
4928 B(Jump), U8(-21), // 4928 B(Jump), U8(-20), //
4929 B(LdaUndefined), // 4929 B(LdaUndefined), //
4930 B(Return), // 4930 B(Return), //
4931 }, 4931 },
4932 1, 4932 1,
4933 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4933 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
4934 {"var x = 0;\n" 4934 {"var x = 0;\n"
4935 "for (var p in [1,2,3]) { x += p; }", 4935 "for (var p in [1,2,3]) { x += p; }",
4936 8 * kPointerSize, 4936 8 * kPointerSize,
4937 1, 4937 1,
4938 51, 4938 48,
4939 { 4939 {
4940 B(LdaZero), // 4940 B(LdaZero), //
4941 B(Star), R(1), // 4941 B(Star), R(1), //
4942 B(CreateArrayLiteral), U8(0), U8(0), U8(3), // 4942 B(CreateArrayLiteral), U8(0), U8(0), U8(3), //
4943 B(JumpIfUndefined), U8(42), // 4943 B(JumpIfUndefined), U8(39), //
4944 B(JumpIfNull), U8(40), // 4944 B(JumpIfNull), U8(37), //
4945 B(ToObject), // 4945 B(ToObject), //
4946 B(JumpIfNull), U8(37), // 4946 B(JumpIfNull), U8(34), //
4947 B(Star), R(3), // 4947 B(Star), R(3), //
4948 B(ForInPrepare), R(4), R(5), R(6), // 4948 B(ForInPrepare), R(4), //
4949 B(LdaZero), // 4949 B(LdaZero), //
4950 B(Star), R(7), // 4950 B(Star), R(7), //
4951 B(ForInDone), R(7), R(6), // 4951 B(ForInDone), R(7), R(6), //
4952 B(JumpIfTrue), U8(23), // 4952 B(JumpIfTrue), U8(22), //
4953 B(ForInNext), R(3), R(4), R(5), R(7), // 4953 B(ForInNext), R(3), R(7), R(4), //
4954 B(JumpIfUndefined), U8(10), // 4954 B(JumpIfUndefined), U8(10), //
4955 B(Star), R(0), // 4955 B(Star), R(0), //
4956 B(Star), R(2), // 4956 B(Star), R(2), //
4957 B(Add), R(1), // 4957 B(Add), R(1), //
4958 B(Star), R(1), // 4958 B(Star), R(1), //
4959 B(ForInStep), R(7), // 4959 B(ForInStep), R(7), //
4960 B(Star), R(7), // 4960 B(Star), R(7), //
4961 B(Jump), U8(-24), // 4961 B(Jump), U8(-23), //
4962 B(LdaUndefined), // 4962 B(LdaUndefined), //
4963 B(Return), // 4963 B(Return), //
4964 }, 4964 },
4965 1, 4965 1,
4966 {InstanceType::FIXED_ARRAY_TYPE}}, 4966 {InstanceType::FIXED_ARRAY_TYPE}},
4967 {"var x = { 'a': 1, 'b': 2 };\n" 4967 {"var x = { 'a': 1, 'b': 2 };\n"
4968 "for (x['a'] in [10, 20, 30]) {\n" 4968 "for (x['a'] in [10, 20, 30]) {\n"
4969 " if (x['a'] == 10) continue;\n" 4969 " if (x['a'] == 10) continue;\n"
4970 " if (x['a'] == 20) break;\n" 4970 " if (x['a'] == 20) break;\n"
4971 "}", 4971 "}",
4972 7 * kPointerSize, 4972 7 * kPointerSize,
4973 1, 4973 1,
4974 80, 4974 77,
4975 { 4975 {
4976 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // 4976 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
4977 B(Star), R(0), // 4977 B(Star), R(0), //
4978 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // 4978 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
4979 B(JumpIfUndefined), U8(68), // 4979 B(JumpIfUndefined), U8(65), //
4980 B(JumpIfNull), U8(66), // 4980 B(JumpIfNull), U8(63), //
4981 B(ToObject), // 4981 B(ToObject), //
4982 B(JumpIfNull), U8(63), // 4982 B(JumpIfNull), U8(60), //
4983 B(Star), R(1), // 4983 B(Star), R(1), //
4984 B(ForInPrepare), R(2), R(3), R(4), // 4984 B(ForInPrepare), R(2), //
4985 B(LdaZero), // 4985 B(LdaZero), //
4986 B(Star), R(5), // 4986 B(Star), R(5), //
4987 B(ForInDone), R(5), R(4), // 4987 B(ForInDone), R(5), R(4), //
4988 B(JumpIfTrue), U8(49), // 4988 B(JumpIfTrue), U8(48), //
4989 B(ForInNext), R(1), R(2), R(3), R(5), // 4989 B(ForInNext), R(1), R(5), R(2), //
4990 B(JumpIfUndefined), U8(36), // 4990 B(JumpIfUndefined), U8(36), //
4991 B(Star), R(6), // 4991 B(Star), R(6), //
4992 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)), // 4992 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)), //
4993 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)), // 4993 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)), //
4994 B(Star), R(6), // 4994 B(Star), R(6), //
4995 B(LdaSmi8), U8(10), // 4995 B(LdaSmi8), U8(10), //
4996 B(TestEqual), R(6), // 4996 B(TestEqual), R(6), //
4997 B(JumpIfFalse), U8(4), // 4997 B(JumpIfFalse), U8(4), //
4998 B(Jump), U8(16), // 4998 B(Jump), U8(16), //
4999 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)), // 4999 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)), //
5000 B(Star), R(6), // 5000 B(Star), R(6), //
5001 B(LdaSmi8), U8(20), // 5001 B(LdaSmi8), U8(20), //
5002 B(TestEqual), R(6), // 5002 B(TestEqual), R(6), //
5003 B(JumpIfFalse), U8(4), // 5003 B(JumpIfFalse), U8(4), //
5004 B(Jump), U8(8), // 5004 B(Jump), U8(8), //
5005 B(ForInStep), R(5), // 5005 B(ForInStep), R(5), //
5006 B(Star), R(5), // 5006 B(Star), R(5), //
5007 B(Jump), U8(-50), // 5007 B(Jump), U8(-49), //
5008 B(LdaUndefined), // 5008 B(LdaUndefined), //
5009 B(Return), // 5009 B(Return), //
5010 }, 5010 },
5011 3, 5011 3,
5012 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, 5012 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
5013 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 5013 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
5014 {"var x = [ 10, 11, 12 ] ;\n" 5014 {"var x = [ 10, 11, 12 ] ;\n"
5015 "for (x[0] in [1,2,3]) { return x[3]; }", 5015 "for (x[0] in [1,2,3]) { return x[3]; }",
5016 8 * kPointerSize, 5016 8 * kPointerSize,
5017 1, 5017 1,
5018 63, 5018 60,
5019 { 5019 {
5020 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // 5020 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), //
5021 B(Star), R(0), // 5021 B(Star), R(0), //
5022 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // 5022 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
5023 B(JumpIfUndefined), U8(51), // 5023 B(JumpIfUndefined), U8(48), //
5024 B(JumpIfNull), U8(49), // 5024 B(JumpIfNull), U8(46), //
5025 B(ToObject), // 5025 B(ToObject), //
5026 B(JumpIfNull), U8(46), // 5026 B(JumpIfNull), U8(43), //
5027 B(Star), R(1), // 5027 B(Star), R(1), //
5028 B(ForInPrepare), R(2), R(3), R(4), // 5028 B(ForInPrepare), R(2), //
5029 B(LdaZero), // 5029 B(LdaZero), //
5030 B(Star), R(5), // 5030 B(Star), R(5), //
5031 B(ForInDone), R(5), R(4), // 5031 B(ForInDone), R(5), R(4), //
5032 B(JumpIfTrue), U8(32), // 5032 B(JumpIfTrue), U8(31), //
5033 B(ForInNext), R(1), R(2), R(3), R(5), // 5033 B(ForInNext), R(1), R(5), R(2), //
5034 B(JumpIfUndefined), U8(19), // 5034 B(JumpIfUndefined), U8(19), //
5035 B(Star), R(6), // 5035 B(Star), R(6), //
5036 B(LdaZero), // 5036 B(LdaZero), //
5037 B(Star), R(7), // 5037 B(Star), R(7), //
5038 B(Ldar), R(6), // 5038 B(Ldar), R(6), //
5039 B(KeyedStoreICSloppy), R(0), R(7), U8(vector->GetIndex(slot3)), // 5039 B(KeyedStoreICSloppy), R(0), R(7), U8(vector->GetIndex(slot3)), //
5040 B(LdaSmi8), U8(3), // 5040 B(LdaSmi8), U8(3), //
5041 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)), // 5041 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)), //
5042 B(Return), // 5042 B(Return), //
5043 B(ForInStep), R(5), // 5043 B(ForInStep), R(5), //
5044 B(Star), R(5), // 5044 B(Star), R(5), //
5045 B(Jump), U8(-33), // 5045 B(Jump), U8(-32), //
5046 B(LdaUndefined), // 5046 B(LdaUndefined), //
5047 B(Return), // 5047 B(Return), //
5048 }, 5048 },
5049 2, 5049 2,
5050 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, 5050 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}},
5051 }; 5051 };
5052 5052
5053 for (size_t i = 0; i < arraysize(snippets); i++) { 5053 for (size_t i = 0; i < arraysize(snippets); i++) {
5054 Handle<BytecodeArray> bytecode_array = 5054 Handle<BytecodeArray> bytecode_array =
5055 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 5055 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
6266 std::string(function_epilogue); 6266 std::string(function_epilogue);
6267 Handle<BytecodeArray> bytecode_array = 6267 Handle<BytecodeArray> bytecode_array =
6268 helper.MakeBytecode(script.c_str(), "t", "f"); 6268 helper.MakeBytecode(script.c_str(), "t", "f");
6269 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 6269 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
6270 } 6270 }
6271 } 6271 }
6272 6272
6273 } // namespace interpreter 6273 } // namespace interpreter
6274 } // namespace internal 6274 } // namespace internal
6275 } // namespace v8 6275 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698