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