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" // Needed here to get TARGET_ARCH_ARM64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
9 | 9 |
10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 const Register function_reg = R6; | 963 const Register function_reg = R6; |
964 new_pp = R13; | 964 new_pp = R13; |
965 | 965 |
966 // Set up pool pointer in new_pp. | 966 // Set up pool pointer in new_pp. |
967 __ LoadPoolPointer(new_pp); | 967 __ LoadPoolPointer(new_pp); |
968 | 968 |
969 // Load function object using the callee's pool pointer. | 969 // Load function object using the callee's pool pointer. |
970 __ LoadObject(function_reg, function, new_pp); | 970 __ LoadObject(function_reg, function, new_pp); |
971 | 971 |
972 // Patch point is after the eventually inlined function object. | 972 // Patch point is after the eventually inlined function object. |
973 AddCurrentDescriptor(PcDescriptors::kEntryPatch, | 973 entry_patch_pc_offset_ = assembler()->CodeSize(); |
974 Isolate::kNoDeoptId, | 974 |
975 0); // No token position. | |
976 intptr_t threshold = FLAG_optimization_counter_threshold; | 975 intptr_t threshold = FLAG_optimization_counter_threshold; |
977 __ LoadFieldFromOffset( | 976 __ LoadFieldFromOffset( |
978 R7, function_reg, Function::usage_counter_offset(), new_pp); | 977 R7, function_reg, Function::usage_counter_offset(), new_pp); |
979 if (is_optimizing()) { | 978 if (is_optimizing()) { |
980 // Reoptimization of an optimized function is triggered by counting in | 979 // Reoptimization of an optimized function is triggered by counting in |
981 // IC stubs, but not at the entry of the function. | 980 // IC stubs, but not at the entry of the function. |
982 threshold = FLAG_reoptimization_counter_threshold; | 981 threshold = FLAG_reoptimization_counter_threshold; |
983 } else { | 982 } else { |
984 __ add(R7, R7, Operand(1)); | 983 __ add(R7, R7, Operand(1)); |
985 __ StoreFieldToOffset( | 984 __ StoreFieldToOffset( |
986 R7, function_reg, Function::usage_counter_offset(), new_pp); | 985 R7, function_reg, Function::usage_counter_offset(), new_pp); |
987 } | 986 } |
988 __ CompareImmediate(R7, threshold, new_pp); | 987 __ CompareImmediate(R7, threshold, new_pp); |
989 ASSERT(function_reg == R6); | 988 ASSERT(function_reg == R6); |
990 Label dont_optimize; | 989 Label dont_optimize; |
991 __ b(&dont_optimize, LT); | 990 __ b(&dont_optimize, LT); |
992 __ Branch(&StubCode::OptimizeFunctionLabel(), new_pp); | 991 __ Branch(&StubCode::OptimizeFunctionLabel(), new_pp); |
993 __ Bind(&dont_optimize); | 992 __ Bind(&dont_optimize); |
994 } else if (!flow_graph().IsCompiledForOsr()) { | 993 } else if (!flow_graph().IsCompiledForOsr()) { |
995 // We have to load the PP here too because a load of an external label | 994 // We have to load the PP here too because a load of an external label |
996 // may be patched at the AddCurrentDescriptor below. | 995 // may be patched at the AddCurrentDescriptor below. |
997 new_pp = R13; | 996 new_pp = R13; |
998 | 997 |
999 // Set up pool pointer in new_pp. | 998 // Set up pool pointer in new_pp. |
1000 __ LoadPoolPointer(new_pp); | 999 __ LoadPoolPointer(new_pp); |
1001 | 1000 |
1002 AddCurrentDescriptor(PcDescriptors::kEntryPatch, | 1001 entry_patch_pc_offset_ = assembler()->CodeSize(); |
1003 Isolate::kNoDeoptId, | |
1004 0); // No token position. | |
1005 } | 1002 } |
1006 __ Comment("Enter frame"); | 1003 __ Comment("Enter frame"); |
1007 if (flow_graph().IsCompiledForOsr()) { | 1004 if (flow_graph().IsCompiledForOsr()) { |
1008 intptr_t extra_slots = StackSize() | 1005 intptr_t extra_slots = StackSize() |
1009 - flow_graph().num_stack_locals() | 1006 - flow_graph().num_stack_locals() |
1010 - flow_graph().num_copied_params(); | 1007 - flow_graph().num_copied_params(); |
1011 ASSERT(extra_slots >= 0); | 1008 ASSERT(extra_slots >= 0); |
1012 __ EnterOsrFrame(extra_slots * kWordSize, new_pp); | 1009 __ EnterOsrFrame(extra_slots * kWordSize, new_pp); |
1013 } else { | 1010 } else { |
1014 ASSERT(StackSize() >= 0); | 1011 ASSERT(StackSize() >= 0); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 for (intptr_t i = 0; i < num_locals; ++i) { | 1092 for (intptr_t i = 0; i < num_locals; ++i) { |
1096 // Subtract index i (locals lie at lower addresses than FP). | 1093 // Subtract index i (locals lie at lower addresses than FP). |
1097 __ StoreToOffset(R0, FP, (slot_base - i) * kWordSize, PP); | 1094 __ StoreToOffset(R0, FP, (slot_base - i) * kWordSize, PP); |
1098 } | 1095 } |
1099 } | 1096 } |
1100 | 1097 |
1101 VisitBlocks(); | 1098 VisitBlocks(); |
1102 | 1099 |
1103 __ hlt(0); | 1100 __ hlt(0); |
1104 GenerateDeferredCode(); | 1101 GenerateDeferredCode(); |
| 1102 |
1105 // Emit function patching code. This will be swapped with the first 3 | 1103 // Emit function patching code. This will be swapped with the first 3 |
1106 // instructions at entry point. | 1104 // instructions at entry point. |
1107 AddCurrentDescriptor(PcDescriptors::kPatchCode, | 1105 patch_code_pc_offset_ = assembler()->CodeSize(); |
1108 Isolate::kNoDeoptId, | |
1109 0); // No token position. | |
1110 __ BranchPatchable(&StubCode::FixCallersTargetLabel()); | 1106 __ BranchPatchable(&StubCode::FixCallersTargetLabel()); |
1111 | 1107 |
1112 AddCurrentDescriptor(PcDescriptors::kLazyDeoptJump, | 1108 if (is_optimizing()) { |
1113 Isolate::kNoDeoptId, | 1109 lazy_deopt_pc_offset_ = assembler()->CodeSize(); |
1114 0); // No token position. | |
1115 __ BranchPatchable(&StubCode::DeoptimizeLazyLabel()); | 1110 __ BranchPatchable(&StubCode::DeoptimizeLazyLabel()); |
| 1111 } |
1116 } | 1112 } |
1117 | 1113 |
1118 | 1114 |
1119 void FlowGraphCompiler::GenerateCall(intptr_t token_pos, | 1115 void FlowGraphCompiler::GenerateCall(intptr_t token_pos, |
1120 const ExternalLabel* label, | 1116 const ExternalLabel* label, |
1121 PcDescriptors::Kind kind, | 1117 PcDescriptors::Kind kind, |
1122 LocationSummary* locs) { | 1118 LocationSummary* locs) { |
1123 __ BranchLinkPatchable(label); | 1119 __ BranchLinkPatchable(label); |
1124 AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); | 1120 AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); |
1125 RecordSafepoint(locs); | 1121 RecordSafepoint(locs); |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1734 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
1739 UNIMPLEMENTED(); | 1735 UNIMPLEMENTED(); |
1740 } | 1736 } |
1741 | 1737 |
1742 | 1738 |
1743 #undef __ | 1739 #undef __ |
1744 | 1740 |
1745 } // namespace dart | 1741 } // namespace dart |
1746 | 1742 |
1747 #endif // defined TARGET_ARCH_ARM64 | 1743 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |