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/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 ASM_LOCATION("GenerateRecordCallTarget"); | 2003 ASM_LOCATION("GenerateRecordCallTarget"); |
2004 DCHECK(!AreAliased(scratch1, scratch2, scratch3, argc, function, | 2004 DCHECK(!AreAliased(scratch1, scratch2, scratch3, argc, function, |
2005 feedback_vector, index, new_target)); | 2005 feedback_vector, index, new_target)); |
2006 // Cache the called function in a feedback vector slot. Cache states are | 2006 // Cache the called function in a feedback vector slot. Cache states are |
2007 // uninitialized, monomorphic (indicated by a JSFunction), and megamorphic. | 2007 // uninitialized, monomorphic (indicated by a JSFunction), and megamorphic. |
2008 // argc : number of arguments to the construct function | 2008 // argc : number of arguments to the construct function |
2009 // function : the function to call | 2009 // function : the function to call |
2010 // feedback_vector : the feedback vector | 2010 // feedback_vector : the feedback vector |
2011 // index : slot in feedback vector (smi) | 2011 // index : slot in feedback vector (smi) |
2012 Label initialize, done, miss, megamorphic, not_array_function; | 2012 Label initialize, done, miss, megamorphic, not_array_function; |
| 2013 Label done_initialize_count, done_increment_count; |
2013 | 2014 |
2014 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 2015 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
2015 masm->isolate()->heap()->megamorphic_symbol()); | 2016 masm->isolate()->heap()->megamorphic_symbol()); |
2016 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 2017 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
2017 masm->isolate()->heap()->uninitialized_symbol()); | 2018 masm->isolate()->heap()->uninitialized_symbol()); |
2018 | 2019 |
2019 // Load the cache state. | 2020 // Load the cache state. |
2020 Register feedback = scratch1; | 2021 Register feedback = scratch1; |
2021 Register feedback_map = scratch2; | 2022 Register feedback_map = scratch2; |
2022 Register feedback_value = scratch3; | 2023 Register feedback_value = scratch3; |
2023 __ Add(feedback, feedback_vector, | 2024 __ Add(feedback, feedback_vector, |
2024 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 2025 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
2025 __ Ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); | 2026 __ Ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); |
2026 | 2027 |
2027 // A monomorphic cache hit or an already megamorphic state: invoke the | 2028 // A monomorphic cache hit or an already megamorphic state: invoke the |
2028 // function without changing the state. | 2029 // function without changing the state. |
2029 // We don't know if feedback value is a WeakCell or a Symbol, but it's | 2030 // We don't know if feedback value is a WeakCell or a Symbol, but it's |
2030 // harmless to read at this position in a symbol (see static asserts in | 2031 // harmless to read at this position in a symbol (see static asserts in |
2031 // type-feedback-vector.h). | 2032 // type-feedback-vector.h). |
2032 Label check_allocation_site; | 2033 Label check_allocation_site; |
2033 __ Ldr(feedback_value, FieldMemOperand(feedback, WeakCell::kValueOffset)); | 2034 __ Ldr(feedback_value, FieldMemOperand(feedback, WeakCell::kValueOffset)); |
2034 __ Cmp(function, feedback_value); | 2035 __ Cmp(function, feedback_value); |
2035 __ B(eq, &done); | 2036 __ B(eq, &done_increment_count); |
2036 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); | 2037 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); |
2037 __ B(eq, &done); | 2038 __ B(eq, &done); |
2038 __ Ldr(feedback_map, FieldMemOperand(feedback, HeapObject::kMapOffset)); | 2039 __ Ldr(feedback_map, FieldMemOperand(feedback, HeapObject::kMapOffset)); |
2039 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); | 2040 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); |
2040 __ B(ne, &check_allocation_site); | 2041 __ B(ne, &check_allocation_site); |
2041 | 2042 |
2042 // If the weak cell is cleared, we have a new chance to become monomorphic. | 2043 // If the weak cell is cleared, we have a new chance to become monomorphic. |
2043 __ JumpIfSmi(feedback_value, &initialize); | 2044 __ JumpIfSmi(feedback_value, &initialize); |
2044 __ B(&megamorphic); | 2045 __ B(&megamorphic); |
2045 | 2046 |
2046 __ bind(&check_allocation_site); | 2047 __ bind(&check_allocation_site); |
2047 // If we came here, we need to see if we are the array function. | 2048 // If we came here, we need to see if we are the array function. |
2048 // If we didn't have a matching function, and we didn't find the megamorph | 2049 // If we didn't have a matching function, and we didn't find the megamorph |
2049 // sentinel, then we have in the slot either some other function or an | 2050 // sentinel, then we have in the slot either some other function or an |
2050 // AllocationSite. | 2051 // AllocationSite. |
2051 __ JumpIfNotRoot(feedback_map, Heap::kAllocationSiteMapRootIndex, &miss); | 2052 __ JumpIfNotRoot(feedback_map, Heap::kAllocationSiteMapRootIndex, &miss); |
2052 | 2053 |
2053 // Make sure the function is the Array() function | 2054 // Make sure the function is the Array() function |
2054 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); | 2055 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); |
2055 __ Cmp(function, scratch1); | 2056 __ Cmp(function, scratch1); |
2056 __ B(ne, &megamorphic); | 2057 __ B(ne, &megamorphic); |
2057 __ B(&done); | 2058 __ B(&done_increment_count); |
2058 | 2059 |
2059 __ Bind(&miss); | 2060 __ Bind(&miss); |
2060 | 2061 |
2061 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 2062 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
2062 // megamorphic. | 2063 // megamorphic. |
2063 __ JumpIfRoot(scratch1, Heap::kuninitialized_symbolRootIndex, &initialize); | 2064 __ JumpIfRoot(scratch1, Heap::kuninitialized_symbolRootIndex, &initialize); |
2064 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 2065 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
2065 // write-barrier is needed. | 2066 // write-barrier is needed. |
2066 __ Bind(&megamorphic); | 2067 __ Bind(&megamorphic); |
2067 __ Add(scratch1, feedback_vector, | 2068 __ Add(scratch1, feedback_vector, |
(...skipping 10 matching lines...) Expand all Loading... |
2078 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); | 2079 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); |
2079 __ Cmp(function, scratch1); | 2080 __ Cmp(function, scratch1); |
2080 __ B(ne, ¬_array_function); | 2081 __ B(ne, ¬_array_function); |
2081 | 2082 |
2082 // The target function is the Array constructor, | 2083 // The target function is the Array constructor, |
2083 // Create an AllocationSite if we don't already have it, store it in the | 2084 // Create an AllocationSite if we don't already have it, store it in the |
2084 // slot. | 2085 // slot. |
2085 CreateAllocationSiteStub create_stub(masm->isolate()); | 2086 CreateAllocationSiteStub create_stub(masm->isolate()); |
2086 CallStubInRecordCallTarget(masm, &create_stub, argc, function, | 2087 CallStubInRecordCallTarget(masm, &create_stub, argc, function, |
2087 feedback_vector, index, new_target); | 2088 feedback_vector, index, new_target); |
2088 __ B(&done); | 2089 __ B(&done_initialize_count); |
2089 | 2090 |
2090 __ Bind(¬_array_function); | 2091 __ Bind(¬_array_function); |
2091 CreateWeakCellStub weak_cell_stub(masm->isolate()); | 2092 CreateWeakCellStub weak_cell_stub(masm->isolate()); |
2092 CallStubInRecordCallTarget(masm, &weak_cell_stub, argc, function, | 2093 CallStubInRecordCallTarget(masm, &weak_cell_stub, argc, function, |
2093 feedback_vector, index, new_target); | 2094 feedback_vector, index, new_target); |
| 2095 |
| 2096 __ bind(&done_initialize_count); |
| 2097 // Initialize the call counter. |
| 2098 __ Mov(scratch1, Operand(Smi::FromInt(1))); |
| 2099 __ Adds(scratch2, feedback_vector, |
| 2100 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
| 2101 __ Str(scratch1, |
| 2102 FieldMemOperand(scratch2, FixedArray::kHeaderSize + kPointerSize)); |
| 2103 __ b(&done); |
| 2104 |
| 2105 __ bind(&done_increment_count); |
| 2106 |
| 2107 // Increment the call count for monomorphic function calls. |
| 2108 __ Add(scratch1, feedback_vector, |
| 2109 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
| 2110 __ Add(scratch1, scratch1, Operand(FixedArray::kHeaderSize + kPointerSize)); |
| 2111 __ Ldr(scratch2, FieldMemOperand(scratch1, 0)); |
| 2112 __ Add(scratch2, scratch2, Operand(Smi::FromInt(1))); |
| 2113 __ Str(scratch2, FieldMemOperand(scratch1, 0)); |
| 2114 |
2094 __ Bind(&done); | 2115 __ Bind(&done); |
2095 } | 2116 } |
2096 | 2117 |
2097 | 2118 |
2098 void CallConstructStub::Generate(MacroAssembler* masm) { | 2119 void CallConstructStub::Generate(MacroAssembler* masm) { |
2099 ASM_LOCATION("CallConstructStub::Generate"); | 2120 ASM_LOCATION("CallConstructStub::Generate"); |
2100 // x0 : number of arguments | 2121 // x0 : number of arguments |
2101 // x1 : the function to call | 2122 // x1 : the function to call |
2102 // x2 : feedback vector | 2123 // x2 : feedback vector |
2103 // x3 : slot in feedback vector (Smi, for RecordCallTarget) | 2124 // x3 : slot in feedback vector (Smi, for RecordCallTarget) |
(...skipping 3716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5820 kStackUnwindSpace, NULL, spill_offset, | 5841 kStackUnwindSpace, NULL, spill_offset, |
5821 return_value_operand, NULL); | 5842 return_value_operand, NULL); |
5822 } | 5843 } |
5823 | 5844 |
5824 #undef __ | 5845 #undef __ |
5825 | 5846 |
5826 } // namespace internal | 5847 } // namespace internal |
5827 } // namespace v8 | 5848 } // namespace v8 |
5828 | 5849 |
5829 #endif // V8_TARGET_ARCH_ARM64 | 5850 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |