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