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 3164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3175 | 3175 |
3176 __ bind(&done); | 3176 __ bind(&done); |
3177 } | 3177 } |
3178 | 3178 |
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 // The receiver might implicitly be the global object. This is |
| 3186 // indicated by passing the hole as the receiver to the call |
| 3187 // function stub. |
| 3188 if (ReceiverMightBeImplicit()) { |
| 3189 Label call; |
| 3190 // Get the receiver from the stack. |
| 3191 // function, receiver [, arguments] |
| 3192 __ ldr(r4, MemOperand(sp, argc_ * kPointerSize)); |
| 3193 // Call as function is indicated with the hole. |
| 3194 __ CompareRoot(r4, Heap::kTheHoleValueRootIndex); |
| 3195 __ b(ne, &call); |
| 3196 // Patch the receiver on the stack with the global receiver object. |
| 3197 __ ldr(r3, |
| 3198 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 3199 __ ldr(r3, FieldMemOperand(r3, GlobalObject::kGlobalReceiverOffset)); |
| 3200 __ str(r3, MemOperand(sp, argc_ * kPointerSize)); |
| 3201 __ bind(&call); |
| 3202 } |
| 3203 |
3185 // Check that the function is really a JavaScript function. | 3204 // Check that the function is really a JavaScript function. |
3186 // r1: pushed function (to be verified) | 3205 // r1: pushed function (to be verified) |
3187 __ JumpIfSmi(r1, &non_function); | 3206 __ JumpIfSmi(r1, &non_function); |
3188 | 3207 // Get the map of the function object. |
3189 // The receiver might implicitly be the global object. This is | 3208 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); |
3190 // indicated by passing the hole as the receiver to the call | 3209 __ b(ne, &slow); |
3191 // function stub. | |
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(ip, Heap::kUndefinedValueRootIndex); | |
3212 __ str(ip, 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 | 3210 |
3227 if (RecordCallTarget()) { | 3211 if (RecordCallTarget()) { |
3228 GenerateRecordCallTarget(masm); | 3212 GenerateRecordCallTarget(masm); |
3229 } | 3213 } |
3230 | 3214 |
3231 // Fast-case: Invoke the function now. | 3215 // Fast-case: Invoke the function now. |
3232 // r1: pushed function | 3216 // r1: pushed function |
3233 ParameterCount actual(argc_); | 3217 ParameterCount actual(argc_); |
3234 | 3218 |
3235 if (ReceiverMightBeImplicit()) { | 3219 if (ReceiverMightBeImplicit()) { |
(...skipping 24 matching lines...) Expand all Loading... |
3260 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 3244 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
3261 __ str(ip, FieldMemOperand(r2, Cell::kValueOffset)); | 3245 __ str(ip, FieldMemOperand(r2, Cell::kValueOffset)); |
3262 } | 3246 } |
3263 // Check for function proxy. | 3247 // Check for function proxy. |
3264 __ cmp(r3, Operand(JS_FUNCTION_PROXY_TYPE)); | 3248 __ cmp(r3, Operand(JS_FUNCTION_PROXY_TYPE)); |
3265 __ b(ne, &non_function); | 3249 __ b(ne, &non_function); |
3266 __ push(r1); // put proxy as additional argument | 3250 __ push(r1); // put proxy as additional argument |
3267 __ mov(r0, Operand(argc_ + 1, RelocInfo::NONE32)); | 3251 __ mov(r0, Operand(argc_ + 1, RelocInfo::NONE32)); |
3268 __ mov(r2, Operand::Zero()); | 3252 __ mov(r2, Operand::Zero()); |
3269 __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY); | 3253 __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY); |
3270 __ SetCallKind(r5, CALL_AS_FUNCTION); | 3254 __ SetCallKind(r5, CALL_AS_METHOD); |
3271 { | 3255 { |
3272 Handle<Code> adaptor = | 3256 Handle<Code> adaptor = |
3273 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 3257 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
3274 __ Jump(adaptor, RelocInfo::CODE_TARGET); | 3258 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
3275 } | 3259 } |
3276 | 3260 |
3277 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 3261 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
3278 // of the original receiver from the call site). | 3262 // of the original receiver from the call site). |
3279 __ bind(&non_function); | 3263 __ bind(&non_function); |
3280 __ str(r1, MemOperand(sp, argc_ * kPointerSize)); | 3264 __ str(r1, MemOperand(sp, argc_ * kPointerSize)); |
(...skipping 2573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5854 __ bind(&fast_elements_case); | 5838 __ bind(&fast_elements_case); |
5855 GenerateCase(masm, FAST_ELEMENTS); | 5839 GenerateCase(masm, FAST_ELEMENTS); |
5856 } | 5840 } |
5857 | 5841 |
5858 | 5842 |
5859 #undef __ | 5843 #undef __ |
5860 | 5844 |
5861 } } // namespace v8::internal | 5845 } } // namespace v8::internal |
5862 | 5846 |
5863 #endif // V8_TARGET_ARCH_ARM | 5847 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |