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/interpreter/interpreter-assembler.h" | 5 #include "src/interpreter/interpreter-assembler.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 Node* first_arg, Node* arg_count) { | 688 Node* first_arg, Node* arg_count) { |
689 Callable callable = CodeFactory::InterpreterPushArgsAndCall( | 689 Callable callable = CodeFactory::InterpreterPushArgsAndCall( |
690 isolate(), TailCallMode::kDisallow, | 690 isolate(), TailCallMode::kDisallow, |
691 InterpreterPushArgsMode::kWithFinalSpread); | 691 InterpreterPushArgsMode::kWithFinalSpread); |
692 Node* code_target = HeapConstant(callable.code()); | 692 Node* code_target = HeapConstant(callable.code()); |
693 | 693 |
694 return CallStub(callable.descriptor(), code_target, context, arg_count, | 694 return CallStub(callable.descriptor(), code_target, context, arg_count, |
695 first_arg, function); | 695 first_arg, function); |
696 } | 696 } |
697 | 697 |
698 Node* InterpreterAssembler::CallConstruct(Node* constructor, Node* context, | 698 Node* InterpreterAssembler::Construct(Node* constructor, Node* context, |
699 Node* new_target, Node* first_arg, | 699 Node* new_target, Node* first_arg, |
700 Node* arg_count, Node* slot_id, | 700 Node* arg_count, Node* slot_id, |
701 Node* type_feedback_vector) { | 701 Node* type_feedback_vector) { |
702 Variable return_value(this, MachineRepresentation::kTagged); | 702 Variable return_value(this, MachineRepresentation::kTagged); |
703 Variable allocation_feedback(this, MachineRepresentation::kTagged); | 703 Variable allocation_feedback(this, MachineRepresentation::kTagged); |
704 Label call_construct_function(this, &allocation_feedback), | 704 Label call_construct_function(this, &allocation_feedback), |
705 extra_checks(this, Label::kDeferred), call_construct(this), end(this); | 705 extra_checks(this, Label::kDeferred), call_construct(this), end(this); |
706 | 706 |
707 // Slot id of 0 is used to indicate no type feedback is available. | 707 // Slot id of 0 is used to indicate no type feedback is available. |
708 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 708 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
709 Node* is_feedback_unavailable = WordEqual(slot_id, IntPtrConstant(0)); | 709 Node* is_feedback_unavailable = WordEqual(slot_id, IntPtrConstant(0)); |
710 GotoIf(is_feedback_unavailable, &call_construct); | 710 GotoIf(is_feedback_unavailable, &call_construct); |
711 | 711 |
712 // Check that the constructor is not a smi. | 712 // Check that the constructor is not a smi. |
713 Node* is_smi = TaggedIsSmi(constructor); | 713 Node* is_smi = TaggedIsSmi(constructor); |
714 GotoIf(is_smi, &call_construct); | 714 GotoIf(is_smi, &call_construct); |
715 | 715 |
716 // Check that constructor is a JSFunction. | 716 // Check that constructor is a JSFunction. |
717 Node* instance_type = LoadInstanceType(constructor); | 717 Node* instance_type = LoadInstanceType(constructor); |
718 Node* is_js_function = | 718 Node* is_js_function = |
719 Word32Equal(instance_type, Int32Constant(JS_FUNCTION_TYPE)); | 719 Word32Equal(instance_type, Int32Constant(JS_FUNCTION_TYPE)); |
720 GotoUnless(is_js_function, &call_construct); | 720 GotoUnless(is_js_function, &call_construct); |
721 | 721 |
722 // Check if it is a monomorphic constructor. | 722 // Check if it is a monomorphic constructor. |
723 Node* feedback_element = LoadFixedArrayElement(type_feedback_vector, slot_id); | 723 Node* feedback_element = LoadFixedArrayElement(type_feedback_vector, slot_id); |
724 Node* feedback_value = LoadWeakCellValueUnchecked(feedback_element); | 724 Node* feedback_value = LoadWeakCellValueUnchecked(feedback_element); |
725 Node* is_monomorphic = WordEqual(constructor, feedback_value); | 725 Node* is_monomorphic = WordEqual(constructor, feedback_value); |
726 allocation_feedback.Bind(UndefinedConstant()); | 726 allocation_feedback.Bind(UndefinedConstant()); |
727 Branch(is_monomorphic, &call_construct_function, &extra_checks); | 727 Branch(is_monomorphic, &call_construct_function, &extra_checks); |
728 | 728 |
729 Bind(&call_construct_function); | 729 Bind(&call_construct_function); |
730 { | 730 { |
731 Comment("call using callConstructFunction"); | 731 Comment("call using ConstructFunction"); |
732 IncrementCallCount(type_feedback_vector, slot_id); | 732 IncrementCallCount(type_feedback_vector, slot_id); |
733 Callable callable_function = CodeFactory::InterpreterPushArgsAndConstruct( | 733 Callable callable_function = CodeFactory::InterpreterPushArgsAndConstruct( |
734 isolate(), InterpreterPushArgsMode::kJSFunction); | 734 isolate(), InterpreterPushArgsMode::kJSFunction); |
735 return_value.Bind(CallStub(callable_function.descriptor(), | 735 return_value.Bind(CallStub(callable_function.descriptor(), |
736 HeapConstant(callable_function.code()), context, | 736 HeapConstant(callable_function.code()), context, |
737 arg_count, new_target, constructor, | 737 arg_count, new_target, constructor, |
738 allocation_feedback.value(), first_arg)); | 738 allocation_feedback.value(), first_arg)); |
739 Goto(&end); | 739 Goto(&end); |
740 } | 740 } |
741 | 741 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 StoreFixedArrayElement( | 825 StoreFixedArrayElement( |
826 type_feedback_vector, slot_id, | 826 type_feedback_vector, slot_id, |
827 HeapConstant(TypeFeedbackVector::MegamorphicSentinel(isolate())), | 827 HeapConstant(TypeFeedbackVector::MegamorphicSentinel(isolate())), |
828 SKIP_WRITE_BARRIER); | 828 SKIP_WRITE_BARRIER); |
829 Goto(&call_construct_function); | 829 Goto(&call_construct_function); |
830 } | 830 } |
831 } | 831 } |
832 | 832 |
833 Bind(&call_construct); | 833 Bind(&call_construct); |
834 { | 834 { |
835 Comment("call using callConstruct builtin"); | 835 Comment("call using Construct builtin"); |
836 Callable callable = CodeFactory::InterpreterPushArgsAndConstruct( | 836 Callable callable = CodeFactory::InterpreterPushArgsAndConstruct( |
837 isolate(), InterpreterPushArgsMode::kOther); | 837 isolate(), InterpreterPushArgsMode::kOther); |
838 Node* code_target = HeapConstant(callable.code()); | 838 Node* code_target = HeapConstant(callable.code()); |
839 return_value.Bind(CallStub(callable.descriptor(), code_target, context, | 839 return_value.Bind(CallStub(callable.descriptor(), code_target, context, |
840 arg_count, new_target, constructor, | 840 arg_count, new_target, constructor, |
841 UndefinedConstant(), first_arg)); | 841 UndefinedConstant(), first_arg)); |
842 Goto(&end); | 842 Goto(&end); |
843 } | 843 } |
844 | 844 |
845 Bind(&end); | 845 Bind(&end); |
846 return return_value.value(); | 846 return return_value.value(); |
847 } | 847 } |
848 | 848 |
849 Node* InterpreterAssembler::CallConstructWithSpread(Node* constructor, | 849 Node* InterpreterAssembler::ConstructWithSpread(Node* constructor, |
850 Node* context, | 850 Node* context, Node* new_target, |
851 Node* new_target, | 851 Node* first_arg, |
852 Node* first_arg, | 852 Node* arg_count) { |
853 Node* arg_count) { | |
854 Variable return_value(this, MachineRepresentation::kTagged); | 853 Variable return_value(this, MachineRepresentation::kTagged); |
855 Comment("call using ConstructWithSpread"); | 854 Comment("call using ConstructWithSpread"); |
856 Callable callable = CodeFactory::InterpreterPushArgsAndConstruct( | 855 Callable callable = CodeFactory::InterpreterPushArgsAndConstruct( |
857 isolate(), InterpreterPushArgsMode::kWithFinalSpread); | 856 isolate(), InterpreterPushArgsMode::kWithFinalSpread); |
858 Node* code_target = HeapConstant(callable.code()); | 857 Node* code_target = HeapConstant(callable.code()); |
859 return_value.Bind(CallStub(callable.descriptor(), code_target, context, | 858 return_value.Bind(CallStub(callable.descriptor(), code_target, context, |
860 arg_count, new_target, constructor, | 859 arg_count, new_target, constructor, |
861 UndefinedConstant(), first_arg)); | 860 UndefinedConstant(), first_arg)); |
862 | 861 |
863 return return_value.value(); | 862 return return_value.value(); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 Goto(&loop); | 1360 Goto(&loop); |
1362 } | 1361 } |
1363 Bind(&done_loop); | 1362 Bind(&done_loop); |
1364 | 1363 |
1365 return array; | 1364 return array; |
1366 } | 1365 } |
1367 | 1366 |
1368 } // namespace interpreter | 1367 } // namespace interpreter |
1369 } // namespace internal | 1368 } // namespace internal |
1370 } // namespace v8 | 1369 } // namespace v8 |
OLD | NEW |