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

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

Issue 1531693002: [Interpreter] Implement ForIn in bytecode graph builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth-0009-phi
Patch Set: Minor clean-up/simplication in Runtime_InterpreterForInPrepare. Created 5 years 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 4756 matching lines...) Expand 10 before | Expand all | Expand 10 after
4767 1, 4767 1,
4768 2, 4768 2,
4769 {B(LdaUndefined), B(Return)}, 4769 {B(LdaUndefined), B(Return)},
4770 0}, 4770 0},
4771 {"for (var p in undefined) {}", 4771 {"for (var p in undefined) {}",
4772 2 * kPointerSize, 4772 2 * kPointerSize,
4773 1, 4773 1,
4774 2, 4774 2,
4775 {B(LdaUndefined), B(Return)}, 4775 {B(LdaUndefined), B(Return)},
4776 0}, 4776 0},
4777 {"for (var p in undefined) {}",
4778 2 * kPointerSize,
4779 1,
4780 2,
4781 {B(LdaUndefined), B(Return)},
4782 0},
4777 {"var x = 'potatoes';\n" 4783 {"var x = 'potatoes';\n"
4778 "for (var p in x) { return p; }", 4784 "for (var p in x) { return p; }",
4779 5 * kPointerSize, 4785 8 * kPointerSize,
4780 1, 4786 1,
4781 46, 4787 45,
4782 { 4788 {
4783 B(LdaConstant), U8(0), // 4789 B(LdaConstant), U8(0), //
4784 B(Star), R(1), // 4790 B(Star), R(1), //
4785 B(JumpIfUndefined), U8(40), // 4791 B(JumpIfUndefined), U8(39), //
4786 B(JumpIfNull), U8(38), // 4792 B(JumpIfNull), U8(37), //
4787 B(ToObject), // 4793 B(ToObject), //
4788 B(Star), R(3), // 4794 B(JumpIfNull), U8(34), //
4789 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // 4795 B(Star), R(3), //
4790 B(ForInPrepare), R(3), // 4796 B(ForInPrepare), R(4), R(5), R(6), //
4791 B(JumpIfUndefined), U8(26), // 4797 B(LdaZero), //
4792 B(Star), R(4), // 4798 B(Star), R(7), //
4793 B(LdaZero), // 4799 B(ForInDone), R(7), R(6), //
4794 B(Star), R(3), // 4800 B(JumpIfTrue), U8(20), //
4795 B(ForInDone), R(4), // 4801 B(ForInNext), R(3), R(4), R(5), R(7), //
4796 B(JumpIfTrue), U8(17), // 4802 B(JumpIfUndefined), U8(7), //
4797 B(ForInNext), R(4), R(3), // 4803 B(Star), R(0), //
4798 B(JumpIfUndefined), U8(7), // 4804 B(Star), R(2), //
4799 B(Star), R(0), // 4805 B(Return), //
4800 B(Star), R(2), // 4806 B(ForInStep), R(7), //
4801 B(Return), // 4807 B(Star), R(7), //
4802 B(Ldar), R(3), // 4808 B(Jump), U8(-21), //
4803 B(Inc), // 4809 B(LdaUndefined), //
4804 B(Jump), U8(-19), // 4810 B(Return), //
4805 B(LdaUndefined), //
4806 B(Return), //
4807 }, 4811 },
4808 1, 4812 1,
4809 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4813 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
4810 {"var x = 0;\n" 4814 {"var x = 0;\n"
4811 "for (var p in [1,2,3]) { x += p; }", 4815 "for (var p in [1,2,3]) { x += p; }",
4812 5 * kPointerSize, 4816 8 * kPointerSize,
4813 1, 4817 1,
4814 52, 4818 51,
4815 { 4819 {
4816 B(LdaZero), // 4820 B(LdaZero), //
4817 B(Star), R(1), // 4821 B(Star), R(1), //
4818 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // 4822 B(CreateArrayLiteral), U8(0), U8(0), U8(3), //
4819 B(JumpIfUndefined), U8(43), // 4823 B(JumpIfUndefined), U8(42), //
4820 B(JumpIfNull), U8(41), // 4824 B(JumpIfNull), U8(40), //
4821 B(ToObject), // 4825 B(ToObject), //
4822 B(Star), R(3), // 4826 B(JumpIfNull), U8(37), //
4823 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // 4827 B(Star), R(3), //
4824 B(ForInPrepare), R(3), // 4828 B(ForInPrepare), R(4), R(5), R(6), //
4825 B(JumpIfUndefined), U8(29), // 4829 B(LdaZero), //
4826 B(Star), R(4), // 4830 B(Star), R(7), //
4827 B(LdaZero), // 4831 B(ForInDone), R(7), R(6), //
4828 B(Star), R(3), // 4832 B(JumpIfTrue), U8(23), //
4829 B(ForInDone), R(4), // 4833 B(ForInNext), R(3), R(4), R(5), R(7), //
4830 B(JumpIfTrue), U8(20), // 4834 B(JumpIfUndefined), U8(10), //
4831 B(ForInNext), R(4), R(3), // 4835 B(Star), R(0), //
4832 B(JumpIfUndefined), U8(10), // 4836 B(Star), R(2), //
4833 B(Star), R(0), // 4837 B(Add), R(1), //
4834 B(Star), R(2), // 4838 B(Star), R(1), //
4835 B(Add), R(1), // 4839 B(ForInStep), R(7), //
4836 B(Star), R(1), // 4840 B(Star), R(7), //
4837 B(Ldar), R(3), // 4841 B(Jump), U8(-24), //
4838 B(Inc), // 4842 B(LdaUndefined), //
4839 B(Jump), U8(-22), // 4843 B(Return), //
4840 B(LdaUndefined), //
4841 B(Return), //
4842 }, 4844 },
4843 1, 4845 1,
4844 {InstanceType::FIXED_ARRAY_TYPE}}, 4846 {InstanceType::FIXED_ARRAY_TYPE}},
4845 {"var x = { 'a': 1, 'b': 2 };\n" 4847 {"var x = { 'a': 1, 'b': 2 };\n"
4846 "for (x['a'] in [10, 20, 30]) {\n" 4848 "for (x['a'] in [10, 20, 30]) {\n"
4847 " if (x['a'] == 10) continue;\n" 4849 " if (x['a'] == 10) continue;\n"
4848 " if (x['a'] == 20) break;\n" 4850 " if (x['a'] == 20) break;\n"
4849 "}", 4851 "}",
4850 4 * kPointerSize, 4852 7 * kPointerSize,
4851 1, 4853 1,
4852 81, 4854 80,
4853 { 4855 {
4854 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // 4856 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
4855 B(Star), R(0), // 4857 B(Star), R(0), //
4856 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // 4858 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
4857 B(JumpIfUndefined), U8(69), // 4859 B(JumpIfUndefined), U8(68), //
4858 B(JumpIfNull), U8(67), // 4860 B(JumpIfNull), U8(66), //
4859 B(ToObject), // 4861 B(ToObject), //
4860 B(Star), R(1), // 4862 B(JumpIfNull), U8(63), //
4861 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // 4863 B(Star), R(1), //
4862 B(ForInPrepare), R(1), // 4864 B(ForInPrepare), R(2), R(3), R(4), //
4863 B(JumpIfUndefined), U8(55), // 4865 B(LdaZero), //
4864 B(Star), R(2), // 4866 B(Star), R(5), //
4865 B(LdaZero), // 4867 B(ForInDone), R(5), R(4), //
4866 B(Star), R(1), // 4868 B(JumpIfTrue), U8(49), //
4867 B(ForInDone), R(2), // 4869 B(ForInNext), R(1), R(2), R(3), R(5), //
4868 B(JumpIfTrue), U8(46), // 4870 B(JumpIfUndefined), U8(36), //
4869 B(ForInNext), R(2), R(1), // 4871 B(Star), R(6), //
4870 B(JumpIfUndefined), U8(36), // 4872 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)), //
4871 B(Star), R(3), // 4873 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)), //
4872 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)), // 4874 B(Star), R(6), //
4873 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)), // 4875 B(LdaSmi8), U8(10), //
4874 B(Star), R(3), // 4876 B(TestEqual), R(6), //
4875 B(LdaSmi8), U8(10), // 4877 B(JumpIfFalse), U8(4), //
4876 B(TestEqual), R(3), // 4878 B(Jump), U8(16), //
4877 B(JumpIfFalse), U8(4), // 4879 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)), //
4878 B(Jump), U8(16), // 4880 B(Star), R(6), //
4879 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)), // 4881 B(LdaSmi8), U8(20), //
4880 B(Star), R(3), // 4882 B(TestEqual), R(6), //
4881 B(LdaSmi8), U8(20), // 4883 B(JumpIfFalse), U8(4), //
4882 B(TestEqual), R(3), // 4884 B(Jump), U8(8), //
4883 B(JumpIfFalse), U8(4), // 4885 B(ForInStep), R(5), //
4884 B(Jump), U8(7), // 4886 B(Star), R(5), //
4885 B(Ldar), R(1), // 4887 B(Jump), U8(-50), //
4886 B(Inc), // 4888 B(LdaUndefined), //
4887 B(Jump), U8(-48), // 4889 B(Return), //
4888 B(LdaUndefined), //
4889 B(Return), //
4890 }, 4890 },
4891 3, 4891 3,
4892 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, 4892 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
4893 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4893 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
4894 {"var x = [ 10, 11, 12 ] ;\n" 4894 {"var x = [ 10, 11, 12 ] ;\n"
4895 "for (x[0] in [1,2,3]) { return x[3]; }", 4895 "for (x[0] in [1,2,3]) { return x[3]; }",
4896 5 * kPointerSize, 4896 8 * kPointerSize,
4897 1, 4897 1,
4898 64, 4898 63,
4899 { 4899 {
4900 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // 4900 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), //
4901 B(Star), R(0), // 4901 B(Star), R(0), //
4902 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // 4902 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
4903 B(JumpIfUndefined), U8(52), // 4903 B(JumpIfUndefined), U8(51), //
4904 B(JumpIfNull), U8(50), // 4904 B(JumpIfNull), U8(49), //
4905 B(ToObject), // 4905 B(ToObject), //
4906 B(Star), R(1), // 4906 B(JumpIfNull), U8(46), //
4907 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // 4907 B(Star), R(1), //
4908 B(ForInPrepare), R(1), // 4908 B(ForInPrepare), R(2), R(3), R(4), //
4909 B(JumpIfUndefined), U8(38), // 4909 B(LdaZero), //
4910 B(Star), R(2), // 4910 B(Star), R(5), //
4911 B(LdaZero), // 4911 B(ForInDone), R(5), R(4), //
4912 B(Star), R(1), // 4912 B(JumpIfTrue), U8(32), //
4913 B(ForInDone), R(2), // 4913 B(ForInNext), R(1), R(2), R(3), R(5), //
4914 B(JumpIfTrue), U8(29), // 4914 B(JumpIfUndefined), U8(19), //
4915 B(ForInNext), R(2), R(1), // 4915 B(Star), R(6), //
4916 B(JumpIfUndefined), U8(19), // 4916 B(LdaZero), //
4917 B(Star), R(3), // 4917 B(Star), R(7), //
4918 B(LdaZero), // 4918 B(Ldar), R(6), //
4919 B(Star), R(4), // 4919 B(KeyedStoreICSloppy), R(0), R(7), U8(vector->GetIndex(slot3)), //
4920 B(Ldar), R(3), // 4920 B(LdaSmi8), U8(3), //
4921 B(KeyedStoreICSloppy), R(0), R(4), U8(vector->GetIndex(slot3)), // 4921 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)), //
4922 B(LdaSmi8), U8(3), // 4922 B(Return), //
4923 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)), // 4923 B(ForInStep), R(5), //
4924 B(Return), // 4924 B(Star), R(5), //
4925 B(Ldar), R(1), // 4925 B(Jump), U8(-33), //
4926 B(Inc), // 4926 B(LdaUndefined), //
4927 B(Jump), U8(-31), // 4927 B(Return), //
4928 B(LdaUndefined), //
4929 B(Return), //
4930 }, 4928 },
4931 2, 4929 2,
4932 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, 4930 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}},
4933 }; 4931 };
4934 4932
4935 for (size_t i = 0; i < arraysize(snippets); i++) { 4933 for (size_t i = 0; i < arraysize(snippets); i++) {
4936 Handle<BytecodeArray> bytecode_array = 4934 Handle<BytecodeArray> bytecode_array =
4937 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 4935 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
4938 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 4936 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
4939 } 4937 }
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
5792 // inside eval. 5790 // inside eval.
5793 Handle<BytecodeArray> bytecode_array = 5791 Handle<BytecodeArray> bytecode_array =
5794 helper.MakeBytecode(script.c_str(), "t", "f"); 5792 helper.MakeBytecode(script.c_str(), "t", "f");
5795 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 5793 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5796 } 5794 }
5797 } 5795 }
5798 5796
5799 } // namespace interpreter 5797 } // namespace interpreter
5800 } // namespace internal 5798 } // namespace internal
5801 } // namespace v8 5799 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698