| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 6 | 6 |
| 7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 // -- x1 : target function (preserved for callee) | 1340 // -- x1 : target function (preserved for callee) |
| 1341 // ----------------------------------- | 1341 // ----------------------------------- |
| 1342 // First lookup code, maybe we don't need to compile! | 1342 // First lookup code, maybe we don't need to compile! |
| 1343 Label gotta_call_runtime; | 1343 Label gotta_call_runtime; |
| 1344 Label try_shared; | 1344 Label try_shared; |
| 1345 Label loop_top, loop_bottom; | 1345 Label loop_top, loop_bottom; |
| 1346 | 1346 |
| 1347 Register closure = x1; | 1347 Register closure = x1; |
| 1348 Register map = x13; | 1348 Register map = x13; |
| 1349 Register index = x2; | 1349 Register index = x2; |
| 1350 |
| 1351 // Do we have a valid feedback vector? |
| 1352 __ Ldr(index, FieldMemOperand(closure, JSFunction::kLiteralsOffset)); |
| 1353 __ Ldr(index, FieldMemOperand(index, LiteralsArray::kFeedbackVectorOffset)); |
| 1354 __ JumpIfRoot(index, Heap::kUndefinedValueRootIndex, &gotta_call_runtime); |
| 1355 |
| 1350 __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1356 __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1351 __ Ldr(map, | 1357 __ Ldr(map, |
| 1352 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | 1358 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
| 1353 __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset)); | 1359 __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset)); |
| 1354 __ Cmp(index, Operand(2)); | 1360 __ Cmp(index, Operand(2)); |
| 1355 __ B(lt, &gotta_call_runtime); | 1361 __ B(lt, &gotta_call_runtime); |
| 1356 | 1362 |
| 1357 // Find literals. | |
| 1358 // x3 : native context | 1363 // x3 : native context |
| 1359 // x2 : length / index | 1364 // x2 : length / index |
| 1360 // x13 : optimized code map | 1365 // x13 : optimized code map |
| 1361 // stack[0] : new target | 1366 // stack[0] : new target |
| 1362 // stack[4] : closure | 1367 // stack[4] : closure |
| 1363 Register native_context = x4; | 1368 Register native_context = x4; |
| 1364 __ Ldr(native_context, NativeContextMemOperand()); | 1369 __ Ldr(native_context, NativeContextMemOperand()); |
| 1365 | 1370 |
| 1366 __ Bind(&loop_top); | 1371 __ Bind(&loop_top); |
| 1367 Register temp = x5; | 1372 Register temp = x5; |
| 1368 Register array_pointer = x6; | 1373 Register array_pointer = x6; |
| 1369 | 1374 |
| 1370 // Does the native context match? | 1375 // Does the native context match? |
| 1371 __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2)); | 1376 __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2)); |
| 1372 __ Ldr(temp, FieldMemOperand(array_pointer, | 1377 __ Ldr(temp, FieldMemOperand(array_pointer, |
| 1373 SharedFunctionInfo::kOffsetToPreviousContext)); | 1378 SharedFunctionInfo::kOffsetToPreviousContext)); |
| 1374 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | 1379 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1375 __ Cmp(temp, native_context); | 1380 __ Cmp(temp, native_context); |
| 1376 __ B(ne, &loop_bottom); | 1381 __ B(ne, &loop_bottom); |
| 1377 // Literals available? | |
| 1378 __ Ldr(temp, FieldMemOperand(array_pointer, | |
| 1379 SharedFunctionInfo::kOffsetToPreviousLiterals)); | |
| 1380 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | |
| 1381 __ JumpIfSmi(temp, &gotta_call_runtime); | |
| 1382 | |
| 1383 // Save the literals in the closure. | |
| 1384 __ Str(temp, FieldMemOperand(closure, JSFunction::kLiteralsOffset)); | |
| 1385 __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, x7, | |
| 1386 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
| 1387 OMIT_SMI_CHECK); | |
| 1388 | 1382 |
| 1389 // Code available? | 1383 // Code available? |
| 1390 Register entry = x7; | 1384 Register entry = x7; |
| 1391 __ Ldr(entry, | 1385 __ Ldr(entry, |
| 1392 FieldMemOperand(array_pointer, | 1386 FieldMemOperand(array_pointer, |
| 1393 SharedFunctionInfo::kOffsetToPreviousCachedCode)); | 1387 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
| 1394 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | 1388 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1395 __ JumpIfSmi(entry, &try_shared); | 1389 __ JumpIfSmi(entry, &try_shared); |
| 1396 | 1390 |
| 1397 // Found literals and code. Get them into the closure and return. | 1391 // Found code. Get it into the closure and return. |
| 1398 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1392 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1399 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | 1393 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
| 1400 __ RecordWriteCodeEntryField(closure, entry, x5); | 1394 __ RecordWriteCodeEntryField(closure, entry, x5); |
| 1401 | 1395 |
| 1402 // Link the closure into the optimized function list. | 1396 // Link the closure into the optimized function list. |
| 1403 // x7 : code entry | 1397 // x7 : code entry |
| 1404 // x4 : native context | 1398 // x4 : native context |
| 1405 // x1 : closure | 1399 // x1 : closure |
| 1406 __ Ldr(x8, | 1400 __ Ldr(x8, |
| 1407 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | 1401 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1408 __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); | 1402 __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); |
| 1409 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x13, | 1403 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x13, |
| 1410 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | 1404 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1411 OMIT_SMI_CHECK); | 1405 OMIT_SMI_CHECK); |
| 1412 const int function_list_offset = | 1406 const int function_list_offset = |
| 1413 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); | 1407 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); |
| 1414 __ Str(closure, | 1408 __ Str(closure, |
| 1415 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | 1409 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1416 __ Mov(x5, closure); | 1410 __ Mov(x5, closure); |
| 1417 __ RecordWriteContextSlot(native_context, function_list_offset, x5, x13, | 1411 __ RecordWriteContextSlot(native_context, function_list_offset, x5, x13, |
| 1418 kLRHasNotBeenSaved, kDontSaveFPRegs); | 1412 kLRHasNotBeenSaved, kDontSaveFPRegs); |
| 1419 __ Jump(entry); | 1413 __ Jump(entry); |
| 1420 | 1414 |
| 1421 __ Bind(&loop_bottom); | 1415 __ Bind(&loop_bottom); |
| 1422 __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength)); | 1416 __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength)); |
| 1423 __ Cmp(index, Operand(1)); | 1417 __ Cmp(index, Operand(1)); |
| 1424 __ B(gt, &loop_top); | 1418 __ B(gt, &loop_top); |
| 1425 | 1419 |
| 1426 // We found neither literals nor code. | 1420 // We found no code. |
| 1427 __ B(&gotta_call_runtime); | 1421 __ B(&gotta_call_runtime); |
| 1428 | 1422 |
| 1429 __ Bind(&try_shared); | 1423 __ Bind(&try_shared); |
| 1430 __ Ldr(entry, | 1424 __ Ldr(entry, |
| 1431 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1425 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1432 // Is the shared function marked for tier up? | 1426 // Is the shared function marked for tier up? |
| 1433 __ Ldrb(temp, FieldMemOperand( | 1427 __ Ldrb(temp, FieldMemOperand( |
| 1434 entry, SharedFunctionInfo::kMarkedForTierUpByteOffset)); | 1428 entry, SharedFunctionInfo::kMarkedForTierUpByteOffset)); |
| 1435 __ TestAndBranchIfAnySet( | 1429 __ TestAndBranchIfAnySet( |
| 1436 temp, 1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte, | 1430 temp, 1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte, |
| (...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2998 __ Unreachable(); | 2992 __ Unreachable(); |
| 2999 } | 2993 } |
| 3000 } | 2994 } |
| 3001 | 2995 |
| 3002 #undef __ | 2996 #undef __ |
| 3003 | 2997 |
| 3004 } // namespace internal | 2998 } // namespace internal |
| 3005 } // namespace v8 | 2999 } // namespace v8 |
| 3006 | 3000 |
| 3007 #endif // V8_TARGET_ARCH_ARM | 3001 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |