OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2970 | 2970 |
2971 __ Push(r4, r2, r1); | 2971 __ Push(r4, r2, r1); |
2972 __ RecordWrite(r2, r4, r1, kLRHasNotBeenSaved, kDontSaveFPRegs, | 2972 __ RecordWrite(r2, r4, r1, kLRHasNotBeenSaved, kDontSaveFPRegs, |
2973 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 2973 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
2974 __ Pop(r4, r2, r1); | 2974 __ Pop(r4, r2, r1); |
2975 | 2975 |
2976 __ bind(&done); | 2976 __ bind(&done); |
2977 } | 2977 } |
2978 | 2978 |
2979 | 2979 |
2980 static void GenericCallHelper(MacroAssembler* masm, | 2980 void CallFunctionStub::Generate(MacroAssembler* masm) { |
2981 const CallIC::State& state) { | |
2982 // r1 : the function to call | 2981 // r1 : the function to call |
| 2982 // r2 : feedback vector |
| 2983 // r3 : (only if r2 is not the megamorphic symbol) slot in feedback |
| 2984 // vector (Smi) |
2983 Label slow, non_function, wrap, cont; | 2985 Label slow, non_function, wrap, cont; |
2984 | 2986 |
2985 if (state.IsGeneric()) { | 2987 if (NeedsChecks()) { |
2986 // Check that the function is really a JavaScript function. | 2988 // Check that the function is really a JavaScript function. |
2987 // r1: pushed function (to be verified) | 2989 // r1: pushed function (to be verified) |
2988 __ JumpIfSmi(r1, &non_function); | 2990 __ JumpIfSmi(r1, &non_function); |
2989 | 2991 |
2990 // Goto slow case if we do not have a function. | 2992 // Goto slow case if we do not have a function. |
2991 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); | 2993 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); |
2992 __ b(ne, &slow); | 2994 __ b(ne, &slow); |
| 2995 |
| 2996 if (RecordCallTarget()) { |
| 2997 GenerateRecordCallTarget(masm); |
| 2998 // Type information was updated. Because we may call Array, which |
| 2999 // expects either undefined or an AllocationSite in ebx we need |
| 3000 // to set ebx to undefined. |
| 3001 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
| 3002 } |
2993 } | 3003 } |
2994 | 3004 |
2995 // Fast-case: Invoke the function now. | 3005 // Fast-case: Invoke the function now. |
2996 // r1: pushed function | 3006 // r1: pushed function |
2997 int argc = state.arg_count(); | 3007 ParameterCount actual(argc_); |
2998 ParameterCount actual(argc); | |
2999 | 3008 |
3000 if (state.CallAsMethod()) { | 3009 if (CallAsMethod()) { |
3001 if (state.IsGeneric()) { | 3010 if (NeedsChecks()) { |
3002 // Do not transform the receiver for strict mode functions. | 3011 // Do not transform the receiver for strict mode functions. |
3003 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 3012 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
3004 __ ldr(r4, FieldMemOperand(r3, SharedFunctionInfo::kCompilerHintsOffset)); | 3013 __ ldr(r4, FieldMemOperand(r3, SharedFunctionInfo::kCompilerHintsOffset)); |
3005 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + | 3014 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + |
3006 kSmiTagSize))); | 3015 kSmiTagSize))); |
3007 __ b(ne, &cont); | 3016 __ b(ne, &cont); |
3008 | 3017 |
3009 // Do not transform the receiver for native (Compilerhints already in r3). | 3018 // Do not transform the receiver for native (Compilerhints already in r3). |
3010 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); | 3019 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); |
3011 __ b(ne, &cont); | 3020 __ b(ne, &cont); |
3012 } | 3021 } |
3013 | 3022 |
3014 if (state.IsSloppy()) { | 3023 // Compute the receiver in sloppy mode. |
3015 // Compute the receiver in sloppy mode. | 3024 __ ldr(r3, MemOperand(sp, argc_ * kPointerSize)); |
3016 __ ldr(r3, MemOperand(sp, argc * kPointerSize)); | |
3017 | 3025 |
| 3026 if (NeedsChecks()) { |
3018 __ JumpIfSmi(r3, &wrap); | 3027 __ JumpIfSmi(r3, &wrap); |
3019 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); | 3028 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); |
3020 __ b(lt, &wrap); | 3029 __ b(lt, &wrap); |
| 3030 } else { |
| 3031 __ jmp(&wrap); |
3021 } | 3032 } |
3022 | 3033 |
3023 __ bind(&cont); | 3034 __ bind(&cont); |
3024 } | 3035 } |
| 3036 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper()); |
3025 | 3037 |
3026 if (state.ArgumentsMustMatch()) { | 3038 if (NeedsChecks()) { |
3027 __ InvokeFunction(r1, actual, actual, JUMP_FUNCTION, NullCallWrapper()); | |
3028 } else { | |
3029 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper()); | |
3030 } | |
3031 | |
3032 if (state.IsGeneric()) { | |
3033 // Slow-case: Non-function called. | 3039 // Slow-case: Non-function called. |
3034 __ bind(&slow); | 3040 __ bind(&slow); |
| 3041 if (RecordCallTarget()) { |
| 3042 // If there is a call target cache, mark it megamorphic in the |
| 3043 // non-function case. MegamorphicSentinel is an immortal immovable |
| 3044 // object (megamorphic symbol) so no write barrier is needed. |
| 3045 ASSERT_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()), |
| 3046 masm->isolate()->heap()->megamorphic_symbol()); |
| 3047 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); |
| 3048 __ LoadRoot(ip, Heap::kMegamorphicSymbolRootIndex); |
| 3049 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize)); |
| 3050 } |
3035 // Check for function proxy. | 3051 // Check for function proxy. |
3036 __ cmp(r4, Operand(JS_FUNCTION_PROXY_TYPE)); | 3052 __ cmp(r4, Operand(JS_FUNCTION_PROXY_TYPE)); |
3037 __ b(ne, &non_function); | 3053 __ b(ne, &non_function); |
3038 __ push(r1); // put proxy as additional argument | 3054 __ push(r1); // put proxy as additional argument |
3039 __ mov(r0, Operand(argc + 1, RelocInfo::NONE32)); | 3055 __ mov(r0, Operand(argc_ + 1, RelocInfo::NONE32)); |
3040 __ mov(r2, Operand::Zero()); | 3056 __ mov(r2, Operand::Zero()); |
3041 __ GetBuiltinFunction(r1, Builtins::CALL_FUNCTION_PROXY); | 3057 __ GetBuiltinFunction(r1, Builtins::CALL_FUNCTION_PROXY); |
3042 { | 3058 { |
3043 Handle<Code> adaptor = | 3059 Handle<Code> adaptor = |
3044 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 3060 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
3045 __ Jump(adaptor, RelocInfo::CODE_TARGET); | 3061 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
3046 } | 3062 } |
3047 | 3063 |
3048 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 3064 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
3049 // of the original receiver from the call site). | 3065 // of the original receiver from the call site). |
3050 __ bind(&non_function); | 3066 __ bind(&non_function); |
3051 __ str(r1, MemOperand(sp, argc * kPointerSize)); | 3067 __ str(r1, MemOperand(sp, argc_ * kPointerSize)); |
3052 __ mov(r0, Operand(argc)); // Set up the number of arguments. | 3068 __ mov(r0, Operand(argc_)); // Set up the number of arguments. |
3053 __ mov(r2, Operand::Zero()); | 3069 __ mov(r2, Operand::Zero()); |
3054 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION); | 3070 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION); |
3055 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 3071 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
3056 RelocInfo::CODE_TARGET); | 3072 RelocInfo::CODE_TARGET); |
3057 } | 3073 } |
3058 | 3074 |
3059 if (state.CallAsMethod() && state.IsSloppy()) { | 3075 if (CallAsMethod()) { |
3060 __ bind(&wrap); | 3076 __ bind(&wrap); |
3061 | |
3062 if (!state.IsGeneric()) { | |
3063 __ ldr(r5, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | |
3064 __ ldr(r4, FieldMemOperand(r5, SharedFunctionInfo::kCompilerHintsOffset)); | |
3065 | |
3066 // Do not transform the receiver for native | |
3067 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); | |
3068 __ b(ne, &cont); | |
3069 } | |
3070 | |
3071 // Wrap the receiver and patch it back onto the stack. | 3077 // Wrap the receiver and patch it back onto the stack. |
3072 { FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL); | 3078 { FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL); |
3073 __ Push(r1, r3); | 3079 __ Push(r1, r3); |
3074 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 3080 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
3075 __ pop(r1); | 3081 __ pop(r1); |
3076 } | 3082 } |
3077 __ str(r0, MemOperand(sp, argc * kPointerSize)); | 3083 __ str(r0, MemOperand(sp, argc_ * kPointerSize)); |
3078 __ jmp(&cont); | 3084 __ jmp(&cont); |
3079 } | 3085 } |
3080 } | 3086 } |
3081 | 3087 |
3082 | 3088 |
3083 void CallFunctionStub::Generate(MacroAssembler* masm) { | |
3084 // r1 : the function to call | |
3085 | |
3086 // GenericCallHelper expresses it's options in terms of CallIC::State. | |
3087 CallIC::CallType call_type = CallAsMethod() ? | |
3088 CallIC::METHOD : CallIC::FUNCTION; | |
3089 | |
3090 if (NeedsChecks()) { | |
3091 GenericCallHelper(masm, | |
3092 CallIC::State::SlowCallState( | |
3093 argc_, | |
3094 call_type)); | |
3095 } else { | |
3096 GenericCallHelper(masm, | |
3097 CallIC::State::MonomorphicCallState( | |
3098 argc_, | |
3099 call_type, | |
3100 CallIC::ARGUMENTS_COUNT_UNKNOWN, | |
3101 SLOPPY)); | |
3102 } | |
3103 } | |
3104 | |
3105 | |
3106 void CallConstructStub::Generate(MacroAssembler* masm) { | 3089 void CallConstructStub::Generate(MacroAssembler* masm) { |
3107 // r0 : number of arguments | 3090 // r0 : number of arguments |
3108 // r1 : the function to call | 3091 // r1 : the function to call |
3109 // r2 : feedback vector | 3092 // r2 : feedback vector |
3110 // r3 : (only if r2 is not the megamorphic symbol) slot in feedback | 3093 // r3 : (only if r2 is not the megamorphic symbol) slot in feedback |
3111 // vector (Smi) | 3094 // vector (Smi) |
3112 Label slow, non_function_call; | 3095 Label slow, non_function_call; |
3113 | 3096 |
3114 // Check that the function is not a smi. | 3097 // Check that the function is not a smi. |
3115 __ JumpIfSmi(r1, &non_function_call); | 3098 __ JumpIfSmi(r1, &non_function_call); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3160 __ bind(&non_function_call); | 3143 __ bind(&non_function_call); |
3161 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 3144 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
3162 __ bind(&do_call); | 3145 __ bind(&do_call); |
3163 // Set expected number of arguments to zero (not changing r0). | 3146 // Set expected number of arguments to zero (not changing r0). |
3164 __ mov(r2, Operand::Zero()); | 3147 __ mov(r2, Operand::Zero()); |
3165 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 3148 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
3166 RelocInfo::CODE_TARGET); | 3149 RelocInfo::CODE_TARGET); |
3167 } | 3150 } |
3168 | 3151 |
3169 | 3152 |
3170 void CallICStub::GenerateMonomorphicCall(MacroAssembler* masm) { | |
3171 GenericCallHelper(masm, | |
3172 CallIC::State::MonomorphicCallState( | |
3173 state_.arg_count(), | |
3174 state_.call_type(), | |
3175 state_.argument_check(), | |
3176 state_.strict_mode())); | |
3177 } | |
3178 | |
3179 | |
3180 void CallICStub::GenerateSlowCall(MacroAssembler* masm) { | |
3181 GenericCallHelper(masm, | |
3182 CallIC::State::SlowCallState( | |
3183 state_.arg_count(), | |
3184 state_.call_type())); | |
3185 } | |
3186 | |
3187 | |
3188 void CallICStub::Generate(MacroAssembler* masm) { | |
3189 // r1 - function | |
3190 // r2 - vector | |
3191 // r3 - slot id (Smi) | |
3192 Label extra_checks_or_miss, slow; | |
3193 | |
3194 // The checks. First, does r1 match the recorded monomorphic target? | |
3195 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | |
3196 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize)); | |
3197 __ cmp(r1, r4); | |
3198 __ b(ne, &extra_checks_or_miss); | |
3199 | |
3200 GenerateMonomorphicCall(masm); | |
3201 | |
3202 __ bind(&extra_checks_or_miss); | |
3203 if (IsGeneric()) { | |
3204 Label miss_uninit; | |
3205 | |
3206 __ CompareRoot(r4, Heap::kMegamorphicSymbolRootIndex); | |
3207 __ b(eq, &slow); | |
3208 __ CompareRoot(r4, Heap::kUninitializedSymbolRootIndex); | |
3209 __ b(eq, &miss_uninit); | |
3210 // If we get here, go from monomorphic to megamorphic, Don't bother missing, | |
3211 // just update. | |
3212 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | |
3213 __ LoadRoot(ip, Heap::kMegamorphicSymbolRootIndex); | |
3214 __ str(ip, FieldMemOperand(r4, FixedArray::kHeaderSize)); | |
3215 __ jmp(&slow); | |
3216 | |
3217 __ bind(&miss_uninit); | |
3218 } | |
3219 | |
3220 GenerateMiss(masm); | |
3221 | |
3222 // the slow case | |
3223 __ bind(&slow); | |
3224 GenerateSlowCall(masm); | |
3225 } | |
3226 | |
3227 | |
3228 void CallICStub::GenerateMiss(MacroAssembler* masm) { | |
3229 // Get the receiver of the function from the stack; 1 ~ return address. | |
3230 __ ldr(r4, MemOperand(sp, (state_.arg_count() + 1) * kPointerSize)); | |
3231 | |
3232 { | |
3233 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | |
3234 | |
3235 // Push the receiver and the function and feedback info. | |
3236 __ Push(r4, r1, r2, r3); | |
3237 | |
3238 // Call the entry. | |
3239 ExternalReference miss = ExternalReference(IC_Utility(IC::kCallIC_Miss), | |
3240 masm->isolate()); | |
3241 __ CallExternalReference(miss, 4); | |
3242 | |
3243 // Move result to edi and exit the internal frame. | |
3244 __ mov(r1, r0); | |
3245 } | |
3246 } | |
3247 | |
3248 | |
3249 // StringCharCodeAtGenerator | 3153 // StringCharCodeAtGenerator |
3250 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { | 3154 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { |
3251 Label flat_string; | 3155 Label flat_string; |
3252 Label ascii_string; | 3156 Label ascii_string; |
3253 Label got_char_code; | 3157 Label got_char_code; |
3254 Label sliced_string; | 3158 Label sliced_string; |
3255 | 3159 |
3256 // If the receiver is a smi trigger the non-string case. | 3160 // If the receiver is a smi trigger the non-string case. |
3257 __ JumpIfSmi(object_, receiver_not_string_); | 3161 __ JumpIfSmi(object_, receiver_not_string_); |
3258 | 3162 |
(...skipping 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5555 MemOperand(fp, 6 * kPointerSize), | 5459 MemOperand(fp, 6 * kPointerSize), |
5556 NULL); | 5460 NULL); |
5557 } | 5461 } |
5558 | 5462 |
5559 | 5463 |
5560 #undef __ | 5464 #undef __ |
5561 | 5465 |
5562 } } // namespace v8::internal | 5466 } } // namespace v8::internal |
5563 | 5467 |
5564 #endif // V8_TARGET_ARCH_ARM | 5468 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |