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 3168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3179 | 3179 |
3180 void CallFunctionStub::Generate(MacroAssembler* masm) { | 3180 void CallFunctionStub::Generate(MacroAssembler* masm) { |
3181 // r1 : the function to call | 3181 // r1 : the function to call |
3182 // r2 : cache cell for call target | 3182 // r2 : cache cell for call target |
3183 Label slow, non_function; | 3183 Label slow, non_function; |
3184 | 3184 |
3185 // Check that the function is really a JavaScript function. | 3185 // Check that the function is really a JavaScript function. |
3186 // r1: pushed function (to be verified) | 3186 // r1: pushed function (to be verified) |
3187 __ JumpIfSmi(r1, &non_function); | 3187 __ JumpIfSmi(r1, &non_function); |
3188 | 3188 |
3189 // The receiver might implicitly be the global object. This is | 3189 // Goto slow case if we do not have a function. |
3190 // indicated by passing the hole as the receiver to the call | 3190 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); |
3191 // function stub. | 3191 __ b(ne, &slow); |
3192 if (ReceiverMightBeImplicit() || ReceiverIsImplicit()) { | |
3193 Label try_call, call, patch_current_context; | |
3194 if (ReceiverMightBeImplicit()) { | |
3195 // Get the receiver from the stack. | |
3196 // function, receiver [, arguments] | |
3197 __ ldr(r4, MemOperand(sp, argc_ * kPointerSize)); | |
3198 // Call as function is indicated with the hole. | |
3199 __ CompareRoot(r4, Heap::kTheHoleValueRootIndex); | |
3200 __ b(ne, &try_call); | |
3201 } | |
3202 // Patch the receiver on the stack with the global receiver object. | |
3203 // Goto slow case if we do not have a function. | |
3204 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); | |
3205 __ b(ne, &patch_current_context); | |
3206 CallStubCompiler::FetchGlobalProxy(masm, r3, r1); | |
3207 __ str(r3, MemOperand(sp, argc_ * kPointerSize)); | |
3208 __ jmp(&call); | |
3209 | |
3210 __ bind(&patch_current_context); | |
3211 __ LoadRoot(r4, Heap::kUndefinedValueRootIndex); | |
3212 __ str(r4, MemOperand(sp, argc_ * kPointerSize)); | |
3213 __ jmp(&slow); | |
3214 | |
3215 __ bind(&try_call); | |
3216 // Get the map of the function object. | |
3217 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); | |
3218 __ b(ne, &slow); | |
3219 | |
3220 __ bind(&call); | |
3221 } else { | |
3222 // Get the map of the function object. | |
3223 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); | |
3224 __ b(ne, &slow); | |
3225 } | |
3226 | 3192 |
3227 if (RecordCallTarget()) { | 3193 if (RecordCallTarget()) { |
3228 GenerateRecordCallTarget(masm); | 3194 GenerateRecordCallTarget(masm); |
3229 } | 3195 } |
3230 | 3196 |
3231 // Fast-case: Invoke the function now. | 3197 // Fast-case: Invoke the function now. |
3232 // r1: pushed function | 3198 // r1: pushed function |
3233 ParameterCount actual(argc_); | 3199 ParameterCount actual(argc_); |
3234 | 3200 |
3235 if (ReceiverMightBeImplicit()) { | |
3236 Label call_as_function; | |
3237 __ CompareRoot(r4, Heap::kTheHoleValueRootIndex); | |
3238 __ b(eq, &call_as_function); | |
3239 __ InvokeFunction(r1, | |
3240 actual, | |
3241 JUMP_FUNCTION, | |
3242 NullCallWrapper(), | |
3243 CALL_AS_METHOD); | |
3244 __ bind(&call_as_function); | |
3245 } | |
3246 __ InvokeFunction(r1, | 3201 __ InvokeFunction(r1, |
3247 actual, | 3202 actual, |
3248 JUMP_FUNCTION, | 3203 JUMP_FUNCTION, |
3249 NullCallWrapper(), | 3204 NullCallWrapper(), |
3250 CALL_AS_FUNCTION); | 3205 CALL_AS_FUNCTION); |
3251 | 3206 |
3252 // Slow-case: Non-function called. | 3207 // Slow-case: Non-function called. |
3253 __ bind(&slow); | 3208 __ bind(&slow); |
3254 if (RecordCallTarget()) { | 3209 if (RecordCallTarget()) { |
3255 // If there is a call target cache, mark it megamorphic in the | 3210 // If there is a call target cache, mark it megamorphic in the |
(...skipping 18 matching lines...) Expand all Loading... |
3274 __ Jump(adaptor, RelocInfo::CODE_TARGET); | 3229 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
3275 } | 3230 } |
3276 | 3231 |
3277 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 3232 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
3278 // of the original receiver from the call site). | 3233 // of the original receiver from the call site). |
3279 __ bind(&non_function); | 3234 __ bind(&non_function); |
3280 __ str(r1, MemOperand(sp, argc_ * kPointerSize)); | 3235 __ str(r1, MemOperand(sp, argc_ * kPointerSize)); |
3281 __ mov(r0, Operand(argc_)); // Set up the number of arguments. | 3236 __ mov(r0, Operand(argc_)); // Set up the number of arguments. |
3282 __ mov(r2, Operand::Zero()); | 3237 __ mov(r2, Operand::Zero()); |
3283 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 3238 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
3284 __ SetCallKind(r5, CALL_AS_METHOD); | 3239 __ SetCallKind(r5, CALL_AS_FUNCTION); |
3285 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 3240 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
3286 RelocInfo::CODE_TARGET); | 3241 RelocInfo::CODE_TARGET); |
3287 } | 3242 } |
3288 | 3243 |
3289 | 3244 |
3290 void CallConstructStub::Generate(MacroAssembler* masm) { | 3245 void CallConstructStub::Generate(MacroAssembler* masm) { |
3291 // r0 : number of arguments | 3246 // r0 : number of arguments |
3292 // r1 : the function to call | 3247 // r1 : the function to call |
3293 // r2 : cache cell for call target | 3248 // r2 : cache cell for call target |
3294 Label slow, non_function_call; | 3249 Label slow, non_function_call; |
(...skipping 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5845 __ bind(&fast_elements_case); | 5800 __ bind(&fast_elements_case); |
5846 GenerateCase(masm, FAST_ELEMENTS); | 5801 GenerateCase(masm, FAST_ELEMENTS); |
5847 } | 5802 } |
5848 | 5803 |
5849 | 5804 |
5850 #undef __ | 5805 #undef __ |
5851 | 5806 |
5852 } } // namespace v8::internal | 5807 } } // namespace v8::internal |
5853 | 5808 |
5854 #endif // V8_TARGET_ARCH_ARM | 5809 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |