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" // Needed here to get TARGET_ARCH_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
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 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 // The noSuchMethod call may return to the caller, but not here. | 1067 // The noSuchMethod call may return to the caller, but not here. |
1068 } else { | 1068 } else { |
1069 __ Stop("Wrong number of arguments"); | 1069 __ Stop("Wrong number of arguments"); |
1070 } | 1070 } |
1071 __ Bind(&correct_num_arguments); | 1071 __ Bind(&correct_num_arguments); |
1072 } | 1072 } |
1073 } else if (!flow_graph().IsCompiledForOsr()) { | 1073 } else if (!flow_graph().IsCompiledForOsr()) { |
1074 CopyParameters(); | 1074 CopyParameters(); |
1075 } | 1075 } |
1076 | 1076 |
| 1077 if (function.IsClosureFunction() && !flow_graph().IsCompiledForOsr()) { |
| 1078 // Load context from the closure object (first argument). |
| 1079 LocalScope* scope = parsed_function().node_sequence()->scope(); |
| 1080 LocalVariable* closure_parameter = scope->VariableAt(0); |
| 1081 __ ldr(CTX, Address(FP, closure_parameter->index() * kWordSize)); |
| 1082 __ ldr(CTX, FieldAddress(CTX, Closure::context_offset())); |
| 1083 } |
| 1084 |
1077 // In unoptimized code, initialize (non-argument) stack allocated slots to | 1085 // In unoptimized code, initialize (non-argument) stack allocated slots to |
1078 // null. | 1086 // null. |
1079 if (!is_optimizing() && (num_locals > 0)) { | 1087 if (!is_optimizing()) { |
| 1088 ASSERT(num_locals > 0); // There is always at least context_var. |
1080 __ Comment("Initialize spill slots"); | 1089 __ Comment("Initialize spill slots"); |
1081 const intptr_t slot_base = parsed_function().first_stack_local_index(); | 1090 const intptr_t slot_base = parsed_function().first_stack_local_index(); |
1082 __ LoadImmediate(R0, reinterpret_cast<intptr_t>(Object::null())); | 1091 const intptr_t context_index = |
| 1092 parsed_function().current_context_var()->index(); |
| 1093 if (num_locals > 1) { |
| 1094 __ LoadImmediate(R0, reinterpret_cast<intptr_t>(Object::null())); |
| 1095 } |
1083 for (intptr_t i = 0; i < num_locals; ++i) { | 1096 for (intptr_t i = 0; i < num_locals; ++i) { |
1084 // Subtract index i (locals lie at lower addresses than FP). | 1097 // Subtract index i (locals lie at lower addresses than FP). |
1085 __ StoreToOffset(kWord, R0, FP, (slot_base - i) * kWordSize); | 1098 if (((slot_base - i) == context_index)) { |
| 1099 if (function.IsClosureFunction()) { |
| 1100 __ StoreToOffset(kWord, CTX, FP, (slot_base - i) * kWordSize); |
| 1101 } else { |
| 1102 const Context& empty_context = Context::ZoneHandle( |
| 1103 isolate(), isolate()->object_store()->empty_context()); |
| 1104 __ LoadObject(R1, empty_context); |
| 1105 __ StoreToOffset(kWord, R1, FP, (slot_base - i) * kWordSize); |
| 1106 } |
| 1107 } else { |
| 1108 ASSERT(num_locals > 1); |
| 1109 __ StoreToOffset(kWord, R0, FP, (slot_base - i) * kWordSize); |
| 1110 } |
1086 } | 1111 } |
1087 } | 1112 } |
1088 | 1113 |
1089 VisitBlocks(); | 1114 VisitBlocks(); |
1090 | 1115 |
1091 __ bkpt(0); | 1116 __ bkpt(0); |
1092 GenerateDeferredCode(); | 1117 GenerateDeferredCode(); |
1093 // Emit function patching code. This will be swapped with the first 3 | 1118 // Emit function patching code. This will be swapped with the first 3 |
1094 // instructions at entry point. | 1119 // instructions at entry point. |
1095 patch_code_pc_offset_ = assembler()->CodeSize(); | 1120 patch_code_pc_offset_ = assembler()->CodeSize(); |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 DRegister dreg = EvenDRegisterOf(reg); | 1831 DRegister dreg = EvenDRegisterOf(reg); |
1807 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); | 1832 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); |
1808 } | 1833 } |
1809 | 1834 |
1810 | 1835 |
1811 #undef __ | 1836 #undef __ |
1812 | 1837 |
1813 } // namespace dart | 1838 } // namespace dart |
1814 | 1839 |
1815 #endif // defined TARGET_ARCH_ARM | 1840 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |