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 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2753 // Do not transform the receiver for strict mode functions. | 2753 // Do not transform the receiver for strict mode functions. |
2754 __ Ldr(x3, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); | 2754 __ Ldr(x3, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); |
2755 __ Ldr(w4, FieldMemOperand(x3, SharedFunctionInfo::kCompilerHintsOffset)); | 2755 __ Ldr(w4, FieldMemOperand(x3, SharedFunctionInfo::kCompilerHintsOffset)); |
2756 __ Tbnz(w4, SharedFunctionInfo::kStrictModeFunction, cont); | 2756 __ Tbnz(w4, SharedFunctionInfo::kStrictModeFunction, cont); |
2757 | 2757 |
2758 // Do not transform the receiver for native (Compilerhints already in x3). | 2758 // Do not transform the receiver for native (Compilerhints already in x3). |
2759 __ Tbnz(w4, SharedFunctionInfo::kNative, cont); | 2759 __ Tbnz(w4, SharedFunctionInfo::kNative, cont); |
2760 } | 2760 } |
2761 | 2761 |
2762 | 2762 |
2763 static void EmitSlowCase(MacroAssembler* masm, | 2763 static void EmitSlowCase(MacroAssembler* masm, int argc) { |
2764 int argc, | 2764 __ Mov(x0, argc); |
2765 Register function, | 2765 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
2766 Register type, | |
2767 Label* non_function) { | |
2768 // Check for function proxy. | |
2769 // x10 : function type. | |
2770 __ CompareAndBranch(type, JS_FUNCTION_PROXY_TYPE, ne, non_function); | |
2771 __ Push(function); // put proxy as additional argument | |
2772 __ Mov(x0, argc + 1); | |
2773 __ Mov(x2, 0); | |
2774 __ GetBuiltinFunction(x1, Context::CALL_FUNCTION_PROXY_BUILTIN_INDEX); | |
2775 { | |
2776 Handle<Code> adaptor = | |
2777 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | |
2778 __ Jump(adaptor, RelocInfo::CODE_TARGET); | |
2779 } | |
2780 | |
2781 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | |
2782 // of the original receiver from the call site). | |
2783 __ Bind(non_function); | |
2784 __ Poke(function, argc * kXRegSize); | |
2785 __ Mov(x0, argc); // Set up the number of arguments. | |
2786 __ Mov(x2, 0); | |
2787 __ GetBuiltinFunction(function, Context::CALL_NON_FUNCTION_BUILTIN_INDEX); | |
2788 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | |
2789 RelocInfo::CODE_TARGET); | |
2790 } | 2766 } |
2791 | 2767 |
2792 | 2768 |
2793 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { | 2769 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { |
2794 // Wrap the receiver and patch it back onto the stack. | 2770 // Wrap the receiver and patch it back onto the stack. |
2795 { FrameScope frame_scope(masm, StackFrame::INTERNAL); | 2771 { FrameScope frame_scope(masm, StackFrame::INTERNAL); |
2796 __ Push(x1); | 2772 __ Push(x1); |
2797 __ Mov(x0, x3); | 2773 __ Mov(x0, x3); |
2798 ToObjectStub stub(masm->isolate()); | 2774 ToObjectStub stub(masm->isolate()); |
2799 __ CallStub(&stub); | 2775 __ CallStub(&stub); |
2800 __ Pop(x1); | 2776 __ Pop(x1); |
2801 } | 2777 } |
2802 __ Poke(x0, argc * kPointerSize); | 2778 __ Poke(x0, argc * kPointerSize); |
2803 __ B(cont); | 2779 __ B(cont); |
2804 } | 2780 } |
2805 | 2781 |
2806 | 2782 |
2807 static void CallFunctionNoFeedback(MacroAssembler* masm, | 2783 static void CallFunctionNoFeedback(MacroAssembler* masm, |
2808 int argc, bool needs_checks, | 2784 int argc, bool needs_checks, |
2809 bool call_as_method) { | 2785 bool call_as_method) { |
2810 // x1 function the function to call | 2786 // x1 function the function to call |
2811 Register function = x1; | 2787 Register function = x1; |
2812 Register type = x4; | 2788 Register type = x4; |
2813 Label slow, non_function, wrap, cont; | 2789 Label slow, wrap, cont; |
2814 | 2790 |
2815 // TODO(jbramley): This function has a lot of unnamed registers. Name them, | 2791 // TODO(jbramley): This function has a lot of unnamed registers. Name them, |
2816 // and tidy things up a bit. | 2792 // and tidy things up a bit. |
2817 | 2793 |
2818 if (needs_checks) { | 2794 if (needs_checks) { |
2819 // Check that the function is really a JavaScript function. | 2795 // Check that the function is really a JavaScript function. |
2820 __ JumpIfSmi(function, &non_function); | 2796 __ JumpIfSmi(function, &slow); |
2821 | 2797 |
2822 // Goto slow case if we do not have a function. | 2798 // Goto slow case if we do not have a function. |
2823 __ JumpIfNotObjectType(function, x10, type, JS_FUNCTION_TYPE, &slow); | 2799 __ JumpIfNotObjectType(function, x10, type, JS_FUNCTION_TYPE, &slow); |
2824 } | 2800 } |
2825 | 2801 |
2826 // Fast-case: Invoke the function now. | 2802 // Fast-case: Invoke the function now. |
2827 // x1 function pushed function | 2803 // x1 function pushed function |
2828 ParameterCount actual(argc); | 2804 ParameterCount actual(argc); |
2829 | 2805 |
2830 if (call_as_method) { | 2806 if (call_as_method) { |
(...skipping 14 matching lines...) Expand all Loading... |
2845 __ Bind(&cont); | 2821 __ Bind(&cont); |
2846 } | 2822 } |
2847 | 2823 |
2848 __ InvokeFunction(function, | 2824 __ InvokeFunction(function, |
2849 actual, | 2825 actual, |
2850 JUMP_FUNCTION, | 2826 JUMP_FUNCTION, |
2851 NullCallWrapper()); | 2827 NullCallWrapper()); |
2852 if (needs_checks) { | 2828 if (needs_checks) { |
2853 // Slow-case: Non-function called. | 2829 // Slow-case: Non-function called. |
2854 __ Bind(&slow); | 2830 __ Bind(&slow); |
2855 EmitSlowCase(masm, argc, function, type, &non_function); | 2831 EmitSlowCase(masm, argc); |
2856 } | 2832 } |
2857 | 2833 |
2858 if (call_as_method) { | 2834 if (call_as_method) { |
2859 __ Bind(&wrap); | 2835 __ Bind(&wrap); |
2860 EmitWrapCase(masm, argc, &cont); | 2836 EmitWrapCase(masm, argc, &cont); |
2861 } | 2837 } |
2862 } | 2838 } |
2863 | 2839 |
2864 | 2840 |
2865 void CallFunctionStub::Generate(MacroAssembler* masm) { | 2841 void CallFunctionStub::Generate(MacroAssembler* masm) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 Register original_constructor = index; | 2971 Register original_constructor = index; |
2996 __ Mov(allocation_site, scratch); | 2972 __ Mov(allocation_site, scratch); |
2997 __ Mov(original_constructor, function); | 2973 __ Mov(original_constructor, function); |
2998 ArrayConstructorStub stub(masm->isolate(), arg_count()); | 2974 ArrayConstructorStub stub(masm->isolate(), arg_count()); |
2999 __ TailCallStub(&stub); | 2975 __ TailCallStub(&stub); |
3000 | 2976 |
3001 __ bind(&miss); | 2977 __ bind(&miss); |
3002 GenerateMiss(masm); | 2978 GenerateMiss(masm); |
3003 | 2979 |
3004 // The slow case, we need this no matter what to complete a call after a miss. | 2980 // The slow case, we need this no matter what to complete a call after a miss. |
3005 CallFunctionNoFeedback(masm, | 2981 __ Mov(x0, arg_count()); |
3006 arg_count(), | 2982 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
3007 true, | |
3008 CallAsMethod()); | |
3009 | |
3010 __ Unreachable(); | |
3011 } | 2983 } |
3012 | 2984 |
3013 | 2985 |
3014 void CallICStub::Generate(MacroAssembler* masm) { | 2986 void CallICStub::Generate(MacroAssembler* masm) { |
3015 ASM_LOCATION("CallICStub"); | 2987 ASM_LOCATION("CallICStub"); |
3016 | 2988 |
3017 // x1 - function | 2989 // x1 - function |
3018 // x3 - slot id (Smi) | 2990 // x3 - slot id (Smi) |
3019 // x2 - vector | 2991 // x2 - vector |
3020 const int with_types_offset = | 2992 const int with_types_offset = |
3021 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); | 2993 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); |
3022 const int generic_offset = | 2994 const int generic_offset = |
3023 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); | 2995 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); |
3024 Label extra_checks_or_miss, slow_start; | 2996 Label extra_checks_or_miss, slow_start; |
3025 Label slow, non_function, wrap, cont; | 2997 Label slow, wrap, cont; |
3026 Label have_js_function; | 2998 Label have_js_function; |
3027 int argc = arg_count(); | 2999 int argc = arg_count(); |
3028 ParameterCount actual(argc); | 3000 ParameterCount actual(argc); |
3029 | 3001 |
3030 Register function = x1; | 3002 Register function = x1; |
3031 Register feedback_vector = x2; | 3003 Register feedback_vector = x2; |
3032 Register index = x3; | 3004 Register index = x3; |
3033 Register type = x4; | 3005 Register type = x4; |
3034 | 3006 |
3035 // The checks. First, does x1 match the recorded monomorphic target? | 3007 // The checks. First, does x1 match the recorded monomorphic target? |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3080 | 3052 |
3081 __ Bind(&cont); | 3053 __ Bind(&cont); |
3082 } | 3054 } |
3083 | 3055 |
3084 __ InvokeFunction(function, | 3056 __ InvokeFunction(function, |
3085 actual, | 3057 actual, |
3086 JUMP_FUNCTION, | 3058 JUMP_FUNCTION, |
3087 NullCallWrapper()); | 3059 NullCallWrapper()); |
3088 | 3060 |
3089 __ bind(&slow); | 3061 __ bind(&slow); |
3090 EmitSlowCase(masm, argc, function, type, &non_function); | 3062 EmitSlowCase(masm, argc); |
3091 | 3063 |
3092 if (CallAsMethod()) { | 3064 if (CallAsMethod()) { |
3093 __ bind(&wrap); | 3065 __ bind(&wrap); |
3094 EmitWrapCase(masm, argc, &cont); | 3066 EmitWrapCase(masm, argc, &cont); |
3095 } | 3067 } |
3096 | 3068 |
3097 __ bind(&extra_checks_or_miss); | 3069 __ bind(&extra_checks_or_miss); |
3098 Label uninitialized, miss; | 3070 Label uninitialized, miss; |
3099 | 3071 |
3100 __ JumpIfRoot(x4, Heap::kmegamorphic_symbolRootIndex, &slow_start); | 3072 __ JumpIfRoot(x4, Heap::kmegamorphic_symbolRootIndex, &slow_start); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3165 | 3137 |
3166 // We are here because tracing is on or we encountered a MISS case we can't | 3138 // We are here because tracing is on or we encountered a MISS case we can't |
3167 // handle here. | 3139 // handle here. |
3168 __ bind(&miss); | 3140 __ bind(&miss); |
3169 GenerateMiss(masm); | 3141 GenerateMiss(masm); |
3170 | 3142 |
3171 // the slow case | 3143 // the slow case |
3172 __ bind(&slow_start); | 3144 __ bind(&slow_start); |
3173 | 3145 |
3174 // Check that the function is really a JavaScript function. | 3146 // Check that the function is really a JavaScript function. |
3175 __ JumpIfSmi(function, &non_function); | 3147 __ JumpIfSmi(function, &slow); |
3176 | 3148 |
3177 // Goto slow case if we do not have a function. | 3149 // Goto slow case if we do not have a function. |
3178 __ JumpIfNotObjectType(function, x10, type, JS_FUNCTION_TYPE, &slow); | 3150 __ JumpIfNotObjectType(function, x10, type, JS_FUNCTION_TYPE, &slow); |
3179 __ B(&have_js_function); | 3151 __ B(&have_js_function); |
3180 } | 3152 } |
3181 | 3153 |
3182 | 3154 |
3183 void CallICStub::GenerateMiss(MacroAssembler* masm) { | 3155 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
3184 ASM_LOCATION("CallICStub[Miss]"); | 3156 ASM_LOCATION("CallICStub[Miss]"); |
3185 | 3157 |
(...skipping 2854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6040 MemOperand(fp, 6 * kPointerSize), NULL); | 6012 MemOperand(fp, 6 * kPointerSize), NULL); |
6041 } | 6013 } |
6042 | 6014 |
6043 | 6015 |
6044 #undef __ | 6016 #undef __ |
6045 | 6017 |
6046 } // namespace internal | 6018 } // namespace internal |
6047 } // namespace v8 | 6019 } // namespace v8 |
6048 | 6020 |
6049 #endif // V8_TARGET_ARCH_ARM64 | 6021 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |