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 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 __ popq(RBX); // Restore IC data array. | 1538 __ popq(RBX); // Restore IC data array. |
1540 __ popq(R10); // Restore arguments descriptor array. | 1539 __ popq(R10); // Restore arguments descriptor array. |
1541 __ LeaveStubFrame(); | 1540 __ LeaveStubFrame(); |
1542 | 1541 |
1543 __ movq(RAX, FieldAddress(RAX, Function::instructions_offset())); | 1542 __ movq(RAX, FieldAddress(RAX, Function::instructions_offset())); |
1544 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1543 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
1545 __ jmp(RAX); | 1544 __ jmp(RAX); |
1546 } | 1545 } |
1547 | 1546 |
1548 | 1547 |
1549 // RBX, R10: May contain arguments to runtime stub. | 1548 // RBX: Contains an ICData. |
1550 // TOS(0): return address (Dart code). | 1549 // TOS(0): return address (Dart code). |
1551 void StubCode::GenerateBreakpointRuntimeStub(Assembler* assembler) { | 1550 void StubCode::GenerateICCallBreakpointStub(Assembler* assembler) { |
| 1551 __ EnterStubFrame(); |
| 1552 // Preserve IC data. |
| 1553 __ pushq(RBX); |
| 1554 // Room for result. Debugger stub returns address of the |
| 1555 // unpatched runtime stub. |
| 1556 __ LoadObject(R12, Object::null_object(), PP); |
| 1557 __ pushq(R12); // Room for result. |
| 1558 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); |
| 1559 __ popq(RAX); // Address of original. |
| 1560 __ popq(RBX); // Restore IC data. |
| 1561 __ LeaveStubFrame(); |
| 1562 __ jmp(RAX); // Jump to original stub. |
| 1563 } |
| 1564 |
| 1565 |
| 1566 // RBX: Contains Smi 0 (need to preserve a GC-safe value for the lazy compile |
| 1567 // stub). |
| 1568 // R10: Contains an arguments descriptor. |
| 1569 // TOS(0): return address (Dart code). |
| 1570 void StubCode::GenerateClosureCallBreakpointStub(Assembler* assembler) { |
1552 __ EnterStubFrame(); | 1571 __ EnterStubFrame(); |
1553 // Preserve runtime args. | 1572 // Preserve runtime args. |
1554 __ pushq(RBX); | 1573 __ pushq(RBX); |
1555 __ pushq(R10); | 1574 __ pushq(R10); |
1556 // Room for result. Debugger stub returns address of the | 1575 // Room for result. Debugger stub returns address of the |
1557 // unpatched runtime stub. | 1576 // unpatched runtime stub. |
1558 __ LoadObject(R12, Object::null_object(), PP); | 1577 __ LoadObject(R12, Object::null_object(), PP); |
1559 __ pushq(R12); // Room for result. | 1578 __ pushq(R12); // Room for result. |
1560 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); | 1579 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); |
1561 __ popq(RAX); // Address of original. | 1580 __ popq(RAX); // Address of original. |
1562 __ popq(R10); // Restore arguments. | 1581 __ popq(R10); // Restore arguments. |
1563 __ popq(RBX); | 1582 __ popq(RBX); |
1564 __ LeaveStubFrame(); | 1583 __ LeaveStubFrame(); |
1565 __ jmp(RAX); // Jump to original stub. | 1584 __ jmp(RAX); // Jump to original stub. |
1566 } | 1585 } |
1567 | 1586 |
1568 | 1587 |
| 1588 // TOS(0): return address (Dart code). |
| 1589 void StubCode::GenerateRuntimeCallBreakpointStub(Assembler* assembler) { |
| 1590 __ EnterStubFrame(); |
| 1591 // Room for result. Debugger stub returns address of the |
| 1592 // unpatched runtime stub. |
| 1593 __ LoadObject(R12, Object::null_object(), PP); |
| 1594 __ pushq(R12); // Room for result. |
| 1595 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); |
| 1596 __ popq(RAX); // Address of original. |
| 1597 __ LeaveStubFrame(); |
| 1598 __ jmp(RAX); // Jump to original stub. |
| 1599 } |
| 1600 |
| 1601 |
1569 // Called only from unoptimized code. | 1602 // Called only from unoptimized code. |
1570 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { | 1603 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { |
1571 if (FLAG_enable_debugger) { | 1604 if (FLAG_enable_debugger) { |
1572 // Check single stepping. | 1605 // Check single stepping. |
1573 Label not_stepping; | 1606 Label not_stepping; |
1574 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 1607 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); |
1575 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); | 1608 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); |
1576 __ cmpq(RAX, Immediate(0)); | 1609 __ cmpq(RAX, Immediate(0)); |
1577 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); | 1610 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); |
1578 | 1611 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 | 1893 |
1861 __ movq(left, Address(RSP, 2 * kWordSize)); | 1894 __ movq(left, Address(RSP, 2 * kWordSize)); |
1862 __ movq(right, Address(RSP, 1 * kWordSize)); | 1895 __ movq(right, Address(RSP, 1 * kWordSize)); |
1863 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 1896 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
1864 __ ret(); | 1897 __ ret(); |
1865 } | 1898 } |
1866 | 1899 |
1867 } // namespace dart | 1900 } // namespace dart |
1868 | 1901 |
1869 #endif // defined TARGET_ARCH_X64 | 1902 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |