OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
12 #include "vm/flow_graph_compiler.h" | 12 #include "vm/flow_graph_compiler.h" |
13 #include "vm/heap.h" | 13 #include "vm/heap.h" |
14 #include "vm/instructions.h" | 14 #include "vm/instructions.h" |
15 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
16 #include "vm/stack_frame.h" | 16 #include "vm/stack_frame.h" |
17 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
18 #include "vm/tags.h" | 18 #include "vm/tags.h" |
19 | 19 |
20 #define __ assembler-> | 20 #define __ assembler-> |
21 | 21 |
22 namespace dart { | 22 namespace dart { |
23 | 23 |
24 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); | 24 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); |
25 DEFINE_FLAG(bool, use_slow_path, false, | 25 DEFINE_FLAG(bool, use_slow_path, false, |
26 "Set to true for debugging & verifying the slow paths."); | 26 "Set to true for debugging & verifying the slow paths."); |
27 DECLARE_FLAG(bool, trace_optimized_ic_calls); | 27 DECLARE_FLAG(bool, trace_optimized_ic_calls); |
28 | 28 |
| 29 DECLARE_FLAG(bool, enable_debugger); |
| 30 |
29 // Input parameters: | 31 // Input parameters: |
30 // LR : return address. | 32 // LR : return address. |
31 // SP : address of last argument in argument array. | 33 // SP : address of last argument in argument array. |
32 // SP + 8*R4 - 8 : address of first argument in argument array. | 34 // SP + 8*R4 - 8 : address of first argument in argument array. |
33 // SP + 8*R4 : address of return value. | 35 // SP + 8*R4 : address of return value. |
34 // R5 : address of the runtime function to call. | 36 // R5 : address of the runtime function to call. |
35 // R4 : number of arguments to the call. | 37 // R4 : number of arguments to the call. |
36 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 38 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
37 const intptr_t isolate_offset = NativeArguments::isolate_offset(); | 39 const intptr_t isolate_offset = NativeArguments::isolate_offset(); |
38 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); | 40 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 kNoPP, kUnsignedWord); | 1305 kNoPP, kUnsignedWord); |
1304 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. | 1306 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. |
1305 __ andi(R6, R6, ICData::NumArgsTestedMask()); | 1307 __ andi(R6, R6, ICData::NumArgsTestedMask()); |
1306 __ CompareImmediate(R6, num_args, kNoPP); | 1308 __ CompareImmediate(R6, num_args, kNoPP); |
1307 __ b(&ok, EQ); | 1309 __ b(&ok, EQ); |
1308 __ Stop("Incorrect stub for IC data"); | 1310 __ Stop("Incorrect stub for IC data"); |
1309 __ Bind(&ok); | 1311 __ Bind(&ok); |
1310 } | 1312 } |
1311 #endif // DEBUG | 1313 #endif // DEBUG |
1312 | 1314 |
1313 // Check single stepping. | 1315 if (FLAG_enable_debugger) { |
1314 Label not_stepping; | 1316 // Check single stepping. |
1315 __ LoadFieldFromOffset(R6, CTX, Context::isolate_offset(), kNoPP); | 1317 Label not_stepping; |
1316 __ LoadFromOffset( | 1318 __ LoadFieldFromOffset(R6, CTX, Context::isolate_offset(), kNoPP); |
1317 R6, R6, Isolate::single_step_offset(), kNoPP, kUnsignedByte); | 1319 __ LoadFromOffset( |
1318 __ CompareRegisters(R6, ZR); | 1320 R6, R6, Isolate::single_step_offset(), kNoPP, kUnsignedByte); |
1319 __ b(¬_stepping, EQ); | 1321 __ CompareRegisters(R6, ZR); |
1320 __ EnterStubFrame(); | 1322 __ b(¬_stepping, EQ); |
1321 __ Push(R5); // Preserve IC data. | 1323 __ EnterStubFrame(); |
1322 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1324 __ Push(R5); // Preserve IC data. |
1323 __ Pop(R5); | 1325 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1324 __ LeaveStubFrame(); | 1326 __ Pop(R5); |
1325 __ Bind(¬_stepping); | 1327 __ LeaveStubFrame(); |
| 1328 __ Bind(¬_stepping); |
| 1329 } |
1326 | 1330 |
1327 // Load arguments descriptor into R4. | 1331 // Load arguments descriptor into R4. |
1328 __ LoadFieldFromOffset(R4, R5, ICData::arguments_descriptor_offset(), kNoPP); | 1332 __ LoadFieldFromOffset(R4, R5, ICData::arguments_descriptor_offset(), kNoPP); |
1329 // Loop that checks if there is an IC data match. | 1333 // Loop that checks if there is an IC data match. |
1330 Label loop, update, test, found, get_class_id_as_smi; | 1334 Label loop, update, test, found, get_class_id_as_smi; |
1331 // R5: IC data object (preserved). | 1335 // R5: IC data object (preserved). |
1332 __ LoadFieldFromOffset(R6, R5, ICData::ic_data_offset(), kNoPP); | 1336 __ LoadFieldFromOffset(R6, R5, ICData::ic_data_offset(), kNoPP); |
1333 // R6: ic_data_array with check entries: classes and target functions. | 1337 // R6: ic_data_array with check entries: classes and target functions. |
1334 __ AddImmediate(R6, R6, Array::data_offset() - kHeapObjectTag, kNoPP); | 1338 __ AddImmediate(R6, R6, Array::data_offset() - kHeapObjectTag, kNoPP); |
1335 // R6: points directly to the first ic data array element. | 1339 // R6: points directly to the first ic data array element. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 kNoPP, kUnsignedWord); | 1556 kNoPP, kUnsignedWord); |
1553 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. | 1557 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. |
1554 __ andi(R6, R6, ICData::NumArgsTestedMask()); | 1558 __ andi(R6, R6, ICData::NumArgsTestedMask()); |
1555 __ CompareImmediate(R6, 0, kNoPP); | 1559 __ CompareImmediate(R6, 0, kNoPP); |
1556 __ b(&ok, EQ); | 1560 __ b(&ok, EQ); |
1557 __ Stop("Incorrect IC data for unoptimized static call"); | 1561 __ Stop("Incorrect IC data for unoptimized static call"); |
1558 __ Bind(&ok); | 1562 __ Bind(&ok); |
1559 } | 1563 } |
1560 #endif // DEBUG | 1564 #endif // DEBUG |
1561 | 1565 |
1562 // Check single stepping. | 1566 if (FLAG_enable_debugger) { |
1563 Label not_stepping; | 1567 // Check single stepping. |
1564 __ LoadFieldFromOffset(R6, CTX, Context::isolate_offset(), kNoPP); | 1568 Label not_stepping; |
1565 __ LoadFromOffset( | 1569 __ LoadFieldFromOffset(R6, CTX, Context::isolate_offset(), kNoPP); |
1566 R6, R6, Isolate::single_step_offset(), kNoPP, kUnsignedByte); | 1570 __ LoadFromOffset( |
1567 __ CompareImmediate(R6, 0, kNoPP); | 1571 R6, R6, Isolate::single_step_offset(), kNoPP, kUnsignedByte); |
1568 __ b(¬_stepping, EQ); | 1572 __ CompareImmediate(R6, 0, kNoPP); |
1569 __ EnterStubFrame(); | 1573 __ b(¬_stepping, EQ); |
1570 __ Push(R5); // Preserve IC data. | 1574 __ EnterStubFrame(); |
1571 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1575 __ Push(R5); // Preserve IC data. |
1572 __ Pop(R5); | 1576 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1573 __ LeaveStubFrame(); | 1577 __ Pop(R5); |
1574 __ Bind(¬_stepping); | 1578 __ LeaveStubFrame(); |
| 1579 __ Bind(¬_stepping); |
| 1580 } |
1575 | 1581 |
1576 // R5: IC data object (preserved). | 1582 // R5: IC data object (preserved). |
1577 __ LoadFieldFromOffset(R6, R5, ICData::ic_data_offset(), kNoPP); | 1583 __ LoadFieldFromOffset(R6, R5, ICData::ic_data_offset(), kNoPP); |
1578 // R6: ic_data_array with entries: target functions and count. | 1584 // R6: ic_data_array with entries: target functions and count. |
1579 __ AddImmediate(R6, R6, Array::data_offset() - kHeapObjectTag, kNoPP); | 1585 __ AddImmediate(R6, R6, Array::data_offset() - kHeapObjectTag, kNoPP); |
1580 // R6: points directly to the first ic data array element. | 1586 // R6: points directly to the first ic data array element. |
1581 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize; | 1587 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize; |
1582 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize; | 1588 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize; |
1583 | 1589 |
1584 // Increment count for this call. | 1590 // Increment count for this call. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 __ Pop(R4); | 1654 __ Pop(R4); |
1649 __ Pop(R5); | 1655 __ Pop(R5); |
1650 __ LeaveStubFrame(); | 1656 __ LeaveStubFrame(); |
1651 __ br(R0); | 1657 __ br(R0); |
1652 } | 1658 } |
1653 | 1659 |
1654 | 1660 |
1655 // Called only from unoptimized code. All relevant registers have been saved. | 1661 // Called only from unoptimized code. All relevant registers have been saved. |
1656 void StubCode::GenerateDebugStepCheckStub( | 1662 void StubCode::GenerateDebugStepCheckStub( |
1657 Assembler* assembler) { | 1663 Assembler* assembler) { |
1658 // Check single stepping. | 1664 if (FLAG_enable_debugger) { |
1659 Label not_stepping; | 1665 // Check single stepping. |
1660 __ LoadFieldFromOffset(R1, CTX, Context::isolate_offset(), kNoPP); | 1666 Label not_stepping; |
1661 __ LoadFromOffset( | 1667 __ LoadFieldFromOffset(R1, CTX, Context::isolate_offset(), kNoPP); |
1662 R1, R1, Isolate::single_step_offset(), kNoPP, kUnsignedByte); | 1668 __ LoadFromOffset( |
1663 __ CompareImmediate(R1, 0, kNoPP); | 1669 R1, R1, Isolate::single_step_offset(), kNoPP, kUnsignedByte); |
1664 __ b(¬_stepping, EQ); | 1670 __ CompareImmediate(R1, 0, kNoPP); |
1665 __ EnterStubFrame(); | 1671 __ b(¬_stepping, EQ); |
1666 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1672 __ EnterStubFrame(); |
1667 __ LeaveStubFrame(); | 1673 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1668 __ Bind(¬_stepping); | 1674 __ LeaveStubFrame(); |
| 1675 __ Bind(¬_stepping); |
| 1676 } |
1669 __ ret(); | 1677 __ ret(); |
1670 } | 1678 } |
1671 | 1679 |
1672 | 1680 |
1673 // Used to check class and type arguments. Arguments passed in registers: | 1681 // Used to check class and type arguments. Arguments passed in registers: |
1674 // LR: return address. | 1682 // LR: return address. |
1675 // R0: instance (must be preserved). | 1683 // R0: instance (must be preserved). |
1676 // R1: instantiator type arguments or NULL. | 1684 // R1: instantiator type arguments or NULL. |
1677 // R2: cache array. | 1685 // R2: cache array. |
1678 // Result in R1: null -> not found, otherwise result (true or false). | 1686 // Result in R1: null -> not found, otherwise result (true or false). |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 } | 1882 } |
1875 | 1883 |
1876 | 1884 |
1877 // Called only from unoptimized code. All relevant registers have been saved. | 1885 // Called only from unoptimized code. All relevant registers have been saved. |
1878 // LR: return address. | 1886 // LR: return address. |
1879 // SP + 4: left operand. | 1887 // SP + 4: left operand. |
1880 // SP + 0: right operand. | 1888 // SP + 0: right operand. |
1881 // Return Zero condition flag set if equal. | 1889 // Return Zero condition flag set if equal. |
1882 void StubCode::GenerateUnoptimizedIdenticalWithNumberCheckStub( | 1890 void StubCode::GenerateUnoptimizedIdenticalWithNumberCheckStub( |
1883 Assembler* assembler) { | 1891 Assembler* assembler) { |
1884 // Check single stepping. | 1892 if (FLAG_enable_debugger) { |
1885 Label not_stepping; | 1893 // Check single stepping. |
1886 __ LoadFieldFromOffset(R1, CTX, Context::isolate_offset(), kNoPP); | 1894 Label not_stepping; |
1887 __ LoadFromOffset( | 1895 __ LoadFieldFromOffset(R1, CTX, Context::isolate_offset(), kNoPP); |
1888 R1, R1, Isolate::single_step_offset(), kNoPP, kUnsignedByte); | 1896 __ LoadFromOffset( |
1889 __ CompareImmediate(R1, 0, kNoPP); | 1897 R1, R1, Isolate::single_step_offset(), kNoPP, kUnsignedByte); |
1890 __ b(¬_stepping, EQ); | 1898 __ CompareImmediate(R1, 0, kNoPP); |
1891 __ EnterStubFrame(); | 1899 __ b(¬_stepping, EQ); |
1892 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1900 __ EnterStubFrame(); |
1893 __ LeaveStubFrame(); | 1901 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1894 __ Bind(¬_stepping); | 1902 __ LeaveStubFrame(); |
| 1903 __ Bind(¬_stepping); |
| 1904 } |
1895 | 1905 |
1896 const Register left = R1; | 1906 const Register left = R1; |
1897 const Register right = R0; | 1907 const Register right = R0; |
1898 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); | 1908 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); |
1899 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); | 1909 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); |
1900 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 1910 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
1901 __ ret(); | 1911 __ ret(); |
1902 } | 1912 } |
1903 | 1913 |
1904 | 1914 |
1905 // Called from optimized code only. | 1915 // Called from optimized code only. |
1906 // LR: return address. | 1916 // LR: return address. |
1907 // SP + 4: left operand. | 1917 // SP + 4: left operand. |
1908 // SP + 0: right operand. | 1918 // SP + 0: right operand. |
1909 // Return Zero condition flag set if equal. | 1919 // Return Zero condition flag set if equal. |
1910 void StubCode::GenerateOptimizedIdenticalWithNumberCheckStub( | 1920 void StubCode::GenerateOptimizedIdenticalWithNumberCheckStub( |
1911 Assembler* assembler) { | 1921 Assembler* assembler) { |
1912 const Register temp = R2; | 1922 const Register temp = R2; |
1913 const Register left = R1; | 1923 const Register left = R1; |
1914 const Register right = R0; | 1924 const Register right = R0; |
1915 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); | 1925 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); |
1916 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); | 1926 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); |
1917 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 1927 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
1918 __ ret(); | 1928 __ ret(); |
1919 } | 1929 } |
1920 | 1930 |
1921 } // namespace dart | 1931 } // namespace dart |
1922 | 1932 |
1923 #endif // defined TARGET_ARCH_ARM64 | 1933 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |