| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
| 10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
| (...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2224 | 2224 |
| 2225 Label non_callable, non_function, non_smi; | 2225 Label non_callable, non_function, non_smi; |
| 2226 __ JumpIfSmi(edi, &non_callable); | 2226 __ JumpIfSmi(edi, &non_callable); |
| 2227 __ bind(&non_smi); | 2227 __ bind(&non_smi); |
| 2228 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 2228 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 2229 __ j(equal, masm->isolate()->builtins()->CallFunction(mode, tail_call_mode), | 2229 __ j(equal, masm->isolate()->builtins()->CallFunction(mode, tail_call_mode), |
| 2230 RelocInfo::CODE_TARGET); | 2230 RelocInfo::CODE_TARGET); |
| 2231 __ CmpInstanceType(ecx, JS_BOUND_FUNCTION_TYPE); | 2231 __ CmpInstanceType(ecx, JS_BOUND_FUNCTION_TYPE); |
| 2232 __ j(equal, masm->isolate()->builtins()->CallBoundFunction(tail_call_mode), | 2232 __ j(equal, masm->isolate()->builtins()->CallBoundFunction(tail_call_mode), |
| 2233 RelocInfo::CODE_TARGET); | 2233 RelocInfo::CODE_TARGET); |
| 2234 |
| 2235 // Check if target has a [[Call]] internal method. |
| 2236 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsCallable); |
| 2237 __ j(zero, &non_callable); |
| 2238 |
| 2234 __ CmpInstanceType(ecx, JS_PROXY_TYPE); | 2239 __ CmpInstanceType(ecx, JS_PROXY_TYPE); |
| 2235 __ j(not_equal, &non_function); | 2240 __ j(not_equal, &non_function); |
| 2236 | 2241 |
| 2237 // 0. Prepare for tail call if necessary. | 2242 // 0. Prepare for tail call if necessary. |
| 2238 if (tail_call_mode == TailCallMode::kAllow) { | 2243 if (tail_call_mode == TailCallMode::kAllow) { |
| 2239 PrepareForTailCall(masm, eax, ebx, ecx, edx); | 2244 PrepareForTailCall(masm, eax, ebx, ecx, edx); |
| 2240 } | 2245 } |
| 2241 | 2246 |
| 2242 // 1. Runtime fallback for Proxy [[Call]]. | 2247 // 1. Runtime fallback for Proxy [[Call]]. |
| 2243 __ PopReturnAddressTo(ecx); | 2248 __ PopReturnAddressTo(ecx); |
| 2244 __ Push(edi); | 2249 __ Push(edi); |
| 2245 __ PushReturnAddressFrom(ecx); | 2250 __ PushReturnAddressFrom(ecx); |
| 2246 // Increase the arguments size to include the pushed function and the | 2251 // Increase the arguments size to include the pushed function and the |
| 2247 // existing receiver on the stack. | 2252 // existing receiver on the stack. |
| 2248 __ add(eax, Immediate(2)); | 2253 __ add(eax, Immediate(2)); |
| 2249 // Tail-call to the runtime. | 2254 // Tail-call to the runtime. |
| 2250 __ JumpToExternalReference( | 2255 __ JumpToExternalReference( |
| 2251 ExternalReference(Runtime::kJSProxyCall, masm->isolate())); | 2256 ExternalReference(Runtime::kJSProxyCall, masm->isolate())); |
| 2252 | 2257 |
| 2253 // 2. Call to something else, which might have a [[Call]] internal method (if | 2258 // 2. Call to something else, which might have a [[Call]] internal method (if |
| 2254 // not we raise an exception). | 2259 // not we raise an exception). |
| 2255 __ bind(&non_function); | 2260 __ bind(&non_function); |
| 2256 // Check if target has a [[Call]] internal method. | |
| 2257 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsCallable); | |
| 2258 __ j(zero, &non_callable, Label::kNear); | |
| 2259 // Overwrite the original receiver with the (original) target. | 2261 // Overwrite the original receiver with the (original) target. |
| 2260 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi); | 2262 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi); |
| 2261 // Let the "call_as_function_delegate" take care of the rest. | 2263 // Let the "call_as_function_delegate" take care of the rest. |
| 2262 __ LoadGlobalFunction(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, edi); | 2264 __ LoadGlobalFunction(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, edi); |
| 2263 __ Jump(masm->isolate()->builtins()->CallFunction( | 2265 __ Jump(masm->isolate()->builtins()->CallFunction( |
| 2264 ConvertReceiverMode::kNotNullOrUndefined, tail_call_mode), | 2266 ConvertReceiverMode::kNotNullOrUndefined, tail_call_mode), |
| 2265 RelocInfo::CODE_TARGET); | 2267 RelocInfo::CODE_TARGET); |
| 2266 | 2268 |
| 2267 // 3. Call to something that is not callable. | 2269 // 3. Call to something that is not callable. |
| 2268 __ bind(&non_callable); | 2270 __ bind(&non_callable); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 | 2691 |
| 2690 __ bind(&ok); | 2692 __ bind(&ok); |
| 2691 __ ret(0); | 2693 __ ret(0); |
| 2692 } | 2694 } |
| 2693 | 2695 |
| 2694 #undef __ | 2696 #undef __ |
| 2695 } // namespace internal | 2697 } // namespace internal |
| 2696 } // namespace v8 | 2698 } // namespace v8 |
| 2697 | 2699 |
| 2698 #endif // V8_TARGET_ARCH_X87 | 2700 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |