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 | |
31 // Input parameters: | 29 // Input parameters: |
32 // LR : return address. | 30 // LR : return address. |
33 // SP : address of last argument in argument array. | 31 // SP : address of last argument in argument array. |
34 // SP + 8*R4 - 8 : address of first argument in argument array. | 32 // SP + 8*R4 - 8 : address of first argument in argument array. |
35 // SP + 8*R4 : address of return value. | 33 // SP + 8*R4 : address of return value. |
36 // R5 : address of the runtime function to call. | 34 // R5 : address of the runtime function to call. |
37 // R4 : number of arguments to the call. | 35 // R4 : number of arguments to the call. |
38 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 36 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
39 const intptr_t isolate_offset = NativeArguments::isolate_offset(); | 37 const intptr_t isolate_offset = NativeArguments::isolate_offset(); |
40 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); | 38 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); |
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. | 1338 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. |
1341 __ andi(R6, R6, ICData::NumArgsTestedMask()); | 1339 __ andi(R6, R6, ICData::NumArgsTestedMask()); |
1342 __ CompareImmediate(R6, num_args, kNoPP); | 1340 __ CompareImmediate(R6, num_args, kNoPP); |
1343 __ b(&ok, EQ); | 1341 __ b(&ok, EQ); |
1344 __ Stop("Incorrect stub for IC data"); | 1342 __ Stop("Incorrect stub for IC data"); |
1345 __ Bind(&ok); | 1343 __ Bind(&ok); |
1346 } | 1344 } |
1347 #endif // DEBUG | 1345 #endif // DEBUG |
1348 | 1346 |
1349 Label stepping, done_stepping; | 1347 Label stepping, done_stepping; |
1350 if (FLAG_enable_debugger) { | 1348 // Check single stepping. |
1351 // Check single stepping. | 1349 __ LoadFieldFromOffset(R6, CTX, Context::isolate_offset(), kNoPP); |
1352 __ LoadFieldFromOffset(R6, CTX, Context::isolate_offset(), kNoPP); | 1350 __ LoadFromOffset( |
1353 __ LoadFromOffset( | 1351 R6, R6, Isolate::single_step_offset(), kNoPP, kUnsignedByte); |
1354 R6, R6, Isolate::single_step_offset(), kNoPP, kUnsignedByte); | 1352 __ CompareRegisters(R6, ZR); |
1355 __ CompareRegisters(R6, ZR); | 1353 __ b(&stepping, NE); |
1356 __ b(&stepping, NE); | 1354 __ Bind(&done_stepping); |
1357 __ Bind(&done_stepping); | |
1358 } | |
1359 | 1355 |
1360 // Load arguments descriptor into R4. | 1356 // Load arguments descriptor into R4. |
1361 __ LoadFieldFromOffset(R4, R5, ICData::arguments_descriptor_offset(), kNoPP); | 1357 __ LoadFieldFromOffset(R4, R5, ICData::arguments_descriptor_offset(), kNoPP); |
1362 // Loop that checks if there is an IC data match. | 1358 // Loop that checks if there is an IC data match. |
1363 Label loop, update, test, found; | 1359 Label loop, update, test, found; |
1364 // R5: IC data object (preserved). | 1360 // R5: IC data object (preserved). |
1365 __ LoadFieldFromOffset(R6, R5, ICData::ic_data_offset(), kNoPP); | 1361 __ LoadFieldFromOffset(R6, R5, ICData::ic_data_offset(), kNoPP); |
1366 // R6: ic_data_array with check entries: classes and target functions. | 1362 // R6: ic_data_array with check entries: classes and target functions. |
1367 __ AddImmediate(R6, R6, Array::data_offset() - kHeapObjectTag, kNoPP); | 1363 __ AddImmediate(R6, R6, Array::data_offset() - kHeapObjectTag, kNoPP); |
1368 // R6: points directly to the first ic data array element. | 1364 // R6: points directly to the first ic data array element. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 __ csel(R1, R2, R1, VS); // Overflow. | 1460 __ csel(R1, R2, R1, VS); // Overflow. |
1465 __ StoreToOffset(R1, R6, count_offset, kNoPP); | 1461 __ StoreToOffset(R1, R6, count_offset, kNoPP); |
1466 | 1462 |
1467 __ Bind(&call_target_function); | 1463 __ Bind(&call_target_function); |
1468 // R0: target function. | 1464 // R0: target function. |
1469 __ LoadFieldFromOffset(R2, R0, Function::instructions_offset(), kNoPP); | 1465 __ LoadFieldFromOffset(R2, R0, Function::instructions_offset(), kNoPP); |
1470 __ AddImmediate( | 1466 __ AddImmediate( |
1471 R2, R2, Instructions::HeaderSize() - kHeapObjectTag, kNoPP); | 1467 R2, R2, Instructions::HeaderSize() - kHeapObjectTag, kNoPP); |
1472 __ br(R2); | 1468 __ br(R2); |
1473 | 1469 |
1474 if (FLAG_enable_debugger) { | 1470 __ Bind(&stepping); |
1475 __ Bind(&stepping); | 1471 __ EnterStubFrame(); |
1476 __ EnterStubFrame(); | 1472 __ Push(R5); // Preserve IC data. |
1477 __ Push(R5); // Preserve IC data. | 1473 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1478 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1474 __ Pop(R5); |
1479 __ Pop(R5); | 1475 __ LeaveStubFrame(); |
1480 __ LeaveStubFrame(); | 1476 __ b(&done_stepping); |
1481 __ b(&done_stepping); | |
1482 } | |
1483 } | 1477 } |
1484 | 1478 |
1485 | 1479 |
1486 // Use inline cache data array to invoke the target or continue in inline | 1480 // Use inline cache data array to invoke the target or continue in inline |
1487 // cache miss handler. Stub for 1-argument check (receiver class). | 1481 // cache miss handler. Stub for 1-argument check (receiver class). |
1488 // LR: return address. | 1482 // LR: return address. |
1489 // R5: inline cache data object. | 1483 // R5: inline cache data object. |
1490 // Inline cache data object structure: | 1484 // Inline cache data object structure: |
1491 // 0: function-name | 1485 // 0: function-name |
1492 // 1: N, number of arguments checked. | 1486 // 1: N, number of arguments checked. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 kNoPP, kUnsignedWord); | 1548 kNoPP, kUnsignedWord); |
1555 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. | 1549 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. |
1556 __ andi(R6, R6, ICData::NumArgsTestedMask()); | 1550 __ andi(R6, R6, ICData::NumArgsTestedMask()); |
1557 __ CompareImmediate(R6, 0, kNoPP); | 1551 __ CompareImmediate(R6, 0, kNoPP); |
1558 __ b(&ok, EQ); | 1552 __ b(&ok, EQ); |
1559 __ Stop("Incorrect IC data for unoptimized static call"); | 1553 __ Stop("Incorrect IC data for unoptimized static call"); |
1560 __ Bind(&ok); | 1554 __ Bind(&ok); |
1561 } | 1555 } |
1562 #endif // DEBUG | 1556 #endif // DEBUG |
1563 | 1557 |
1564 if (FLAG_enable_debugger) { | 1558 // Check single stepping. |
1565 // Check single stepping. | 1559 Label not_stepping; |
1566 Label not_stepping; | 1560 __ LoadFieldFromOffset(R6, CTX, Context::isolate_offset(), kNoPP); |
1567 __ LoadFieldFromOffset(R6, CTX, Context::isolate_offset(), kNoPP); | 1561 __ LoadFromOffset( |
1568 __ LoadFromOffset( | 1562 R6, R6, Isolate::single_step_offset(), kNoPP, kUnsignedByte); |
1569 R6, R6, Isolate::single_step_offset(), kNoPP, kUnsignedByte); | 1563 __ CompareImmediate(R6, 0, kNoPP); |
1570 __ CompareImmediate(R6, 0, kNoPP); | 1564 __ b(¬_stepping, EQ); |
1571 __ b(¬_stepping, EQ); | 1565 __ EnterStubFrame(); |
1572 __ EnterStubFrame(); | 1566 __ Push(R5); // Preserve IC data. |
1573 __ Push(R5); // Preserve IC data. | 1567 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1574 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1568 __ Pop(R5); |
1575 __ Pop(R5); | 1569 __ LeaveStubFrame(); |
1576 __ LeaveStubFrame(); | 1570 __ Bind(¬_stepping); |
1577 __ Bind(¬_stepping); | |
1578 } | |
1579 | 1571 |
1580 // R5: IC data object (preserved). | 1572 // R5: IC data object (preserved). |
1581 __ LoadFieldFromOffset(R6, R5, ICData::ic_data_offset(), kNoPP); | 1573 __ LoadFieldFromOffset(R6, R5, ICData::ic_data_offset(), kNoPP); |
1582 // R6: ic_data_array with entries: target functions and count. | 1574 // R6: ic_data_array with entries: target functions and count. |
1583 __ AddImmediate(R6, R6, Array::data_offset() - kHeapObjectTag, kNoPP); | 1575 __ AddImmediate(R6, R6, Array::data_offset() - kHeapObjectTag, kNoPP); |
1584 // R6: points directly to the first ic data array element. | 1576 // R6: points directly to the first ic data array element. |
1585 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize; | 1577 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize; |
1586 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize; | 1578 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize; |
1587 | 1579 |
1588 // Increment count for this call. | 1580 // Increment count for this call. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 __ PushObject(Object::null_object(), PP); // Space for result. | 1667 __ PushObject(Object::null_object(), PP); // Space for result. |
1676 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); | 1668 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); |
1677 __ Pop(R0); | 1669 __ Pop(R0); |
1678 __ LeaveStubFrame(); | 1670 __ LeaveStubFrame(); |
1679 __ br(R0); | 1671 __ br(R0); |
1680 } | 1672 } |
1681 | 1673 |
1682 // Called only from unoptimized code. All relevant registers have been saved. | 1674 // Called only from unoptimized code. All relevant registers have been saved. |
1683 void StubCode::GenerateDebugStepCheckStub( | 1675 void StubCode::GenerateDebugStepCheckStub( |
1684 Assembler* assembler) { | 1676 Assembler* assembler) { |
1685 if (FLAG_enable_debugger) { | 1677 // Check single stepping. |
1686 // Check single stepping. | 1678 Label not_stepping; |
1687 Label not_stepping; | 1679 __ LoadFieldFromOffset(R1, CTX, Context::isolate_offset(), kNoPP); |
1688 __ LoadFieldFromOffset(R1, CTX, Context::isolate_offset(), kNoPP); | 1680 __ LoadFromOffset( |
1689 __ LoadFromOffset( | 1681 R1, R1, Isolate::single_step_offset(), kNoPP, kUnsignedByte); |
1690 R1, R1, Isolate::single_step_offset(), kNoPP, kUnsignedByte); | 1682 __ CompareImmediate(R1, 0, kNoPP); |
1691 __ CompareImmediate(R1, 0, kNoPP); | 1683 __ b(¬_stepping, EQ); |
1692 __ b(¬_stepping, EQ); | 1684 __ EnterStubFrame(); |
1693 __ EnterStubFrame(); | 1685 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1694 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1686 __ LeaveStubFrame(); |
1695 __ LeaveStubFrame(); | 1687 __ Bind(¬_stepping); |
1696 __ Bind(¬_stepping); | 1688 |
1697 } | |
1698 __ ret(); | 1689 __ ret(); |
1699 } | 1690 } |
1700 | 1691 |
1701 | 1692 |
1702 // Used to check class and type arguments. Arguments passed in registers: | 1693 // Used to check class and type arguments. Arguments passed in registers: |
1703 // LR: return address. | 1694 // LR: return address. |
1704 // R0: instance (must be preserved). | 1695 // R0: instance (must be preserved). |
1705 // R1: instantiator type arguments or NULL. | 1696 // R1: instantiator type arguments or NULL. |
1706 // R2: cache array. | 1697 // R2: cache array. |
1707 // Result in R1: null -> not found, otherwise result (true or false). | 1698 // Result in R1: null -> not found, otherwise result (true or false). |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1925 } | 1916 } |
1926 | 1917 |
1927 | 1918 |
1928 // Called only from unoptimized code. All relevant registers have been saved. | 1919 // Called only from unoptimized code. All relevant registers have been saved. |
1929 // LR: return address. | 1920 // LR: return address. |
1930 // SP + 4: left operand. | 1921 // SP + 4: left operand. |
1931 // SP + 0: right operand. | 1922 // SP + 0: right operand. |
1932 // Return Zero condition flag set if equal. | 1923 // Return Zero condition flag set if equal. |
1933 void StubCode::GenerateUnoptimizedIdenticalWithNumberCheckStub( | 1924 void StubCode::GenerateUnoptimizedIdenticalWithNumberCheckStub( |
1934 Assembler* assembler) { | 1925 Assembler* assembler) { |
1935 if (FLAG_enable_debugger) { | |
1936 // Check single stepping. | 1926 // Check single stepping. |
1937 Label not_stepping; | 1927 Label not_stepping; |
1938 __ LoadFieldFromOffset(R1, CTX, Context::isolate_offset(), kNoPP); | 1928 __ LoadFieldFromOffset(R1, CTX, Context::isolate_offset(), kNoPP); |
1939 __ LoadFromOffset( | 1929 __ LoadFromOffset( |
1940 R1, R1, Isolate::single_step_offset(), kNoPP, kUnsignedByte); | 1930 R1, R1, Isolate::single_step_offset(), kNoPP, kUnsignedByte); |
1941 __ CompareImmediate(R1, 0, kNoPP); | 1931 __ CompareImmediate(R1, 0, kNoPP); |
1942 __ b(¬_stepping, EQ); | 1932 __ b(¬_stepping, EQ); |
1943 __ EnterStubFrame(); | 1933 __ EnterStubFrame(); |
1944 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1934 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1945 __ LeaveStubFrame(); | 1935 __ LeaveStubFrame(); |
1946 __ Bind(¬_stepping); | 1936 __ Bind(¬_stepping); |
1947 } | |
1948 | 1937 |
1949 const Register left = R1; | 1938 const Register left = R1; |
1950 const Register right = R0; | 1939 const Register right = R0; |
1951 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); | 1940 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); |
1952 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); | 1941 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); |
1953 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 1942 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
1954 __ ret(); | 1943 __ ret(); |
1955 } | 1944 } |
1956 | 1945 |
1957 | 1946 |
1958 // Called from optimized code only. | 1947 // Called from optimized code only. |
1959 // LR: return address. | 1948 // LR: return address. |
1960 // SP + 4: left operand. | 1949 // SP + 4: left operand. |
1961 // SP + 0: right operand. | 1950 // SP + 0: right operand. |
1962 // Return Zero condition flag set if equal. | 1951 // Return Zero condition flag set if equal. |
1963 void StubCode::GenerateOptimizedIdenticalWithNumberCheckStub( | 1952 void StubCode::GenerateOptimizedIdenticalWithNumberCheckStub( |
1964 Assembler* assembler) { | 1953 Assembler* assembler) { |
1965 const Register temp = R2; | 1954 const Register temp = R2; |
1966 const Register left = R1; | 1955 const Register left = R1; |
1967 const Register right = R0; | 1956 const Register right = R0; |
1968 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); | 1957 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); |
1969 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); | 1958 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); |
1970 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 1959 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
1971 __ ret(); | 1960 __ ret(); |
1972 } | 1961 } |
1973 | 1962 |
1974 } // namespace dart | 1963 } // namespace dart |
1975 | 1964 |
1976 #endif // defined TARGET_ARCH_ARM64 | 1965 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |