Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: src/arm64/code-stubs-arm64.cc

Issue 1476413003: Provide call counts for constructor calls, surface them as a vector IC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm/interface-descriptors-arm.cc ('k') | src/arm64/interface-descriptors-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
2647 2648
2648 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), 2649 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()),
2649 masm->isolate()->heap()->megamorphic_symbol()); 2650 masm->isolate()->heap()->megamorphic_symbol());
2650 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), 2651 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()),
2651 masm->isolate()->heap()->uninitialized_symbol()); 2652 masm->isolate()->heap()->uninitialized_symbol());
2652 2653
2653 // Load the cache state. 2654 // Load the cache state.
2654 Register feedback = scratch1; 2655 Register feedback = scratch1;
2655 Register feedback_map = scratch2; 2656 Register feedback_map = scratch2;
2656 Register feedback_value = scratch3; 2657 Register feedback_value = scratch3;
2657 __ Add(feedback, feedback_vector, 2658 __ Add(feedback, feedback_vector,
2658 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); 2659 Operand::UntagSmiAndScale(index, kPointerSizeLog2));
2659 __ Ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); 2660 __ Ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
2660 2661
2661 // A monomorphic cache hit or an already megamorphic state: invoke the 2662 // A monomorphic cache hit or an already megamorphic state: invoke the
2662 // function without changing the state. 2663 // function without changing the state.
2663 // We don't know if feedback value is a WeakCell or a Symbol, but it's 2664 // We don't know if feedback value is a WeakCell or a Symbol, but it's
2664 // harmless to read at this position in a symbol (see static asserts in 2665 // harmless to read at this position in a symbol (see static asserts in
2665 // type-feedback-vector.h). 2666 // type-feedback-vector.h).
2666 Label check_allocation_site; 2667 Label check_allocation_site;
2667 __ Ldr(feedback_value, FieldMemOperand(feedback, WeakCell::kValueOffset)); 2668 __ Ldr(feedback_value, FieldMemOperand(feedback, WeakCell::kValueOffset));
2668 __ Cmp(function, feedback_value); 2669 __ Cmp(function, feedback_value);
2669 __ B(eq, &done); 2670 __ B(eq, &done_increment_count);
2670 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); 2671 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
2671 __ B(eq, &done); 2672 __ B(eq, &done);
2672 __ Ldr(feedback_map, FieldMemOperand(feedback, HeapObject::kMapOffset)); 2673 __ Ldr(feedback_map, FieldMemOperand(feedback, HeapObject::kMapOffset));
2673 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); 2674 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex);
2674 __ B(ne, &check_allocation_site); 2675 __ B(ne, &check_allocation_site);
2675 2676
2676 // If the weak cell is cleared, we have a new chance to become monomorphic. 2677 // If the weak cell is cleared, we have a new chance to become monomorphic.
2677 __ JumpIfSmi(feedback_value, &initialize); 2678 __ JumpIfSmi(feedback_value, &initialize);
2678 __ B(&megamorphic); 2679 __ B(&megamorphic);
2679 2680
2680 __ bind(&check_allocation_site); 2681 __ bind(&check_allocation_site);
2681 // If we came here, we need to see if we are the array function. 2682 // If we came here, we need to see if we are the array function.
2682 // If we didn't have a matching function, and we didn't find the megamorph 2683 // If we didn't have a matching function, and we didn't find the megamorph
2683 // sentinel, then we have in the slot either some other function or an 2684 // sentinel, then we have in the slot either some other function or an
2684 // AllocationSite. 2685 // AllocationSite.
2685 __ JumpIfNotRoot(feedback_map, Heap::kAllocationSiteMapRootIndex, &miss); 2686 __ JumpIfNotRoot(feedback_map, Heap::kAllocationSiteMapRootIndex, &miss);
2686 2687
2687 // Make sure the function is the Array() function 2688 // Make sure the function is the Array() function
2688 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); 2689 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1);
2689 __ Cmp(function, scratch1); 2690 __ Cmp(function, scratch1);
2690 __ B(ne, &megamorphic); 2691 __ B(ne, &megamorphic);
2691 __ B(&done); 2692 __ B(&done_increment_count);
2692 2693
2693 __ Bind(&miss); 2694 __ Bind(&miss);
2694 2695
2695 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 2696 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
2696 // megamorphic. 2697 // megamorphic.
2697 __ JumpIfRoot(scratch1, Heap::kuninitialized_symbolRootIndex, &initialize); 2698 __ JumpIfRoot(scratch1, Heap::kuninitialized_symbolRootIndex, &initialize);
2698 // MegamorphicSentinel is an immortal immovable object (undefined) so no 2699 // MegamorphicSentinel is an immortal immovable object (undefined) so no
2699 // write-barrier is needed. 2700 // write-barrier is needed.
2700 __ Bind(&megamorphic); 2701 __ Bind(&megamorphic);
2701 __ Add(scratch1, feedback_vector, 2702 __ Add(scratch1, feedback_vector,
2702 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); 2703 Operand::UntagSmiAndScale(index, kPointerSizeLog2));
2703 __ LoadRoot(scratch2, Heap::kmegamorphic_symbolRootIndex); 2704 __ LoadRoot(scratch2, Heap::kmegamorphic_symbolRootIndex);
2704 __ Str(scratch2, FieldMemOperand(scratch1, FixedArray::kHeaderSize)); 2705 __ Str(scratch2, FieldMemOperand(scratch1, FixedArray::kHeaderSize));
2705 __ B(&done); 2706 __ B(&done);
2706 2707
2707 // An uninitialized cache is patched with the function or sentinel to 2708 // An uninitialized cache is patched with the function or sentinel to
2708 // indicate the ElementsKind if function is the Array constructor. 2709 // indicate the ElementsKind if function is the Array constructor.
2709 __ Bind(&initialize); 2710 __ Bind(&initialize);
2710 2711
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
2711 // Make sure the function is the Array() function 2719 // Make sure the function is the Array() function
2712 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); 2720 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1);
2713 __ Cmp(function, scratch1); 2721 __ Cmp(function, scratch1);
2714 __ B(ne, &not_array_function); 2722 __ B(ne, &not_array_function);
2715 2723
2716 // The target function is the Array constructor, 2724 // The target function is the Array constructor,
2717 // Create an AllocationSite if we don't already have it, store it in the 2725 // Create an AllocationSite if we don't already have it, store it in the
2718 // slot. 2726 // slot.
2719 CreateAllocationSiteStub create_stub(masm->isolate()); 2727 CreateAllocationSiteStub create_stub(masm->isolate());
2720 CallStubInRecordCallTarget(masm, &create_stub, argc, function, 2728 CallStubInRecordCallTarget(masm, &create_stub, argc, function,
2721 feedback_vector, index, new_target); 2729 feedback_vector, index, new_target);
2722 __ B(&done); 2730 __ B(&done);
2723 2731
2724 __ Bind(&not_array_function); 2732 __ Bind(&not_array_function);
2725 CreateWeakCellStub weak_cell_stub(masm->isolate()); 2733 CreateWeakCellStub weak_cell_stub(masm->isolate());
2726 CallStubInRecordCallTarget(masm, &weak_cell_stub, argc, function, 2734 CallStubInRecordCallTarget(masm, &weak_cell_stub, argc, function,
2727 feedback_vector, index, new_target); 2735 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
2728 __ Bind(&done); 2748 __ Bind(&done);
2729 } 2749 }
2730 2750
2731 2751
2732 void CallConstructStub::Generate(MacroAssembler* masm) { 2752 void ConstructICStub::Generate(MacroAssembler* masm) {
2733 ASM_LOCATION("CallConstructStub::Generate"); 2753 ASM_LOCATION("CallConstructStub::Generate");
2734 // x0 : number of arguments 2754 // x0 : number of arguments
2735 // x1 : the function to call 2755 // x1 : the function to call
2736 // x2 : feedback vector 2756 // x2 : feedback vector
2737 // x3 : slot in feedback vector (Smi, for RecordCallTarget) 2757 // x3 : slot in feedback vector (Smi, for RecordCallTarget)
2738 Register function = x1; 2758 Register function = x1;
2739 2759
2740 Label non_function; 2760 Label non_function;
2741 // Check that the function is not a smi. 2761 // Check that the function is not a smi.
2742 __ JumpIfSmi(function, &non_function); 2762 __ JumpIfSmi(function, &non_function);
(...skipping 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after
5793 MemOperand(fp, 6 * kPointerSize), NULL); 5813 MemOperand(fp, 6 * kPointerSize), NULL);
5794 } 5814 }
5795 5815
5796 5816
5797 #undef __ 5817 #undef __
5798 5818
5799 } // namespace internal 5819 } // namespace internal
5800 } // namespace v8 5820 } // namespace v8
5801 5821
5802 #endif // V8_TARGET_ARCH_ARM64 5822 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/interface-descriptors-arm.cc ('k') | src/arm64/interface-descriptors-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698