| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 | 1505 |
| 1506 // Remove the stub frame as we are about to return. | 1506 // Remove the stub frame as we are about to return. |
| 1507 __ LeaveFrame(); | 1507 __ LeaveFrame(); |
| 1508 __ ret(); | 1508 __ ret(); |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 | 1511 |
| 1512 | 1512 |
| 1513 // Generate inline cache check for 'num_args'. | 1513 // Generate inline cache check for 'num_args'. |
| 1514 // RBX: Inline cache data object. | 1514 // RBX: Inline cache data object. |
| 1515 // R10: Arguments array. | 1515 // R10: Arguments descriptor array. |
| 1516 // TOS(0): return address | 1516 // TOS(0): return address |
| 1517 // Control flow: | 1517 // Control flow: |
| 1518 // - If receiver is null -> jump to IC miss. | 1518 // - If receiver is null -> jump to IC miss. |
| 1519 // - If receiver is Smi -> load Smi class. | 1519 // - If receiver is Smi -> load Smi class. |
| 1520 // - If receiver is not-Smi -> load receiver's class. | 1520 // - If receiver is not-Smi -> load receiver's class. |
| 1521 // - Check if 'num_args' (including receiver) match any IC data group. | 1521 // - Check if 'num_args' (including receiver) match any IC data group. |
| 1522 // - Match found -> jump to target. | 1522 // - Match found -> jump to target. |
| 1523 // - Match not found -> jump to IC miss. | 1523 // - Match not found -> jump to IC miss. |
| 1524 void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler, | 1524 void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler, |
| 1525 intptr_t num_args) { | 1525 intptr_t num_args) { |
| 1526 // TODO(srdjan): Add usage counter increment and test (see ia32). | 1526 // TODO(srdjan): Add usage counter increment and test (see ia32). |
| 1527 ASSERT(num_args > 0); | 1527 ASSERT(num_args > 0); |
| 1528 // Get receiver. | 1528 // Get receiver (first read number of arguments from argument descriptor array |
| 1529 // and then access the receiver from the stack). |
| 1529 __ movq(RAX, FieldAddress(R10, Array::data_offset())); | 1530 __ movq(RAX, FieldAddress(R10, Array::data_offset())); |
| 1530 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi. | 1531 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi. |
| 1531 | 1532 |
| 1532 Label get_class, ic_miss; | 1533 Label get_class, ic_miss; |
| 1533 __ call(&get_class); | 1534 __ call(&get_class); |
| 1534 // RAX: receiver's class | 1535 // RAX: receiver's class |
| 1535 // RBX: IC data array. | 1536 // RBX: IC data array. |
| 1536 | 1537 |
| 1537 #if defined(DEBUG) | 1538 #if defined(DEBUG) |
| 1538 { Label ok; | 1539 { Label ok; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 __ call(&get_class); | 1583 __ call(&get_class); |
| 1583 __ cmpq(RAX, R13); // Match? | 1584 __ cmpq(RAX, R13); // Match? |
| 1584 __ j(EQUAL, &found); | 1585 __ j(EQUAL, &found); |
| 1585 __ Bind(&no_match); | 1586 __ Bind(&no_match); |
| 1586 __ addq(R12, Immediate(kWordSize * (1 + num_args))); // Next element. | 1587 __ addq(R12, Immediate(kWordSize * (1 + num_args))); // Next element. |
| 1587 __ cmpq(R13, raw_null); // Done? | 1588 __ cmpq(R13, raw_null); // Done? |
| 1588 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); | 1589 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); |
| 1589 } | 1590 } |
| 1590 | 1591 |
| 1591 __ Bind(&ic_miss); | 1592 __ Bind(&ic_miss); |
| 1592 // Get receiver, again. | 1593 // Compute address of arguments (first read number of arguments from argument |
| 1594 // descriptor array and then compute address on the stack). |
| 1593 __ movq(RAX, FieldAddress(R10, Array::data_offset())); | 1595 __ movq(RAX, FieldAddress(R10, Array::data_offset())); |
| 1594 __ leaq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX is Smi. | 1596 __ leaq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX is Smi. |
| 1595 __ EnterFrame(0); | 1597 __ EnterFrame(0); |
| 1596 __ pushq(R10); // Preserve arguments array. | 1598 __ pushq(R10); // Preserve arguments array. |
| 1597 __ pushq(RBX); // Preserve IC data array | 1599 __ pushq(RBX); // Preserve IC data array |
| 1598 __ pushq(raw_null); // Setup space on stack for result (target code object). | 1600 __ pushq(raw_null); // Setup space on stack for result (target code object). |
| 1599 __ movq(R10, FieldAddress(R10, Array::data_offset())); | |
| 1600 // Push call arguments. | 1601 // Push call arguments. |
| 1601 for (intptr_t i = 0; i < num_args; i++) { | 1602 for (intptr_t i = 0; i < num_args; i++) { |
| 1602 __ movq(R10, Address(RAX, -kWordSize * i)); | 1603 __ movq(R10, Address(RAX, -kWordSize * i)); |
| 1603 __ pushq(R10); | 1604 __ pushq(R10); |
| 1604 } | 1605 } |
| 1605 if (num_args == 1) { | 1606 if (num_args == 1) { |
| 1606 __ CallRuntimeFromStub(kInlineCacheMissHandlerOneArgRuntimeEntry); | 1607 __ CallRuntimeFromStub(kInlineCacheMissHandlerOneArgRuntimeEntry); |
| 1607 } else if (num_args == 2) { | 1608 } else if (num_args == 2) { |
| 1608 __ CallRuntimeFromStub(kInlineCacheMissHandlerTwoArgsRuntimeEntry); | 1609 __ CallRuntimeFromStub(kInlineCacheMissHandlerTwoArgsRuntimeEntry); |
| 1609 } else { | 1610 } else { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 __ j(EQUAL, ¬_found, Assembler::kNearJump); | 1805 __ j(EQUAL, ¬_found, Assembler::kNearJump); |
| 1805 __ movq(R10, FieldAddress(R10, Type::type_class_offset())); | 1806 __ movq(R10, FieldAddress(R10, Type::type_class_offset())); |
| 1806 __ cmpq(RCX, R10); | 1807 __ cmpq(RCX, R10); |
| 1807 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); | 1808 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); |
| 1808 __ jmp(&found, Assembler::kNearJump); | 1809 __ jmp(&found, Assembler::kNearJump); |
| 1809 } | 1810 } |
| 1810 | 1811 |
| 1811 } // namespace dart | 1812 } // namespace dart |
| 1812 | 1813 |
| 1813 #endif // defined TARGET_ARCH_X64 | 1814 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |