Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 12494012: new style of property/function callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 685
686 // rcx must be used to pass the pointer to the return value slot. 686 // rcx must be used to pass the pointer to the return value slot.
687 lea(rcx, StackSpaceOperand(arg_stack_space)); 687 lea(rcx, StackSpaceOperand(arg_stack_space));
688 #else 688 #else
689 EnterApiExitFrame(arg_stack_space); 689 EnterApiExitFrame(arg_stack_space);
690 #endif 690 #endif
691 } 691 }
692 692
693 693
694 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, 694 void MacroAssembler::CallApiFunctionAndReturn(Address function_address,
695 int stack_space) { 695 int stack_space,
696 Label empty_result; 696 int return_value_offset) {
697 Label prologue; 697 Label prologue;
698 Label promote_scheduled_exception; 698 Label promote_scheduled_exception;
699 Label delete_allocated_handles; 699 Label delete_allocated_handles;
700 Label leave_exit_frame; 700 Label leave_exit_frame;
701 Label write_back; 701 Label write_back;
702 702
703 Factory* factory = isolate()->factory(); 703 Factory* factory = isolate()->factory();
704 ExternalReference next_address = 704 ExternalReference next_address =
705 ExternalReference::handle_scope_next_address(isolate()); 705 ExternalReference::handle_scope_next_address(isolate());
706 const int kNextOffset = 0; 706 const int kNextOffset = 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 738
739 if (FLAG_log_timer_events) { 739 if (FLAG_log_timer_events) {
740 FrameScope frame(this, StackFrame::MANUAL); 740 FrameScope frame(this, StackFrame::MANUAL);
741 PushSafepointRegisters(); 741 PushSafepointRegisters();
742 PrepareCallCFunction(1); 742 PrepareCallCFunction(1);
743 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); 743 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate()));
744 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); 744 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
745 PopSafepointRegisters(); 745 PopSafepointRegisters();
746 } 746 }
747 747
748 // Can skip the result check for new-style callbacks
749 // TODO(dcarney): may need to pass this information down
750 // as some function_addresses might not have been registered
751 if (!CallbackTable::ReturnsVoid(isolate(), function_address)) {
752 Label empty_result;
748 #if defined(_WIN64) && !defined(__MINGW64__) 753 #if defined(_WIN64) && !defined(__MINGW64__)
749 // rax keeps a pointer to v8::Handle, unpack it. 754 // rax keeps a pointer to v8::Handle, unpack it.
750 movq(rax, Operand(rax, 0)); 755 movq(rax, Operand(rax, 0));
751 #endif 756 #endif
752 // Check if the result handle holds 0. 757 // Check if the result handle holds 0.
753 testq(rax, rax); 758 testq(rax, rax);
754 j(zero, &empty_result); 759 j(zero, &empty_result);
755 // It was non-zero. Dereference to get the result value. 760 // It was non-zero. Dereference to get the result value.
756 movq(rax, Operand(rax, 0)); 761 movq(rax, Operand(rax, 0));
762 jmp(&prologue);
763 bind(&empty_result);
764 }
765 // Load the value from ReturnValue
766 movq(rax, StackSpaceOperand(0));
767 movq(rax, Operand(rax, return_value_offset * kPointerSize));
757 bind(&prologue); 768 bind(&prologue);
758 769
759 // No more valid handles (the result handle was the last one). Restore 770 // No more valid handles (the result handle was the last one). Restore
760 // previous handle scope. 771 // previous handle scope.
761 subl(Operand(base_reg, kLevelOffset), Immediate(1)); 772 subl(Operand(base_reg, kLevelOffset), Immediate(1));
762 movq(Operand(base_reg, kNextOffset), prev_next_address_reg); 773 movq(Operand(base_reg, kNextOffset), prev_next_address_reg);
763 cmpq(prev_limit_reg, Operand(base_reg, kLimitOffset)); 774 cmpq(prev_limit_reg, Operand(base_reg, kLimitOffset));
764 j(not_equal, &delete_allocated_handles); 775 j(not_equal, &delete_allocated_handles);
765 bind(&leave_exit_frame); 776 bind(&leave_exit_frame);
766 777
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 j(equal, &ok, Label::kNear); 811 j(equal, &ok, Label::kNear);
801 812
802 Abort("API call returned invalid object"); 813 Abort("API call returned invalid object");
803 814
804 bind(&ok); 815 bind(&ok);
805 #endif 816 #endif
806 817
807 LeaveApiExitFrame(); 818 LeaveApiExitFrame();
808 ret(stack_space * kPointerSize); 819 ret(stack_space * kPointerSize);
809 820
810 bind(&empty_result);
811 // It was zero; the result is undefined.
812 LoadRoot(rax, Heap::kUndefinedValueRootIndex);
813 jmp(&prologue);
814
815 bind(&promote_scheduled_exception); 821 bind(&promote_scheduled_exception);
816 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); 822 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
817 823
818 // HandleScope limit has changed. Delete allocated extensions. 824 // HandleScope limit has changed. Delete allocated extensions.
819 bind(&delete_allocated_handles); 825 bind(&delete_allocated_handles);
820 movq(Operand(base_reg, kLimitOffset), prev_limit_reg); 826 movq(Operand(base_reg, kLimitOffset), prev_limit_reg);
821 movq(prev_limit_reg, rax); 827 movq(prev_limit_reg, rax);
822 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); 828 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate()));
823 LoadAddress(rax, 829 LoadAddress(rax,
824 ExternalReference::delete_handle_scope_extensions(isolate())); 830 ExternalReference::delete_handle_scope_extensions(isolate()));
(...skipping 3810 matching lines...) Expand 10 before | Expand all | Expand 10 after
4635 j(greater, &no_info_available); 4641 j(greater, &no_info_available);
4636 CompareRoot(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), 4642 CompareRoot(MemOperand(scratch_reg, -AllocationSiteInfo::kSize),
4637 Heap::kAllocationSiteInfoMapRootIndex); 4643 Heap::kAllocationSiteInfoMapRootIndex);
4638 bind(&no_info_available); 4644 bind(&no_info_available);
4639 } 4645 }
4640 4646
4641 4647
4642 } } // namespace v8::internal 4648 } } // namespace v8::internal
4643 4649
4644 #endif // V8_TARGET_ARCH_X64 4650 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698