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 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 // The noSuchMethod call may return to the caller, but not here. | 1072 // The noSuchMethod call may return to the caller, but not here. |
1073 } else { | 1073 } else { |
1074 __ Stop("Wrong number of arguments"); | 1074 __ Stop("Wrong number of arguments"); |
1075 } | 1075 } |
1076 __ Bind(&correct_num_arguments); | 1076 __ Bind(&correct_num_arguments); |
1077 } | 1077 } |
1078 } else if (!flow_graph().IsCompiledForOsr()) { | 1078 } else if (!flow_graph().IsCompiledForOsr()) { |
1079 CopyParameters(); | 1079 CopyParameters(); |
1080 } | 1080 } |
1081 | 1081 |
| 1082 if (function.IsClosureFunction() && !flow_graph().IsCompiledForOsr()) { |
| 1083 // Load context from the closure object (first argument). |
| 1084 LocalScope* scope = parsed_function().node_sequence()->scope(); |
| 1085 LocalVariable* closure_parameter = scope->VariableAt(0); |
| 1086 __ ldr(CTX, Address(FP, closure_parameter->index() * kWordSize)); |
| 1087 __ ldr(CTX, FieldAddress(CTX, Closure::context_offset())); |
| 1088 } |
| 1089 |
1082 // In unoptimized code, initialize (non-argument) stack allocated slots to | 1090 // In unoptimized code, initialize (non-argument) stack allocated slots to |
1083 // null. | 1091 // null. |
1084 if (!is_optimizing() && (num_locals > 0)) { | 1092 if (!is_optimizing()) { |
| 1093 ASSERT(num_locals > 0); // There is always at least context_var. |
1085 __ Comment("Initialize spill slots"); | 1094 __ Comment("Initialize spill slots"); |
1086 const intptr_t slot_base = parsed_function().first_stack_local_index(); | 1095 const intptr_t slot_base = parsed_function().first_stack_local_index(); |
1087 __ LoadObject(R0, Object::null_object(), PP); | 1096 const intptr_t context_index = |
| 1097 parsed_function().current_context_var()->index(); |
| 1098 if (num_locals > 1) { |
| 1099 __ LoadObject(R0, Object::null_object(), PP); |
| 1100 } |
1088 for (intptr_t i = 0; i < num_locals; ++i) { | 1101 for (intptr_t i = 0; i < num_locals; ++i) { |
1089 // Subtract index i (locals lie at lower addresses than FP). | 1102 // Subtract index i (locals lie at lower addresses than FP). |
1090 __ StoreToOffset(R0, FP, (slot_base - i) * kWordSize, PP); | 1103 if (((slot_base - i) == context_index)) { |
| 1104 if (function.IsClosureFunction()) { |
| 1105 __ StoreToOffset(CTX, FP, (slot_base - i) * kWordSize, PP); |
| 1106 } else { |
| 1107 const Context& empty_context = Context::ZoneHandle( |
| 1108 isolate(), isolate()->object_store()->empty_context()); |
| 1109 __ LoadObject(R1, empty_context, PP); |
| 1110 __ StoreToOffset(R1, FP, (slot_base - i) * kWordSize, PP); |
| 1111 } |
| 1112 } else { |
| 1113 ASSERT(num_locals > 1); |
| 1114 __ StoreToOffset(R0, FP, (slot_base - i) * kWordSize, PP); |
| 1115 } |
1091 } | 1116 } |
1092 } | 1117 } |
1093 | 1118 |
1094 VisitBlocks(); | 1119 VisitBlocks(); |
1095 | 1120 |
1096 __ brk(0); | 1121 __ brk(0); |
1097 GenerateDeferredCode(); | 1122 GenerateDeferredCode(); |
1098 | 1123 |
1099 // Emit function patching code. This will be swapped with the first 3 | 1124 // Emit function patching code. This will be swapped with the first 3 |
1100 // instructions at entry point. | 1125 // instructions at entry point. |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1792 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
1768 __ PopDouble(reg); | 1793 __ PopDouble(reg); |
1769 } | 1794 } |
1770 | 1795 |
1771 | 1796 |
1772 #undef __ | 1797 #undef __ |
1773 | 1798 |
1774 } // namespace dart | 1799 } // namespace dart |
1775 | 1800 |
1776 #endif // defined TARGET_ARCH_ARM64 | 1801 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |