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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 feedback_element, | 584 feedback_element, |
585 HeapConstant(TypeFeedbackVector::MegamorphicSentinel(isolate()))); | 585 HeapConstant(TypeFeedbackVector::MegamorphicSentinel(isolate()))); |
586 GotoIf(is_megamorphic, &call); | 586 GotoIf(is_megamorphic, &call); |
587 | 587 |
588 Comment("check if it is an allocation site"); | 588 Comment("check if it is an allocation site"); |
589 Node* is_allocation_site = WordEqual( | 589 Node* is_allocation_site = WordEqual( |
590 LoadMap(feedback_element), LoadRoot(Heap::kAllocationSiteMapRootIndex)); | 590 LoadMap(feedback_element), LoadRoot(Heap::kAllocationSiteMapRootIndex)); |
591 GotoUnless(is_allocation_site, &check_initialized); | 591 GotoUnless(is_allocation_site, &check_initialized); |
592 | 592 |
593 // If it is not the Array() function, mark megamorphic. | 593 // If it is not the Array() function, mark megamorphic. |
594 Node* context_slot = | 594 Node* context_slot = LoadContextElement(LoadNativeContext(context), |
595 LoadFixedArrayElement(LoadNativeContext(context), | 595 Context::ARRAY_FUNCTION_INDEX); |
596 Int32Constant(Context::ARRAY_FUNCTION_INDEX)); | |
597 Node* is_array_function = WordEqual(context_slot, function); | 596 Node* is_array_function = WordEqual(context_slot, function); |
598 GotoUnless(is_array_function, &mark_megamorphic); | 597 GotoUnless(is_array_function, &mark_megamorphic); |
599 | 598 |
600 // It is a monomorphic Array function. Increment the call count. | 599 // It is a monomorphic Array function. Increment the call count. |
601 IncrementCallCount(type_feedback_vector, slot_id); | 600 IncrementCallCount(type_feedback_vector, slot_id); |
602 | 601 |
603 // Call ArrayConstructorStub. | 602 // Call ArrayConstructorStub. |
604 Callable callable_call = | 603 Callable callable_call = |
605 CodeFactory::InterpreterPushArgsAndConstructArray(isolate()); | 604 CodeFactory::InterpreterPushArgsAndConstructArray(isolate()); |
606 Node* code_target_call = HeapConstant(callable_call.code()); | 605 Node* code_target_call = HeapConstant(callable_call.code()); |
(...skipping 17 matching lines...) Expand all Loading... |
624 Node* is_smi = TaggedIsSmi(function); | 623 Node* is_smi = TaggedIsSmi(function); |
625 GotoIf(is_smi, &mark_megamorphic); | 624 GotoIf(is_smi, &mark_megamorphic); |
626 | 625 |
627 // Check if function is an object of JSFunction type. | 626 // Check if function is an object of JSFunction type. |
628 Node* instance_type = LoadInstanceType(function); | 627 Node* instance_type = LoadInstanceType(function); |
629 Node* is_js_function = | 628 Node* is_js_function = |
630 WordEqual(instance_type, Int32Constant(JS_FUNCTION_TYPE)); | 629 WordEqual(instance_type, Int32Constant(JS_FUNCTION_TYPE)); |
631 GotoUnless(is_js_function, &mark_megamorphic); | 630 GotoUnless(is_js_function, &mark_megamorphic); |
632 | 631 |
633 // Check if it is the Array() function. | 632 // Check if it is the Array() function. |
634 Node* context_slot = | 633 Node* context_slot = LoadContextElement(LoadNativeContext(context), |
635 LoadFixedArrayElement(LoadNativeContext(context), | 634 Context::ARRAY_FUNCTION_INDEX); |
636 Int32Constant(Context::ARRAY_FUNCTION_INDEX)); | |
637 Node* is_array_function = WordEqual(context_slot, function); | 635 Node* is_array_function = WordEqual(context_slot, function); |
638 GotoIf(is_array_function, &create_allocation_site); | 636 GotoIf(is_array_function, &create_allocation_site); |
639 | 637 |
640 // Check if the function belongs to the same native context. | 638 // Check if the function belongs to the same native context. |
641 Node* native_context = LoadNativeContext( | 639 Node* native_context = LoadNativeContext( |
642 LoadObjectField(function, JSFunction::kContextOffset)); | 640 LoadObjectField(function, JSFunction::kContextOffset)); |
643 Node* is_same_native_context = | 641 Node* is_same_native_context = |
644 WordEqual(native_context, LoadNativeContext(context)); | 642 WordEqual(native_context, LoadNativeContext(context)); |
645 GotoUnless(is_same_native_context, &mark_megamorphic); | 643 GotoUnless(is_same_native_context, &mark_megamorphic); |
646 | 644 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 | 773 |
776 Bind(&check_allocation_site); | 774 Bind(&check_allocation_site); |
777 { | 775 { |
778 Comment("check if it is an allocation site"); | 776 Comment("check if it is an allocation site"); |
779 Node* is_allocation_site = | 777 Node* is_allocation_site = |
780 WordEqual(LoadObjectField(feedback_element, 0), | 778 WordEqual(LoadObjectField(feedback_element, 0), |
781 LoadRoot(Heap::kAllocationSiteMapRootIndex)); | 779 LoadRoot(Heap::kAllocationSiteMapRootIndex)); |
782 GotoUnless(is_allocation_site, &check_initialized); | 780 GotoUnless(is_allocation_site, &check_initialized); |
783 | 781 |
784 // Make sure the function is the Array() function. | 782 // Make sure the function is the Array() function. |
785 Node* context_slot = | 783 Node* context_slot = LoadContextElement(LoadNativeContext(context), |
786 LoadFixedArrayElement(LoadNativeContext(context), | 784 Context::ARRAY_FUNCTION_INDEX); |
787 Int32Constant(Context::ARRAY_FUNCTION_INDEX)); | |
788 Node* is_array_function = WordEqual(context_slot, constructor); | 785 Node* is_array_function = WordEqual(context_slot, constructor); |
789 GotoUnless(is_array_function, &mark_megamorphic); | 786 GotoUnless(is_array_function, &mark_megamorphic); |
790 | 787 |
791 allocation_feedback.Bind(feedback_element); | 788 allocation_feedback.Bind(feedback_element); |
792 Goto(&call_construct_function); | 789 Goto(&call_construct_function); |
793 } | 790 } |
794 | 791 |
795 Bind(&check_initialized); | 792 Bind(&check_initialized); |
796 { | 793 { |
797 // Check if it is uninitialized. | 794 // Check if it is uninitialized. |
798 Comment("check if uninitialized"); | 795 Comment("check if uninitialized"); |
799 Node* is_uninitialized = WordEqual( | 796 Node* is_uninitialized = WordEqual( |
800 feedback_element, LoadRoot(Heap::kuninitialized_symbolRootIndex)); | 797 feedback_element, LoadRoot(Heap::kuninitialized_symbolRootIndex)); |
801 Branch(is_uninitialized, &initialize, &mark_megamorphic); | 798 Branch(is_uninitialized, &initialize, &mark_megamorphic); |
802 } | 799 } |
803 | 800 |
804 Bind(&initialize); | 801 Bind(&initialize); |
805 { | 802 { |
806 Label create_allocation_site(this), create_weak_cell(this); | 803 Label create_allocation_site(this), create_weak_cell(this); |
807 Comment("initialize the feedback element"); | 804 Comment("initialize the feedback element"); |
808 // Create an allocation site if the function is an array function, | 805 // Create an allocation site if the function is an array function, |
809 // otherwise create a weak cell. | 806 // otherwise create a weak cell. |
810 Node* context_slot = | 807 Node* context_slot = LoadContextElement(LoadNativeContext(context), |
811 LoadFixedArrayElement(LoadNativeContext(context), | 808 Context::ARRAY_FUNCTION_INDEX); |
812 Int32Constant(Context::ARRAY_FUNCTION_INDEX)); | |
813 Node* is_array_function = WordEqual(context_slot, constructor); | 809 Node* is_array_function = WordEqual(context_slot, constructor); |
814 Branch(is_array_function, &create_allocation_site, &create_weak_cell); | 810 Branch(is_array_function, &create_allocation_site, &create_weak_cell); |
815 | 811 |
816 Bind(&create_allocation_site); | 812 Bind(&create_allocation_site); |
817 { | 813 { |
818 Node* site = CreateAllocationSiteInFeedbackVector(type_feedback_vector, | 814 Node* site = CreateAllocationSiteInFeedbackVector(type_feedback_vector, |
819 SmiTag(slot_id)); | 815 SmiTag(slot_id)); |
820 allocation_feedback.Bind(site); | 816 allocation_feedback.Bind(site); |
821 Goto(&call_construct_function); | 817 Goto(&call_construct_function); |
822 } | 818 } |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 Goto(&loop); | 1326 Goto(&loop); |
1331 } | 1327 } |
1332 Bind(&done_loop); | 1328 Bind(&done_loop); |
1333 | 1329 |
1334 return array; | 1330 return array; |
1335 } | 1331 } |
1336 | 1332 |
1337 } // namespace interpreter | 1333 } // namespace interpreter |
1338 } // namespace internal | 1334 } // namespace internal |
1339 } // namespace v8 | 1335 } // namespace v8 |
OLD | NEW |