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