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 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 // This simulates the initial call to bytecode handlers in interpreter entry | 1208 // This simulates the initial call to bytecode handlers in interpreter entry |
1209 // trampoline. The return will never actually be taken, but our stack walker | 1209 // trampoline. The return will never actually be taken, but our stack walker |
1210 // uses this address to determine whether a frame is interpreted. | 1210 // uses this address to determine whether a frame is interpreted. |
1211 __ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); | 1211 __ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); |
1212 | 1212 |
1213 Generate_EnterBytecodeDispatch(masm); | 1213 Generate_EnterBytecodeDispatch(masm); |
1214 } | 1214 } |
1215 | 1215 |
1216 | 1216 |
1217 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1217 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| 1218 // ----------- S t a t e ------------- |
| 1219 // -- a0 : argument count (preserved for callee) |
| 1220 // -- a3 : new target (preserved for callee) |
| 1221 // -- a1 : target function (preserved for callee) |
| 1222 // ----------------------------------- |
| 1223 // First lookup code, maybe we don't need to compile! |
| 1224 Label gotta_call_runtime, gotta_call_runtime_no_stack; |
| 1225 Label maybe_call_runtime; |
| 1226 Label try_shared; |
| 1227 Label loop_top, loop_bottom; |
| 1228 |
| 1229 Register argument_count = a0; |
| 1230 Register closure = a1; |
| 1231 Register new_target = a3; |
| 1232 __ push(argument_count); |
| 1233 __ push(new_target); |
| 1234 __ push(closure); |
| 1235 |
| 1236 Register map = a0; |
| 1237 Register index = a2; |
| 1238 __ ld(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1239 __ ld(map, FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
| 1240 __ ld(index, FieldMemOperand(map, FixedArray::kLengthOffset)); |
| 1241 __ Branch(&gotta_call_runtime, lt, index, Operand(Smi::FromInt(2))); |
| 1242 |
| 1243 // Find literals. |
| 1244 // a3 : native context |
| 1245 // a2 : length / index |
| 1246 // a0 : optimized code map |
| 1247 // stack[0] : new target |
| 1248 // stack[4] : closure |
| 1249 Register native_context = a3; |
| 1250 __ ld(native_context, NativeContextMemOperand()); |
| 1251 |
| 1252 __ bind(&loop_top); |
| 1253 Register temp = a1; |
| 1254 Register array_pointer = a5; |
| 1255 |
| 1256 // Does the native context match? |
| 1257 __ SmiScale(at, index, kPointerSizeLog2); |
| 1258 __ Daddu(array_pointer, map, Operand(at)); |
| 1259 __ ld(temp, FieldMemOperand(array_pointer, |
| 1260 SharedFunctionInfo::kOffsetToPreviousContext)); |
| 1261 __ ld(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1262 __ Branch(&loop_bottom, ne, temp, Operand(native_context)); |
| 1263 // OSR id set to none? |
| 1264 __ ld(temp, FieldMemOperand(array_pointer, |
| 1265 SharedFunctionInfo::kOffsetToPreviousOsrAstId)); |
| 1266 const int bailout_id = BailoutId::None().ToInt(); |
| 1267 __ Branch(&loop_bottom, ne, temp, Operand(Smi::FromInt(bailout_id))); |
| 1268 // Literals available? |
| 1269 __ ld(temp, FieldMemOperand(array_pointer, |
| 1270 SharedFunctionInfo::kOffsetToPreviousLiterals)); |
| 1271 __ ld(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1272 __ JumpIfSmi(temp, &gotta_call_runtime); |
| 1273 |
| 1274 // Save the literals in the closure. |
| 1275 __ ld(a4, MemOperand(sp, 0)); |
| 1276 __ sd(temp, FieldMemOperand(a4, JSFunction::kLiteralsOffset)); |
| 1277 __ push(index); |
| 1278 __ RecordWriteField(a4, JSFunction::kLiteralsOffset, temp, index, |
| 1279 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1280 OMIT_SMI_CHECK); |
| 1281 __ pop(index); |
| 1282 |
| 1283 // Code available? |
| 1284 Register entry = a4; |
| 1285 __ ld(entry, |
| 1286 FieldMemOperand(array_pointer, |
| 1287 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
| 1288 __ ld(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1289 __ JumpIfSmi(entry, &maybe_call_runtime); |
| 1290 |
| 1291 // Found literals and code. Get them into the closure and return. |
| 1292 __ pop(closure); |
| 1293 // Store code entry in the closure. |
| 1294 __ Daddu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1295 |
| 1296 Label install_optimized_code_and_tailcall; |
| 1297 __ bind(&install_optimized_code_and_tailcall); |
| 1298 __ sd(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
| 1299 __ RecordWriteCodeEntryField(closure, entry, a5); |
| 1300 |
| 1301 // Link the closure into the optimized function list. |
| 1302 // a4 : code entry |
| 1303 // a3 : native context |
| 1304 // a1 : closure |
| 1305 __ ld(a5, |
| 1306 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1307 __ sd(a5, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); |
| 1308 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, a5, a0, |
| 1309 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1310 OMIT_SMI_CHECK); |
| 1311 const int function_list_offset = |
| 1312 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); |
| 1313 __ sd(closure, |
| 1314 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1315 // Save closure before the write barrier. |
| 1316 __ mov(a5, closure); |
| 1317 __ RecordWriteContextSlot(native_context, function_list_offset, closure, a0, |
| 1318 kRAHasNotBeenSaved, kDontSaveFPRegs); |
| 1319 __ mov(closure, a5); |
| 1320 __ pop(new_target); |
| 1321 __ pop(argument_count); |
| 1322 __ Jump(entry); |
| 1323 |
| 1324 __ bind(&loop_bottom); |
| 1325 __ Dsubu(index, index, |
| 1326 Operand(Smi::FromInt(SharedFunctionInfo::kEntryLength))); |
| 1327 __ Branch(&loop_top, gt, index, Operand(Smi::FromInt(1))); |
| 1328 |
| 1329 // We found neither literals nor code. |
| 1330 __ jmp(&gotta_call_runtime); |
| 1331 |
| 1332 __ bind(&maybe_call_runtime); |
| 1333 __ pop(closure); |
| 1334 |
| 1335 // Last possibility. Check the context free optimized code map entry. |
| 1336 __ ld(entry, FieldMemOperand(map, FixedArray::kHeaderSize + |
| 1337 SharedFunctionInfo::kSharedCodeIndex)); |
| 1338 __ ld(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1339 __ JumpIfSmi(entry, &try_shared); |
| 1340 |
| 1341 // Store code entry in the closure. |
| 1342 __ Daddu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1343 __ jmp(&install_optimized_code_and_tailcall); |
| 1344 |
| 1345 __ bind(&try_shared); |
| 1346 __ pop(new_target); |
| 1347 __ pop(argument_count); |
| 1348 // Is the full code valid? |
| 1349 __ ld(entry, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1350 __ ld(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); |
| 1351 __ ld(a5, FieldMemOperand(entry, Code::kFlagsOffset)); |
| 1352 __ And(a5, a5, Operand(Code::KindField::kMask)); |
| 1353 __ dsrl(a5, a5, Code::KindField::kShift); |
| 1354 __ Branch(&gotta_call_runtime_no_stack, eq, a5, Operand(Code::BUILTIN)); |
| 1355 // Yes, install the full code. |
| 1356 __ Daddu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1357 __ sd(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
| 1358 __ RecordWriteCodeEntryField(closure, entry, a5); |
| 1359 __ Jump(entry); |
| 1360 |
| 1361 __ bind(&gotta_call_runtime); |
| 1362 __ pop(closure); |
| 1363 __ pop(new_target); |
| 1364 __ pop(argument_count); |
| 1365 __ bind(&gotta_call_runtime_no_stack); |
1218 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); | 1366 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); |
1219 } | 1367 } |
1220 | 1368 |
1221 | 1369 |
1222 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1370 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
1223 GenerateTailCallToReturnedCode(masm, | 1371 GenerateTailCallToReturnedCode(masm, |
1224 Runtime::kCompileOptimized_NotConcurrent); | 1372 Runtime::kCompileOptimized_NotConcurrent); |
1225 } | 1373 } |
1226 | 1374 |
1227 | |
1228 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { | 1375 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { |
1229 GenerateTailCallToReturnedCode(masm, Runtime::kCompileOptimized_Concurrent); | 1376 GenerateTailCallToReturnedCode(masm, Runtime::kCompileOptimized_Concurrent); |
1230 } | 1377 } |
1231 | 1378 |
1232 | 1379 |
1233 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { | 1380 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |
1234 // For now, we are relying on the fact that make_code_young doesn't do any | 1381 // For now, we are relying on the fact that make_code_young doesn't do any |
1235 // garbage collection which allows us to save/restore the registers without | 1382 // garbage collection which allows us to save/restore the registers without |
1236 // worrying about which of them contain pointers. We also don't build an | 1383 // worrying about which of them contain pointers. We also don't build an |
1237 // internal frame to make the code faster, since we shouldn't have to do stack | 1384 // internal frame to make the code faster, since we shouldn't have to do stack |
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2699 } | 2846 } |
2700 } | 2847 } |
2701 | 2848 |
2702 | 2849 |
2703 #undef __ | 2850 #undef __ |
2704 | 2851 |
2705 } // namespace internal | 2852 } // namespace internal |
2706 } // namespace v8 | 2853 } // namespace v8 |
2707 | 2854 |
2708 #endif // V8_TARGET_ARCH_MIPS64 | 2855 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |