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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 __ Bind(&bytecode_array_loaded); | 1013 __ Bind(&bytecode_array_loaded); |
1014 | 1014 |
1015 // Check whether we should continue to use the interpreter. | 1015 // Check whether we should continue to use the interpreter. |
1016 Label switch_to_different_code_kind; | 1016 Label switch_to_different_code_kind; |
1017 __ Ldr(x0, FieldMemOperand(x0, SharedFunctionInfo::kCodeOffset)); | 1017 __ Ldr(x0, FieldMemOperand(x0, SharedFunctionInfo::kCodeOffset)); |
1018 __ Cmp(x0, Operand(masm->CodeObject())); // Self-reference to this code. | 1018 __ Cmp(x0, Operand(masm->CodeObject())); // Self-reference to this code. |
1019 __ B(ne, &switch_to_different_code_kind); | 1019 __ B(ne, &switch_to_different_code_kind); |
1020 | 1020 |
1021 // Increment invocation count for the function. | 1021 // Increment invocation count for the function. |
1022 __ Ldr(x11, FieldMemOperand(x1, JSFunction::kFeedbackVectorOffset)); | 1022 __ Ldr(x11, FieldMemOperand(x1, JSFunction::kFeedbackVectorOffset)); |
| 1023 __ Ldr(x11, FieldMemOperand(x11, Cell::kValueOffset)); |
1023 __ Ldr(x10, FieldMemOperand(x11, TypeFeedbackVector::kInvocationCountIndex * | 1024 __ Ldr(x10, FieldMemOperand(x11, TypeFeedbackVector::kInvocationCountIndex * |
1024 kPointerSize + | 1025 kPointerSize + |
1025 TypeFeedbackVector::kHeaderSize)); | 1026 TypeFeedbackVector::kHeaderSize)); |
1026 __ Add(x10, x10, Operand(Smi::FromInt(1))); | 1027 __ Add(x10, x10, Operand(Smi::FromInt(1))); |
1027 __ Str(x10, FieldMemOperand(x11, TypeFeedbackVector::kInvocationCountIndex * | 1028 __ Str(x10, FieldMemOperand(x11, TypeFeedbackVector::kInvocationCountIndex * |
1028 kPointerSize + | 1029 kPointerSize + |
1029 TypeFeedbackVector::kHeaderSize)); | 1030 TypeFeedbackVector::kHeaderSize)); |
1030 | 1031 |
1031 // Check function data field is actually a BytecodeArray object. | 1032 // Check function data field is actually a BytecodeArray object. |
1032 if (FLAG_debug_code) { | 1033 if (FLAG_debug_code) { |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 // -- x1 : target function (preserved for callee) | 1344 // -- x1 : target function (preserved for callee) |
1344 // ----------------------------------- | 1345 // ----------------------------------- |
1345 // First lookup code, maybe we don't need to compile! | 1346 // First lookup code, maybe we don't need to compile! |
1346 Label gotta_call_runtime; | 1347 Label gotta_call_runtime; |
1347 Label try_shared; | 1348 Label try_shared; |
1348 Label loop_top, loop_bottom; | 1349 Label loop_top, loop_bottom; |
1349 | 1350 |
1350 Register closure = x1; | 1351 Register closure = x1; |
1351 Register map = x13; | 1352 Register map = x13; |
1352 Register index = x2; | 1353 Register index = x2; |
| 1354 |
| 1355 // Do we have a valid feedback vector? |
| 1356 __ Ldr(index, FieldMemOperand(closure, JSFunction::kFeedbackVectorOffset)); |
| 1357 __ Ldr(index, FieldMemOperand(index, Cell::kValueOffset)); |
| 1358 __ JumpIfRoot(index, Heap::kUndefinedValueRootIndex, &gotta_call_runtime); |
| 1359 |
1353 __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1360 __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1354 __ Ldr(map, | 1361 __ Ldr(map, |
1355 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | 1362 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
1356 __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset)); | 1363 __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset)); |
1357 __ Cmp(index, Operand(2)); | 1364 __ Cmp(index, Operand(2)); |
1358 __ B(lt, &gotta_call_runtime); | 1365 __ B(lt, &try_shared); |
1359 | 1366 |
1360 // Find literals. | |
1361 // x3 : native context | 1367 // x3 : native context |
1362 // x2 : length / index | 1368 // x2 : length / index |
1363 // x13 : optimized code map | 1369 // x13 : optimized code map |
1364 // stack[0] : new target | 1370 // stack[0] : new target |
1365 // stack[4] : closure | 1371 // stack[4] : closure |
1366 Register native_context = x4; | 1372 Register native_context = x4; |
1367 __ Ldr(native_context, NativeContextMemOperand()); | 1373 __ Ldr(native_context, NativeContextMemOperand()); |
1368 | 1374 |
1369 __ Bind(&loop_top); | 1375 __ Bind(&loop_top); |
1370 Register temp = x5; | 1376 Register temp = x5; |
1371 Register array_pointer = x6; | 1377 Register array_pointer = x6; |
1372 | 1378 |
1373 // Does the native context match? | 1379 // Does the native context match? |
1374 __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2)); | 1380 __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2)); |
1375 __ Ldr(temp, FieldMemOperand(array_pointer, | 1381 __ Ldr(temp, FieldMemOperand(array_pointer, |
1376 SharedFunctionInfo::kOffsetToPreviousContext)); | 1382 SharedFunctionInfo::kOffsetToPreviousContext)); |
1377 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | 1383 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
1378 __ Cmp(temp, native_context); | 1384 __ Cmp(temp, native_context); |
1379 __ B(ne, &loop_bottom); | 1385 __ B(ne, &loop_bottom); |
1380 // Feedback vector 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 feedback vector in the closure. | |
1387 __ Str(temp, FieldMemOperand(closure, JSFunction::kFeedbackVectorOffset)); | |
1388 __ RecordWriteField(closure, JSFunction::kFeedbackVectorOffset, temp, x7, | |
1389 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
1390 OMIT_SMI_CHECK); | |
1391 | 1386 |
1392 // Code available? | 1387 // Code available? |
1393 Register entry = x7; | 1388 Register entry = x7; |
1394 __ Ldr(entry, | 1389 __ Ldr(entry, |
1395 FieldMemOperand(array_pointer, | 1390 FieldMemOperand(array_pointer, |
1396 SharedFunctionInfo::kOffsetToPreviousCachedCode)); | 1391 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
1397 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | 1392 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
1398 __ JumpIfSmi(entry, &try_shared); | 1393 __ JumpIfSmi(entry, &try_shared); |
1399 | 1394 |
1400 // Found literals and code. Get them into the closure and return. | 1395 // Found code. Get it into the closure and return. |
1401 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1396 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1402 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | 1397 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
1403 __ RecordWriteCodeEntryField(closure, entry, x5); | 1398 __ RecordWriteCodeEntryField(closure, entry, x5); |
1404 | 1399 |
1405 // Link the closure into the optimized function list. | 1400 // Link the closure into the optimized function list. |
1406 // x7 : code entry | 1401 // x7 : code entry |
1407 // x4 : native context | 1402 // x4 : native context |
1408 // x1 : closure | 1403 // x1 : closure |
1409 __ Ldr(x8, | 1404 __ Ldr(x8, |
1410 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | 1405 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
1411 __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); | 1406 __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); |
1412 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x13, | 1407 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x13, |
1413 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | 1408 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
1414 OMIT_SMI_CHECK); | 1409 OMIT_SMI_CHECK); |
1415 const int function_list_offset = | 1410 const int function_list_offset = |
1416 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); | 1411 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); |
1417 __ Str(closure, | 1412 __ Str(closure, |
1418 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | 1413 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
1419 __ Mov(x5, closure); | 1414 __ Mov(x5, closure); |
1420 __ RecordWriteContextSlot(native_context, function_list_offset, x5, x13, | 1415 __ RecordWriteContextSlot(native_context, function_list_offset, x5, x13, |
1421 kLRHasNotBeenSaved, kDontSaveFPRegs); | 1416 kLRHasNotBeenSaved, kDontSaveFPRegs); |
1422 __ Jump(entry); | 1417 __ Jump(entry); |
1423 | 1418 |
1424 __ Bind(&loop_bottom); | 1419 __ Bind(&loop_bottom); |
1425 __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength)); | 1420 __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength)); |
1426 __ Cmp(index, Operand(1)); | 1421 __ Cmp(index, Operand(1)); |
1427 __ B(gt, &loop_top); | 1422 __ B(gt, &loop_top); |
1428 | 1423 |
1429 // We found neither literals nor code. | 1424 // We found no code. |
1430 __ B(&gotta_call_runtime); | |
1431 | |
1432 __ Bind(&try_shared); | 1425 __ Bind(&try_shared); |
1433 __ Ldr(entry, | 1426 __ Ldr(entry, |
1434 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1427 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1435 // Is the shared function marked for tier up? | 1428 // Is the shared function marked for tier up? |
1436 __ Ldrb(temp, FieldMemOperand( | 1429 __ Ldrb(temp, FieldMemOperand( |
1437 entry, SharedFunctionInfo::kMarkedForTierUpByteOffset)); | 1430 entry, SharedFunctionInfo::kMarkedForTierUpByteOffset)); |
1438 __ TestAndBranchIfAnySet( | 1431 __ TestAndBranchIfAnySet( |
1439 temp, 1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte, | 1432 temp, 1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte, |
1440 &gotta_call_runtime); | 1433 &gotta_call_runtime); |
1441 | 1434 |
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3226 __ Unreachable(); | 3219 __ Unreachable(); |
3227 } | 3220 } |
3228 } | 3221 } |
3229 | 3222 |
3230 #undef __ | 3223 #undef __ |
3231 | 3224 |
3232 } // namespace internal | 3225 } // namespace internal |
3233 } // namespace v8 | 3226 } // namespace v8 |
3234 | 3227 |
3235 #endif // V8_TARGET_ARCH_ARM | 3228 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |