| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #if V8_TARGET_ARCH_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
| (...skipping 2626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2637 ASM_LOCATION("GenerateRecordCallTarget"); | 2637 ASM_LOCATION("GenerateRecordCallTarget"); |
| 2638 DCHECK(!AreAliased(scratch1, scratch2, scratch3, argc, function, | 2638 DCHECK(!AreAliased(scratch1, scratch2, scratch3, argc, function, |
| 2639 feedback_vector, index, new_target)); | 2639 feedback_vector, index, new_target)); |
| 2640 // Cache the called function in a feedback vector slot. Cache states are | 2640 // Cache the called function in a feedback vector slot. Cache states are |
| 2641 // uninitialized, monomorphic (indicated by a JSFunction), and megamorphic. | 2641 // uninitialized, monomorphic (indicated by a JSFunction), and megamorphic. |
| 2642 // argc : number of arguments to the construct function | 2642 // argc : number of arguments to the construct function |
| 2643 // function : the function to call | 2643 // function : the function to call |
| 2644 // feedback_vector : the feedback vector | 2644 // feedback_vector : the feedback vector |
| 2645 // index : slot in feedback vector (smi) | 2645 // index : slot in feedback vector (smi) |
| 2646 Label initialize, done, miss, megamorphic, not_array_function; | 2646 Label initialize, done, miss, megamorphic, not_array_function; |
| 2647 Label done_increment_count; | |
| 2648 | 2647 |
| 2649 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 2648 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
| 2650 masm->isolate()->heap()->megamorphic_symbol()); | 2649 masm->isolate()->heap()->megamorphic_symbol()); |
| 2651 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 2650 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
| 2652 masm->isolate()->heap()->uninitialized_symbol()); | 2651 masm->isolate()->heap()->uninitialized_symbol()); |
| 2653 | 2652 |
| 2654 // Load the cache state. | 2653 // Load the cache state. |
| 2655 Register feedback = scratch1; | 2654 Register feedback = scratch1; |
| 2656 Register feedback_map = scratch2; | 2655 Register feedback_map = scratch2; |
| 2657 Register feedback_value = scratch3; | 2656 Register feedback_value = scratch3; |
| 2658 __ Add(feedback, feedback_vector, | 2657 __ Add(feedback, feedback_vector, |
| 2659 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 2658 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
| 2660 __ Ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); | 2659 __ Ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); |
| 2661 | 2660 |
| 2662 // A monomorphic cache hit or an already megamorphic state: invoke the | 2661 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 2663 // function without changing the state. | 2662 // function without changing the state. |
| 2664 // We don't know if feedback value is a WeakCell or a Symbol, but it's | 2663 // We don't know if feedback value is a WeakCell or a Symbol, but it's |
| 2665 // harmless to read at this position in a symbol (see static asserts in | 2664 // harmless to read at this position in a symbol (see static asserts in |
| 2666 // type-feedback-vector.h). | 2665 // type-feedback-vector.h). |
| 2667 Label check_allocation_site; | 2666 Label check_allocation_site; |
| 2668 __ Ldr(feedback_value, FieldMemOperand(feedback, WeakCell::kValueOffset)); | 2667 __ Ldr(feedback_value, FieldMemOperand(feedback, WeakCell::kValueOffset)); |
| 2669 __ Cmp(function, feedback_value); | 2668 __ Cmp(function, feedback_value); |
| 2670 __ B(eq, &done_increment_count); | 2669 __ B(eq, &done); |
| 2671 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); | 2670 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); |
| 2672 __ B(eq, &done); | 2671 __ B(eq, &done); |
| 2673 __ Ldr(feedback_map, FieldMemOperand(feedback, HeapObject::kMapOffset)); | 2672 __ Ldr(feedback_map, FieldMemOperand(feedback, HeapObject::kMapOffset)); |
| 2674 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); | 2673 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); |
| 2675 __ B(ne, &check_allocation_site); | 2674 __ B(ne, &check_allocation_site); |
| 2676 | 2675 |
| 2677 // If the weak cell is cleared, we have a new chance to become monomorphic. | 2676 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 2678 __ JumpIfSmi(feedback_value, &initialize); | 2677 __ JumpIfSmi(feedback_value, &initialize); |
| 2679 __ B(&megamorphic); | 2678 __ B(&megamorphic); |
| 2680 | 2679 |
| 2681 __ bind(&check_allocation_site); | 2680 __ bind(&check_allocation_site); |
| 2682 // If we came here, we need to see if we are the array function. | 2681 // If we came here, we need to see if we are the array function. |
| 2683 // If we didn't have a matching function, and we didn't find the megamorph | 2682 // If we didn't have a matching function, and we didn't find the megamorph |
| 2684 // sentinel, then we have in the slot either some other function or an | 2683 // sentinel, then we have in the slot either some other function or an |
| 2685 // AllocationSite. | 2684 // AllocationSite. |
| 2686 __ JumpIfNotRoot(feedback_map, Heap::kAllocationSiteMapRootIndex, &miss); | 2685 __ JumpIfNotRoot(feedback_map, Heap::kAllocationSiteMapRootIndex, &miss); |
| 2687 | 2686 |
| 2688 // Make sure the function is the Array() function | 2687 // Make sure the function is the Array() function |
| 2689 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); | 2688 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); |
| 2690 __ Cmp(function, scratch1); | 2689 __ Cmp(function, scratch1); |
| 2691 __ B(ne, &megamorphic); | 2690 __ B(ne, &megamorphic); |
| 2692 __ B(&done_increment_count); | 2691 __ B(&done); |
| 2693 | 2692 |
| 2694 __ Bind(&miss); | 2693 __ Bind(&miss); |
| 2695 | 2694 |
| 2696 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 2695 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 2697 // megamorphic. | 2696 // megamorphic. |
| 2698 __ JumpIfRoot(scratch1, Heap::kuninitialized_symbolRootIndex, &initialize); | 2697 __ JumpIfRoot(scratch1, Heap::kuninitialized_symbolRootIndex, &initialize); |
| 2699 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 2698 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 2700 // write-barrier is needed. | 2699 // write-barrier is needed. |
| 2701 __ Bind(&megamorphic); | 2700 __ Bind(&megamorphic); |
| 2702 __ Add(scratch1, feedback_vector, | 2701 __ Add(scratch1, feedback_vector, |
| 2703 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 2702 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
| 2704 __ LoadRoot(scratch2, Heap::kmegamorphic_symbolRootIndex); | 2703 __ LoadRoot(scratch2, Heap::kmegamorphic_symbolRootIndex); |
| 2705 __ Str(scratch2, FieldMemOperand(scratch1, FixedArray::kHeaderSize)); | 2704 __ Str(scratch2, FieldMemOperand(scratch1, FixedArray::kHeaderSize)); |
| 2706 __ B(&done); | 2705 __ B(&done); |
| 2707 | 2706 |
| 2708 // An uninitialized cache is patched with the function or sentinel to | 2707 // An uninitialized cache is patched with the function or sentinel to |
| 2709 // indicate the ElementsKind if function is the Array constructor. | 2708 // indicate the ElementsKind if function is the Array constructor. |
| 2710 __ Bind(&initialize); | 2709 __ Bind(&initialize); |
| 2711 | 2710 |
| 2712 // Initialize the call counter. | |
| 2713 __ Mov(scratch1, Smi::FromInt(ConstructICNexus::kCallCountIncrement)); | |
| 2714 __ Adds(scratch2, feedback_vector, | |
| 2715 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | |
| 2716 __ Str(scratch1, | |
| 2717 FieldMemOperand(scratch2, FixedArray::kHeaderSize + kPointerSize)); | |
| 2718 | |
| 2719 // Make sure the function is the Array() function | 2711 // Make sure the function is the Array() function |
| 2720 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); | 2712 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); |
| 2721 __ Cmp(function, scratch1); | 2713 __ Cmp(function, scratch1); |
| 2722 __ B(ne, ¬_array_function); | 2714 __ B(ne, ¬_array_function); |
| 2723 | 2715 |
| 2724 // The target function is the Array constructor, | 2716 // The target function is the Array constructor, |
| 2725 // Create an AllocationSite if we don't already have it, store it in the | 2717 // Create an AllocationSite if we don't already have it, store it in the |
| 2726 // slot. | 2718 // slot. |
| 2727 CreateAllocationSiteStub create_stub(masm->isolate()); | 2719 CreateAllocationSiteStub create_stub(masm->isolate()); |
| 2728 CallStubInRecordCallTarget(masm, &create_stub, argc, function, | 2720 CallStubInRecordCallTarget(masm, &create_stub, argc, function, |
| 2729 feedback_vector, index, new_target); | 2721 feedback_vector, index, new_target); |
| 2730 __ B(&done); | 2722 __ B(&done); |
| 2731 | 2723 |
| 2732 __ Bind(¬_array_function); | 2724 __ Bind(¬_array_function); |
| 2733 CreateWeakCellStub weak_cell_stub(masm->isolate()); | 2725 CreateWeakCellStub weak_cell_stub(masm->isolate()); |
| 2734 CallStubInRecordCallTarget(masm, &weak_cell_stub, argc, function, | 2726 CallStubInRecordCallTarget(masm, &weak_cell_stub, argc, function, |
| 2735 feedback_vector, index, new_target); | 2727 feedback_vector, index, new_target); |
| 2736 __ B(&done); | |
| 2737 | |
| 2738 __ bind(&done_increment_count); | |
| 2739 __ Adds(scratch2, feedback_vector, | |
| 2740 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | |
| 2741 __ Ldr(scratch1, | |
| 2742 FieldMemOperand(scratch2, FixedArray::kHeaderSize + kPointerSize)); | |
| 2743 __ Add(scratch1, scratch1, | |
| 2744 Operand(Smi::FromInt(CallICNexus::kCallCountIncrement))); | |
| 2745 __ Str(scratch1, | |
| 2746 FieldMemOperand(scratch2, FixedArray::kHeaderSize + kPointerSize)); | |
| 2747 | |
| 2748 __ Bind(&done); | 2728 __ Bind(&done); |
| 2749 } | 2729 } |
| 2750 | 2730 |
| 2751 | 2731 |
| 2752 void ConstructICStub::Generate(MacroAssembler* masm) { | 2732 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 2753 ASM_LOCATION("CallConstructStub::Generate"); | 2733 ASM_LOCATION("CallConstructStub::Generate"); |
| 2754 // x0 : number of arguments | 2734 // x0 : number of arguments |
| 2755 // x1 : the function to call | 2735 // x1 : the function to call |
| 2756 // x2 : feedback vector | 2736 // x2 : feedback vector |
| 2757 // x3 : slot in feedback vector (Smi, for RecordCallTarget) | 2737 // x3 : slot in feedback vector (Smi, for RecordCallTarget) |
| 2758 Register function = x1; | 2738 Register function = x1; |
| 2759 | 2739 |
| 2760 Label non_function; | 2740 Label non_function; |
| 2761 // Check that the function is not a smi. | 2741 // Check that the function is not a smi. |
| 2762 __ JumpIfSmi(function, &non_function); | 2742 __ JumpIfSmi(function, &non_function); |
| (...skipping 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5813 MemOperand(fp, 6 * kPointerSize), NULL); | 5793 MemOperand(fp, 6 * kPointerSize), NULL); |
| 5814 } | 5794 } |
| 5815 | 5795 |
| 5816 | 5796 |
| 5817 #undef __ | 5797 #undef __ |
| 5818 | 5798 |
| 5819 } // namespace internal | 5799 } // namespace internal |
| 5820 } // namespace v8 | 5800 } // namespace v8 |
| 5821 | 5801 |
| 5822 #endif // V8_TARGET_ARCH_ARM64 | 5802 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |