| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 void CEntryStub::Generate(MacroAssembler* masm) { | 1063 void CEntryStub::Generate(MacroAssembler* masm) { |
| 1064 // Called from JavaScript; parameters are on stack as if calling JS function | 1064 // Called from JavaScript; parameters are on stack as if calling JS function |
| 1065 // a0: number of arguments including receiver | 1065 // a0: number of arguments including receiver |
| 1066 // a1: pointer to builtin function | 1066 // a1: pointer to builtin function |
| 1067 // fp: frame pointer (restored after C call) | 1067 // fp: frame pointer (restored after C call) |
| 1068 // sp: stack pointer (restored as callee's sp after C call) | 1068 // sp: stack pointer (restored as callee's sp after C call) |
| 1069 // cp: current context (C callee-saved) | 1069 // cp: current context (C callee-saved) |
| 1070 | 1070 |
| 1071 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 1071 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 1072 | 1072 |
| 1073 // Compute the argv pointer in a callee-saved register. | 1073 __ mov(t9, a1); // Function pointer to t9 to conform to ABI for PIC. |
| 1074 __ sll(s1, a0, kPointerSizeLog2); | 1074 // Compute the argv pointer in a1. |
| 1075 __ Addu(s1, sp, s1); | 1075 __ sll(a1, a0, kPointerSizeLog2); |
| 1076 __ Subu(s1, s1, kPointerSize); | 1076 __ Addu(a1, sp, a1); |
| 1077 __ Subu(a1, a1, kPointerSize); |
| 1077 | 1078 |
| 1078 // Enter the exit frame that transitions from JavaScript to C++. | 1079 // Enter the exit frame that transitions from JavaScript to C++. |
| 1079 FrameScope scope(masm, StackFrame::MANUAL); | 1080 FrameScope scope(masm, StackFrame::MANUAL); |
| 1080 __ EnterExitFrame(save_doubles()); | 1081 __ EnterExitFrame(save_doubles()); |
| 1081 | 1082 |
| 1082 // s0: number of arguments including receiver (C callee-saved) | 1083 // argc will be saved in s5 (callee-saved) in delay-slot of bal() below. |
| 1083 // s1: pointer to first argument (C callee-saved) | 1084 // a0, s5: number of arguments including receiver. |
| 1084 // s2: pointer to builtin function (C callee-saved) | 1085 // a1: pointer to the first argument. |
| 1085 | 1086 // t9: pointer to builtin function. |
| 1086 // Prepare arguments for C routine. | |
| 1087 // a0 = argc | |
| 1088 __ mov(s0, a0); | |
| 1089 __ mov(s2, a1); | |
| 1090 // a1 = argv (set in the delay slot after find_ra below). | |
| 1091 | 1087 |
| 1092 // We are calling compiled C/C++ code. a0 and a1 hold our two arguments. We | 1088 // We are calling compiled C/C++ code. a0 and a1 hold our two arguments. We |
| 1093 // also need to reserve the 4 argument slots on the stack. | 1089 // also need to reserve the 4 argument slots on the stack. |
| 1094 | 1090 |
| 1095 __ AssertStackIsAligned(); | 1091 __ AssertStackIsAligned(); |
| 1096 | 1092 |
| 1097 __ li(a2, Operand(ExternalReference::isolate_address(isolate()))); | 1093 __ li(a2, Operand(ExternalReference::isolate_address(isolate()))); |
| 1098 | 1094 |
| 1099 // To let the GC traverse the return address of the exit frames, we need to | 1095 // To let the GC traverse the return address of the exit frames, we need to |
| 1100 // know where the return address is. The CEntryStub is unmovable, so | 1096 // know where the return address is. The CEntryStub is unmovable, so |
| 1101 // we can store the address on the stack to be able to find it again and | 1097 // we can store the address on the stack to be able to find it again and |
| 1102 // we never have to restore it, because it will not change. | 1098 // we never have to restore it, because it will not change. |
| 1103 { Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm); | 1099 { Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm); |
| 1104 // This branch-and-link sequence is needed to find the current PC on mips, | 1100 // This branch-and-link sequence is needed to find the current PC on mips, |
| 1105 // saved to the ra register. | 1101 // saved to the ra register. |
| 1106 // Use masm-> here instead of the double-underscore macro since extra | 1102 // Use masm-> here instead of the double-underscore macro since extra |
| 1107 // coverage code can interfere with the proper calculation of ra. | 1103 // coverage code can interfere with the proper calculation of ra. |
| 1108 Label find_ra; | 1104 Label find_ra; |
| 1109 masm->bal(&find_ra); // bal exposes branch delay slot. | 1105 masm->bal(&find_ra); // bal exposes branch delay slot. |
| 1110 masm->mov(a1, s1); | 1106 masm->mov(s5, a0); // Save argc for LeaveExitFrame() below. |
| 1111 masm->bind(&find_ra); | 1107 masm->bind(&find_ra); |
| 1112 | 1108 |
| 1113 // Adjust the value in ra to point to the correct return location, 2nd | 1109 // Adjust the value in ra to point to the correct return location, 2nd |
| 1114 // instruction past the real call into C code (the jalr(t9)), and push it. | 1110 // instruction past the real call into C code (the jalr(t9)), and push it. |
| 1115 // This is the return address of the exit frame. | 1111 // This is the return address of the exit frame. |
| 1116 const int kNumInstructionsToJump = 5; | 1112 const int kNumInstructionsToJump = 4; |
| 1117 masm->Addu(ra, ra, kNumInstructionsToJump * kPointerSize); | 1113 masm->Addu(ra, ra, kNumInstructionsToJump * kPointerSize); |
| 1118 masm->sw(ra, MemOperand(sp)); // This spot was reserved in EnterExitFrame. | 1114 masm->sw(ra, MemOperand(sp)); // This spot was reserved in EnterExitFrame. |
| 1119 // Stack space reservation moved to the branch delay slot below. | 1115 // Stack space reservation moved to the branch delay slot below. |
| 1120 // Stack is still aligned. | 1116 // Stack is still aligned. |
| 1121 | 1117 |
| 1122 // Call the C routine. | 1118 // Call the C routine. |
| 1123 masm->mov(t9, s2); // Function pointer to t9 to conform to ABI for PIC. | |
| 1124 masm->jalr(t9); | 1119 masm->jalr(t9); |
| 1125 // Set up sp in the delay slot. | 1120 // Set up sp in the delay slot. |
| 1126 masm->addiu(sp, sp, -kCArgsSlotsSize); | 1121 masm->addiu(sp, sp, -kCArgsSlotsSize); |
| 1127 // Make sure the stored 'ra' points to this position. | 1122 // Make sure the stored 'ra' points to this position. |
| 1128 DCHECK_EQ(kNumInstructionsToJump, | 1123 DCHECK_EQ(kNumInstructionsToJump, |
| 1129 masm->InstructionsGeneratedSince(&find_ra)); | 1124 masm->InstructionsGeneratedSince(&find_ra)); |
| 1130 } | 1125 } |
| 1131 | 1126 |
| 1132 | 1127 |
| 1133 // Check result for exception sentinel. | 1128 // Check result for exception sentinel. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1147 // Cannot use check here as it attempts to generate call into runtime. | 1142 // Cannot use check here as it attempts to generate call into runtime. |
| 1148 __ Branch(&okay, eq, t0, Operand(a2)); | 1143 __ Branch(&okay, eq, t0, Operand(a2)); |
| 1149 __ stop("Unexpected pending exception"); | 1144 __ stop("Unexpected pending exception"); |
| 1150 __ bind(&okay); | 1145 __ bind(&okay); |
| 1151 } | 1146 } |
| 1152 | 1147 |
| 1153 // Exit C frame and return. | 1148 // Exit C frame and return. |
| 1154 // v0:v1: result | 1149 // v0:v1: result |
| 1155 // sp: stack pointer | 1150 // sp: stack pointer |
| 1156 // fp: frame pointer | 1151 // fp: frame pointer |
| 1157 // s0: still holds argc (callee-saved). | 1152 // s5: still holds argc (callee-saved). |
| 1158 __ LeaveExitFrame(save_doubles(), s0, true, EMIT_RETURN); | 1153 __ LeaveExitFrame(save_doubles(), s5, true, EMIT_RETURN); |
| 1159 | 1154 |
| 1160 // Handling of exception. | 1155 // Handling of exception. |
| 1161 __ bind(&exception_returned); | 1156 __ bind(&exception_returned); |
| 1162 | 1157 |
| 1163 ExternalReference pending_handler_context_address( | 1158 ExternalReference pending_handler_context_address( |
| 1164 Isolate::kPendingHandlerContextAddress, isolate()); | 1159 Isolate::kPendingHandlerContextAddress, isolate()); |
| 1165 ExternalReference pending_handler_code_address( | 1160 ExternalReference pending_handler_code_address( |
| 1166 Isolate::kPendingHandlerCodeAddress, isolate()); | 1161 Isolate::kPendingHandlerCodeAddress, isolate()); |
| 1167 ExternalReference pending_handler_offset_address( | 1162 ExternalReference pending_handler_offset_address( |
| 1168 Isolate::kPendingHandlerOffsetAddress, isolate()); | 1163 Isolate::kPendingHandlerOffsetAddress, isolate()); |
| (...skipping 4549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5718 MemOperand(fp, 6 * kPointerSize), NULL); | 5713 MemOperand(fp, 6 * kPointerSize), NULL); |
| 5719 } | 5714 } |
| 5720 | 5715 |
| 5721 | 5716 |
| 5722 #undef __ | 5717 #undef __ |
| 5723 | 5718 |
| 5724 } // namespace internal | 5719 } // namespace internal |
| 5725 } // namespace v8 | 5720 } // namespace v8 |
| 5726 | 5721 |
| 5727 #endif // V8_TARGET_ARCH_MIPS | 5722 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |