| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3); | 541 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3); |
| 542 // Discard arguments. | 542 // Discard arguments. |
| 543 __ popq(RAX); | 543 __ popq(RAX); |
| 544 __ popq(RAX); | 544 __ popq(RAX); |
| 545 __ popq(RAX); | 545 __ popq(RAX); |
| 546 __ popq(RAX); // Return value from the runtime call (function). | 546 __ popq(RAX); // Return value from the runtime call (function). |
| 547 __ popq(R10); // Restore arguments descriptor. | 547 __ popq(R10); // Restore arguments descriptor. |
| 548 __ popq(RBX); // Restore IC data. | 548 __ popq(RBX); // Restore IC data. |
| 549 __ LeaveStubFrame(); | 549 __ LeaveStubFrame(); |
| 550 | 550 |
| 551 __ movq(RCX, FieldAddress(RAX, Function::code_offset())); | 551 __ movq(RCX, FieldAddress(RAX, Function::instructions_offset())); |
| 552 __ movq(RCX, FieldAddress(RCX, Code::instructions_offset())); | |
| 553 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 552 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 554 __ jmp(RCX); | 553 __ jmp(RCX); |
| 555 } | 554 } |
| 556 | 555 |
| 557 | 556 |
| 558 // Called for inline allocation of arrays. | 557 // Called for inline allocation of arrays. |
| 559 // Input parameters: | 558 // Input parameters: |
| 560 // R10 : Array length as Smi. | 559 // R10 : Array length as Smi. |
| 561 // RBX : array element type (either NULL or an instantiated type). | 560 // RBX : array element type (either NULL or an instantiated type). |
| 562 // NOTE: R10 cannot be clobbered here as the caller relies on it being saved. | 561 // NOTE: R10 cannot be clobbered here as the caller relies on it being saved. |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; | 1333 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; |
| 1335 __ movq(RAX, Address(R12, target_offset)); | 1334 __ movq(RAX, Address(R12, target_offset)); |
| 1336 __ addq(Address(R12, count_offset), Immediate(Smi::RawValue(1))); | 1335 __ addq(Address(R12, count_offset), Immediate(Smi::RawValue(1))); |
| 1337 __ j(NO_OVERFLOW, &call_target_function, Assembler::kNearJump); | 1336 __ j(NO_OVERFLOW, &call_target_function, Assembler::kNearJump); |
| 1338 __ movq(Address(R12, count_offset), | 1337 __ movq(Address(R12, count_offset), |
| 1339 Immediate(Smi::RawValue(Smi::kMaxValue))); | 1338 Immediate(Smi::RawValue(Smi::kMaxValue))); |
| 1340 | 1339 |
| 1341 __ Bind(&call_target_function); | 1340 __ Bind(&call_target_function); |
| 1342 // RAX: Target function. | 1341 // RAX: Target function. |
| 1343 Label is_compiled; | 1342 Label is_compiled; |
| 1344 __ movq(RCX, FieldAddress(RAX, Function::code_offset())); | 1343 __ movq(RCX, FieldAddress(RAX, Function::instructions_offset())); |
| 1345 __ movq(RCX, FieldAddress(RCX, Code::instructions_offset())); | |
| 1346 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1344 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1347 __ jmp(RCX); | 1345 __ jmp(RCX); |
| 1348 | 1346 |
| 1349 __ Bind(&get_class_id_as_smi); | 1347 __ Bind(&get_class_id_as_smi); |
| 1350 Label not_smi; | 1348 Label not_smi; |
| 1351 // Test if Smi -> load Smi class for comparison. | 1349 // Test if Smi -> load Smi class for comparison. |
| 1352 __ testq(RAX, Immediate(kSmiTagMask)); | 1350 __ testq(RAX, Immediate(kSmiTagMask)); |
| 1353 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); | 1351 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); |
| 1354 __ movq(RAX, Immediate(Smi::RawValue(kSmiCid))); | 1352 __ movq(RAX, Immediate(Smi::RawValue(kSmiCid))); |
| 1355 __ ret(); | 1353 __ ret(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 __ j(NO_OVERFLOW, &increment_done, Assembler::kNearJump); | 1479 __ j(NO_OVERFLOW, &increment_done, Assembler::kNearJump); |
| 1482 __ movq(Address(R12, count_offset), | 1480 __ movq(Address(R12, count_offset), |
| 1483 Immediate(Smi::RawValue(Smi::kMaxValue))); | 1481 Immediate(Smi::RawValue(Smi::kMaxValue))); |
| 1484 __ Bind(&increment_done); | 1482 __ Bind(&increment_done); |
| 1485 | 1483 |
| 1486 // Load arguments descriptor into R10. | 1484 // Load arguments descriptor into R10. |
| 1487 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset())); | 1485 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset())); |
| 1488 | 1486 |
| 1489 // Get function and call it, if possible. | 1487 // Get function and call it, if possible. |
| 1490 __ movq(RAX, Address(R12, target_offset)); | 1488 __ movq(RAX, Address(R12, target_offset)); |
| 1491 __ movq(RCX, FieldAddress(RAX, Function::code_offset())); | 1489 __ movq(RCX, FieldAddress(RAX, Function::instructions_offset())); |
| 1492 // RCX: Target code. | 1490 // RCX: Target instructions. |
| 1493 __ movq(RCX, FieldAddress(RCX, Code::instructions_offset())); | |
| 1494 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1491 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1495 __ jmp(RCX); | 1492 __ jmp(RCX); |
| 1496 } | 1493 } |
| 1497 | 1494 |
| 1498 | 1495 |
| 1499 void StubCode::GenerateTwoArgsUnoptimizedStaticCallStub(Assembler* assembler) { | 1496 void StubCode::GenerateTwoArgsUnoptimizedStaticCallStub(Assembler* assembler) { |
| 1500 GenerateUsageCounterIncrement(assembler, RCX); | 1497 GenerateUsageCounterIncrement(assembler, RCX); |
| 1501 GenerateNArgsCheckInlineCacheStub( | 1498 GenerateNArgsCheckInlineCacheStub( |
| 1502 assembler, 2, kStaticCallMissHandlerTwoArgsRuntimeEntry); | 1499 assembler, 2, kStaticCallMissHandlerTwoArgsRuntimeEntry); |
| 1503 } | 1500 } |
| 1504 | 1501 |
| 1505 | 1502 |
| 1506 // Stub for compiling a function and jumping to the compiled code. | 1503 // Stub for compiling a function and jumping to the compiled code. |
| 1507 // RCX: IC-Data (for methods). | 1504 // RCX: IC-Data (for methods). |
| 1508 // R10: Arguments descriptor. | 1505 // R10: Arguments descriptor. |
| 1509 // RAX: Function. | 1506 // RAX: Function. |
| 1510 void StubCode::GenerateLazyCompileStub(Assembler* assembler) { | 1507 void StubCode::GenerateLazyCompileStub(Assembler* assembler) { |
| 1511 __ EnterStubFrame(); | 1508 __ EnterStubFrame(); |
| 1512 __ pushq(R10); // Preserve arguments descriptor array. | 1509 __ pushq(R10); // Preserve arguments descriptor array. |
| 1513 __ pushq(RBX); // Preserve IC data object. | 1510 __ pushq(RBX); // Preserve IC data object. |
| 1514 __ pushq(RAX); // Pass function. | 1511 __ pushq(RAX); // Pass function. |
| 1515 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); | 1512 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); |
| 1516 __ popq(RAX); // Restore function. | 1513 __ popq(RAX); // Restore function. |
| 1517 __ popq(RBX); // Restore IC data array. | 1514 __ popq(RBX); // Restore IC data array. |
| 1518 __ popq(R10); // Restore arguments descriptor array. | 1515 __ popq(R10); // Restore arguments descriptor array. |
| 1519 __ LeaveStubFrame(); | 1516 __ LeaveStubFrame(); |
| 1520 | 1517 |
| 1521 __ movq(RAX, FieldAddress(RAX, Function::code_offset())); | 1518 __ movq(RAX, FieldAddress(RAX, Function::instructions_offset())); |
| 1522 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset())); | |
| 1523 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1519 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1524 __ jmp(RAX); | 1520 __ jmp(RAX); |
| 1525 } | 1521 } |
| 1526 | 1522 |
| 1527 | 1523 |
| 1528 // RBX, R10: May contain arguments to runtime stub. | 1524 // RBX, R10: May contain arguments to runtime stub. |
| 1529 // TOS(0): return address (Dart code). | 1525 // TOS(0): return address (Dart code). |
| 1530 void StubCode::GenerateBreakpointRuntimeStub(Assembler* assembler) { | 1526 void StubCode::GenerateBreakpointRuntimeStub(Assembler* assembler) { |
| 1531 __ EnterStubFrame(); | 1527 __ EnterStubFrame(); |
| 1532 // Preserve runtime args. | 1528 // Preserve runtime args. |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1829 | 1825 |
| 1830 __ movq(left, Address(RSP, 2 * kWordSize)); | 1826 __ movq(left, Address(RSP, 2 * kWordSize)); |
| 1831 __ movq(right, Address(RSP, 1 * kWordSize)); | 1827 __ movq(right, Address(RSP, 1 * kWordSize)); |
| 1832 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 1828 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
| 1833 __ ret(); | 1829 __ ret(); |
| 1834 } | 1830 } |
| 1835 | 1831 |
| 1836 } // namespace dart | 1832 } // namespace dart |
| 1837 | 1833 |
| 1838 #endif // defined TARGET_ARCH_X64 | 1834 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |