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 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 // Push function as argument and compile for baseline. | 1145 // Push function as argument and compile for baseline. |
1146 __ push(a1); | 1146 __ push(a1); |
1147 __ CallRuntime(Runtime::kCompileBaseline); | 1147 __ CallRuntime(Runtime::kCompileBaseline); |
1148 | 1148 |
1149 // Restore return value. | 1149 // Restore return value. |
1150 __ pop(v0); | 1150 __ pop(v0); |
1151 } | 1151 } |
1152 __ Jump(ra); | 1152 __ Jump(ra); |
1153 } | 1153 } |
1154 | 1154 |
| 1155 static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args, |
| 1156 Register scratch1, Register scratch2, |
| 1157 Label* stack_overflow) { |
| 1158 // Check the stack for overflow. We are not trying to catch |
| 1159 // interruptions (e.g. debug break and preemption) here, so the "real stack |
| 1160 // limit" is checked. |
| 1161 __ LoadRoot(scratch1, Heap::kRealStackLimitRootIndex); |
| 1162 // Make scratch1 the space we have left. The stack might already be overflowed |
| 1163 // here which will cause scratch1 to become negative. |
| 1164 __ dsubu(scratch1, sp, scratch1); |
| 1165 // Check if the arguments will overflow the stack. |
| 1166 __ dsll(scratch2, num_args, kPointerSizeLog2); |
| 1167 // Signed comparison. |
| 1168 __ Branch(stack_overflow, le, scratch1, Operand(scratch2)); |
| 1169 } |
| 1170 |
1155 static void Generate_InterpreterPushArgs(MacroAssembler* masm, | 1171 static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
1156 Register num_args, Register index, | 1172 Register num_args, Register index, |
1157 Register last_addr, Register scratch) { | 1173 Register scratch, Register scratch2, |
| 1174 Label* stack_overflow) { |
| 1175 // Generate_StackOverflowCheck(masm, num_args, scratch, scratch2, |
| 1176 // stack_overflow); |
| 1177 |
1158 // Find the address of the last argument. | 1178 // Find the address of the last argument. |
1159 __ mov(last_addr, num_args); | 1179 __ mov(scratch2, num_args); |
1160 __ dsll(last_addr, last_addr, kPointerSizeLog2); | 1180 __ dsll(scratch2, scratch2, kPointerSizeLog2); |
1161 __ Dsubu(last_addr, index, Operand(last_addr)); | 1181 __ Dsubu(scratch2, index, Operand(scratch2)); |
1162 | 1182 |
1163 // Push the arguments. | 1183 // Push the arguments. |
1164 Label loop_header, loop_check; | 1184 Label loop_header, loop_check; |
1165 __ Branch(&loop_check); | 1185 __ Branch(&loop_check); |
1166 __ bind(&loop_header); | 1186 __ bind(&loop_header); |
1167 __ ld(scratch, MemOperand(index)); | 1187 __ ld(scratch, MemOperand(index)); |
1168 __ Daddu(index, index, Operand(-kPointerSize)); | 1188 __ Daddu(index, index, Operand(-kPointerSize)); |
1169 __ push(scratch); | 1189 __ push(scratch); |
1170 __ bind(&loop_check); | 1190 __ bind(&loop_check); |
1171 __ Branch(&loop_header, gt, index, Operand(last_addr)); | 1191 __ Branch(&loop_header, gt, index, Operand(scratch2)); |
1172 } | 1192 } |
1173 | 1193 |
1174 // static | 1194 // static |
1175 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1195 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
1176 MacroAssembler* masm, TailCallMode tail_call_mode, | 1196 MacroAssembler* masm, TailCallMode tail_call_mode, |
1177 CallableType function_type) { | 1197 CallableType function_type) { |
1178 // ----------- S t a t e ------------- | 1198 // ----------- S t a t e ------------- |
1179 // -- a0 : the number of arguments (not including the receiver) | 1199 // -- a0 : the number of arguments (not including the receiver) |
1180 // -- a2 : the address of the first argument to be pushed. Subsequent | 1200 // -- a2 : the address of the first argument to be pushed. Subsequent |
1181 // arguments should be consecutive above this, in the same order as | 1201 // arguments should be consecutive above this, in the same order as |
1182 // they are to be pushed onto the stack. | 1202 // they are to be pushed onto the stack. |
1183 // -- a1 : the target to call (can be any Object). | 1203 // -- a1 : the target to call (can be any Object). |
1184 // ----------------------------------- | 1204 // ----------------------------------- |
| 1205 Label stack_overflow; |
1185 | 1206 |
1186 __ Daddu(a3, a0, Operand(1)); // Add one for receiver. | 1207 __ Daddu(a3, a0, Operand(1)); // Add one for receiver. |
1187 | 1208 |
1188 // This function modifies a2, t0 and a4. | 1209 // This function modifies a2, t0 and a4. |
1189 Generate_InterpreterPushArgs(masm, a3, a2, a4, t0); | 1210 Generate_InterpreterPushArgs(masm, a3, a2, a4, t0, &stack_overflow); |
1190 | 1211 |
1191 // Call the target. | 1212 // Call the target. |
1192 if (function_type == CallableType::kJSFunction) { | 1213 if (function_type == CallableType::kJSFunction) { |
1193 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 1214 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
1194 tail_call_mode), | 1215 tail_call_mode), |
1195 RelocInfo::CODE_TARGET); | 1216 RelocInfo::CODE_TARGET); |
1196 } else { | 1217 } else { |
1197 DCHECK_EQ(function_type, CallableType::kAny); | 1218 DCHECK_EQ(function_type, CallableType::kAny); |
1198 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1219 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
1199 tail_call_mode), | 1220 tail_call_mode), |
1200 RelocInfo::CODE_TARGET); | 1221 RelocInfo::CODE_TARGET); |
1201 } | 1222 } |
| 1223 |
| 1224 __ bind(&stack_overflow); |
| 1225 { |
| 1226 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 1227 __ break_(0xCC); |
| 1228 } |
1202 } | 1229 } |
1203 | 1230 |
1204 // static | 1231 // static |
1205 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( | 1232 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
1206 MacroAssembler* masm, CallableType construct_type) { | 1233 MacroAssembler* masm, CallableType construct_type) { |
1207 // ----------- S t a t e ------------- | 1234 // ----------- S t a t e ------------- |
1208 // -- a0 : argument count (not including receiver) | 1235 // -- a0 : argument count (not including receiver) |
1209 // -- a3 : new target | 1236 // -- a3 : new target |
1210 // -- a1 : constructor to call | 1237 // -- a1 : constructor to call |
1211 // -- a2 : allocation site feedback if available, undefined otherwise. | 1238 // -- a2 : allocation site feedback if available, undefined otherwise. |
1212 // -- a4 : address of the first argument | 1239 // -- a4 : address of the first argument |
1213 // ----------------------------------- | 1240 // ----------------------------------- |
| 1241 Label stack_overflow; |
1214 | 1242 |
1215 // Push a slot for the receiver. | 1243 // Push a slot for the receiver. |
1216 __ push(zero_reg); | 1244 __ push(zero_reg); |
1217 | 1245 |
1218 // This function modifies t0, a4 and a5. | 1246 // This function modifies t0, a4 and a5. |
1219 Generate_InterpreterPushArgs(masm, a0, a4, a5, t0); | 1247 Generate_InterpreterPushArgs(masm, a0, a4, a5, t0, &stack_overflow); |
1220 | 1248 |
1221 __ AssertUndefinedOrAllocationSite(a2, t0); | 1249 __ AssertUndefinedOrAllocationSite(a2, t0); |
1222 if (construct_type == CallableType::kJSFunction) { | 1250 if (construct_type == CallableType::kJSFunction) { |
1223 __ AssertFunction(a1); | 1251 __ AssertFunction(a1); |
1224 | 1252 |
1225 // Tail call to the function-specific construct stub (still in the caller | 1253 // Tail call to the function-specific construct stub (still in the caller |
1226 // context at this point). | 1254 // context at this point). |
1227 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 1255 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
1228 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset)); | 1256 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset)); |
1229 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1257 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1230 __ Jump(at); | 1258 __ Jump(at); |
1231 } else { | 1259 } else { |
1232 DCHECK_EQ(construct_type, CallableType::kAny); | 1260 DCHECK_EQ(construct_type, CallableType::kAny); |
1233 // Call the constructor with a0, a1, and a3 unmodified. | 1261 // Call the constructor with a0, a1, and a3 unmodified. |
1234 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1262 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
1235 } | 1263 } |
| 1264 |
| 1265 __ bind(&stack_overflow); |
| 1266 { |
| 1267 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 1268 __ break_(0xCC); |
| 1269 } |
1236 } | 1270 } |
1237 | 1271 |
1238 // static | 1272 // static |
1239 void Builtins::Generate_InterpreterPushArgsAndConstructArray( | 1273 void Builtins::Generate_InterpreterPushArgsAndConstructArray( |
1240 MacroAssembler* masm) { | 1274 MacroAssembler* masm) { |
1241 // ----------- S t a t e ------------- | 1275 // ----------- S t a t e ------------- |
1242 // -- a0 : the number of arguments (not including the receiver) | 1276 // -- a0 : the number of arguments (not including the receiver) |
1243 // -- a1 : the target to call checked to be Array function. | 1277 // -- a1 : the target to call checked to be Array function. |
1244 // -- a2 : allocation site feedback. | 1278 // -- a2 : allocation site feedback. |
1245 // -- a3 : the address of the first argument to be pushed. Subsequent | 1279 // -- a3 : the address of the first argument to be pushed. Subsequent |
1246 // arguments should be consecutive above this, in the same order as | 1280 // arguments should be consecutive above this, in the same order as |
1247 // they are to be pushed onto the stack. | 1281 // they are to be pushed onto the stack. |
1248 // ----------------------------------- | 1282 // ----------------------------------- |
| 1283 Label stack_overflow; |
1249 | 1284 |
1250 __ Daddu(a4, a0, Operand(1)); // Add one for receiver. | 1285 __ Daddu(a4, a0, Operand(1)); // Add one for receiver. |
1251 | 1286 |
1252 // This function modifies a3, a5 and a6. | 1287 // This function modifies a3, a5 and a6. |
1253 Generate_InterpreterPushArgs(masm, a4, a3, a5, a6); | 1288 Generate_InterpreterPushArgs(masm, a4, a3, a5, a6, &stack_overflow); |
1254 | 1289 |
1255 // ArrayConstructor stub expects constructor in a3. Set it here. | 1290 // ArrayConstructor stub expects constructor in a3. Set it here. |
1256 __ mov(a3, a1); | 1291 __ mov(a3, a1); |
1257 | 1292 |
1258 ArrayConstructorStub stub(masm->isolate()); | 1293 ArrayConstructorStub stub(masm->isolate()); |
1259 __ TailCallStub(&stub); | 1294 __ TailCallStub(&stub); |
| 1295 |
| 1296 __ bind(&stack_overflow); |
| 1297 { |
| 1298 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 1299 __ break_(0xCC); |
| 1300 } |
1260 } | 1301 } |
1261 | 1302 |
1262 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 1303 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
1263 // Set the return address to the correct point in the interpreter entry | 1304 // Set the return address to the correct point in the interpreter entry |
1264 // trampoline. | 1305 // trampoline. |
1265 Smi* interpreter_entry_return_pc_offset( | 1306 Smi* interpreter_entry_return_pc_offset( |
1266 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 1307 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
1267 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 1308 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
1268 __ li(t0, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); | 1309 __ li(t0, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); |
1269 __ Daddu(ra, t0, Operand(interpreter_entry_return_pc_offset->value() + | 1310 __ Daddu(ra, t0, Operand(interpreter_entry_return_pc_offset->value() + |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 } | 2190 } |
2150 | 2191 |
2151 // 4c. The new.target is not a constructor, throw an appropriate TypeError. | 2192 // 4c. The new.target is not a constructor, throw an appropriate TypeError. |
2152 __ bind(&new_target_not_constructor); | 2193 __ bind(&new_target_not_constructor); |
2153 { | 2194 { |
2154 __ sd(a3, MemOperand(sp)); | 2195 __ sd(a3, MemOperand(sp)); |
2155 __ TailCallRuntime(Runtime::kThrowCalledNonCallable); | 2196 __ TailCallRuntime(Runtime::kThrowCalledNonCallable); |
2156 } | 2197 } |
2157 } | 2198 } |
2158 | 2199 |
2159 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, | |
2160 Label* stack_overflow) { | |
2161 // ----------- S t a t e ------------- | |
2162 // -- a0 : actual number of arguments | |
2163 // -- a1 : function (passed through to callee) | |
2164 // -- a2 : expected number of arguments | |
2165 // -- a3 : new target (passed through to callee) | |
2166 // ----------------------------------- | |
2167 // Check the stack for overflow. We are not trying to catch | |
2168 // interruptions (e.g. debug break and preemption) here, so the "real stack | |
2169 // limit" is checked. | |
2170 __ LoadRoot(a5, Heap::kRealStackLimitRootIndex); | |
2171 // Make a5 the space we have left. The stack might already be overflowed | |
2172 // here which will cause a5 to become negative. | |
2173 __ dsubu(a5, sp, a5); | |
2174 // Check if the arguments will overflow the stack. | |
2175 __ dsll(at, a2, kPointerSizeLog2); | |
2176 // Signed comparison. | |
2177 __ Branch(stack_overflow, le, a5, Operand(at)); | |
2178 } | |
2179 | |
2180 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 2200 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
2181 // __ sll(a0, a0, kSmiTagSize); | 2201 // __ sll(a0, a0, kSmiTagSize); |
2182 __ dsll32(a0, a0, 0); | 2202 __ dsll32(a0, a0, 0); |
2183 __ li(a4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 2203 __ li(a4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
2184 __ MultiPush(a0.bit() | a1.bit() | a4.bit() | fp.bit() | ra.bit()); | 2204 __ MultiPush(a0.bit() | a1.bit() | a4.bit() | fp.bit() | ra.bit()); |
2185 __ Daddu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp + | 2205 __ Daddu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp + |
2186 kPointerSize)); | 2206 kPointerSize)); |
2187 } | 2207 } |
2188 | 2208 |
2189 static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { | 2209 static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2933 // We use Uless as the number of argument should always be greater than 0. | 2953 // We use Uless as the number of argument should always be greater than 0. |
2934 __ Branch(&too_few, Uless, a0, Operand(a2)); | 2954 __ Branch(&too_few, Uless, a0, Operand(a2)); |
2935 | 2955 |
2936 { // Enough parameters: actual >= expected. | 2956 { // Enough parameters: actual >= expected. |
2937 // a0: actual number of arguments as a smi | 2957 // a0: actual number of arguments as a smi |
2938 // a1: function | 2958 // a1: function |
2939 // a2: expected number of arguments | 2959 // a2: expected number of arguments |
2940 // a3: new target (passed through to callee) | 2960 // a3: new target (passed through to callee) |
2941 __ bind(&enough); | 2961 __ bind(&enough); |
2942 EnterArgumentsAdaptorFrame(masm); | 2962 EnterArgumentsAdaptorFrame(masm); |
2943 ArgumentAdaptorStackCheck(masm, &stack_overflow); | 2963 Generate_StackOverflowCheck(masm, a2, a5, at, &stack_overflow); |
2944 | 2964 |
2945 // Calculate copy start address into a0 and copy end address into a4. | 2965 // Calculate copy start address into a0 and copy end address into a4. |
2946 __ SmiScale(a0, a0, kPointerSizeLog2); | 2966 __ SmiScale(a0, a0, kPointerSizeLog2); |
2947 __ Daddu(a0, fp, a0); | 2967 __ Daddu(a0, fp, a0); |
2948 // Adjust for return address and receiver. | 2968 // Adjust for return address and receiver. |
2949 __ Daddu(a0, a0, Operand(2 * kPointerSize)); | 2969 __ Daddu(a0, a0, Operand(2 * kPointerSize)); |
2950 // Compute copy end address. | 2970 // Compute copy end address. |
2951 __ dsll(a4, a2, kPointerSizeLog2); | 2971 __ dsll(a4, a2, kPointerSizeLog2); |
2952 __ dsubu(a4, a0, a4); | 2972 __ dsubu(a4, a0, a4); |
2953 | 2973 |
(...skipping 10 matching lines...) Expand all Loading... |
2964 __ push(a5); | 2984 __ push(a5); |
2965 __ Branch(USE_DELAY_SLOT, ©, ne, a0, Operand(a4)); | 2985 __ Branch(USE_DELAY_SLOT, ©, ne, a0, Operand(a4)); |
2966 __ daddiu(a0, a0, -kPointerSize); // In delay slot. | 2986 __ daddiu(a0, a0, -kPointerSize); // In delay slot. |
2967 | 2987 |
2968 __ jmp(&invoke); | 2988 __ jmp(&invoke); |
2969 } | 2989 } |
2970 | 2990 |
2971 { // Too few parameters: Actual < expected. | 2991 { // Too few parameters: Actual < expected. |
2972 __ bind(&too_few); | 2992 __ bind(&too_few); |
2973 EnterArgumentsAdaptorFrame(masm); | 2993 EnterArgumentsAdaptorFrame(masm); |
2974 ArgumentAdaptorStackCheck(masm, &stack_overflow); | 2994 Generate_StackOverflowCheck(masm, a2, a5, at, &stack_overflow); |
2975 | 2995 |
2976 // Calculate copy start address into a0 and copy end address into a7. | 2996 // Calculate copy start address into a0 and copy end address into a7. |
2977 // a0: actual number of arguments as a smi | 2997 // a0: actual number of arguments as a smi |
2978 // a1: function | 2998 // a1: function |
2979 // a2: expected number of arguments | 2999 // a2: expected number of arguments |
2980 // a3: new target (passed through to callee) | 3000 // a3: new target (passed through to callee) |
2981 __ SmiScale(a0, a0, kPointerSizeLog2); | 3001 __ SmiScale(a0, a0, kPointerSizeLog2); |
2982 __ Daddu(a0, fp, a0); | 3002 __ Daddu(a0, fp, a0); |
2983 // Adjust for return address and receiver. | 3003 // Adjust for return address and receiver. |
2984 __ Daddu(a0, a0, Operand(2 * kPointerSize)); | 3004 __ Daddu(a0, a0, Operand(2 * kPointerSize)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3047 __ break_(0xCC); | 3067 __ break_(0xCC); |
3048 } | 3068 } |
3049 } | 3069 } |
3050 | 3070 |
3051 #undef __ | 3071 #undef __ |
3052 | 3072 |
3053 } // namespace internal | 3073 } // namespace internal |
3054 } // namespace v8 | 3074 } // namespace v8 |
3055 | 3075 |
3056 #endif // V8_TARGET_ARCH_MIPS64 | 3076 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |