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 7558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7569 int context = Register::current_context().index(); | 7569 int context = Register::current_context().index(); |
7570 int new_target = Register::new_target().index(); | 7570 int new_target = Register::new_target().index(); |
7571 | 7571 |
7572 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 7572 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
7573 | 7573 |
7574 // clang-format off | 7574 // clang-format off |
7575 ExpectedSnippet<const char*> snippets[] = { | 7575 ExpectedSnippet<const char*> snippets[] = { |
7576 {"return eval('1;');", | 7576 {"return eval('1;');", |
7577 9 * kPointerSize, | 7577 9 * kPointerSize, |
7578 1, | 7578 1, |
7579 68, | 7579 65, |
7580 { | 7580 { |
7581 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 7581 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
7582 /* */ U8(1), // | 7582 /* */ U8(1), // |
7583 B(PushContext), R(0), // | 7583 B(PushContext), R(0), // |
7584 B(Ldar), THIS(1), // | 7584 B(Ldar), THIS(1), // |
7585 B(StaContextSlot), R(context), U8(first_context_slot), // | 7585 B(StaContextSlot), R(context), U8(first_context_slot), // |
7586 B(CreateMappedArguments), // | 7586 B(CreateMappedArguments), // |
7587 B(StaContextSlot), R(context), U8(first_context_slot + 1), // | 7587 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
7588 B(Ldar), R(new_target), // | 7588 B(Ldar), R(new_target), // |
7589 B(StaContextSlot), R(context), U8(first_context_slot + 2), // | 7589 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
7590 B(StackCheck), // | 7590 B(StackCheck), // |
7591 B(Mov), R(context), R(3), // | |
7592 B(LdaConstant), U8(0), // | 7591 B(LdaConstant), U8(0), // |
7593 B(Star), R(4), // | 7592 B(Star), R(3), // |
7594 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 7593 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // |
7595 /* */ R(3), U8(2), R(1), // | 7594 /* */ R(3), U8(1), R(1), // |
7596 B(LdaConstant), U8(1), // | 7595 B(LdaConstant), U8(1), // |
7597 B(Star), R(3), // | 7596 B(Star), R(3), // |
7598 B(Mov), R(1), R(4), // | 7597 B(Mov), R(1), R(4), // |
7599 B(Mov), R(3), R(5), // | 7598 B(Mov), R(3), R(5), // |
7600 B(Mov), R(closure), R(6), // | 7599 B(Mov), R(closure), R(6), // |
7601 B(LdaZero), // | 7600 B(LdaZero), // |
7602 B(Star), R(7), // | 7601 B(Star), R(7), // |
7603 B(LdaSmi8), U8(10), // | 7602 B(LdaSmi8), U8(10), // |
7604 B(Star), R(8), // | 7603 B(Star), R(8), // |
7605 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 7604 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
(...skipping 22 matching lines...) Expand all Loading... |
7628 int closure = Register::function_closure().index(); | 7627 int closure = Register::function_closure().index(); |
7629 int context = Register::current_context().index(); | 7628 int context = Register::current_context().index(); |
7630 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 7629 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
7631 int new_target = Register::new_target().index(); | 7630 int new_target = Register::new_target().index(); |
7632 | 7631 |
7633 // clang-format off | 7632 // clang-format off |
7634 ExpectedSnippet<const char*> snippets[] = { | 7633 ExpectedSnippet<const char*> snippets[] = { |
7635 {"eval('var x = 10;'); return x;", | 7634 {"eval('var x = 10;'); return x;", |
7636 9 * kPointerSize, | 7635 9 * kPointerSize, |
7637 1, | 7636 1, |
7638 70, | 7637 67, |
7639 { | 7638 { |
7640 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 7639 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
7641 /* */ U8(1), // | 7640 /* */ U8(1), // |
7642 B(PushContext), R(0), // | 7641 B(PushContext), R(0), // |
7643 B(Ldar), THIS(1), // | 7642 B(Ldar), THIS(1), // |
7644 B(StaContextSlot), R(context), U8(first_context_slot), // | 7643 B(StaContextSlot), R(context), U8(first_context_slot), // |
7645 B(CreateMappedArguments), // | 7644 B(CreateMappedArguments), // |
7646 B(StaContextSlot), R(context), U8(first_context_slot + 1), // | 7645 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
7647 B(Ldar), R(new_target), // | 7646 B(Ldar), R(new_target), // |
7648 B(StaContextSlot), R(context), U8(first_context_slot + 2), // | 7647 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
7649 B(StackCheck), // | 7648 B(StackCheck), // |
7650 B(Mov), R(context), R(3), // | |
7651 B(LdaConstant), U8(0), // | 7649 B(LdaConstant), U8(0), // |
7652 B(Star), R(4), // | 7650 B(Star), R(3), // |
7653 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 7651 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // |
7654 R(3), U8(2), R(1), // | 7652 R(3), U8(1), R(1), // |
7655 B(LdaConstant), U8(1), // | 7653 B(LdaConstant), U8(1), // |
7656 B(Star), R(3), // | 7654 B(Star), R(3), // |
7657 B(Mov), R(1), R(4), // | 7655 B(Mov), R(1), R(4), // |
7658 B(Mov), R(3), R(5), // | 7656 B(Mov), R(3), R(5), // |
7659 B(Mov), R(closure), R(6), // | 7657 B(Mov), R(closure), R(6), // |
7660 B(LdaZero), // | 7658 B(LdaZero), // |
7661 B(Star), R(7), // | 7659 B(Star), R(7), // |
7662 B(LdaSmi8), U8(10), // | 7660 B(LdaSmi8), U8(10), // |
7663 B(Star), R(8), // | 7661 B(Star), R(8), // |
7664 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 7662 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
7665 U8(5), // | 7663 U8(5), // |
7666 B(Star), R(1), // | 7664 B(Star), R(1), // |
7667 B(Call), R(1), R(2), U8(2), U8(0), // | 7665 B(Call), R(1), R(2), U8(2), U8(0), // |
7668 B(LdaLookupSlot), U8(2), // | 7666 B(LdaLookupSlot), U8(2), // |
7669 B(Return), // | 7667 B(Return), // |
7670 }, | 7668 }, |
7671 3, | 7669 3, |
7672 {"eval", "var x = 10;", "x"}}, | 7670 {"eval", "var x = 10;", "x"}}, |
7673 {"eval('var x = 10;'); return typeof x;", | 7671 {"eval('var x = 10;'); return typeof x;", |
7674 9 * kPointerSize, | 7672 9 * kPointerSize, |
7675 1, | 7673 1, |
7676 71, | 7674 68, |
7677 { | 7675 { |
7678 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 7676 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
7679 /* */ U8(1), // | 7677 /* */ U8(1), // |
7680 B(PushContext), R(0), // | 7678 B(PushContext), R(0), // |
7681 B(Ldar), THIS(1), // | 7679 B(Ldar), THIS(1), // |
7682 B(StaContextSlot), R(context), U8(first_context_slot), // | 7680 B(StaContextSlot), R(context), U8(first_context_slot), // |
7683 B(CreateMappedArguments), // | 7681 B(CreateMappedArguments), // |
7684 B(StaContextSlot), R(context), U8(first_context_slot + 1), // | 7682 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
7685 B(Ldar), R(new_target), // | 7683 B(Ldar), R(new_target), // |
7686 B(StaContextSlot), R(context), U8(first_context_slot + 2), // | 7684 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
7687 B(StackCheck), // | 7685 B(StackCheck), // |
7688 B(Mov), R(context), R(3), // | |
7689 B(LdaConstant), U8(0), // | 7686 B(LdaConstant), U8(0), // |
7690 B(Star), R(4), // | 7687 B(Star), R(3), // |
7691 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 7688 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // |
7692 /* */ R(3), U8(2), R(1), // | 7689 /* */ R(3), U8(1), R(1), // |
7693 B(LdaConstant), U8(1), // | 7690 B(LdaConstant), U8(1), // |
7694 B(Star), R(3), // | 7691 B(Star), R(3), // |
7695 B(Mov), R(1), R(4), // | 7692 B(Mov), R(1), R(4), // |
7696 B(Mov), R(3), R(5), // | 7693 B(Mov), R(3), R(5), // |
7697 B(Mov), R(closure), R(6), // | 7694 B(Mov), R(closure), R(6), // |
7698 B(LdaZero), // | 7695 B(LdaZero), // |
7699 B(Star), R(7), // | 7696 B(Star), R(7), // |
7700 B(LdaSmi8), U8(10), // | 7697 B(LdaSmi8), U8(10), // |
7701 B(Star), R(8), // | 7698 B(Star), R(8), // |
7702 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 7699 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
7703 /* */ U8(5), // | 7700 /* */ U8(5), // |
7704 B(Star), R(1), // | 7701 B(Star), R(1), // |
7705 B(Call), R(1), R(2), U8(2), U8(0), // | 7702 B(Call), R(1), R(2), U8(2), U8(0), // |
7706 B(LdaLookupSlotInsideTypeof), U8(2), // | 7703 B(LdaLookupSlotInsideTypeof), U8(2), // |
7707 B(TypeOf), // | 7704 B(TypeOf), // |
7708 B(Return), // | 7705 B(Return), // |
7709 }, | 7706 }, |
7710 3, | 7707 3, |
7711 {"eval", "var x = 10;", "x"}}, | 7708 {"eval", "var x = 10;", "x"}}, |
7712 {"x = 20; return eval('');", | 7709 {"x = 20; return eval('');", |
7713 9 * kPointerSize, | 7710 9 * kPointerSize, |
7714 1, | 7711 1, |
7715 72, | 7712 69, |
7716 { | 7713 { |
7717 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 7714 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
7718 U8(1), // | 7715 U8(1), // |
7719 B(PushContext), R(0), // | 7716 B(PushContext), R(0), // |
7720 B(Ldar), THIS(1), // | 7717 B(Ldar), THIS(1), // |
7721 B(StaContextSlot), R(context), U8(first_context_slot), // | 7718 B(StaContextSlot), R(context), U8(first_context_slot), // |
7722 B(CreateMappedArguments), // | 7719 B(CreateMappedArguments), // |
7723 B(StaContextSlot), R(context), U8(first_context_slot + 1), // | 7720 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
7724 B(Ldar), R(new_target), // | 7721 B(Ldar), R(new_target), // |
7725 B(StaContextSlot), R(context), U8(first_context_slot + 2), // | 7722 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
7726 B(StackCheck), // | 7723 B(StackCheck), // |
7727 B(LdaSmi8), U8(20), // | 7724 B(LdaSmi8), U8(20), // |
7728 B(StaLookupSlotSloppy), U8(0), // | 7725 B(StaLookupSlotSloppy), U8(0), // |
7729 B(Mov), R(context), R(3), // | |
7730 B(LdaConstant), U8(1), // | 7726 B(LdaConstant), U8(1), // |
7731 B(Star), R(4), // | 7727 B(Star), R(3), // |
7732 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 7728 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // |
7733 /* */ R(3), U8(2), R(1), // | 7729 /* */ R(3), U8(1), R(1), // |
7734 B(LdaConstant), U8(2), // | 7730 B(LdaConstant), U8(2), // |
7735 B(Star), R(3), // | 7731 B(Star), R(3), // |
7736 B(Mov), R(1), R(4), // | 7732 B(Mov), R(1), R(4), // |
7737 B(Mov), R(3), R(5), // | 7733 B(Mov), R(3), R(5), // |
7738 B(Mov), R(closure), R(6), // | 7734 B(Mov), R(closure), R(6), // |
7739 B(LdaZero), // | 7735 B(LdaZero), // |
7740 B(Star), R(7), // | 7736 B(Star), R(7), // |
7741 B(LdaSmi8), U8(10), // | 7737 B(LdaSmi8), U8(10), // |
7742 B(Star), R(8), // | 7738 B(Star), R(8), // |
7743 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 7739 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
(...skipping 30 matching lines...) Expand all Loading... |
7774 | 7770 |
7775 int closure = Register::function_closure().index(); | 7771 int closure = Register::function_closure().index(); |
7776 int context = Register::current_context().index(); | 7772 int context = Register::current_context().index(); |
7777 int new_target = Register::new_target().index(); | 7773 int new_target = Register::new_target().index(); |
7778 | 7774 |
7779 // clang-format off | 7775 // clang-format off |
7780 ExpectedSnippet<InstanceType> snippets[] = { | 7776 ExpectedSnippet<InstanceType> snippets[] = { |
7781 {"g = function(){}; eval(''); return g();", | 7777 {"g = function(){}; eval(''); return g();", |
7782 9 * kPointerSize, | 7778 9 * kPointerSize, |
7783 1, | 7779 1, |
7784 91, | 7780 85, |
7785 { | 7781 { |
7786 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 7782 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
7787 /* */ U8(1), // | 7783 /* */ U8(1), // |
7788 B(PushContext), R(0), // | 7784 B(PushContext), R(0), // |
7789 B(Ldar), THIS(1), // | 7785 B(Ldar), THIS(1), // |
7790 B(StaContextSlot), R(context), U8(4), // | 7786 B(StaContextSlot), R(context), U8(4), // |
7791 B(CreateMappedArguments), // | 7787 B(CreateMappedArguments), // |
7792 B(StaContextSlot), R(context), U8(5), // | 7788 B(StaContextSlot), R(context), U8(5), // |
7793 B(Ldar), R(new_target), // | 7789 B(Ldar), R(new_target), // |
7794 B(StaContextSlot), R(context), U8(6), // | 7790 B(StaContextSlot), R(context), U8(6), // |
7795 B(StackCheck), // | 7791 B(StackCheck), // |
7796 B(CreateClosure), U8(0), U8(0), // | 7792 B(CreateClosure), U8(0), U8(0), // |
7797 B(StaLookupSlotSloppy), U8(1), // | 7793 B(StaLookupSlotSloppy), U8(1), // |
7798 B(Mov), R(context), R(3), // | |
7799 B(LdaConstant), U8(2), // | 7794 B(LdaConstant), U8(2), // |
7800 B(Star), R(4), // | 7795 B(Star), R(3), // |
7801 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 7796 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // |
7802 R(3), U8(2), R(1), // | 7797 R(3), U8(1), R(1), // |
7803 B(LdaConstant), U8(3), // | 7798 B(LdaConstant), U8(3), // |
7804 B(Star), R(3), // | 7799 B(Star), R(3), // |
7805 B(Mov), R(1), R(4), // | 7800 B(Mov), R(1), R(4), // |
7806 B(Mov), R(3), R(5), // | 7801 B(Mov), R(3), R(5), // |
7807 B(Mov), R(closure), R(6), // | 7802 B(Mov), R(closure), R(6), // |
7808 B(LdaZero), // | 7803 B(LdaZero), // |
7809 B(Star), R(7), // | 7804 B(Star), R(7), // |
7810 B(LdaSmi8), U8(10), // | 7805 B(LdaSmi8), U8(10), // |
7811 B(Star), R(8), // | 7806 B(Star), R(8), // |
7812 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 7807 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
7813 U8(5), // | 7808 U8(5), // |
7814 B(Star), R(1), // | 7809 B(Star), R(1), // |
7815 B(Call), R(1), R(2), U8(2), U8(0), // | 7810 B(Call), R(1), R(2), U8(2), U8(0), // |
7816 B(Mov), R(context), R(3), // | |
7817 B(LdaConstant), U8(1), // | 7811 B(LdaConstant), U8(1), // |
7818 B(Star), R(4), // | 7812 B(Star), R(3), // |
7819 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 7813 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // |
7820 R(3), U8(2), R(1), // | 7814 R(3), U8(1), R(1), // |
7821 B(Call), R(1), R(2), U8(1), U8(vector->GetIndex(slot2)), // | 7815 B(Call), R(1), R(2), U8(1), U8(vector->GetIndex(slot2)), // |
7822 B(Return), // | 7816 B(Return), // |
7823 }, | 7817 }, |
7824 4, | 7818 4, |
7825 {InstanceType::SHARED_FUNCTION_INFO_TYPE, | 7819 {InstanceType::SHARED_FUNCTION_INFO_TYPE, |
7826 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 7820 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
7827 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 7821 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
7828 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 7822 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
7829 }; | 7823 }; |
7830 // clang-format on | 7824 // clang-format on |
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9232 for (size_t i = 0; i < arraysize(snippets); i++) { | 9226 for (size_t i = 0; i < arraysize(snippets); i++) { |
9233 Handle<BytecodeArray> bytecode_array = | 9227 Handle<BytecodeArray> bytecode_array = |
9234 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 9228 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
9235 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 9229 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
9236 } | 9230 } |
9237 } | 9231 } |
9238 | 9232 |
9239 } // namespace interpreter | 9233 } // namespace interpreter |
9240 } // namespace internal | 9234 } // namespace internal |
9241 } // namespace v8 | 9235 } // namespace v8 |
OLD | NEW |