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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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 __ movl(CTX, Address(EBP, closure_parameter->index() * kWordSize)); |
| 1082 __ movl(CTX, FieldAddress(CTX, Closure::context_offset())); |
| 1083 #ifdef dEBUG |
| 1084 Label ok; |
| 1085 __ LoadClassId(EBX, CTX); |
| 1086 __ cmpl(EBX, Immediate(kContextCid)); |
| 1087 __ j(EQUAL, &ok, Assembler::kNearJump); |
| 1088 __ Stop("Incorrect context at entry"); |
| 1089 __ Bind(&ok); |
| 1090 #endif |
| 1091 } |
| 1092 |
1077 // In unoptimized code, initialize (non-argument) stack allocated slots to | 1093 // In unoptimized code, initialize (non-argument) stack allocated slots to |
1078 // null. | 1094 // null. |
1079 if (!is_optimizing() && (num_locals > 0)) { | 1095 if (!is_optimizing()) { |
| 1096 ASSERT(num_locals > 0); // There is always at least context_var. |
1080 __ Comment("Initialize spill slots"); | 1097 __ Comment("Initialize spill slots"); |
1081 const intptr_t slot_base = parsed_function().first_stack_local_index(); | 1098 const intptr_t slot_base = parsed_function().first_stack_local_index(); |
1082 const Immediate& raw_null = | 1099 const intptr_t context_index = |
1083 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1100 parsed_function().current_context_var()->index(); |
1084 __ movl(EAX, raw_null); | 1101 if (num_locals > 1) { |
| 1102 const Immediate& raw_null = |
| 1103 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1104 __ movl(EAX, raw_null); |
| 1105 } |
1085 for (intptr_t i = 0; i < num_locals; ++i) { | 1106 for (intptr_t i = 0; i < num_locals; ++i) { |
1086 // Subtract index i (locals lie at lower addresses than EBP). | 1107 // Subtract index i (locals lie at lower addresses than EBP). |
1087 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); | 1108 if (((slot_base - i) == context_index)) { |
| 1109 if (function.IsClosureFunction()) { |
| 1110 __ movl(Address(EBP, (slot_base - i) * kWordSize), CTX); |
| 1111 } else { |
| 1112 const Immediate& raw_empty_context = |
| 1113 Immediate(reinterpret_cast<intptr_t>( |
| 1114 isolate()->object_store()->empty_context())); |
| 1115 __ movl(Address(EBP, (slot_base - i) * kWordSize), raw_empty_context); |
| 1116 } |
| 1117 } else { |
| 1118 ASSERT(num_locals > 1); |
| 1119 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); |
| 1120 } |
1088 } | 1121 } |
1089 } | 1122 } |
1090 | 1123 |
1091 ASSERT(!block_order().is_empty()); | 1124 ASSERT(!block_order().is_empty()); |
1092 VisitBlocks(); | 1125 VisitBlocks(); |
1093 | 1126 |
1094 __ int3(); | 1127 __ int3(); |
1095 GenerateDeferredCode(); | 1128 GenerateDeferredCode(); |
1096 // Emit function patching code. This will be swapped with the first 5 bytes | 1129 // Emit function patching code. This will be swapped with the first 5 bytes |
1097 // at entry point. | 1130 // at entry point. |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 __ movups(reg, Address(ESP, 0)); | 1801 __ movups(reg, Address(ESP, 0)); |
1769 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1802 __ addl(ESP, Immediate(kFpuRegisterSize)); |
1770 } | 1803 } |
1771 | 1804 |
1772 | 1805 |
1773 #undef __ | 1806 #undef __ |
1774 | 1807 |
1775 } // namespace dart | 1808 } // namespace dart |
1776 | 1809 |
1777 #endif // defined TARGET_ARCH_IA32 | 1810 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |