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

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

Issue 23475052: MIPS: reland 16744: add context save for GenerateFastApiCall. (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: Enum flags added. Created 7 years, 3 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
« no previous file with comments | « src/mips/macro-assembler-mips.h ('k') | src/mips/stub-cache-mips.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 3829 matching lines...) Expand 10 before | Expand all | Expand 10 after
3840 stub->CompilingCallsToThisStubIsGCSafe(isolate())); 3840 stub->CompilingCallsToThisStubIsGCSafe(isolate()));
3841 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); 3841 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET);
3842 } 3842 }
3843 3843
3844 3844
3845 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { 3845 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
3846 return ref0.address() - ref1.address(); 3846 return ref0.address() - ref1.address();
3847 } 3847 }
3848 3848
3849 3849
3850 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, 3850 void MacroAssembler::CallApiFunctionAndReturn(
3851 Address function_address, 3851 ExternalReference function,
3852 ExternalReference thunk_ref, 3852 Address function_address,
3853 Register thunk_last_arg, 3853 ExternalReference thunk_ref,
3854 int stack_space, 3854 Register thunk_last_arg,
3855 int return_value_offset_from_fp) { 3855 int stack_space,
3856 MemOperand return_value_operand,
3857 MemOperand* context_restore_operand) {
3856 ExternalReference next_address = 3858 ExternalReference next_address =
3857 ExternalReference::handle_scope_next_address(isolate()); 3859 ExternalReference::handle_scope_next_address(isolate());
3858 const int kNextOffset = 0; 3860 const int kNextOffset = 0;
3859 const int kLimitOffset = AddressOffset( 3861 const int kLimitOffset = AddressOffset(
3860 ExternalReference::handle_scope_limit_address(isolate()), 3862 ExternalReference::handle_scope_limit_address(isolate()),
3861 next_address); 3863 next_address);
3862 const int kLevelOffset = AddressOffset( 3864 const int kLevelOffset = AddressOffset(
3863 ExternalReference::handle_scope_level_address(isolate()), 3865 ExternalReference::handle_scope_level_address(isolate()),
3864 next_address); 3866 next_address);
3865 3867
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3908 if (FLAG_log_timer_events) { 3910 if (FLAG_log_timer_events) {
3909 FrameScope frame(this, StackFrame::MANUAL); 3911 FrameScope frame(this, StackFrame::MANUAL);
3910 PushSafepointRegisters(); 3912 PushSafepointRegisters();
3911 PrepareCallCFunction(1, a0); 3913 PrepareCallCFunction(1, a0);
3912 li(a0, Operand(ExternalReference::isolate_address(isolate()))); 3914 li(a0, Operand(ExternalReference::isolate_address(isolate())));
3913 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); 3915 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
3914 PopSafepointRegisters(); 3916 PopSafepointRegisters();
3915 } 3917 }
3916 3918
3917 Label promote_scheduled_exception; 3919 Label promote_scheduled_exception;
3920 Label exception_handled;
3918 Label delete_allocated_handles; 3921 Label delete_allocated_handles;
3919 Label leave_exit_frame; 3922 Label leave_exit_frame;
3920 Label return_value_loaded; 3923 Label return_value_loaded;
3921 3924
3922 // Load value from ReturnValue. 3925 // Load value from ReturnValue.
3923 lw(v0, MemOperand(fp, return_value_offset_from_fp*kPointerSize)); 3926 lw(v0, return_value_operand);
3924 bind(&return_value_loaded); 3927 bind(&return_value_loaded);
3925 3928
3926 // No more valid handles (the result handle was the last one). Restore 3929 // No more valid handles (the result handle was the last one). Restore
3927 // previous handle scope. 3930 // previous handle scope.
3928 sw(s0, MemOperand(s3, kNextOffset)); 3931 sw(s0, MemOperand(s3, kNextOffset));
3929 if (emit_debug_code()) { 3932 if (emit_debug_code()) {
3930 lw(a1, MemOperand(s3, kLevelOffset)); 3933 lw(a1, MemOperand(s3, kLevelOffset));
3931 Check(eq, kUnexpectedLevelAfterReturnFromApiCall, a1, Operand(s2)); 3934 Check(eq, kUnexpectedLevelAfterReturnFromApiCall, a1, Operand(s2));
3932 } 3935 }
3933 Subu(s2, s2, Operand(1)); 3936 Subu(s2, s2, Operand(1));
3934 sw(s2, MemOperand(s3, kLevelOffset)); 3937 sw(s2, MemOperand(s3, kLevelOffset));
3935 lw(at, MemOperand(s3, kLimitOffset)); 3938 lw(at, MemOperand(s3, kLimitOffset));
3936 Branch(&delete_allocated_handles, ne, s1, Operand(at)); 3939 Branch(&delete_allocated_handles, ne, s1, Operand(at));
3937 3940
3938 // Check if the function scheduled an exception. 3941 // Check if the function scheduled an exception.
3939 bind(&leave_exit_frame); 3942 bind(&leave_exit_frame);
3940 LoadRoot(t0, Heap::kTheHoleValueRootIndex); 3943 LoadRoot(t0, Heap::kTheHoleValueRootIndex);
3941 li(at, Operand(ExternalReference::scheduled_exception_address(isolate()))); 3944 li(at, Operand(ExternalReference::scheduled_exception_address(isolate())));
3942 lw(t1, MemOperand(at)); 3945 lw(t1, MemOperand(at));
3943 Branch(&promote_scheduled_exception, ne, t0, Operand(t1)); 3946 Branch(&promote_scheduled_exception, ne, t0, Operand(t1));
3947 bind(&exception_handled);
3948
3949 bool restore_context = context_restore_operand != NULL;
3950 if (restore_context) {
3951 lw(cp, *context_restore_operand);
3952 }
3944 li(s0, Operand(stack_space)); 3953 li(s0, Operand(stack_space));
3945 LeaveExitFrame(false, s0, true); 3954 LeaveExitFrame(false, s0, !restore_context, EMIT_RETURN);
3946 3955
3947 bind(&promote_scheduled_exception); 3956 bind(&promote_scheduled_exception);
3948 TailCallExternalReference( 3957 {
3949 ExternalReference(Runtime::kPromoteScheduledException, isolate()), 3958 FrameScope frame(this, StackFrame::INTERNAL);
3950 0, 3959 CallExternalReference(
3951 1); 3960 ExternalReference(Runtime::kPromoteScheduledException, isolate()),
3961 0);
3962 }
3963 jmp(&exception_handled);
3952 3964
3953 // HandleScope limit has changed. Delete allocated extensions. 3965 // HandleScope limit has changed. Delete allocated extensions.
3954 bind(&delete_allocated_handles); 3966 bind(&delete_allocated_handles);
3955 sw(s1, MemOperand(s3, kLimitOffset)); 3967 sw(s1, MemOperand(s3, kLimitOffset));
3956 mov(s0, v0); 3968 mov(s0, v0);
3957 mov(a0, v0); 3969 mov(a0, v0);
3958 PrepareCallCFunction(1, s1); 3970 PrepareCallCFunction(1, s1);
3959 li(a0, Operand(ExternalReference::isolate_address(isolate()))); 3971 li(a0, Operand(ExternalReference::isolate_address(isolate())));
3960 CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate()), 3972 CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate()),
3961 1); 3973 1);
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
4677 4689
4678 // Set the exit frame sp value to point just before the return address 4690 // Set the exit frame sp value to point just before the return address
4679 // location. 4691 // location.
4680 addiu(at, sp, kPointerSize); 4692 addiu(at, sp, kPointerSize);
4681 sw(at, MemOperand(fp, ExitFrameConstants::kSPOffset)); 4693 sw(at, MemOperand(fp, ExitFrameConstants::kSPOffset));
4682 } 4694 }
4683 4695
4684 4696
4685 void MacroAssembler::LeaveExitFrame(bool save_doubles, 4697 void MacroAssembler::LeaveExitFrame(bool save_doubles,
4686 Register argument_count, 4698 Register argument_count,
4699 bool restore_context,
4687 bool do_return) { 4700 bool do_return) {
4688 // Optionally restore all double registers. 4701 // Optionally restore all double registers.
4689 if (save_doubles) { 4702 if (save_doubles) {
4690 // Remember: we only need to restore every 2nd double FPU value. 4703 // Remember: we only need to restore every 2nd double FPU value.
4691 lw(t8, MemOperand(fp, ExitFrameConstants::kSPOffset)); 4704 lw(t8, MemOperand(fp, ExitFrameConstants::kSPOffset));
4692 for (int i = 0; i < FPURegister::kMaxNumRegisters; i+=2) { 4705 for (int i = 0; i < FPURegister::kMaxNumRegisters; i+=2) {
4693 FPURegister reg = FPURegister::from_code(i); 4706 FPURegister reg = FPURegister::from_code(i);
4694 ldc1(reg, MemOperand(t8, i * kDoubleSize + kPointerSize)); 4707 ldc1(reg, MemOperand(t8, i * kDoubleSize + kPointerSize));
4695 } 4708 }
4696 } 4709 }
4697 4710
4698 // Clear top frame. 4711 // Clear top frame.
4699 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); 4712 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate())));
4700 sw(zero_reg, MemOperand(t8)); 4713 sw(zero_reg, MemOperand(t8));
4701 4714
4702 // Restore current context from top and clear it in debug mode. 4715 // Restore current context from top and clear it in debug mode.
4716 if (restore_context) {
4717 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate())));
4718 lw(cp, MemOperand(t8));
4719 }
4720 #ifdef DEBUG
4703 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); 4721 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate())));
4704 lw(cp, MemOperand(t8));
4705 #ifdef DEBUG
4706 sw(a3, MemOperand(t8)); 4722 sw(a3, MemOperand(t8));
4707 #endif 4723 #endif
4708 4724
4709 // Pop the arguments, restore registers, and return. 4725 // Pop the arguments, restore registers, and return.
4710 mov(sp, fp); // Respect ABI stack constraint. 4726 mov(sp, fp); // Respect ABI stack constraint.
4711 lw(fp, MemOperand(sp, ExitFrameConstants::kCallerFPOffset)); 4727 lw(fp, MemOperand(sp, ExitFrameConstants::kCallerFPOffset));
4712 lw(ra, MemOperand(sp, ExitFrameConstants::kCallerPCOffset)); 4728 lw(ra, MemOperand(sp, ExitFrameConstants::kCallerPCOffset));
4713 4729
4714 if (argument_count.is_valid()) { 4730 if (argument_count.is_valid()) {
4715 sll(t8, argument_count, kPointerSizeLog2); 4731 sll(t8, argument_count, kPointerSizeLog2);
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
5596 opcode == BGTZL); 5612 opcode == BGTZL);
5597 opcode = (cond == eq) ? BEQ : BNE; 5613 opcode = (cond == eq) ? BEQ : BNE;
5598 instr = (instr & ~kOpcodeMask) | opcode; 5614 instr = (instr & ~kOpcodeMask) | opcode;
5599 masm_.emit(instr); 5615 masm_.emit(instr);
5600 } 5616 }
5601 5617
5602 5618
5603 } } // namespace v8::internal 5619 } } // namespace v8::internal
5604 5620
5605 #endif // V8_TARGET_ARCH_MIPS 5621 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/macro-assembler-mips.h ('k') | src/mips/stub-cache-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698