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

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: make arm look like other architectures Created 7 years, 7 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
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 670
671 671
672 static int Offset(ExternalReference ref0, ExternalReference ref1) { 672 static int Offset(ExternalReference ref0, ExternalReference ref1) {
673 int64_t offset = (ref0.address() - ref1.address()); 673 int64_t offset = (ref0.address() - ref1.address());
674 // Check that fits into int. 674 // Check that fits into int.
675 ASSERT(static_cast<int>(offset) == offset); 675 ASSERT(static_cast<int>(offset) == offset);
676 return static_cast<int>(offset); 676 return static_cast<int>(offset);
677 } 677 }
678 678
679 679
680 void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) { 680 void MacroAssembler::PrepareCallApiFunction(int arg_stack_space,
681 bool returns_handle) {
681 #if defined(_WIN64) && !defined(__MINGW64__) 682 #if defined(_WIN64) && !defined(__MINGW64__)
683 if (!returns_handle) {
684 EnterApiExitFrame(arg_stack_space);
685 return;
686 }
682 // We need to prepare a slot for result handle on stack and put 687 // We need to prepare a slot for result handle on stack and put
683 // a pointer to it into 1st arg register. 688 // a pointer to it into 1st arg register.
684 EnterApiExitFrame(arg_stack_space + 1); 689 EnterApiExitFrame(arg_stack_space + 1);
685 690
686 // rcx must be used to pass the pointer to the return value slot. 691 // rcx must be used to pass the pointer to the return value slot.
687 lea(rcx, StackSpaceOperand(arg_stack_space)); 692 lea(rcx, StackSpaceOperand(arg_stack_space));
688 #else 693 #else
689 EnterApiExitFrame(arg_stack_space); 694 EnterApiExitFrame(arg_stack_space);
690 #endif 695 #endif
691 } 696 }
692 697
693 698
694 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, 699 void MacroAssembler::CallApiFunctionAndReturn(Address function_address,
695 int stack_space) { 700 int stack_space,
696 Label empty_result; 701 bool returns_handle,
702 int return_value_offset) {
697 Label prologue; 703 Label prologue;
698 Label promote_scheduled_exception; 704 Label promote_scheduled_exception;
699 Label delete_allocated_handles; 705 Label delete_allocated_handles;
700 Label leave_exit_frame; 706 Label leave_exit_frame;
701 Label write_back; 707 Label write_back;
702 708
703 Factory* factory = isolate()->factory(); 709 Factory* factory = isolate()->factory();
704 ExternalReference next_address = 710 ExternalReference next_address =
705 ExternalReference::handle_scope_next_address(isolate()); 711 ExternalReference::handle_scope_next_address(isolate());
706 const int kNextOffset = 0; 712 const int kNextOffset = 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 744
739 if (FLAG_log_timer_events) { 745 if (FLAG_log_timer_events) {
740 FrameScope frame(this, StackFrame::MANUAL); 746 FrameScope frame(this, StackFrame::MANUAL);
741 PushSafepointRegisters(); 747 PushSafepointRegisters();
742 PrepareCallCFunction(1); 748 PrepareCallCFunction(1);
743 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); 749 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate()));
744 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); 750 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
745 PopSafepointRegisters(); 751 PopSafepointRegisters();
746 } 752 }
747 753
754 // Can skip the result check for new-style callbacks
755 // TODO(dcarney): may need to pass this information down
756 // as some function_addresses might not have been registered
757 if (returns_handle) {
758 Label empty_result;
748 #if defined(_WIN64) && !defined(__MINGW64__) 759 #if defined(_WIN64) && !defined(__MINGW64__)
749 // rax keeps a pointer to v8::Handle, unpack it. 760 // rax keeps a pointer to v8::Handle, unpack it.
750 movq(rax, Operand(rax, 0)); 761 movq(rax, Operand(rax, 0));
751 #endif 762 #endif
752 // Check if the result handle holds 0. 763 // Check if the result handle holds 0.
753 testq(rax, rax); 764 testq(rax, rax);
754 j(zero, &empty_result); 765 j(zero, &empty_result);
755 // It was non-zero. Dereference to get the result value. 766 // It was non-zero. Dereference to get the result value.
756 movq(rax, Operand(rax, 0)); 767 movq(rax, Operand(rax, 0));
768 jmp(&prologue);
769 bind(&empty_result);
770 }
771 // Load the value from ReturnValue
772 movq(rax, Operand(rbp, return_value_offset * kPointerSize));
757 bind(&prologue); 773 bind(&prologue);
758 774
759 // No more valid handles (the result handle was the last one). Restore 775 // No more valid handles (the result handle was the last one). Restore
760 // previous handle scope. 776 // previous handle scope.
761 subl(Operand(base_reg, kLevelOffset), Immediate(1)); 777 subl(Operand(base_reg, kLevelOffset), Immediate(1));
762 movq(Operand(base_reg, kNextOffset), prev_next_address_reg); 778 movq(Operand(base_reg, kNextOffset), prev_next_address_reg);
763 cmpq(prev_limit_reg, Operand(base_reg, kLimitOffset)); 779 cmpq(prev_limit_reg, Operand(base_reg, kLimitOffset));
764 j(not_equal, &delete_allocated_handles); 780 j(not_equal, &delete_allocated_handles);
765 bind(&leave_exit_frame); 781 bind(&leave_exit_frame);
766 782
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 j(equal, &ok, Label::kNear); 816 j(equal, &ok, Label::kNear);
801 817
802 Abort("API call returned invalid object"); 818 Abort("API call returned invalid object");
803 819
804 bind(&ok); 820 bind(&ok);
805 #endif 821 #endif
806 822
807 LeaveApiExitFrame(); 823 LeaveApiExitFrame();
808 ret(stack_space * kPointerSize); 824 ret(stack_space * kPointerSize);
809 825
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); 826 bind(&promote_scheduled_exception);
816 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); 827 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
817 828
818 // HandleScope limit has changed. Delete allocated extensions. 829 // HandleScope limit has changed. Delete allocated extensions.
819 bind(&delete_allocated_handles); 830 bind(&delete_allocated_handles);
820 movq(Operand(base_reg, kLimitOffset), prev_limit_reg); 831 movq(Operand(base_reg, kLimitOffset), prev_limit_reg);
821 movq(prev_limit_reg, rax); 832 movq(prev_limit_reg, rax);
822 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); 833 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate()));
823 LoadAddress(rax, 834 LoadAddress(rax,
824 ExternalReference::delete_handle_scope_extensions(isolate())); 835 ExternalReference::delete_handle_scope_extensions(isolate()));
(...skipping 3847 matching lines...) Expand 10 before | Expand all | Expand 10 after
4672 j(greater, &no_info_available); 4683 j(greater, &no_info_available);
4673 CompareRoot(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), 4684 CompareRoot(MemOperand(scratch_reg, -AllocationSiteInfo::kSize),
4674 Heap::kAllocationSiteInfoMapRootIndex); 4685 Heap::kAllocationSiteInfoMapRootIndex);
4675 bind(&no_info_available); 4686 bind(&no_info_available);
4676 } 4687 }
4677 4688
4678 4689
4679 } } // namespace v8::internal 4690 } } // namespace v8::internal
4680 4691
4681 #endif // V8_TARGET_ARCH_X64 4692 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698