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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 | 678 |
679 | 679 |
680 static int Offset(ExternalReference ref0, ExternalReference ref1) { | 680 static int Offset(ExternalReference ref0, ExternalReference ref1) { |
681 int64_t offset = (ref0.address() - ref1.address()); | 681 int64_t offset = (ref0.address() - ref1.address()); |
682 // Check that fits into int. | 682 // Check that fits into int. |
683 ASSERT(static_cast<int>(offset) == offset); | 683 ASSERT(static_cast<int>(offset) == offset); |
684 return static_cast<int>(offset); | 684 return static_cast<int>(offset); |
685 } | 685 } |
686 | 686 |
687 | 687 |
688 void MacroAssembler::PrepareCallApiFunction(int arg_stack_space, | 688 void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) { |
689 bool returns_handle) { | |
690 #if defined(_WIN64) && !defined(__MINGW64__) | |
691 if (!returns_handle) { | |
692 EnterApiExitFrame(arg_stack_space); | |
693 return; | |
694 } | |
695 // We need to prepare a slot for result handle on stack and put | |
696 // a pointer to it into 1st arg register. | |
697 EnterApiExitFrame(arg_stack_space + 1); | |
698 | |
699 // rcx must be used to pass the pointer to the return value slot. | |
700 lea(rcx, StackSpaceOperand(arg_stack_space)); | |
701 #else | |
702 EnterApiExitFrame(arg_stack_space); | 689 EnterApiExitFrame(arg_stack_space); |
703 #endif | |
704 } | 690 } |
705 | 691 |
706 | 692 |
707 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, | 693 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, |
708 Address thunk_address, | 694 Address thunk_address, |
709 Register thunk_last_arg, | 695 Register thunk_last_arg, |
710 int stack_space, | 696 int stack_space, |
711 bool returns_handle, | |
712 int return_value_offset) { | 697 int return_value_offset) { |
713 Label prologue; | 698 Label prologue; |
714 Label promote_scheduled_exception; | 699 Label promote_scheduled_exception; |
715 Label delete_allocated_handles; | 700 Label delete_allocated_handles; |
716 Label leave_exit_frame; | 701 Label leave_exit_frame; |
717 Label write_back; | 702 Label write_back; |
718 | 703 |
719 Factory* factory = isolate()->factory(); | 704 Factory* factory = isolate()->factory(); |
720 ExternalReference next_address = | 705 ExternalReference next_address = |
721 ExternalReference::handle_scope_next_address(isolate()); | 706 ExternalReference::handle_scope_next_address(isolate()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 | 759 |
775 if (FLAG_log_timer_events) { | 760 if (FLAG_log_timer_events) { |
776 FrameScope frame(this, StackFrame::MANUAL); | 761 FrameScope frame(this, StackFrame::MANUAL); |
777 PushSafepointRegisters(); | 762 PushSafepointRegisters(); |
778 PrepareCallCFunction(1); | 763 PrepareCallCFunction(1); |
779 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); | 764 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); |
780 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); | 765 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); |
781 PopSafepointRegisters(); | 766 PopSafepointRegisters(); |
782 } | 767 } |
783 | 768 |
784 // Can skip the result check for new-style callbacks | |
785 // TODO(dcarney): may need to pass this information down | |
786 // as some function_addresses might not have been registered | |
787 if (returns_handle) { | |
788 Label empty_result; | |
789 #if defined(_WIN64) && !defined(__MINGW64__) | |
790 // rax keeps a pointer to v8::Handle, unpack it. | |
791 movq(rax, Operand(rax, 0)); | |
792 #endif | |
793 // Check if the result handle holds 0. | |
794 testq(rax, rax); | |
795 j(zero, &empty_result); | |
796 // It was non-zero. Dereference to get the result value. | |
797 movq(rax, Operand(rax, 0)); | |
798 jmp(&prologue); | |
799 bind(&empty_result); | |
800 } | |
801 // Load the value from ReturnValue | 769 // Load the value from ReturnValue |
802 movq(rax, Operand(rbp, return_value_offset * kPointerSize)); | 770 movq(rax, Operand(rbp, return_value_offset * kPointerSize)); |
803 bind(&prologue); | 771 bind(&prologue); |
804 | 772 |
805 // No more valid handles (the result handle was the last one). Restore | 773 // No more valid handles (the result handle was the last one). Restore |
806 // previous handle scope. | 774 // previous handle scope. |
807 subl(Operand(base_reg, kLevelOffset), Immediate(1)); | 775 subl(Operand(base_reg, kLevelOffset), Immediate(1)); |
808 movq(Operand(base_reg, kNextOffset), prev_next_address_reg); | 776 movq(Operand(base_reg, kNextOffset), prev_next_address_reg); |
809 cmpq(prev_limit_reg, Operand(base_reg, kLimitOffset)); | 777 cmpq(prev_limit_reg, Operand(base_reg, kLimitOffset)); |
810 j(not_equal, &delete_allocated_handles); | 778 j(not_equal, &delete_allocated_handles); |
(...skipping 3889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4700 j(greater, &no_memento_available); | 4668 j(greater, &no_memento_available); |
4701 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4669 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
4702 Heap::kAllocationMementoMapRootIndex); | 4670 Heap::kAllocationMementoMapRootIndex); |
4703 bind(&no_memento_available); | 4671 bind(&no_memento_available); |
4704 } | 4672 } |
4705 | 4673 |
4706 | 4674 |
4707 } } // namespace v8::internal | 4675 } } // namespace v8::internal |
4708 | 4676 |
4709 #endif // V8_TARGET_ARCH_X64 | 4677 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |