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

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: Fix missing comment. 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 4667 matching lines...) Expand 10 before | Expand all | Expand 10 after
4678 1, 4678 1,
4679 2, 4679 2,
4680 {B(LdaUndefined), B(Return)}, 4680 {B(LdaUndefined), B(Return)},
4681 0}, 4681 0},
4682 {"for (var p in undefined) {}", 4682 {"for (var p in undefined) {}",
4683 2 * kPointerSize, 4683 2 * kPointerSize,
4684 1, 4684 1,
4685 2, 4685 2,
4686 {B(LdaUndefined), B(Return)}, 4686 {B(LdaUndefined), B(Return)},
4687 0}, 4687 0},
4688 {"for (var p in undefined) {}",
4689 2 * kPointerSize,
4690 1,
4691 2,
4692 {B(LdaUndefined), B(Return)},
4693 0},
4688 {"var x = 'potatoes';\n" 4694 {"var x = 'potatoes';\n"
4689 "for (var p in x) { return p; }", 4695 "for (var p in x) { return p; }",
4690 5 * kPointerSize, 4696 8 * kPointerSize,
4691 1, 4697 1,
4692 46, 4698 44,
4693 { 4699 {
4694 B(LdaConstant), U8(0), // 4700 B(LdaConstant), U8(0), //
4695 B(Star), R(1), // 4701 B(Star), R(1), //
4696 B(JumpIfUndefined), U8(40), // 4702 B(JumpIfUndefined), U8(38), //
4697 B(JumpIfNull), U8(38), // 4703 B(JumpIfNull), U8(36), //
4698 B(ToObject), // 4704 B(ToObject), //
4699 B(Star), R(3), // 4705 B(JumpIfNull), U8(33), //
4700 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // 4706 B(Star), R(3), //
4701 B(ForInPrepare), R(3), // 4707 B(ForInPrepare), R(3), R(4), R(5), R(6), //
4702 B(JumpIfUndefined), U8(26), // 4708 B(LdaZero), //
4703 B(Star), R(4), // 4709 B(Star), R(7), //
4704 B(LdaZero), // 4710 B(ForInDone), R(7), R(6), //
4705 B(Star), R(3), // 4711 B(JumpIfTrue), U8(18), //
4706 B(ForInDone), R(4), // 4712 B(ForInNext), R(3), R(4), R(5), R(7), //
4707 B(JumpIfTrue), U8(17), // 4713 B(JumpIfUndefined), U8(7), //
4708 B(ForInNext), R(4), R(3), // 4714 B(Star), R(0), //
4709 B(JumpIfUndefined), U8(7), // 4715 B(Star), R(2), //
4710 B(Star), R(0), // 4716 B(Return), //
4711 B(Star), R(2), // 4717 B(ForInStep), R(7), //
4712 B(Return), // 4718 B(Jump), U8(-19), //
4713 B(Ldar), R(3), // 4719 B(LdaUndefined), //
4714 B(Inc), // 4720 B(Return), //
4715 B(Jump), U8(-19), //
4716 B(LdaUndefined), //
4717 B(Return), //
4718 }, 4721 },
4719 1, 4722 1,
4720 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4723 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
4721 {"var x = 0;\n" 4724 {"var x = 0;\n"
4722 "for (var p in [1,2,3]) { x += p; }", 4725 "for (var p in [1,2,3]) { x += p; }",
4723 5 * kPointerSize, 4726 8 * kPointerSize,
4724 1, 4727 1,
4725 52, 4728 50,
4726 { 4729 {
4727 B(LdaZero), // 4730 B(LdaZero), //
4728 B(Star), R(1), // 4731 B(Star), R(1), //
4729 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // 4732 B(CreateArrayLiteral), U8(0), U8(0), U8(3), //
4730 B(JumpIfUndefined), U8(43), // 4733 B(JumpIfUndefined), U8(41), //
4731 B(JumpIfNull), U8(41), // 4734 B(JumpIfNull), U8(39), //
4732 B(ToObject), // 4735 B(ToObject), //
4733 B(Star), R(3), // 4736 B(JumpIfNull), U8(36), //
4734 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // 4737 B(Star), R(3), //
4735 B(ForInPrepare), R(3), // 4738 B(ForInPrepare), R(3), R(4), R(5), R(6), //
4736 B(JumpIfUndefined), U8(29), // 4739 B(LdaZero), //
4737 B(Star), R(4), // 4740 B(Star), R(7), //
4738 B(LdaZero), // 4741 B(ForInDone), R(7), R(6), //
4739 B(Star), R(3), // 4742 B(JumpIfTrue), U8(21), //
4740 B(ForInDone), R(4), // 4743 B(ForInNext), R(3), R(4), R(5), R(7), //
4741 B(JumpIfTrue), U8(20), // 4744 B(JumpIfUndefined), U8(10), //
4742 B(ForInNext), R(4), R(3), // 4745 B(Star), R(0), //
4743 B(JumpIfUndefined), U8(10), // 4746 B(Star), R(2), //
4744 B(Star), R(0), // 4747 B(Add), R(1), //
4745 B(Star), R(2), // 4748 B(Star), R(1), //
4746 B(Add), R(1), // 4749 B(ForInStep), R(7), //
4747 B(Star), R(1), // 4750 B(Jump), U8(-22), //
4748 B(Ldar), R(3), // 4751 B(LdaUndefined), //
4749 B(Inc), // 4752 B(Return), //
4750 B(Jump), U8(-22), //
4751 B(LdaUndefined), //
4752 B(Return), //
4753 }, 4753 },
4754 1, 4754 1,
4755 {InstanceType::FIXED_ARRAY_TYPE}}, 4755 {InstanceType::FIXED_ARRAY_TYPE}},
4756 {"var x = { 'a': 1, 'b': 2 };\n" 4756 {"var x = { 'a': 1, 'b': 2 };\n"
4757 "for (x['a'] in [10, 20, 30]) {\n" 4757 "for (x['a'] in [10, 20, 30]) {\n"
4758 " if (x['a'] == 10) continue;\n" 4758 " if (x['a'] == 10) continue;\n"
4759 " if (x['a'] == 20) break;\n" 4759 " if (x['a'] == 20) break;\n"
4760 "}", 4760 "}",
4761 4 * kPointerSize, 4761 7 * kPointerSize,
4762 1, 4762 1,
4763 81, 4763 79,
4764 { 4764 {
4765 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // 4765 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
4766 B(Star), R(0), // 4766 B(Star), R(0), //
4767 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // 4767 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
4768 B(JumpIfUndefined), U8(69), // 4768 B(JumpIfUndefined), U8(67), //
4769 B(JumpIfNull), U8(67), // 4769 B(JumpIfNull), U8(65), //
4770 B(ToObject), // 4770 B(ToObject), //
4771 B(Star), R(1), // 4771 B(JumpIfNull), U8(62), //
4772 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // 4772 B(Star), R(1), //
4773 B(ForInPrepare), R(1), // 4773 B(ForInPrepare), R(1), R(2), R(3), R(4), //
4774 B(JumpIfUndefined), U8(55), // 4774 B(LdaZero), //
4775 B(Star), R(2), // 4775 B(Star), R(5), //
4776 B(LdaZero), // 4776 B(ForInDone), R(5), R(4), //
4777 B(Star), R(1), // 4777 B(JumpIfTrue), U8(47), //
4778 B(ForInDone), R(2), // 4778 B(ForInNext), R(1), R(2), R(3), R(5), //
4779 B(JumpIfTrue), U8(46), // 4779 B(JumpIfUndefined), U8(36), //
4780 B(ForInNext), R(2), R(1), // 4780 B(Star), R(6), //
4781 B(JumpIfUndefined), U8(36), // 4781 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)), //
4782 B(Star), R(3), // 4782 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)), //
4783 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)), // 4783 B(Star), R(6), //
4784 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)), // 4784 B(LdaSmi8), U8(10), //
4785 B(Star), R(3), // 4785 B(TestEqual), R(6), //
4786 B(LdaSmi8), U8(10), // 4786 B(JumpIfFalse), U8(4), //
4787 B(TestEqual), R(3), // 4787 B(Jump), U8(16), //
4788 B(JumpIfFalse), U8(4), // 4788 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)), //
4789 B(Jump), U8(16), // 4789 B(Star), R(6), //
4790 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)), // 4790 B(LdaSmi8), U8(20), //
4791 B(Star), R(3), // 4791 B(TestEqual), R(6), //
4792 B(LdaSmi8), U8(20), // 4792 B(JumpIfFalse), U8(4), //
4793 B(TestEqual), R(3), // 4793 B(Jump), U8(6), //
4794 B(JumpIfFalse), U8(4), // 4794 B(ForInStep), R(5), //
4795 B(Jump), U8(7), // 4795 B(Jump), U8(-48), //
4796 B(Ldar), R(1), // 4796 B(LdaUndefined), //
4797 B(Inc), // 4797 B(Return), //
4798 B(Jump), U8(-48), //
4799 B(LdaUndefined), //
4800 B(Return), //
4801 }, 4798 },
4802 3, 4799 3,
4803 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, 4800 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
4804 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4801 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
4805 {"var x = [ 10, 11, 12 ] ;\n" 4802 {"var x = [ 10, 11, 12 ] ;\n"
4806 "for (x[0] in [1,2,3]) { return x[3]; }", 4803 "for (x[0] in [1,2,3]) { return x[3]; }",
4807 5 * kPointerSize, 4804 8 * kPointerSize,
4808 1, 4805 1,
4809 64, 4806 62,
4810 { 4807 {
4811 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // 4808 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), //
4812 B(Star), R(0), // 4809 B(Star), R(0), //
4813 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // 4810 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
4814 B(JumpIfUndefined), U8(52), // 4811 B(JumpIfUndefined), U8(50), //
4815 B(JumpIfNull), U8(50), // 4812 B(JumpIfNull), U8(48), //
4816 B(ToObject), // 4813 B(ToObject), //
4817 B(Star), R(1), // 4814 B(JumpIfNull), U8(45), //
4818 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // 4815 B(Star), R(1), //
4819 B(ForInPrepare), R(1), // 4816 B(ForInPrepare), R(1), R(2), R(3), R(4), //
4820 B(JumpIfUndefined), U8(38), // 4817 B(LdaZero), //
4821 B(Star), R(2), // 4818 B(Star), R(5), //
4822 B(LdaZero), // 4819 B(ForInDone), R(5), R(4), //
4823 B(Star), R(1), // 4820 B(JumpIfTrue), U8(30), //
4824 B(ForInDone), R(2), // 4821 B(ForInNext), R(1), R(2), R(3), R(5), //
4825 B(JumpIfTrue), U8(29), // 4822 B(JumpIfUndefined), U8(19), //
4826 B(ForInNext), R(2), R(1), // 4823 B(Star), R(6), //
4827 B(JumpIfUndefined), U8(19), // 4824 B(LdaZero), //
4828 B(Star), R(3), // 4825 B(Star), R(7), //
4829 B(LdaZero), // 4826 B(Ldar), R(6), //
4830 B(Star), R(4), // 4827 B(KeyedStoreICSloppy), R(0), R(7), U8(vector->GetIndex(slot3)), //
4831 B(Ldar), R(3), // 4828 B(LdaSmi8), U8(3), //
4832 B(KeyedStoreICSloppy), R(0), R(4), U8(vector->GetIndex(slot3)), // 4829 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)), //
4833 B(LdaSmi8), U8(3), // 4830 B(Return), //
4834 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)), // 4831 B(ForInStep), R(5), //
4835 B(Return), // 4832 B(Jump), U8(-31), //
4836 B(Ldar), R(1), // 4833 B(LdaUndefined), //
4837 B(Inc), // 4834 B(Return), //
4838 B(Jump), U8(-31), //
4839 B(LdaUndefined), //
4840 B(Return), //
4841 }, 4835 },
4842 2, 4836 2,
4843 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, 4837 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}},
4844 }; 4838 };
4845 4839
4846 for (size_t i = 0; i < arraysize(snippets); i++) { 4840 for (size_t i = 0; i < arraysize(snippets); i++) {
4847 Handle<BytecodeArray> bytecode_array = 4841 Handle<BytecodeArray> bytecode_array =
4848 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 4842 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
4849 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 4843 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
4850 } 4844 }
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
5630 for (size_t i = 0; i < arraysize(snippets); i++) { 5624 for (size_t i = 0; i < arraysize(snippets); i++) {
5631 Handle<BytecodeArray> bytecode_array = 5625 Handle<BytecodeArray> bytecode_array =
5632 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 5626 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
5633 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 5627 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5634 } 5628 }
5635 } 5629 }
5636 5630
5637 } // namespace interpreter 5631 } // namespace interpreter
5638 } // namespace internal 5632 } // namespace internal
5639 } // namespace v8 5633 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698