OLD | NEW |
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 4669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 {"var x = 'potatoes';\n" | 4688 {"var x = 'potatoes';\n" |
4689 "for (var p in x) { return p; }", | 4689 "for (var p in x) { return p; }", |
4690 5 * kPointerSize, | 4690 9 * kPointerSize, |
4691 1, | 4691 1, |
4692 46, | 4692 80, |
4693 { | 4693 { |
4694 B(LdaConstant), U8(0), // | 4694 B(LdaConstant), U8(0), // |
4695 B(Star), R(1), // | 4695 B(Star), R(1), // |
4696 B(JumpIfUndefined), U8(40), // | 4696 B(JumpIfUndefined), U8(74), // |
4697 B(JumpIfNull), U8(38), // | 4697 B(JumpIfNull), U8(72), // |
4698 B(ToObject), // | 4698 B(ToObject), // |
4699 B(Star), R(3), // | 4699 B(Star), R(3), // |
4700 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // | 4700 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // |
4701 B(ForInPrepare), R(3), // | 4701 B(ForInPrepare), R(3), // |
4702 B(JumpIfUndefined), U8(26), // | 4702 B(JumpIfUndefined), U8(60), // |
4703 B(Star), R(4), // | 4703 B(Star), R(4), // |
4704 B(LdaZero), // | 4704 B(LdaZero), // |
4705 B(Star), R(3), // | 4705 B(Star), R(5), // |
4706 B(ForInDone), R(4), // | 4706 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(4), U8(2), // |
4707 B(JumpIfTrue), U8(17), // | 4707 B(Star), R(6), // |
4708 B(ForInNext), R(4), R(3), // | 4708 B(LdaSmi8), U8(1), // |
| 4709 B(Star), R(5), // |
| 4710 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(4), U8(2), // |
| 4711 B(Star), R(7), // |
| 4712 B(LdaSmi8), U8(2), // |
| 4713 B(Star), R(5), // |
| 4714 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(4), U8(2), // |
| 4715 B(Star), R(8), // |
| 4716 B(LdaZero), // |
| 4717 B(Star), R(4), // |
| 4718 B(ForInDone), R(4), R(8), // |
| 4719 B(JumpIfTrue), U8(18), // |
| 4720 B(ForInNext), R(3), R(4), R(7), R(6), // |
4709 B(JumpIfUndefined), U8(7), // | 4721 B(JumpIfUndefined), U8(7), // |
4710 B(Star), R(0), // | 4722 B(Star), R(0), // |
4711 B(Star), R(2), // | 4723 B(Star), R(2), // |
4712 B(Return), // | 4724 B(Return), // |
4713 B(Ldar), R(3), // | 4725 B(ForInStep), R(4), // |
4714 B(Inc), // | |
4715 B(Jump), U8(-19), // | 4726 B(Jump), U8(-19), // |
4716 B(LdaUndefined), // | 4727 B(LdaUndefined), // |
4717 B(Return), // | 4728 B(Return), // |
4718 }, | 4729 }, |
4719 1, | 4730 1, |
4720 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 4731 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
4721 {"var x = 0;\n" | 4732 {"var x = 0;\n" |
4722 "for (var p in [1,2,3]) { x += p; }", | 4733 "for (var p in [1,2,3]) { x += p; }", |
4723 5 * kPointerSize, | 4734 9 * kPointerSize, |
4724 1, | 4735 1, |
4725 52, | 4736 86, |
4726 { | 4737 { |
4727 B(LdaZero), // | 4738 B(LdaZero), // |
4728 B(Star), R(1), // | 4739 B(Star), R(1), // |
4729 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // | 4740 B(CreateArrayLiteral), U8(0), U8(0), U8(3), // |
4730 B(JumpIfUndefined), U8(43), // | 4741 B(JumpIfUndefined), U8(77), // |
4731 B(JumpIfNull), U8(41), // | 4742 B(JumpIfNull), U8(75), // |
4732 B(ToObject), // | 4743 B(ToObject), // |
4733 B(Star), R(3), // | 4744 B(Star), R(3), // |
4734 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // | 4745 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // |
4735 B(ForInPrepare), R(3), // | 4746 B(ForInPrepare), R(3), // |
4736 B(JumpIfUndefined), U8(29), // | 4747 B(JumpIfUndefined), U8(63), // |
4737 B(Star), R(4), // | 4748 B(Star), R(4), // |
4738 B(LdaZero), // | 4749 B(LdaZero), // |
4739 B(Star), R(3), // | 4750 B(Star), R(5), // |
4740 B(ForInDone), R(4), // | 4751 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(4), U8(2), // |
4741 B(JumpIfTrue), U8(20), // | 4752 B(Star), R(6), // |
4742 B(ForInNext), R(4), R(3), // | 4753 B(LdaSmi8), U8(1), // |
| 4754 B(Star), R(5), // |
| 4755 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(4), U8(2), // |
| 4756 B(Star), R(7), // |
| 4757 B(LdaSmi8), U8(2), // |
| 4758 B(Star), R(5), // |
| 4759 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(4), U8(2), // |
| 4760 B(Star), R(8), // |
| 4761 B(LdaZero), // |
| 4762 B(Star), R(4), // |
| 4763 B(ForInDone), R(4), R(8), // |
| 4764 B(JumpIfTrue), U8(21), // |
| 4765 B(ForInNext), R(3), R(4), R(7), R(6), // |
4743 B(JumpIfUndefined), U8(10), // | 4766 B(JumpIfUndefined), U8(10), // |
4744 B(Star), R(0), // | 4767 B(Star), R(0), // |
4745 B(Star), R(2), // | 4768 B(Star), R(2), // |
4746 B(Add), R(1), // | 4769 B(Add), R(1), // |
4747 B(Star), R(1), // | 4770 B(Star), R(1), // |
4748 B(Ldar), R(3), // | 4771 B(ForInStep), R(4), // |
4749 B(Inc), // | |
4750 B(Jump), U8(-22), // | 4772 B(Jump), U8(-22), // |
4751 B(LdaUndefined), // | 4773 B(LdaUndefined), // |
4752 B(Return), // | 4774 B(Return), // |
4753 }, | 4775 }, |
4754 1, | 4776 1, |
4755 {InstanceType::FIXED_ARRAY_TYPE}}, | 4777 {InstanceType::FIXED_ARRAY_TYPE}}, |
4756 {"var x = { 'a': 1, 'b': 2 };\n" | 4778 {"var x = { 'a': 1, 'b': 2 };\n" |
4757 "for (x['a'] in [10, 20, 30]) {\n" | 4779 "for (x['a'] in [10, 20, 30]) {\n" |
4758 " if (x['a'] == 10) continue;\n" | 4780 " if (x['a'] == 10) continue;\n" |
4759 " if (x['a'] == 20) break;\n" | 4781 " if (x['a'] == 20) break;\n" |
4760 "}", | 4782 "}", |
4761 4 * kPointerSize, | 4783 8 * kPointerSize, |
4762 1, | 4784 1, |
4763 81, | 4785 115, |
4764 { | 4786 { |
4765 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 4787 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
4766 B(Star), R(0), // | 4788 B(Star), R(0), // |
4767 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // | 4789 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // |
4768 B(JumpIfUndefined), U8(69), // | 4790 B(JumpIfUndefined), U8(103), // |
4769 B(JumpIfNull), U8(67), // | 4791 B(JumpIfNull), U8(101), // |
4770 B(ToObject), // | 4792 B(ToObject), // |
4771 B(Star), R(1), // | 4793 B(Star), R(1), // |
4772 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // | 4794 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // |
4773 B(ForInPrepare), R(1), // | 4795 B(ForInPrepare), R(1), // |
4774 B(JumpIfUndefined), U8(55), // | 4796 B(JumpIfUndefined), U8(89), // |
4775 B(Star), R(2), // | 4797 B(Star), R(2), // |
4776 B(LdaZero), // | 4798 B(LdaZero), // |
4777 B(Star), R(1), // | 4799 B(Star), R(3), // |
4778 B(ForInDone), R(2), // | 4800 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(2), U8(2), // |
4779 B(JumpIfTrue), U8(46), // | 4801 B(Star), R(4), // |
4780 B(ForInNext), R(2), R(1), // | 4802 B(LdaSmi8), U8(1), // |
| 4803 B(Star), R(3), // |
| 4804 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(2), U8(2), // |
| 4805 B(Star), R(5), // |
| 4806 B(LdaSmi8), U8(2), // |
| 4807 B(Star), R(3), // |
| 4808 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(2), U8(2), // |
| 4809 B(Star), R(6), // |
| 4810 B(LdaZero), // |
| 4811 B(Star), R(2), // |
| 4812 B(ForInDone), R(2), R(6), // |
| 4813 B(JumpIfTrue), U8(47), // |
| 4814 B(ForInNext), R(1), R(2), R(5), R(4), // |
4781 B(JumpIfUndefined), U8(36), // | 4815 B(JumpIfUndefined), U8(36), // |
4782 B(Star), R(3), // | 4816 B(Star), R(7), // |
4783 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)), // | 4817 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot4)), // |
4784 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)), // | 4818 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot2)), // |
4785 B(Star), R(3), // | 4819 B(Star), R(7), // |
4786 B(LdaSmi8), U8(10), // | 4820 B(LdaSmi8), U8(10), // |
4787 B(TestEqual), R(3), // | 4821 B(TestEqual), R(7), // |
4788 B(JumpIfFalse), U8(4), // | 4822 B(JumpIfFalse), U8(4), // |
4789 B(Jump), U8(16), // | 4823 B(Jump), U8(16), // |
4790 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)), // | 4824 B(LoadICSloppy), R(0), U8(2), U8(vector->GetIndex(slot3)), // |
4791 B(Star), R(3), // | 4825 B(Star), R(7), // |
4792 B(LdaSmi8), U8(20), // | 4826 B(LdaSmi8), U8(20), // |
4793 B(TestEqual), R(3), // | 4827 B(TestEqual), R(7), // |
4794 B(JumpIfFalse), U8(4), // | 4828 B(JumpIfFalse), U8(4), // |
4795 B(Jump), U8(7), // | 4829 B(Jump), U8(6), // |
4796 B(Ldar), R(1), // | 4830 B(ForInStep), R(2), // |
4797 B(Inc), // | |
4798 B(Jump), U8(-48), // | 4831 B(Jump), U8(-48), // |
4799 B(LdaUndefined), // | 4832 B(LdaUndefined), // |
4800 B(Return), // | 4833 B(Return), // |
4801 }, | 4834 }, |
4802 3, | 4835 3, |
4803 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, | 4836 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
4804 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 4837 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
4805 {"var x = [ 10, 11, 12 ] ;\n" | 4838 {"var x = [ 10, 11, 12 ] ;\n" |
4806 "for (x[0] in [1,2,3]) { return x[3]; }", | 4839 "for (x[0] in [1,2,3]) { return x[3]; }", |
4807 5 * kPointerSize, | 4840 9 * kPointerSize, |
4808 1, | 4841 1, |
4809 64, | 4842 98, |
4810 { | 4843 { |
4811 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // | 4844 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), // |
4812 B(Star), R(0), // | 4845 B(Star), R(0), // |
4813 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // | 4846 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), // |
4814 B(JumpIfUndefined), U8(52), // | 4847 B(JumpIfUndefined), U8(86), // |
4815 B(JumpIfNull), U8(50), // | 4848 B(JumpIfNull), U8(84), // |
4816 B(ToObject), // | 4849 B(ToObject), // |
4817 B(Star), R(1), // | 4850 B(Star), R(1), // |
4818 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // | 4851 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // |
4819 B(ForInPrepare), R(1), // | 4852 B(ForInPrepare), R(1), // |
4820 B(JumpIfUndefined), U8(38), // | 4853 B(JumpIfUndefined), U8(72), // |
4821 B(Star), R(2), // | 4854 B(Star), R(2), // |
4822 B(LdaZero), // | 4855 B(LdaZero), // |
4823 B(Star), R(1), // | 4856 B(Star), R(3), // |
4824 B(ForInDone), R(2), // | 4857 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(2), U8(2), // |
4825 B(JumpIfTrue), U8(29), // | 4858 B(Star), R(4), // |
4826 B(ForInNext), R(2), R(1), // | 4859 B(LdaSmi8), U8(1), // |
| 4860 B(Star), R(3), // |
| 4861 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(2), U8(2), // |
| 4862 B(Star), R(5), // |
| 4863 B(LdaSmi8), U8(2), // |
| 4864 B(Star), R(3), // |
| 4865 B(CallRuntime), U16(Runtime::kFixedArrayGet), R(2), U8(2), // |
| 4866 B(Star), R(6), // |
| 4867 B(LdaZero), // |
| 4868 B(Star), R(2), // |
| 4869 B(ForInDone), R(2), R(6), // |
| 4870 B(JumpIfTrue), U8(30), // |
| 4871 B(ForInNext), R(1), R(2), R(5), R(4), // |
4827 B(JumpIfUndefined), U8(19), // | 4872 B(JumpIfUndefined), U8(19), // |
4828 B(Star), R(3), // | 4873 B(Star), R(7), // |
4829 B(LdaZero), // | 4874 B(LdaZero), // |
4830 B(Star), R(4), // | 4875 B(Star), R(8), // |
4831 B(Ldar), R(3), // | 4876 B(Ldar), R(7), // |
4832 B(KeyedStoreICSloppy), R(0), R(4), U8(vector->GetIndex(slot3)), // | 4877 B(KeyedStoreICSloppy), R(0), R(8), U8(vector->GetIndex(slot3)), // |
4833 B(LdaSmi8), U8(3), // | 4878 B(LdaSmi8), U8(3), // |
4834 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)), // | 4879 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot2)), // |
4835 B(Return), // | 4880 B(Return), // |
4836 B(Ldar), R(1), // | 4881 B(ForInStep), R(2), // |
4837 B(Inc), // | |
4838 B(Jump), U8(-31), // | 4882 B(Jump), U8(-31), // |
4839 B(LdaUndefined), // | 4883 B(LdaUndefined), // |
4840 B(Return), // | 4884 B(Return), // |
4841 }, | 4885 }, |
4842 2, | 4886 2, |
4843 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, | 4887 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, |
4844 }; | 4888 }; |
4845 | 4889 |
4846 for (size_t i = 0; i < arraysize(snippets); i++) { | 4890 for (size_t i = 0; i < arraysize(snippets); i++) { |
4847 Handle<BytecodeArray> bytecode_array = | 4891 Handle<BytecodeArray> bytecode_array = |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5630 for (size_t i = 0; i < arraysize(snippets); i++) { | 5674 for (size_t i = 0; i < arraysize(snippets); i++) { |
5631 Handle<BytecodeArray> bytecode_array = | 5675 Handle<BytecodeArray> bytecode_array = |
5632 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 5676 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
5633 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 5677 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
5634 } | 5678 } |
5635 } | 5679 } |
5636 | 5680 |
5637 } // namespace interpreter | 5681 } // namespace interpreter |
5638 } // namespace internal | 5682 } // namespace internal |
5639 } // namespace v8 | 5683 } // namespace v8 |
OLD | NEW |