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