| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/api-arguments.h" | 7 #include "src/api-arguments.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 2618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 if (stack_space_operand != nullptr) { | 2629 if (stack_space_operand != nullptr) { |
| 2630 __ movp(rbx, *stack_space_operand); | 2630 __ movp(rbx, *stack_space_operand); |
| 2631 } | 2631 } |
| 2632 __ LeaveApiExitFrame(!restore_context); | 2632 __ LeaveApiExitFrame(!restore_context); |
| 2633 | 2633 |
| 2634 // Check if the function scheduled an exception. | 2634 // Check if the function scheduled an exception. |
| 2635 __ Move(rdi, scheduled_exception_address); | 2635 __ Move(rdi, scheduled_exception_address); |
| 2636 __ Cmp(Operand(rdi, 0), factory->the_hole_value()); | 2636 __ Cmp(Operand(rdi, 0), factory->the_hole_value()); |
| 2637 __ j(not_equal, &promote_scheduled_exception); | 2637 __ j(not_equal, &promote_scheduled_exception); |
| 2638 | 2638 |
| 2639 #if DEBUG | |
| 2640 // Check if the function returned a valid JavaScript value. | 2639 // Check if the function returned a valid JavaScript value. |
| 2641 Label ok; | 2640 __ AssertApiCallResult(rax); |
| 2642 Register return_value = rax; | |
| 2643 Register map = rcx; | |
| 2644 | |
| 2645 __ JumpIfSmi(return_value, &ok, Label::kNear); | |
| 2646 __ movp(map, FieldOperand(return_value, HeapObject::kMapOffset)); | |
| 2647 | |
| 2648 __ CmpInstanceType(map, LAST_NAME_TYPE); | |
| 2649 __ j(below_equal, &ok, Label::kNear); | |
| 2650 | |
| 2651 __ CmpInstanceType(map, FIRST_JS_RECEIVER_TYPE); | |
| 2652 __ j(above_equal, &ok, Label::kNear); | |
| 2653 | |
| 2654 __ CompareRoot(map, Heap::kHeapNumberMapRootIndex); | |
| 2655 __ j(equal, &ok, Label::kNear); | |
| 2656 | |
| 2657 __ CompareRoot(return_value, Heap::kUndefinedValueRootIndex); | |
| 2658 __ j(equal, &ok, Label::kNear); | |
| 2659 | |
| 2660 __ CompareRoot(return_value, Heap::kTrueValueRootIndex); | |
| 2661 __ j(equal, &ok, Label::kNear); | |
| 2662 | |
| 2663 __ CompareRoot(return_value, Heap::kFalseValueRootIndex); | |
| 2664 __ j(equal, &ok, Label::kNear); | |
| 2665 | |
| 2666 __ CompareRoot(return_value, Heap::kNullValueRootIndex); | |
| 2667 __ j(equal, &ok, Label::kNear); | |
| 2668 | |
| 2669 __ Abort(kAPICallReturnedInvalidObject); | |
| 2670 | |
| 2671 __ bind(&ok); | |
| 2672 #endif | |
| 2673 | 2641 |
| 2674 if (stack_space_operand != nullptr) { | 2642 if (stack_space_operand != nullptr) { |
| 2675 DCHECK_EQ(stack_space, 0); | 2643 DCHECK_EQ(stack_space, 0); |
| 2676 __ PopReturnAddressTo(rcx); | 2644 __ PopReturnAddressTo(rcx); |
| 2677 __ addq(rsp, rbx); | 2645 __ addq(rsp, rbx); |
| 2678 __ jmp(rcx); | 2646 __ jmp(rcx); |
| 2679 } else { | 2647 } else { |
| 2680 __ ret(stack_space * kPointerSize); | 2648 __ ret(stack_space * kPointerSize); |
| 2681 } | 2649 } |
| 2682 | 2650 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2757 | 2725 |
| 2758 __ movp(scratch, rsp); | 2726 __ movp(scratch, rsp); |
| 2759 // Push return address back on stack. | 2727 // Push return address back on stack. |
| 2760 __ PushReturnAddressFrom(return_address); | 2728 __ PushReturnAddressFrom(return_address); |
| 2761 | 2729 |
| 2762 if (!this->is_lazy()) { | 2730 if (!this->is_lazy()) { |
| 2763 // load context from callee | 2731 // load context from callee |
| 2764 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); | 2732 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); |
| 2765 } | 2733 } |
| 2766 | 2734 |
| 2735 if (!this->is_store()) { |
| 2736 __ Set(rax, this->argc()); |
| 2737 __ jmp(masm->isolate()->builtins()->CallFunctionCallback(), |
| 2738 RelocInfo::CODE_TARGET); |
| 2739 } |
| 2740 |
| 2767 // Allocate the v8::Arguments structure in the arguments' space since | 2741 // Allocate the v8::Arguments structure in the arguments' space since |
| 2768 // it's not controlled by GC. | 2742 // it's not controlled by GC. |
| 2769 const int kApiStackSpace = 3; | 2743 const int kApiStackSpace = 3; |
| 2770 | 2744 |
| 2771 PrepareCallApiFunction(masm, kApiStackSpace); | 2745 PrepareCallApiFunction(masm, kApiStackSpace); |
| 2772 | 2746 |
| 2773 // FunctionCallbackInfo::implicit_args_. | 2747 // FunctionCallbackInfo::implicit_args_. |
| 2774 int argc = this->argc(); | 2748 int argc = this->argc(); |
| 2775 __ movp(StackSpaceOperand(0), scratch); | 2749 __ movp(StackSpaceOperand(0), scratch); |
| 2776 __ addp(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize)); | 2750 __ addp(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize)); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2894 kStackUnwindSpace, nullptr, return_value_operand, | 2868 kStackUnwindSpace, nullptr, return_value_operand, |
| 2895 NULL); | 2869 NULL); |
| 2896 } | 2870 } |
| 2897 | 2871 |
| 2898 #undef __ | 2872 #undef __ |
| 2899 | 2873 |
| 2900 } // namespace internal | 2874 } // namespace internal |
| 2901 } // namespace v8 | 2875 } // namespace v8 |
| 2902 | 2876 |
| 2903 #endif // V8_TARGET_ARCH_X64 | 2877 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |