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 2499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2510 __ bind(&done); | 2510 __ bind(&done); |
2511 } | 2511 } |
2512 | 2512 |
2513 | 2513 |
2514 void CallFunctionStub::Generate(MacroAssembler* masm) { | 2514 void CallFunctionStub::Generate(MacroAssembler* masm) { |
2515 // ebx : cache cell for call target | 2515 // ebx : cache cell for call target |
2516 // edi : the function to call | 2516 // edi : the function to call |
2517 Isolate* isolate = masm->isolate(); | 2517 Isolate* isolate = masm->isolate(); |
2518 Label slow, non_function; | 2518 Label slow, non_function; |
2519 | 2519 |
| 2520 // Check that the function really is a JavaScript function. |
| 2521 __ JumpIfSmi(edi, &non_function); |
| 2522 |
2520 // The receiver might implicitly be the global object. This is | 2523 // The receiver might implicitly be the global object. This is |
2521 // indicated by passing the hole as the receiver to the call | 2524 // indicated by passing the hole as the receiver to the call |
2522 // function stub. | 2525 // function stub. |
2523 if (ReceiverMightBeImplicit()) { | 2526 if (ReceiverMightBeImplicit() || ReceiverIsImplicit()) { |
2524 Label receiver_ok; | 2527 Label try_call, call, patch_current_context; |
2525 // Get the receiver from the stack. | 2528 if (ReceiverMightBeImplicit()) { |
2526 // +1 ~ return address | 2529 // Get the receiver from the stack. |
2527 __ mov(eax, Operand(esp, (argc_ + 1) * kPointerSize)); | 2530 // +1 ~ return address |
2528 // Call as function is indicated with the hole. | 2531 __ mov(eax, Operand(esp, (argc_ + 1) * kPointerSize)); |
2529 __ cmp(eax, isolate->factory()->the_hole_value()); | 2532 // Call as function is indicated with the hole. |
2530 __ j(not_equal, &receiver_ok, Label::kNear); | 2533 __ cmp(eax, isolate->factory()->the_hole_value()); |
| 2534 __ j(not_equal, &try_call, Label::kNear); |
| 2535 } |
2531 // Patch the receiver on the stack with the global receiver object. | 2536 // Patch the receiver on the stack with the global receiver object. |
2532 __ mov(ecx, GlobalObjectOperand()); | 2537 // Goto slow case if we do not have a function. |
2533 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); | 2538 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 2539 __ j(not_equal, &patch_current_context); |
| 2540 CallStubCompiler::FetchGlobalProxy(masm, ecx, edi); |
2534 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), ecx); | 2541 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), ecx); |
2535 __ bind(&receiver_ok); | 2542 __ jmp(&call, Label::kNear); |
| 2543 |
| 2544 __ bind(&patch_current_context); |
| 2545 __ mov(edx, isolate->factory()->undefined_value()); |
| 2546 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edx); |
| 2547 __ jmp(&slow); |
| 2548 |
| 2549 __ bind(&try_call); |
| 2550 // Goto slow case if we do not have a function. |
| 2551 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 2552 __ j(not_equal, &slow); |
| 2553 |
| 2554 __ bind(&call); |
| 2555 } else { |
| 2556 // Goto slow case if we do not have a function. |
| 2557 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 2558 __ j(not_equal, &slow); |
2536 } | 2559 } |
2537 | 2560 |
2538 // Check that the function really is a JavaScript function. | |
2539 __ JumpIfSmi(edi, &non_function); | |
2540 // Goto slow case if we do not have a function. | |
2541 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | |
2542 __ j(not_equal, &slow); | |
2543 | |
2544 if (RecordCallTarget()) { | 2561 if (RecordCallTarget()) { |
2545 GenerateRecordCallTarget(masm); | 2562 GenerateRecordCallTarget(masm); |
2546 } | 2563 } |
2547 | 2564 |
2548 // Fast-case: Just invoke the function. | 2565 // Fast-case: Just invoke the function. |
2549 ParameterCount actual(argc_); | 2566 ParameterCount actual(argc_); |
2550 | 2567 |
2551 if (ReceiverMightBeImplicit()) { | 2568 if (ReceiverMightBeImplicit()) { |
2552 Label call_as_function; | 2569 Label call_as_function; |
2553 __ cmp(eax, isolate->factory()->the_hole_value()); | 2570 __ cmp(eax, isolate->factory()->the_hole_value()); |
(...skipping 3159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5713 __ bind(&fast_elements_case); | 5730 __ bind(&fast_elements_case); |
5714 GenerateCase(masm, FAST_ELEMENTS); | 5731 GenerateCase(masm, FAST_ELEMENTS); |
5715 } | 5732 } |
5716 | 5733 |
5717 | 5734 |
5718 #undef __ | 5735 #undef __ |
5719 | 5736 |
5720 } } // namespace v8::internal | 5737 } } // namespace v8::internal |
5721 | 5738 |
5722 #endif // V8_TARGET_ARCH_IA32 | 5739 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |