| 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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 ASSERT(static_cast<int>(offset) == offset); | 684 ASSERT(static_cast<int>(offset) == offset); |
| 685 return static_cast<int>(offset); | 685 return static_cast<int>(offset); |
| 686 } | 686 } |
| 687 | 687 |
| 688 | 688 |
| 689 void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) { | 689 void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) { |
| 690 EnterApiExitFrame(arg_stack_space); | 690 EnterApiExitFrame(arg_stack_space); |
| 691 } | 691 } |
| 692 | 692 |
| 693 | 693 |
| 694 void MacroAssembler::CallApiFunctionAndReturn( | 694 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, |
| 695 Address function_address, | 695 Address thunk_address, |
| 696 Address thunk_address, | 696 Register thunk_last_arg, |
| 697 Register thunk_last_arg, | 697 int stack_space, |
| 698 int stack_space, | 698 int return_value_offset) { |
| 699 Operand return_value_operand, | |
| 700 Operand* context_restore_operand) { | |
| 701 Label prologue; | 699 Label prologue; |
| 702 Label promote_scheduled_exception; | 700 Label promote_scheduled_exception; |
| 703 Label exception_handled; | |
| 704 Label delete_allocated_handles; | 701 Label delete_allocated_handles; |
| 705 Label leave_exit_frame; | 702 Label leave_exit_frame; |
| 706 Label write_back; | 703 Label write_back; |
| 707 | 704 |
| 708 Factory* factory = isolate()->factory(); | 705 Factory* factory = isolate()->factory(); |
| 709 ExternalReference next_address = | 706 ExternalReference next_address = |
| 710 ExternalReference::handle_scope_next_address(isolate()); | 707 ExternalReference::handle_scope_next_address(isolate()); |
| 711 const int kNextOffset = 0; | 708 const int kNextOffset = 0; |
| 712 const int kLimitOffset = Offset( | 709 const int kLimitOffset = Offset( |
| 713 ExternalReference::handle_scope_limit_address(isolate()), | 710 ExternalReference::handle_scope_limit_address(isolate()), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 if (FLAG_log_timer_events) { | 761 if (FLAG_log_timer_events) { |
| 765 FrameScope frame(this, StackFrame::MANUAL); | 762 FrameScope frame(this, StackFrame::MANUAL); |
| 766 PushSafepointRegisters(); | 763 PushSafepointRegisters(); |
| 767 PrepareCallCFunction(1); | 764 PrepareCallCFunction(1); |
| 768 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); | 765 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); |
| 769 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); | 766 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); |
| 770 PopSafepointRegisters(); | 767 PopSafepointRegisters(); |
| 771 } | 768 } |
| 772 | 769 |
| 773 // Load the value from ReturnValue | 770 // Load the value from ReturnValue |
| 774 movq(rax, return_value_operand); | 771 movq(rax, Operand(rbp, return_value_offset * kPointerSize)); |
| 775 bind(&prologue); | 772 bind(&prologue); |
| 776 | 773 |
| 777 // No more valid handles (the result handle was the last one). Restore | 774 // No more valid handles (the result handle was the last one). Restore |
| 778 // previous handle scope. | 775 // previous handle scope. |
| 779 subl(Operand(base_reg, kLevelOffset), Immediate(1)); | 776 subl(Operand(base_reg, kLevelOffset), Immediate(1)); |
| 780 movq(Operand(base_reg, kNextOffset), prev_next_address_reg); | 777 movq(Operand(base_reg, kNextOffset), prev_next_address_reg); |
| 781 cmpq(prev_limit_reg, Operand(base_reg, kLimitOffset)); | 778 cmpq(prev_limit_reg, Operand(base_reg, kLimitOffset)); |
| 782 j(not_equal, &delete_allocated_handles); | 779 j(not_equal, &delete_allocated_handles); |
| 783 bind(&leave_exit_frame); | 780 bind(&leave_exit_frame); |
| 784 | 781 |
| 785 // Check if the function scheduled an exception. | 782 // Check if the function scheduled an exception. |
| 786 movq(rsi, scheduled_exception_address); | 783 movq(rsi, scheduled_exception_address); |
| 787 Cmp(Operand(rsi, 0), factory->the_hole_value()); | 784 Cmp(Operand(rsi, 0), factory->the_hole_value()); |
| 788 j(not_equal, &promote_scheduled_exception); | 785 j(not_equal, &promote_scheduled_exception); |
| 789 bind(&exception_handled); | |
| 790 | 786 |
| 791 #if ENABLE_EXTRA_CHECKS | 787 #if ENABLE_EXTRA_CHECKS |
| 792 // Check if the function returned a valid JavaScript value. | 788 // Check if the function returned a valid JavaScript value. |
| 793 Label ok; | 789 Label ok; |
| 794 Register return_value = rax; | 790 Register return_value = rax; |
| 795 Register map = rcx; | 791 Register map = rcx; |
| 796 | 792 |
| 797 JumpIfSmi(return_value, &ok, Label::kNear); | 793 JumpIfSmi(return_value, &ok, Label::kNear); |
| 798 movq(map, FieldOperand(return_value, HeapObject::kMapOffset)); | 794 movq(map, FieldOperand(return_value, HeapObject::kMapOffset)); |
| 799 | 795 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 816 j(equal, &ok, Label::kNear); | 812 j(equal, &ok, Label::kNear); |
| 817 | 813 |
| 818 CompareRoot(return_value, Heap::kNullValueRootIndex); | 814 CompareRoot(return_value, Heap::kNullValueRootIndex); |
| 819 j(equal, &ok, Label::kNear); | 815 j(equal, &ok, Label::kNear); |
| 820 | 816 |
| 821 Abort(kAPICallReturnedInvalidObject); | 817 Abort(kAPICallReturnedInvalidObject); |
| 822 | 818 |
| 823 bind(&ok); | 819 bind(&ok); |
| 824 #endif | 820 #endif |
| 825 | 821 |
| 826 bool restore_context = context_restore_operand != NULL; | 822 LeaveApiExitFrame(); |
| 827 if (restore_context) { | |
| 828 movq(rsi, *context_restore_operand); | |
| 829 } | |
| 830 LeaveApiExitFrame(!restore_context); | |
| 831 ret(stack_space * kPointerSize); | 823 ret(stack_space * kPointerSize); |
| 832 | 824 |
| 833 bind(&promote_scheduled_exception); | 825 bind(&promote_scheduled_exception); |
| 834 CallRuntime(Runtime::kPromoteScheduledException, 0); | 826 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); |
| 835 jmp(&exception_handled); | |
| 836 | 827 |
| 837 // HandleScope limit has changed. Delete allocated extensions. | 828 // HandleScope limit has changed. Delete allocated extensions. |
| 838 bind(&delete_allocated_handles); | 829 bind(&delete_allocated_handles); |
| 839 movq(Operand(base_reg, kLimitOffset), prev_limit_reg); | 830 movq(Operand(base_reg, kLimitOffset), prev_limit_reg); |
| 840 movq(prev_limit_reg, rax); | 831 movq(prev_limit_reg, rax); |
| 841 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); | 832 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); |
| 842 LoadAddress(rax, | 833 LoadAddress(rax, |
| 843 ExternalReference::delete_handle_scope_extensions(isolate())); | 834 ExternalReference::delete_handle_scope_extensions(isolate())); |
| 844 call(rax); | 835 call(rax); |
| 845 movq(rax, prev_limit_reg); | 836 movq(rax, prev_limit_reg); |
| (...skipping 2851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3697 // Get the return address from the stack and restore the frame pointer. | 3688 // Get the return address from the stack and restore the frame pointer. |
| 3698 movq(rcx, Operand(rbp, 1 * kPointerSize)); | 3689 movq(rcx, Operand(rbp, 1 * kPointerSize)); |
| 3699 movq(rbp, Operand(rbp, 0 * kPointerSize)); | 3690 movq(rbp, Operand(rbp, 0 * kPointerSize)); |
| 3700 | 3691 |
| 3701 // Drop everything up to and including the arguments and the receiver | 3692 // Drop everything up to and including the arguments and the receiver |
| 3702 // from the caller stack. | 3693 // from the caller stack. |
| 3703 lea(rsp, Operand(r15, 1 * kPointerSize)); | 3694 lea(rsp, Operand(r15, 1 * kPointerSize)); |
| 3704 | 3695 |
| 3705 PushReturnAddressFrom(rcx); | 3696 PushReturnAddressFrom(rcx); |
| 3706 | 3697 |
| 3707 LeaveExitFrameEpilogue(true); | 3698 LeaveExitFrameEpilogue(); |
| 3708 } | 3699 } |
| 3709 | 3700 |
| 3710 | 3701 |
| 3711 void MacroAssembler::LeaveApiExitFrame(bool restore_context) { | 3702 void MacroAssembler::LeaveApiExitFrame() { |
| 3712 movq(rsp, rbp); | 3703 movq(rsp, rbp); |
| 3713 pop(rbp); | 3704 pop(rbp); |
| 3714 | 3705 |
| 3715 LeaveExitFrameEpilogue(restore_context); | 3706 LeaveExitFrameEpilogue(); |
| 3716 } | 3707 } |
| 3717 | 3708 |
| 3718 | 3709 |
| 3719 void MacroAssembler::LeaveExitFrameEpilogue(bool restore_context) { | 3710 void MacroAssembler::LeaveExitFrameEpilogue() { |
| 3720 // Restore current context from top and clear it in debug mode. | 3711 // Restore current context from top and clear it in debug mode. |
| 3721 ExternalReference context_address(Isolate::kContextAddress, isolate()); | 3712 ExternalReference context_address(Isolate::kContextAddress, isolate()); |
| 3722 Operand context_operand = ExternalOperand(context_address); | 3713 Operand context_operand = ExternalOperand(context_address); |
| 3723 if (restore_context) { | 3714 movq(rsi, context_operand); |
| 3724 movq(rsi, context_operand); | |
| 3725 } | |
| 3726 #ifdef DEBUG | 3715 #ifdef DEBUG |
| 3727 movq(context_operand, Immediate(0)); | 3716 movq(context_operand, Immediate(0)); |
| 3728 #endif | 3717 #endif |
| 3729 | 3718 |
| 3730 // Clear the top frame. | 3719 // Clear the top frame. |
| 3731 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, | 3720 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, |
| 3732 isolate()); | 3721 isolate()); |
| 3733 Operand c_entry_fp_operand = ExternalOperand(c_entry_fp_address); | 3722 Operand c_entry_fp_operand = ExternalOperand(c_entry_fp_address); |
| 3734 movq(c_entry_fp_operand, Immediate(0)); | 3723 movq(c_entry_fp_operand, Immediate(0)); |
| 3735 } | 3724 } |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4830 j(greater, &no_memento_available); | 4819 j(greater, &no_memento_available); |
| 4831 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4820 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
| 4832 Heap::kAllocationMementoMapRootIndex); | 4821 Heap::kAllocationMementoMapRootIndex); |
| 4833 bind(&no_memento_available); | 4822 bind(&no_memento_available); |
| 4834 } | 4823 } |
| 4835 | 4824 |
| 4836 | 4825 |
| 4837 } } // namespace v8::internal | 4826 } } // namespace v8::internal |
| 4838 | 4827 |
| 4839 #endif // V8_TARGET_ARCH_X64 | 4828 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |