Chromium Code Reviews| 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 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. | 2520 // Check that the function really is a JavaScript function. |
| 2521 __ JumpIfSmi(edi, &non_function); | 2521 __ JumpIfSmi(edi, &non_function); |
| 2522 | 2522 |
| 2523 // The receiver might implicitly be the global object. This is | 2523 // The receiver might implicitly be the global object. This is |
| 2524 // indicated by passing the hole as the receiver to the call | 2524 // indicated by passing the hole as the receiver to the call |
| 2525 // function stub. | 2525 // function stub. |
| 2526 if (ReceiverMightBeImplicit() || ReceiverIsImplicit()) { | 2526 Label call; |
| 2527 Label try_call, call, patch_current_context; | 2527 if (ReceiverMightBeImplicit()) { |
| 2528 Label try_call, patch_current_context; | |
| 2528 if (ReceiverMightBeImplicit()) { | 2529 if (ReceiverMightBeImplicit()) { |
|
dcarney
2014/01/13 18:35:03
can remove conditional
| |
| 2529 // Get the receiver from the stack. | 2530 // Get the receiver from the stack. |
| 2530 // +1 ~ return address | 2531 // +1 ~ return address |
| 2531 __ mov(eax, Operand(esp, (argc_ + 1) * kPointerSize)); | 2532 __ mov(eax, Operand(esp, (argc_ + 1) * kPointerSize)); |
| 2532 // Call as function is indicated with the hole. | 2533 // Call as function is indicated with the hole. |
| 2533 __ cmp(eax, isolate->factory()->the_hole_value()); | 2534 __ cmp(eax, isolate->factory()->the_hole_value()); |
|
dcarney
2014/01/13 18:35:03
can we just pass undefined in these cases and remo
| |
| 2534 __ j(not_equal, &try_call, Label::kNear); | 2535 __ j(not_equal, &try_call, Label::kNear); |
| 2535 } | 2536 } |
| 2536 // Patch the receiver on the stack with the global receiver object. | 2537 |
| 2538 // Patch the global object on the stack. | |
| 2539 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), | |
| 2540 isolate->factory()->undefined_value()); | |
| 2541 | |
| 2537 // Goto slow case if we do not have a function. | 2542 // Goto slow case if we do not have a function. |
| 2538 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 2543 __ bind(&try_call); |
| 2539 __ j(not_equal, &patch_current_context); | 2544 } |
| 2540 CallStubCompiler::FetchGlobalProxy(masm, ecx, edi); | |
| 2541 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), ecx); | |
| 2542 __ jmp(&call, Label::kNear); | |
| 2543 | 2545 |
| 2544 __ bind(&patch_current_context); | 2546 // Goto slow case if we do not have a function. |
| 2545 __ mov(edx, isolate->factory()->undefined_value()); | 2547 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 2546 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edx); | 2548 __ j(not_equal, &slow); |
| 2547 __ jmp(&slow); | |
| 2548 | 2549 |
| 2549 __ bind(&try_call); | 2550 __ bind(&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 | 2551 |
| 2561 if (RecordCallTarget()) { | 2552 if (RecordCallTarget()) { |
| 2562 GenerateRecordCallTarget(masm); | 2553 GenerateRecordCallTarget(masm); |
| 2563 } | 2554 } |
| 2564 | 2555 |
| 2565 // Fast-case: Just invoke the function. | 2556 // Fast-case: Just invoke the function. |
| 2566 ParameterCount actual(argc_); | 2557 ParameterCount actual(argc_); |
| 2567 | 2558 |
| 2568 if (ReceiverMightBeImplicit()) { | 2559 if (ReceiverMightBeImplicit()) { |
| 2569 Label call_as_function; | 2560 Label call_as_function; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2605 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); | 2596 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); |
| 2606 __ jmp(adaptor, RelocInfo::CODE_TARGET); | 2597 __ jmp(adaptor, RelocInfo::CODE_TARGET); |
| 2607 } | 2598 } |
| 2608 | 2599 |
| 2609 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 2600 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
| 2610 // of the original receiver from the call site). | 2601 // of the original receiver from the call site). |
| 2611 __ bind(&non_function); | 2602 __ bind(&non_function); |
| 2612 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edi); | 2603 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edi); |
| 2613 __ Set(eax, Immediate(argc_)); | 2604 __ Set(eax, Immediate(argc_)); |
| 2614 __ Set(ebx, Immediate(0)); | 2605 __ Set(ebx, Immediate(0)); |
| 2615 __ SetCallKind(ecx, CALL_AS_METHOD); | 2606 __ SetCallKind(ecx, CALL_AS_FUNCTION); |
| 2616 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); | 2607 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); |
| 2617 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); | 2608 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); |
| 2618 __ jmp(adaptor, RelocInfo::CODE_TARGET); | 2609 __ jmp(adaptor, RelocInfo::CODE_TARGET); |
| 2619 } | 2610 } |
| 2620 | 2611 |
| 2621 | 2612 |
| 2622 void CallConstructStub::Generate(MacroAssembler* masm) { | 2613 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 2623 // eax : number of arguments | 2614 // eax : number of arguments |
| 2624 // ebx : cache cell for call target | 2615 // ebx : cache cell for call target |
| 2625 // edi : constructor function | 2616 // edi : constructor function |
| (...skipping 3096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5722 __ bind(&fast_elements_case); | 5713 __ bind(&fast_elements_case); |
| 5723 GenerateCase(masm, FAST_ELEMENTS); | 5714 GenerateCase(masm, FAST_ELEMENTS); |
| 5724 } | 5715 } |
| 5725 | 5716 |
| 5726 | 5717 |
| 5727 #undef __ | 5718 #undef __ |
| 5728 | 5719 |
| 5729 } } // namespace v8::internal | 5720 } } // namespace v8::internal |
| 5730 | 5721 |
| 5731 #endif // V8_TARGET_ARCH_IA32 | 5722 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |