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 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1350 __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1351 __ Ldr(map, | 1351 __ Ldr(map, |
1352 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | 1352 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
1353 __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset)); | 1353 __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset)); |
1354 __ Cmp(index, Operand(2)); | 1354 __ Cmp(index, Operand(2)); |
1355 __ B(lt, &gotta_call_runtime); | 1355 __ B(lt, &gotta_call_runtime); |
1356 | 1356 |
| 1357 // Find literals. |
1357 // x3 : native context | 1358 // x3 : native context |
1358 // x2 : length / index | 1359 // x2 : length / index |
1359 // x13 : optimized code map | 1360 // x13 : optimized code map |
1360 // stack[0] : new target | 1361 // stack[0] : new target |
1361 // stack[4] : closure | 1362 // stack[4] : closure |
1362 Register native_context = x4; | 1363 Register native_context = x4; |
1363 __ Ldr(native_context, NativeContextMemOperand()); | 1364 __ Ldr(native_context, NativeContextMemOperand()); |
1364 | 1365 |
1365 __ Bind(&loop_top); | 1366 __ Bind(&loop_top); |
1366 Register temp = x5; | 1367 Register temp = x5; |
1367 Register array_pointer = x6; | 1368 Register array_pointer = x6; |
1368 | 1369 |
1369 // Does the native context match? | 1370 // Does the native context match? |
1370 __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2)); | 1371 __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2)); |
1371 __ Ldr(temp, FieldMemOperand(array_pointer, | 1372 __ Ldr(temp, FieldMemOperand(array_pointer, |
1372 SharedFunctionInfo::kOffsetToPreviousContext)); | 1373 SharedFunctionInfo::kOffsetToPreviousContext)); |
1373 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | 1374 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
1374 __ Cmp(temp, native_context); | 1375 __ Cmp(temp, native_context); |
1375 __ B(ne, &loop_bottom); | 1376 __ 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); |
1376 | 1388 |
1377 // Code available? | 1389 // Code available? |
1378 Register entry = x7; | 1390 Register entry = x7; |
1379 __ Ldr(entry, | 1391 __ Ldr(entry, |
1380 FieldMemOperand(array_pointer, | 1392 FieldMemOperand(array_pointer, |
1381 SharedFunctionInfo::kOffsetToPreviousCachedCode)); | 1393 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
1382 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | 1394 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
1383 __ JumpIfSmi(entry, &try_shared); | 1395 __ JumpIfSmi(entry, &try_shared); |
1384 | 1396 |
1385 // Found code. Get it into the closure and return. | 1397 // Found literals and code. Get them into the closure and return. |
1386 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1398 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1387 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | 1399 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
1388 __ RecordWriteCodeEntryField(closure, entry, x5); | 1400 __ RecordWriteCodeEntryField(closure, entry, x5); |
1389 | 1401 |
1390 // Link the closure into the optimized function list. | 1402 // Link the closure into the optimized function list. |
1391 // x7 : code entry | 1403 // x7 : code entry |
1392 // x4 : native context | 1404 // x4 : native context |
1393 // x1 : closure | 1405 // x1 : closure |
1394 __ Ldr(x8, | 1406 __ Ldr(x8, |
1395 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | 1407 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
1396 __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); | 1408 __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); |
1397 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x13, | 1409 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x13, |
1398 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | 1410 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
1399 OMIT_SMI_CHECK); | 1411 OMIT_SMI_CHECK); |
1400 const int function_list_offset = | 1412 const int function_list_offset = |
1401 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); | 1413 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); |
1402 __ Str(closure, | 1414 __ Str(closure, |
1403 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | 1415 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
1404 __ Mov(x5, closure); | 1416 __ Mov(x5, closure); |
1405 __ RecordWriteContextSlot(native_context, function_list_offset, x5, x13, | 1417 __ RecordWriteContextSlot(native_context, function_list_offset, x5, x13, |
1406 kLRHasNotBeenSaved, kDontSaveFPRegs); | 1418 kLRHasNotBeenSaved, kDontSaveFPRegs); |
1407 __ Jump(entry); | 1419 __ Jump(entry); |
1408 | 1420 |
1409 __ Bind(&loop_bottom); | 1421 __ Bind(&loop_bottom); |
1410 __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength)); | 1422 __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength)); |
1411 __ Cmp(index, Operand(1)); | 1423 __ Cmp(index, Operand(1)); |
1412 __ B(gt, &loop_top); | 1424 __ B(gt, &loop_top); |
1413 | 1425 |
1414 // We found no code. | 1426 // We found neither literals nor code. |
1415 __ B(&gotta_call_runtime); | 1427 __ B(&gotta_call_runtime); |
1416 | 1428 |
1417 __ Bind(&try_shared); | 1429 __ Bind(&try_shared); |
1418 __ Ldr(entry, | 1430 __ Ldr(entry, |
1419 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1431 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1420 // Is the shared function marked for tier up? | 1432 // Is the shared function marked for tier up? |
1421 __ Ldrb(temp, FieldMemOperand( | 1433 __ Ldrb(temp, FieldMemOperand( |
1422 entry, SharedFunctionInfo::kMarkedForTierUpByteOffset)); | 1434 entry, SharedFunctionInfo::kMarkedForTierUpByteOffset)); |
1423 __ TestAndBranchIfAnySet( | 1435 __ TestAndBranchIfAnySet( |
1424 temp, 1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte, | 1436 temp, 1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte, |
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 __ Unreachable(); | 2998 __ Unreachable(); |
2987 } | 2999 } |
2988 } | 3000 } |
2989 | 3001 |
2990 #undef __ | 3002 #undef __ |
2991 | 3003 |
2992 } // namespace internal | 3004 } // namespace internal |
2993 } // namespace v8 | 3005 } // namespace v8 |
2994 | 3006 |
2995 #endif // V8_TARGET_ARCH_ARM | 3007 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |