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