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 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2332 } | 2332 } |
2333 | 2333 |
2334 | 2334 |
2335 void CallFunctionStub::Generate(MacroAssembler* masm) { | 2335 void CallFunctionStub::Generate(MacroAssembler* masm) { |
2336 // rbx : cache cell for call target | 2336 // rbx : cache cell for call target |
2337 // rdi : the function to call | 2337 // rdi : the function to call |
2338 Isolate* isolate = masm->isolate(); | 2338 Isolate* isolate = masm->isolate(); |
2339 Label slow, non_function; | 2339 Label slow, non_function; |
2340 StackArgumentsAccessor args(rsp, argc_); | 2340 StackArgumentsAccessor args(rsp, argc_); |
2341 | 2341 |
| 2342 // Check that the function really is a JavaScript function. |
| 2343 __ JumpIfSmi(rdi, &non_function); |
| 2344 |
2342 // The receiver might implicitly be the global object. This is | 2345 // The receiver might implicitly be the global object. This is |
2343 // indicated by passing the hole as the receiver to the call | 2346 // indicated by passing the hole as the receiver to the call |
2344 // function stub. | 2347 // function stub. |
2345 if (ReceiverMightBeImplicit()) { | 2348 if (ReceiverMightBeImplicit() || ReceiverIsImplicit()) { |
2346 Label call; | 2349 Label call, patch_current_context; |
2347 // Get the receiver from the stack. | 2350 if (ReceiverMightBeImplicit()) { |
2348 __ movq(rax, args.GetReceiverOperand()); | 2351 // Get the receiver from the stack. |
2349 // Call as function is indicated with the hole. | 2352 __ movq(rax, args.GetReceiverOperand()); |
2350 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); | 2353 // Call as function is indicated with the hole. |
2351 __ j(not_equal, &call, Label::kNear); | 2354 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); |
| 2355 __ j(not_equal, &call, Label::kNear); |
| 2356 } |
2352 // Patch the receiver on the stack with the global receiver object. | 2357 // Patch the receiver on the stack with the global receiver object. |
| 2358 // Goto slow case if we do not have a function. |
| 2359 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
| 2360 __ j(not_equal, &patch_current_context); |
| 2361 CallStubCompiler::FetchGlobalProxy(masm, rcx, rdi); |
| 2362 __ movq(args.GetReceiverOperand(), rcx); |
| 2363 __ jmp(&call, Label::kNear); |
| 2364 __ bind(&patch_current_context); |
2353 __ movq(rcx, GlobalObjectOperand()); | 2365 __ movq(rcx, GlobalObjectOperand()); |
2354 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset)); | 2366 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset)); |
2355 __ movq(args.GetReceiverOperand(), rcx); | 2367 __ movq(args.GetReceiverOperand(), rcx); |
| 2368 __ jmp(&slow); |
2356 __ bind(&call); | 2369 __ bind(&call); |
| 2370 } else { |
| 2371 // Goto slow case if we do not have a function. |
| 2372 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
| 2373 __ j(not_equal, &slow); |
2357 } | 2374 } |
2358 | 2375 |
2359 // Check that the function really is a JavaScript function. | |
2360 __ JumpIfSmi(rdi, &non_function); | |
2361 // Goto slow case if we do not have a function. | |
2362 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | |
2363 __ j(not_equal, &slow); | |
2364 | |
2365 if (RecordCallTarget()) { | 2376 if (RecordCallTarget()) { |
2366 GenerateRecordCallTarget(masm); | 2377 GenerateRecordCallTarget(masm); |
2367 } | 2378 } |
2368 | 2379 |
2369 // Fast-case: Just invoke the function. | 2380 // Fast-case: Just invoke the function. |
2370 ParameterCount actual(argc_); | 2381 ParameterCount actual(argc_); |
2371 | 2382 |
2372 if (ReceiverMightBeImplicit()) { | 2383 if (ReceiverMightBeImplicit()) { |
2373 Label call_as_function; | 2384 Label call_as_function; |
2374 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); | 2385 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); |
(...skipping 3105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5480 __ bind(&fast_elements_case); | 5491 __ bind(&fast_elements_case); |
5481 GenerateCase(masm, FAST_ELEMENTS); | 5492 GenerateCase(masm, FAST_ELEMENTS); |
5482 } | 5493 } |
5483 | 5494 |
5484 | 5495 |
5485 #undef __ | 5496 #undef __ |
5486 | 5497 |
5487 } } // namespace v8::internal | 5498 } } // namespace v8::internal |
5488 | 5499 |
5489 #endif // V8_TARGET_ARCH_X64 | 5500 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |