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" |
11 #include "vm/flow_graph_compiler.h" | 11 #include "vm/flow_graph_compiler.h" |
12 #include "vm/heap.h" | 12 #include "vm/heap.h" |
13 #include "vm/instructions.h" | 13 #include "vm/instructions.h" |
14 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
15 #include "vm/resolver.h" | 15 #include "vm/resolver.h" |
16 #include "vm/scavenger.h" | 16 #include "vm/scavenger.h" |
17 #include "vm/stack_frame.h" | 17 #include "vm/stack_frame.h" |
18 #include "vm/stub_code.h" | 18 #include "vm/stub_code.h" |
19 #include "vm/tags.h" | 19 #include "vm/tags.h" |
20 | 20 |
21 #define __ assembler-> | 21 #define __ assembler-> |
22 | 22 |
23 namespace dart { | 23 namespace dart { |
24 | 24 |
25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); | 25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); |
26 DEFINE_FLAG(bool, use_slow_path, false, | 26 DEFINE_FLAG(bool, use_slow_path, false, |
27 "Set to true for debugging & verifying the slow paths."); | 27 "Set to true for debugging & verifying the slow paths."); |
28 DECLARE_FLAG(bool, trace_optimized_ic_calls); | 28 DECLARE_FLAG(bool, trace_optimized_ic_calls); |
29 | 29 |
| 30 DECLARE_FLAG(bool, enable_debugger); |
30 | 31 |
31 // Input parameters: | 32 // Input parameters: |
32 // RSP : points to return address. | 33 // RSP : points to return address. |
33 // RSP + 8 : address of last argument in argument array. | 34 // RSP + 8 : address of last argument in argument array. |
34 // RSP + 8*R10 : address of first argument in argument array. | 35 // RSP + 8*R10 : address of first argument in argument array. |
35 // RSP + 8*R10 + 8 : address of return value. | 36 // RSP + 8*R10 + 8 : address of return value. |
36 // RBX : address of the runtime function to call. | 37 // RBX : address of the runtime function to call. |
37 // R10 : number of arguments to the call. | 38 // R10 : number of arguments to the call. |
38 // Must preserve callee saved registers R12 and R13. | 39 // Must preserve callee saved registers R12 and R13. |
39 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 40 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 __ movl(RCX, FieldAddress(RBX, ICData::state_bits_offset())); | 1224 __ movl(RCX, FieldAddress(RBX, ICData::state_bits_offset())); |
1224 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. | 1225 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. |
1225 __ andq(RCX, Immediate(ICData::NumArgsTestedMask())); | 1226 __ andq(RCX, Immediate(ICData::NumArgsTestedMask())); |
1226 __ cmpq(RCX, Immediate(num_args)); | 1227 __ cmpq(RCX, Immediate(num_args)); |
1227 __ j(EQUAL, &ok, Assembler::kNearJump); | 1228 __ j(EQUAL, &ok, Assembler::kNearJump); |
1228 __ Stop("Incorrect stub for IC data"); | 1229 __ Stop("Incorrect stub for IC data"); |
1229 __ Bind(&ok); | 1230 __ Bind(&ok); |
1230 } | 1231 } |
1231 #endif // DEBUG | 1232 #endif // DEBUG |
1232 | 1233 |
1233 // Check single stepping. | 1234 if (FLAG_enable_debugger) { |
1234 Label not_stepping; | 1235 // Check single stepping. |
1235 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 1236 Label not_stepping; |
1236 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); | 1237 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); |
1237 __ cmpq(RAX, Immediate(0)); | 1238 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); |
1238 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); | 1239 __ cmpq(RAX, Immediate(0)); |
1239 __ EnterStubFrame(); | 1240 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); |
1240 __ pushq(RBX); | 1241 __ EnterStubFrame(); |
1241 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1242 __ pushq(RBX); |
1242 __ popq(RBX); | 1243 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1243 __ LeaveStubFrame(); | 1244 __ popq(RBX); |
1244 __ Bind(¬_stepping); | 1245 __ LeaveStubFrame(); |
| 1246 __ Bind(¬_stepping); |
| 1247 } |
1245 | 1248 |
1246 // Load arguments descriptor into R10. | 1249 // Load arguments descriptor into R10. |
1247 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset())); | 1250 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset())); |
1248 // Loop that checks if there is an IC data match. | 1251 // Loop that checks if there is an IC data match. |
1249 Label loop, update, test, found, get_class_id_as_smi; | 1252 Label loop, update, test, found, get_class_id_as_smi; |
1250 // RBX: IC data object (preserved). | 1253 // RBX: IC data object (preserved). |
1251 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset())); | 1254 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset())); |
1252 // R12: ic_data_array with check entries: classes and target functions. | 1255 // R12: ic_data_array with check entries: classes and target functions. |
1253 __ leaq(R12, FieldAddress(R12, Array::data_offset())); | 1256 __ leaq(R12, FieldAddress(R12, Array::data_offset())); |
1254 // R12: points directly to the first ic data array element. | 1257 // R12: points directly to the first ic data array element. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 __ movl(RCX, FieldAddress(RBX, ICData::state_bits_offset())); | 1445 __ movl(RCX, FieldAddress(RBX, ICData::state_bits_offset())); |
1443 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. | 1446 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. |
1444 __ andq(RCX, Immediate(ICData::NumArgsTestedMask())); | 1447 __ andq(RCX, Immediate(ICData::NumArgsTestedMask())); |
1445 __ cmpq(RCX, Immediate(0)); | 1448 __ cmpq(RCX, Immediate(0)); |
1446 __ j(EQUAL, &ok, Assembler::kNearJump); | 1449 __ j(EQUAL, &ok, Assembler::kNearJump); |
1447 __ Stop("Incorrect IC data for unoptimized static call"); | 1450 __ Stop("Incorrect IC data for unoptimized static call"); |
1448 __ Bind(&ok); | 1451 __ Bind(&ok); |
1449 } | 1452 } |
1450 #endif // DEBUG | 1453 #endif // DEBUG |
1451 | 1454 |
1452 // Check single stepping. | 1455 if (FLAG_enable_debugger) { |
1453 Label not_stepping; | 1456 // Check single stepping. |
1454 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 1457 Label not_stepping; |
1455 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); | 1458 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); |
1456 __ cmpq(RAX, Immediate(0)); | 1459 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); |
1457 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); | 1460 __ cmpq(RAX, Immediate(0)); |
1458 __ EnterStubFrame(); | 1461 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); |
1459 __ pushq(RBX); // Preserve IC data object. | 1462 __ EnterStubFrame(); |
1460 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1463 __ pushq(RBX); // Preserve IC data object. |
1461 __ popq(RBX); | 1464 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1462 __ LeaveStubFrame(); | 1465 __ popq(RBX); |
1463 __ Bind(¬_stepping); | 1466 __ LeaveStubFrame(); |
| 1467 __ Bind(¬_stepping); |
| 1468 } |
1464 | 1469 |
1465 // RBX: IC data object (preserved). | 1470 // RBX: IC data object (preserved). |
1466 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset())); | 1471 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset())); |
1467 // R12: ic_data_array with entries: target functions and count. | 1472 // R12: ic_data_array with entries: target functions and count. |
1468 __ leaq(R12, FieldAddress(R12, Array::data_offset())); | 1473 __ leaq(R12, FieldAddress(R12, Array::data_offset())); |
1469 // R12: points directly to the first ic data array element. | 1474 // R12: points directly to the first ic data array element. |
1470 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize; | 1475 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize; |
1471 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize; | 1476 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize; |
1472 | 1477 |
1473 // Increment count for this call. | 1478 // Increment count for this call. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 __ popq(RAX); // Address of original. | 1540 __ popq(RAX); // Address of original. |
1536 __ popq(R10); // Restore arguments. | 1541 __ popq(R10); // Restore arguments. |
1537 __ popq(RBX); | 1542 __ popq(RBX); |
1538 __ LeaveStubFrame(); | 1543 __ LeaveStubFrame(); |
1539 __ jmp(RAX); // Jump to original stub. | 1544 __ jmp(RAX); // Jump to original stub. |
1540 } | 1545 } |
1541 | 1546 |
1542 | 1547 |
1543 // Called only from unoptimized code. | 1548 // Called only from unoptimized code. |
1544 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { | 1549 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { |
1545 // Check single stepping. | 1550 if (FLAG_enable_debugger) { |
1546 Label not_stepping; | 1551 // Check single stepping. |
1547 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 1552 Label not_stepping; |
1548 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); | 1553 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); |
1549 __ cmpq(RAX, Immediate(0)); | 1554 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); |
1550 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); | 1555 __ cmpq(RAX, Immediate(0)); |
| 1556 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); |
1551 | 1557 |
1552 __ EnterStubFrame(); | 1558 __ EnterStubFrame(); |
1553 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1559 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1554 __ LeaveStubFrame(); | 1560 __ LeaveStubFrame(); |
1555 __ Bind(¬_stepping); | 1561 __ Bind(¬_stepping); |
| 1562 } |
1556 __ ret(); | 1563 __ ret(); |
1557 } | 1564 } |
1558 | 1565 |
1559 | 1566 |
1560 // Used to check class and type arguments. Arguments passed on stack: | 1567 // Used to check class and type arguments. Arguments passed on stack: |
1561 // TOS + 0: return address. | 1568 // TOS + 0: return address. |
1562 // TOS + 1: instantiator type arguments (can be NULL). | 1569 // TOS + 1: instantiator type arguments (can be NULL). |
1563 // TOS + 2: instance. | 1570 // TOS + 2: instance. |
1564 // TOS + 3: SubtypeTestCache. | 1571 // TOS + 3: SubtypeTestCache. |
1565 // Result in RCX: null -> not found, otherwise result (true or false). | 1572 // Result in RCX: null -> not found, otherwise result (true or false). |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 } | 1787 } |
1781 | 1788 |
1782 | 1789 |
1783 // Called only from unoptimized code. All relevant registers have been saved. | 1790 // Called only from unoptimized code. All relevant registers have been saved. |
1784 // TOS + 0: return address | 1791 // TOS + 0: return address |
1785 // TOS + 1: right argument. | 1792 // TOS + 1: right argument. |
1786 // TOS + 2: left argument. | 1793 // TOS + 2: left argument. |
1787 // Returns ZF set. | 1794 // Returns ZF set. |
1788 void StubCode::GenerateUnoptimizedIdenticalWithNumberCheckStub( | 1795 void StubCode::GenerateUnoptimizedIdenticalWithNumberCheckStub( |
1789 Assembler* assembler) { | 1796 Assembler* assembler) { |
1790 // Check single stepping. | 1797 if (FLAG_enable_debugger) { |
1791 Label not_stepping; | 1798 // Check single stepping. |
1792 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 1799 Label not_stepping; |
1793 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); | 1800 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); |
1794 __ cmpq(RAX, Immediate(0)); | 1801 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); |
1795 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); | 1802 __ cmpq(RAX, Immediate(0)); |
1796 __ EnterStubFrame(); | 1803 __ j(EQUAL, ¬_stepping, Assembler::kNearJump); |
1797 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1804 __ EnterStubFrame(); |
1798 __ LeaveStubFrame(); | 1805 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1799 __ Bind(¬_stepping); | 1806 __ LeaveStubFrame(); |
| 1807 __ Bind(¬_stepping); |
| 1808 } |
1800 | 1809 |
1801 const Register left = RAX; | 1810 const Register left = RAX; |
1802 const Register right = RDX; | 1811 const Register right = RDX; |
1803 | 1812 |
1804 __ movq(left, Address(RSP, 2 * kWordSize)); | 1813 __ movq(left, Address(RSP, 2 * kWordSize)); |
1805 __ movq(right, Address(RSP, 1 * kWordSize)); | 1814 __ movq(right, Address(RSP, 1 * kWordSize)); |
1806 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 1815 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
1807 __ ret(); | 1816 __ ret(); |
1808 } | 1817 } |
1809 | 1818 |
(...skipping 10 matching lines...) Expand all Loading... |
1820 | 1829 |
1821 __ movq(left, Address(RSP, 2 * kWordSize)); | 1830 __ movq(left, Address(RSP, 2 * kWordSize)); |
1822 __ movq(right, Address(RSP, 1 * kWordSize)); | 1831 __ movq(right, Address(RSP, 1 * kWordSize)); |
1823 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 1832 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
1824 __ ret(); | 1833 __ ret(); |
1825 } | 1834 } |
1826 | 1835 |
1827 } // namespace dart | 1836 } // namespace dart |
1828 | 1837 |
1829 #endif // defined TARGET_ARCH_X64 | 1838 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |