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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Reserve space for arguments and align frame before entering C++ world. | 76 // Reserve space for arguments and align frame before entering C++ world. |
77 __ subq(RSP, Immediate(sizeof(NativeArguments))); | 77 __ subq(RSP, Immediate(sizeof(NativeArguments))); |
78 if (OS::ActivationFrameAlignment() > 1) { | 78 if (OS::ActivationFrameAlignment() > 1) { |
79 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 79 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
80 } | 80 } |
81 | 81 |
82 // Pass NativeArguments structure by value and call runtime. | 82 // Pass NativeArguments structure by value and call runtime. |
83 __ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs. | 83 __ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs. |
84 // There are no runtime calls to closures, so we do not need to set the tag | 84 // There are no runtime calls to closures, so we do not need to set the tag |
85 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. | 85 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. |
86 __ SmiUntag(R10); | |
87 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. | 86 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. |
88 __ leaq(RAX, Address(RBP, R10, TIMES_8, 1 * kWordSize)); // Compute argv. | 87 __ leaq(RAX, Address(RBP, R10, TIMES_8, 1 * kWordSize)); // Compute argv. |
89 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. | 88 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. |
90 __ addq(RAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. | 89 __ addq(RAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. |
91 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. | 90 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. |
92 #if defined(_WIN64) | 91 #if defined(_WIN64) |
93 ASSERT(sizeof(NativeArguments) > CallingConventions::kRegisterTransferLimit); | 92 ASSERT(sizeof(NativeArguments) > CallingConventions::kRegisterTransferLimit); |
94 __ movq(CallingConventions::kArg1Reg, RSP); | 93 __ movq(CallingConventions::kArg1Reg, RSP); |
95 #endif | 94 #endif |
96 __ CallCFunction(RBX); | 95 __ CallCFunction(RBX); |
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 __ popq(RBX); // Restore IC data array. | 1536 __ popq(RBX); // Restore IC data array. |
1538 __ popq(R10); // Restore arguments descriptor array. | 1537 __ popq(R10); // Restore arguments descriptor array. |
1539 __ LeaveStubFrame(); | 1538 __ LeaveStubFrame(); |
1540 | 1539 |
1541 __ movq(RAX, FieldAddress(RAX, Function::instructions_offset())); | 1540 __ movq(RAX, FieldAddress(RAX, Function::instructions_offset())); |
1542 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1541 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
1543 __ jmp(RAX); | 1542 __ jmp(RAX); |
1544 } | 1543 } |
1545 | 1544 |
1546 | 1545 |
1547 // RBX, R10: May contain arguments to runtime stub. | 1546 // RBX: Contains an ICData. |
1548 // TOS(0): return address (Dart code). | 1547 // TOS(0): return address (Dart code). |
1549 void StubCode::GenerateBreakpointRuntimeStub(Assembler* assembler) { | 1548 void StubCode::GenerateICCallBreakpointStub(Assembler* assembler) { |
| 1549 __ EnterStubFrame(); |
| 1550 // Preserve IC data. |
| 1551 __ pushq(RBX); |
| 1552 // Room for result. Debugger stub returns address of the |
| 1553 // unpatched runtime stub. |
| 1554 __ LoadObject(R12, Object::null_object(), PP); |
| 1555 __ pushq(R12); // Room for result. |
| 1556 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); |
| 1557 __ popq(RAX); // Address of original. |
| 1558 __ popq(RBX); // Restore IC data. |
| 1559 __ LeaveStubFrame(); |
| 1560 __ jmp(RAX); // Jump to original stub. |
| 1561 } |
| 1562 |
| 1563 |
| 1564 // RBX: Contains Smi 0 (need to preserve a GC-safe value for the lazy compile |
| 1565 // stub). |
| 1566 // R10: Contains an arguments descriptor. |
| 1567 // TOS(0): return address (Dart code). |
| 1568 void StubCode::GenerateClosureCallBreakpointStub(Assembler* assembler) { |
1550 __ EnterStubFrame(); | 1569 __ EnterStubFrame(); |
1551 // Preserve runtime args. | 1570 // Preserve runtime args. |
1552 __ pushq(RBX); | 1571 __ pushq(RBX); |
1553 __ pushq(R10); | 1572 __ pushq(R10); |
1554 // Room for result. Debugger stub returns address of the | 1573 // Room for result. Debugger stub returns address of the |
1555 // unpatched runtime stub. | 1574 // unpatched runtime stub. |
| 1575 __ LoadObject(R12, Object::null_object(), PP); |
| 1576 __ pushq(R12); // Room for result. |
| 1577 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); |
| 1578 __ popq(RAX); // Address of original. |
| 1579 __ popq(R10); // Restore arguments. |
| 1580 __ popq(RBX); |
| 1581 __ LeaveStubFrame(); |
| 1582 __ jmp(RAX); // Jump to original stub. |
| 1583 } |
| 1584 |
| 1585 |
| 1586 // RBX: Garbage or function address. |
| 1587 // R10: Garbage or raw argument count. |
| 1588 // TOS(0): return address (Dart code). |
| 1589 void StubCode::GenerateRuntimeCallBreakpointStub(Assembler* assembler) { |
| 1590 __ EnterStubFrame(); |
| 1591 // Preserve runtime args. |
| 1592 __ andq(RBX, Immediate(~kSmiTagMask)); // Make garbage GC-safe, no-op for |
| 1593 // aligned function pointer |
| 1594 __ pushq(RBX); |
| 1595 __ SmiTag(R10); |
| 1596 __ pushq(R10); |
| 1597 // Room for result. Debugger stub returns address of the |
| 1598 // unpatched runtime stub. |
1556 __ LoadObject(R12, Object::null_object(), PP); | 1599 __ LoadObject(R12, Object::null_object(), PP); |
1557 __ pushq(R12); // Room for result. | 1600 __ pushq(R12); // Room for result. |
1558 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); | 1601 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); |
1559 __ popq(RAX); // Address of original. | 1602 __ popq(RAX); // Address of original. |
1560 __ popq(R10); // Restore arguments. | 1603 __ popq(R10); // Restore arguments. |
| 1604 __ SmiUntag(R10); |
1561 __ popq(RBX); | 1605 __ popq(RBX); |
1562 __ LeaveStubFrame(); | 1606 __ LeaveStubFrame(); |
1563 __ jmp(RAX); // Jump to original stub. | 1607 __ jmp(RAX); // Jump to original stub. |
1564 } | 1608 } |
1565 | 1609 |
1566 | 1610 |
1567 // Called only from unoptimized code. | 1611 // Called only from unoptimized code. |
1568 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { | 1612 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { |
1569 if (FLAG_enable_debugger) { | 1613 if (FLAG_enable_debugger) { |
1570 // Check single stepping. | 1614 // Check single stepping. |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1858 | 1902 |
1859 __ movq(left, Address(RSP, 2 * kWordSize)); | 1903 __ movq(left, Address(RSP, 2 * kWordSize)); |
1860 __ movq(right, Address(RSP, 1 * kWordSize)); | 1904 __ movq(right, Address(RSP, 1 * kWordSize)); |
1861 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 1905 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
1862 __ ret(); | 1906 __ ret(); |
1863 } | 1907 } |
1864 | 1908 |
1865 } // namespace dart | 1909 } // namespace dart |
1866 | 1910 |
1867 #endif // defined TARGET_ARCH_X64 | 1911 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |