OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 void CallFunctionStub::Generate(MacroAssembler* masm) { | 2346 void CallFunctionStub::Generate(MacroAssembler* masm) { |
2347 // rbx : cache cell for call target | 2347 // rbx : cache cell for call target |
2348 // rdi : the function to call | 2348 // rdi : the function to call |
2349 Isolate* isolate = masm->isolate(); | 2349 Isolate* isolate = masm->isolate(); |
2350 Label slow, non_function; | 2350 Label slow, non_function; |
2351 StackArgumentsAccessor args(rsp, argc_); | 2351 StackArgumentsAccessor args(rsp, argc_); |
2352 | 2352 |
2353 // Check that the function really is a JavaScript function. | 2353 // Check that the function really is a JavaScript function. |
2354 __ JumpIfSmi(rdi, &non_function); | 2354 __ JumpIfSmi(rdi, &non_function); |
2355 | 2355 |
2356 // The receiver might implicitly be the global object. This is | 2356 // Goto slow case if we do not have a function. |
2357 // indicated by passing the hole as the receiver to the call | 2357 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
2358 // function stub. | 2358 __ j(not_equal, &slow); |
2359 if (ReceiverMightBeImplicit() || ReceiverIsImplicit()) { | |
2360 Label try_call, call, patch_current_context; | |
2361 if (ReceiverMightBeImplicit()) { | |
2362 // Get the receiver from the stack. | |
2363 __ movq(rax, args.GetReceiverOperand()); | |
2364 // Call as function is indicated with the hole. | |
2365 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); | |
2366 __ j(not_equal, &try_call, Label::kNear); | |
2367 } | |
2368 // Patch the receiver on the stack with the global receiver object. | |
2369 // Goto slow case if we do not have a function. | |
2370 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | |
2371 __ j(not_equal, &patch_current_context); | |
2372 CallStubCompiler::FetchGlobalProxy(masm, rcx, rdi); | |
2373 __ movq(args.GetReceiverOperand(), rcx); | |
2374 __ jmp(&call, Label::kNear); | |
2375 | |
2376 __ bind(&patch_current_context); | |
2377 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); | |
2378 __ movq(args.GetReceiverOperand(), kScratchRegister); | |
2379 __ jmp(&slow); | |
2380 | |
2381 __ bind(&try_call); | |
2382 // Goto slow case if we do not have a function. | |
2383 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | |
2384 __ j(not_equal, &slow); | |
2385 | |
2386 __ bind(&call); | |
2387 } else { | |
2388 // Goto slow case if we do not have a function. | |
2389 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | |
2390 __ j(not_equal, &slow); | |
2391 } | |
2392 | 2359 |
2393 if (RecordCallTarget()) { | 2360 if (RecordCallTarget()) { |
2394 GenerateRecordCallTarget(masm); | 2361 GenerateRecordCallTarget(masm); |
2395 } | 2362 } |
2396 | 2363 |
2397 // Fast-case: Just invoke the function. | 2364 // Fast-case: Just invoke the function. |
2398 ParameterCount actual(argc_); | 2365 ParameterCount actual(argc_); |
2399 | 2366 |
2400 if (ReceiverMightBeImplicit()) { | |
2401 Label call_as_function; | |
2402 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); | |
2403 __ j(equal, &call_as_function); | |
2404 __ InvokeFunction(rdi, | |
2405 actual, | |
2406 JUMP_FUNCTION, | |
2407 NullCallWrapper(), | |
2408 CALL_AS_METHOD); | |
2409 __ bind(&call_as_function); | |
2410 } | |
2411 __ InvokeFunction(rdi, | 2367 __ InvokeFunction(rdi, |
2412 actual, | 2368 actual, |
2413 JUMP_FUNCTION, | 2369 JUMP_FUNCTION, |
2414 NullCallWrapper(), | 2370 NullCallWrapper(), |
2415 CALL_AS_FUNCTION); | 2371 CALL_AS_FUNCTION); |
2416 | 2372 |
2417 // Slow-case: Non-function called. | 2373 // Slow-case: Non-function called. |
2418 __ bind(&slow); | 2374 __ bind(&slow); |
2419 if (RecordCallTarget()) { | 2375 if (RecordCallTarget()) { |
2420 // If there is a call target cache, mark it megamorphic in the | 2376 // If there is a call target cache, mark it megamorphic in the |
(...skipping 17 matching lines...) Expand all Loading... |
2438 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 2394 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
2439 __ jmp(adaptor, RelocInfo::CODE_TARGET); | 2395 __ jmp(adaptor, RelocInfo::CODE_TARGET); |
2440 } | 2396 } |
2441 | 2397 |
2442 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 2398 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
2443 // of the original receiver from the call site). | 2399 // of the original receiver from the call site). |
2444 __ bind(&non_function); | 2400 __ bind(&non_function); |
2445 __ movq(args.GetReceiverOperand(), rdi); | 2401 __ movq(args.GetReceiverOperand(), rdi); |
2446 __ Set(rax, argc_); | 2402 __ Set(rax, argc_); |
2447 __ Set(rbx, 0); | 2403 __ Set(rbx, 0); |
2448 __ SetCallKind(rcx, CALL_AS_METHOD); | 2404 __ SetCallKind(rcx, CALL_AS_FUNCTION); |
2449 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); | 2405 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); |
2450 Handle<Code> adaptor = | 2406 Handle<Code> adaptor = |
2451 isolate->builtins()->ArgumentsAdaptorTrampoline(); | 2407 isolate->builtins()->ArgumentsAdaptorTrampoline(); |
2452 __ Jump(adaptor, RelocInfo::CODE_TARGET); | 2408 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
2453 } | 2409 } |
2454 | 2410 |
2455 | 2411 |
2456 void CallConstructStub::Generate(MacroAssembler* masm) { | 2412 void CallConstructStub::Generate(MacroAssembler* masm) { |
2457 // rax : number of arguments | 2413 // rax : number of arguments |
2458 // rbx : cache cell for call target | 2414 // rbx : cache cell for call target |
(...skipping 3070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5529 __ bind(&fast_elements_case); | 5485 __ bind(&fast_elements_case); |
5530 GenerateCase(masm, FAST_ELEMENTS); | 5486 GenerateCase(masm, FAST_ELEMENTS); |
5531 } | 5487 } |
5532 | 5488 |
5533 | 5489 |
5534 #undef __ | 5490 #undef __ |
5535 | 5491 |
5536 } } // namespace v8::internal | 5492 } } // namespace v8::internal |
5537 | 5493 |
5538 #endif // V8_TARGET_ARCH_X64 | 5494 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |