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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
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 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 // Push function as argument and compile for baseline. | 1153 // Push function as argument and compile for baseline. |
1154 __ push(a1); | 1154 __ push(a1); |
1155 __ CallRuntime(Runtime::kCompileBaseline); | 1155 __ CallRuntime(Runtime::kCompileBaseline); |
1156 | 1156 |
1157 // Restore return value. | 1157 // Restore return value. |
1158 __ pop(v0); | 1158 __ pop(v0); |
1159 } | 1159 } |
1160 __ Jump(ra); | 1160 __ Jump(ra); |
1161 } | 1161 } |
1162 | 1162 |
| 1163 static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
| 1164 Register num_args, Register index, |
| 1165 Register scratch) { |
| 1166 Register last_addr = num_args; |
| 1167 // Find the address of the last argument. |
| 1168 __ sll(last_addr, last_addr, kPointerSizeLog2); |
| 1169 __ Subu(last_addr, index, Operand(last_addr)); |
| 1170 |
| 1171 // Push the arguments. |
| 1172 Label loop_header, loop_check; |
| 1173 __ Branch(&loop_check); |
| 1174 __ bind(&loop_header); |
| 1175 __ lw(scratch, MemOperand(index)); |
| 1176 __ Addu(index, index, Operand(-kPointerSize)); |
| 1177 __ push(scratch); |
| 1178 __ bind(&loop_check); |
| 1179 __ Branch(&loop_header, gt, index, Operand(last_addr)); |
| 1180 } |
| 1181 |
1163 // static | 1182 // static |
1164 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1183 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
1165 MacroAssembler* masm, TailCallMode tail_call_mode, | 1184 MacroAssembler* masm, TailCallMode tail_call_mode, |
1166 CallableType function_type) { | 1185 CallableType function_type) { |
1167 // ----------- S t a t e ------------- | 1186 // ----------- S t a t e ------------- |
1168 // -- a0 : the number of arguments (not including the receiver) | 1187 // -- a0 : the number of arguments (not including the receiver) |
1169 // -- a2 : the address of the first argument to be pushed. Subsequent | 1188 // -- a2 : the address of the first argument to be pushed. Subsequent |
1170 // arguments should be consecutive above this, in the same order as | 1189 // arguments should be consecutive above this, in the same order as |
1171 // they are to be pushed onto the stack. | 1190 // they are to be pushed onto the stack. |
1172 // -- a1 : the target to call (can be any Object). | 1191 // -- a1 : the target to call (can be any Object). |
1173 // ----------------------------------- | 1192 // ----------------------------------- |
1174 | 1193 |
1175 // Find the address of the last argument. | 1194 __ Addu(t0, a0, Operand(1)); // Add one for receiver. |
1176 __ Addu(a3, a0, Operand(1)); // Add one for receiver. | |
1177 __ sll(a3, a3, kPointerSizeLog2); | |
1178 __ Subu(a3, a2, Operand(a3)); | |
1179 | 1195 |
1180 // Push the arguments. | 1196 // This function modifies a2, t4 and t0. |
1181 Label loop_header, loop_check; | 1197 Generate_InterpreterPushArgs(masm, t0, a2, t4); |
1182 __ Branch(&loop_check); | |
1183 __ bind(&loop_header); | |
1184 __ lw(t0, MemOperand(a2)); | |
1185 __ Addu(a2, a2, Operand(-kPointerSize)); | |
1186 __ push(t0); | |
1187 __ bind(&loop_check); | |
1188 __ Branch(&loop_header, gt, a2, Operand(a3)); | |
1189 | 1198 |
1190 // Call the target. | 1199 // Call the target. |
1191 if (function_type == CallableType::kJSFunction) { | 1200 if (function_type == CallableType::kJSFunction) { |
1192 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 1201 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
1193 tail_call_mode), | 1202 tail_call_mode), |
1194 RelocInfo::CODE_TARGET); | 1203 RelocInfo::CODE_TARGET); |
1195 } else { | 1204 } else { |
1196 DCHECK_EQ(function_type, CallableType::kAny); | 1205 DCHECK_EQ(function_type, CallableType::kAny); |
1197 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1206 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
1198 tail_call_mode), | 1207 tail_call_mode), |
1199 RelocInfo::CODE_TARGET); | 1208 RelocInfo::CODE_TARGET); |
1200 } | 1209 } |
1201 } | 1210 } |
1202 | 1211 |
1203 // static | 1212 // static |
1204 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( | 1213 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
1205 MacroAssembler* masm, CallableType construct_type) { | 1214 MacroAssembler* masm, CallableType construct_type) { |
1206 // ----------- S t a t e ------------- | 1215 // ----------- S t a t e ------------- |
1207 // -- a0 : argument count (not including receiver) | 1216 // -- a0 : argument count (not including receiver) |
1208 // -- a3 : new target | 1217 // -- a3 : new target |
1209 // -- a1 : constructor to call | 1218 // -- a1 : constructor to call |
1210 // -- a2 : allocation site feedback if available, undefined otherwise. | 1219 // -- a2 : allocation site feedback if available, undefined otherwise. |
1211 // -- t4 : address of the first argument | 1220 // -- t4 : address of the first argument |
1212 // ----------------------------------- | 1221 // ----------------------------------- |
1213 | 1222 |
1214 // Find the address of the last argument. | |
1215 __ sll(t0, a0, kPointerSizeLog2); | |
1216 __ Subu(t0, t4, Operand(t0)); | |
1217 | |
1218 // Push a slot for the receiver. | 1223 // Push a slot for the receiver. |
1219 __ push(zero_reg); | 1224 __ push(zero_reg); |
1220 | 1225 |
1221 // Push the arguments. | 1226 // num_args parameter will be modified by Generate_PushArgs function. Copy |
1222 Label loop_header, loop_check; | 1227 // it to another register. |
1223 __ Branch(&loop_check); | 1228 __ mov(t0, a0); |
1224 __ bind(&loop_header); | 1229 |
1225 __ lw(t1, MemOperand(t4)); | 1230 // This function modified t0, t4, t1. |
1226 __ Addu(t4, t4, Operand(-kPointerSize)); | 1231 Generate_InterpreterPushArgs(masm, t0, t4, t1); |
1227 __ push(t1); | |
1228 __ bind(&loop_check); | |
1229 __ Branch(&loop_header, gt, t4, Operand(t0)); | |
1230 | 1232 |
1231 __ AssertUndefinedOrAllocationSite(a2, t0); | 1233 __ AssertUndefinedOrAllocationSite(a2, t0); |
1232 if (construct_type == CallableType::kJSFunction) { | 1234 if (construct_type == CallableType::kJSFunction) { |
1233 __ AssertFunction(a1); | 1235 __ AssertFunction(a1); |
1234 | 1236 |
1235 // Tail call to the function-specific construct stub (still in the caller | 1237 // Tail call to the function-specific construct stub (still in the caller |
1236 // context at this point). | 1238 // context at this point). |
1237 __ lw(t0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 1239 __ lw(t0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
1238 __ lw(t0, FieldMemOperand(t0, SharedFunctionInfo::kConstructStubOffset)); | 1240 __ lw(t0, FieldMemOperand(t0, SharedFunctionInfo::kConstructStubOffset)); |
1239 __ Addu(at, t0, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1241 __ Addu(at, t0, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1240 __ Jump(at); | 1242 __ Jump(at); |
1241 } else { | 1243 } else { |
1242 DCHECK_EQ(construct_type, CallableType::kAny); | 1244 DCHECK_EQ(construct_type, CallableType::kAny); |
1243 // Call the constructor with a0, a1, and a3 unmodified. | 1245 // Call the constructor with a0, a1, and a3 unmodified. |
1244 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1246 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
1245 } | 1247 } |
1246 } | 1248 } |
1247 | 1249 |
| 1250 // static |
| 1251 void Builtins::Generate_InterpreterPushArgsAndConstructArray( |
| 1252 MacroAssembler* masm) { |
| 1253 // ----------- S t a t e ------------- |
| 1254 // -- a0 : the number of arguments (not including the receiver) |
| 1255 // -- a1 : the target to call checked to be Array function. |
| 1256 // -- a2 : allocation site feedback. |
| 1257 // -- a3 : the address of the first argument to be pushed. Subsequent |
| 1258 // arguments should be consecutive above this, in the same order as |
| 1259 // they are to be pushed onto the stack. |
| 1260 // ----------------------------------- |
| 1261 |
| 1262 __ Addu(t0, a0, Operand(1)); // Add one for receiver. |
| 1263 |
| 1264 // This function modifies a3, t4 and t0. |
| 1265 Generate_InterpreterPushArgs(masm, t0, a3, t4); |
| 1266 |
| 1267 // ArrayConstructor stub expects constructor in a3. Set it here. |
| 1268 __ mov(a3, a1); |
| 1269 |
| 1270 ArrayConstructorStub stub(masm->isolate()); |
| 1271 __ TailCallStub(&stub); |
| 1272 } |
| 1273 |
1248 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 1274 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
1249 // Set the return address to the correct point in the interpreter entry | 1275 // Set the return address to the correct point in the interpreter entry |
1250 // trampoline. | 1276 // trampoline. |
1251 Smi* interpreter_entry_return_pc_offset( | 1277 Smi* interpreter_entry_return_pc_offset( |
1252 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 1278 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
1253 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 1279 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
1254 __ li(t0, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); | 1280 __ li(t0, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); |
1255 __ Addu(ra, t0, Operand(interpreter_entry_return_pc_offset->value() + | 1281 __ Addu(ra, t0, Operand(interpreter_entry_return_pc_offset->value() + |
1256 Code::kHeaderSize - kHeapObjectTag)); | 1282 Code::kHeaderSize - kHeapObjectTag)); |
1257 | 1283 |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 __ break_(0xCC); | 3056 __ break_(0xCC); |
3031 } | 3057 } |
3032 } | 3058 } |
3033 | 3059 |
3034 #undef __ | 3060 #undef __ |
3035 | 3061 |
3036 } // namespace internal | 3062 } // namespace internal |
3037 } // namespace v8 | 3063 } // namespace v8 |
3038 | 3064 |
3039 #endif // V8_TARGET_ARCH_MIPS | 3065 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |