| 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 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 // This simulates the initial call to bytecode handlers in interpreter entry | 1232 // This simulates the initial call to bytecode handlers in interpreter entry |
| 1233 // trampoline. The return will never actually be taken, but our stack walker | 1233 // trampoline. The return will never actually be taken, but our stack walker |
| 1234 // uses this address to determine whether a frame is interpreted. | 1234 // uses this address to determine whether a frame is interpreted. |
| 1235 __ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); | 1235 __ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); |
| 1236 | 1236 |
| 1237 Generate_EnterBytecodeDispatch(masm); | 1237 Generate_EnterBytecodeDispatch(masm); |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 | 1240 |
| 1241 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1241 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| 1242 // ----------- S t a t e ------------- | |
| 1243 // -- a3 : new target (preserved for callee) | |
| 1244 // -- a1 : target function (preserved for callee) | |
| 1245 // ----------------------------------- | |
| 1246 // First lookup code, maybe we don't need to compile! | |
| 1247 Label gotta_call_runtime, gotta_call_runtime_no_stack; | |
| 1248 Label maybe_call_runtime; | |
| 1249 Label try_shared; | |
| 1250 Label loop_top, loop_bottom; | |
| 1251 | |
| 1252 Register closure = a1; | |
| 1253 Register new_target = a3; | |
| 1254 __ push(new_target); | |
| 1255 __ push(closure); | |
| 1256 | |
| 1257 Register map = a0; | |
| 1258 Register index = a2; | |
| 1259 __ lw(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | |
| 1260 __ lw(map, FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | |
| 1261 __ lw(index, FieldMemOperand(map, FixedArray::kLengthOffset)); | |
| 1262 __ Branch(&gotta_call_runtime, lt, index, Operand(Smi::FromInt(2))); | |
| 1263 | |
| 1264 // Find literals. | |
| 1265 // a3 : native context | |
| 1266 // a2 : length / index | |
| 1267 // a0 : optimized code map | |
| 1268 // stack[0] : new target | |
| 1269 // stack[4] : closure | |
| 1270 Register native_context = a3; | |
| 1271 __ lw(native_context, NativeContextMemOperand()); | |
| 1272 | |
| 1273 __ bind(&loop_top); | |
| 1274 Register temp = a1; | |
| 1275 Register array_pointer = t1; | |
| 1276 | |
| 1277 // Does the native context match? | |
| 1278 __ sll(at, index, kPointerSizeLog2 - kSmiTagSize); | |
| 1279 __ Addu(array_pointer, map, Operand(at)); | |
| 1280 __ lw(temp, FieldMemOperand(array_pointer, | |
| 1281 SharedFunctionInfo::OffsetToPreviousContext())); | |
| 1282 __ lw(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | |
| 1283 __ Branch(&loop_bottom, ne, temp, Operand(native_context)); | |
| 1284 // OSR id set to none? | |
| 1285 __ lw(temp, FieldMemOperand(array_pointer, | |
| 1286 SharedFunctionInfo::OffsetToPreviousOsrAstId())); | |
| 1287 const int bailout_id = BailoutId::None().ToInt(); | |
| 1288 __ Branch(&loop_bottom, ne, temp, Operand(Smi::FromInt(bailout_id))); | |
| 1289 // Literals available? | |
| 1290 __ lw(temp, FieldMemOperand(array_pointer, | |
| 1291 SharedFunctionInfo::OffsetToPreviousLiterals())); | |
| 1292 __ lw(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | |
| 1293 __ JumpIfSmi(temp, &gotta_call_runtime); | |
| 1294 | |
| 1295 // Save the literals in the closure. | |
| 1296 __ lw(t0, MemOperand(sp, 0)); | |
| 1297 __ sw(temp, FieldMemOperand(t0, JSFunction::kLiteralsOffset)); | |
| 1298 __ push(index); | |
| 1299 __ RecordWriteField(t0, JSFunction::kLiteralsOffset, temp, index, | |
| 1300 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
| 1301 OMIT_SMI_CHECK); | |
| 1302 __ pop(index); | |
| 1303 | |
| 1304 // Code available? | |
| 1305 Register entry = t0; | |
| 1306 __ lw(entry, | |
| 1307 FieldMemOperand(array_pointer, | |
| 1308 SharedFunctionInfo::OffsetToPreviousCachedCode())); | |
| 1309 __ lw(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | |
| 1310 __ JumpIfSmi(entry, &maybe_call_runtime); | |
| 1311 | |
| 1312 // Found literals and code. Get them into the closure and return. | |
| 1313 __ pop(closure); | |
| 1314 // Store code entry in the closure. | |
| 1315 __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 1316 | |
| 1317 Label install_optimized_code_and_tailcall; | |
| 1318 __ bind(&install_optimized_code_and_tailcall); | |
| 1319 __ sw(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | |
| 1320 __ RecordWriteCodeEntryField(closure, entry, t1); | |
| 1321 | |
| 1322 // Link the closure into the optimized function list. | |
| 1323 // t0 : code entry | |
| 1324 // a3 : native context | |
| 1325 // a1 : closure | |
| 1326 __ lw(t1, | |
| 1327 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | |
| 1328 __ sw(t1, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); | |
| 1329 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, t1, a0, | |
| 1330 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
| 1331 OMIT_SMI_CHECK); | |
| 1332 const int function_list_offset = | |
| 1333 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); | |
| 1334 __ sw(closure, | |
| 1335 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | |
| 1336 // Save closure before the write barrier. | |
| 1337 __ mov(t1, closure); | |
| 1338 __ RecordWriteContextSlot(native_context, function_list_offset, closure, a0, | |
| 1339 kRAHasNotBeenSaved, kDontSaveFPRegs); | |
| 1340 __ mov(closure, t1); | |
| 1341 __ pop(new_target); | |
| 1342 __ Jump(entry); | |
| 1343 | |
| 1344 __ bind(&loop_bottom); | |
| 1345 __ Subu(index, index, | |
| 1346 Operand(Smi::FromInt(SharedFunctionInfo::kEntryLength))); | |
| 1347 __ Branch(&loop_top, gt, index, Operand(Smi::FromInt(1))); | |
| 1348 | |
| 1349 // We found neither literals nor code. | |
| 1350 __ jmp(&gotta_call_runtime); | |
| 1351 | |
| 1352 __ bind(&maybe_call_runtime); | |
| 1353 __ pop(closure); | |
| 1354 | |
| 1355 // Last possibility. Check the context free optimized code map entry. | |
| 1356 __ lw(entry, FieldMemOperand(map, FixedArray::kHeaderSize + | |
| 1357 SharedFunctionInfo::kSharedCodeIndex)); | |
| 1358 __ lw(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | |
| 1359 __ JumpIfSmi(entry, &try_shared); | |
| 1360 | |
| 1361 // Store code entry in the closure. | |
| 1362 __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 1363 __ jmp(&install_optimized_code_and_tailcall); | |
| 1364 | |
| 1365 __ bind(&try_shared); | |
| 1366 __ pop(new_target); | |
| 1367 // Is the full code valid? | |
| 1368 __ lw(entry, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | |
| 1369 __ lw(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); | |
| 1370 __ lw(t1, FieldMemOperand(entry, Code::kFlagsOffset)); | |
| 1371 __ And(t1, t1, Operand(Code::KindField::kMask)); | |
| 1372 __ srl(t1, t1, Code::KindField::kShift); | |
| 1373 __ Branch(&gotta_call_runtime_no_stack, eq, t1, Operand(Code::BUILTIN)); | |
| 1374 // Yes, install the full code. | |
| 1375 __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 1376 __ sw(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | |
| 1377 __ RecordWriteCodeEntryField(closure, entry, t1); | |
| 1378 __ Jump(entry); | |
| 1379 | |
| 1380 __ bind(&gotta_call_runtime); | |
| 1381 __ pop(closure); | |
| 1382 __ pop(new_target); | |
| 1383 __ bind(&gotta_call_runtime_no_stack); | |
| 1384 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 1242 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
| 1385 GenerateTailCallToReturnedCode(masm); | 1243 GenerateTailCallToReturnedCode(masm); |
| 1386 } | 1244 } |
| 1387 | 1245 |
| 1388 | 1246 |
| 1389 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1247 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
| 1390 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); | 1248 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); |
| 1391 GenerateTailCallToReturnedCode(masm); | 1249 GenerateTailCallToReturnedCode(masm); |
| 1392 } | 1250 } |
| 1393 | 1251 |
| (...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2908 } | 2766 } |
| 2909 } | 2767 } |
| 2910 | 2768 |
| 2911 | 2769 |
| 2912 #undef __ | 2770 #undef __ |
| 2913 | 2771 |
| 2914 } // namespace internal | 2772 } // namespace internal |
| 2915 } // namespace v8 | 2773 } // namespace v8 |
| 2916 | 2774 |
| 2917 #endif // V8_TARGET_ARCH_MIPS | 2775 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |