Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.cc

Issue 10828018: Add support for fixed parameters in the register allocator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "lib/error.h" 10 #include "lib/error.h"
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 CatchClauseNode::kInvalidTryIndex, 951 CatchClauseNode::kInvalidTryIndex,
952 kClosureArgumentMismatchRuntimeEntry); 952 kClosureArgumentMismatchRuntimeEntry);
953 } else { 953 } else {
954 __ Stop("Wrong number of arguments"); 954 __ Stop("Wrong number of arguments");
955 } 955 }
956 __ Bind(&argc_in_range); 956 __ Bind(&argc_in_range);
957 } 957 }
958 } else { 958 } else {
959 CopyParameters(); 959 CopyParameters();
960 } 960 }
961
962 // TODO(vegorov): introduce stack maps and stop initializing all spill slots
963 // with null.
964 const int stack_slot_count =
srdjan 2012/07/26 00:33:56 s/int/intptr_t/
Vyacheslav Egorov (Google) 2012/07/26 11:33:53 Done.
965 is_ssa_ ? block_order_[0]->AsGraphEntry()->spill_slot_count()
966 : local_count;
967
968 const int slot_base =
srdjan 2012/07/26 00:33:56 ditto
Vyacheslav Egorov (Google) 2012/07/26 11:33:53 Done.
969 is_ssa_ ? -2 : parsed_function().first_stack_local_index();
srdjan 2012/07/26 00:33:56 Why is this needed? parsed_function().first_stack_
Vyacheslav Egorov (Google) 2012/07/26 11:33:53 Removed.
970
961 // Initialize (non-argument) stack allocated locals to null. 971 // Initialize (non-argument) stack allocated locals to null.
962 if (local_count > 0) { 972 if (stack_slot_count > 0) {
963 const Immediate raw_null = 973 const Immediate raw_null =
964 Immediate(reinterpret_cast<intptr_t>(Object::null())); 974 Immediate(reinterpret_cast<intptr_t>(Object::null()));
965 __ movl(EAX, raw_null); 975 __ movl(EAX, raw_null);
966 const int base = parsed_function().first_stack_local_index(); 976 for (int i = 0; i < stack_slot_count; ++i) {
967 for (int i = 0; i < local_count; ++i) {
968 // Subtract index i (locals lie at lower addresses than EBP). 977 // Subtract index i (locals lie at lower addresses than EBP).
969 __ movl(Address(EBP, (base - i) * kWordSize), EAX); 978 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX);
970 } 979 }
971 } 980 }
972 981
973 if (!IsLeaf()) { 982 if (!IsLeaf()) {
974 // Generate stack overflow check. 983 // Generate stack overflow check.
975 __ cmpl(ESP, 984 __ cmpl(ESP,
976 Address::Absolute(Isolate::Current()->stack_limit_address())); 985 Address::Absolute(Isolate::Current()->stack_limit_address()));
977 Label no_stack_overflow; 986 Label no_stack_overflow;
978 __ j(ABOVE, &no_stack_overflow, Assembler::kNearJump); 987 __ j(ABOVE, &no_stack_overflow, Assembler::kNearJump);
979 GenerateCallRuntime(AstNode::kNoId, 988 GenerateCallRuntime(AstNode::kNoId,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 __ SmiUntag(temp); 1112 __ SmiUntag(temp);
1104 __ cvtsi2sd(result, temp); 1113 __ cvtsi2sd(result, temp);
1105 __ Bind(&done); 1114 __ Bind(&done);
1106 } 1115 }
1107 1116
1108 1117
1109 #undef __ 1118 #undef __
1110 #define __ compiler_->assembler()-> 1119 #define __ compiler_->assembler()->
1111 1120
1112 1121
1113 static Address ToSpillAddress(Location loc) { 1122 static Address ToStackSlotAddress(Location loc) {
1114 ASSERT(loc.IsSpillSlot()); 1123 ASSERT(loc.IsStackSlot());
1115 const intptr_t offset = 1124 const intptr_t index = loc.stack_index();
1116 (ParsedFunction::kFirstLocalSlotIndex - loc.spill_index()) * kWordSize; 1125 if (index < 0) {
1117 return Address(EBP, offset); 1126 const intptr_t offset = (1 - index) * kWordSize;
1127 return Address(EBP, offset);
1128 } else {
1129 const intptr_t offset =
1130 (ParsedFunction::kFirstLocalSlotIndex - index) * kWordSize;
1131 return Address(EBP, offset);
1132 }
1118 } 1133 }
1119 1134
1120 1135
1121 void ParallelMoveResolver::EmitMove(int index) { 1136 void ParallelMoveResolver::EmitMove(int index) {
1122 MoveOperands* move = moves_[index]; 1137 MoveOperands* move = moves_[index];
1123 const Location source = move->src(); 1138 const Location source = move->src();
1124 const Location destination = move->dest(); 1139 const Location destination = move->dest();
1125 1140
1126 if (source.IsRegister()) { 1141 if (source.IsRegister()) {
1127 if (destination.IsRegister()) { 1142 if (destination.IsRegister()) {
1128 __ movl(destination.reg(), source.reg()); 1143 __ movl(destination.reg(), source.reg());
1129 } else { 1144 } else {
1130 ASSERT(destination.IsSpillSlot()); 1145 ASSERT(destination.IsStackSlot());
1131 __ movl(ToSpillAddress(destination), source.reg()); 1146 __ movl(ToStackSlotAddress(destination), source.reg());
1132 } 1147 }
1133 } else if (source.IsSpillSlot()) { 1148 } else if (source.IsStackSlot()) {
1134 if (destination.IsRegister()) { 1149 if (destination.IsRegister()) {
1135 __ movl(destination.reg(), ToSpillAddress(source)); 1150 __ movl(destination.reg(), ToStackSlotAddress(source));
1136 } else { 1151 } else {
1137 ASSERT(destination.IsSpillSlot()); 1152 ASSERT(destination.IsStackSlot());
1138 MoveMemoryToMemory(ToSpillAddress(destination), ToSpillAddress(source)); 1153 MoveMemoryToMemory(ToStackSlotAddress(destination),
1154 ToStackSlotAddress(source));
1139 } 1155 }
1140 } else { 1156 } else {
1141 ASSERT(source.IsConstant()); 1157 ASSERT(source.IsConstant());
1142 if (destination.IsRegister()) { 1158 if (destination.IsRegister()) {
1143 __ LoadObject(destination.reg(), source.constant()); 1159 __ LoadObject(destination.reg(), source.constant());
1144 } else { 1160 } else {
1145 ASSERT(destination.IsSpillSlot()); 1161 ASSERT(destination.IsStackSlot());
1146 StoreObject(ToSpillAddress(destination), source.constant()); 1162 StoreObject(ToStackSlotAddress(destination), source.constant());
1147 } 1163 }
1148 } 1164 }
1149 1165
1150 move->Eliminate(); 1166 move->Eliminate();
1151 } 1167 }
1152 1168
1153 1169
1154 void ParallelMoveResolver::EmitSwap(int index) { 1170 void ParallelMoveResolver::EmitSwap(int index) {
1155 MoveOperands* move = moves_[index]; 1171 MoveOperands* move = moves_[index];
1156 const Location source = move->src(); 1172 const Location source = move->src();
1157 const Location destination = move->dest(); 1173 const Location destination = move->dest();
1158 1174
1159 if (source.IsRegister() && destination.IsRegister()) { 1175 if (source.IsRegister() && destination.IsRegister()) {
1160 __ xchgl(destination.reg(), source.reg()); 1176 __ xchgl(destination.reg(), source.reg());
1161 } else if (source.IsRegister() && destination.IsSpillSlot()) { 1177 } else if (source.IsRegister() && destination.IsStackSlot()) {
1162 Exchange(source.reg(), ToSpillAddress(destination)); 1178 Exchange(source.reg(), ToStackSlotAddress(destination));
1163 } else if (source.IsSpillSlot() && destination.IsRegister()) { 1179 } else if (source.IsStackSlot() && destination.IsRegister()) {
1164 Exchange(destination.reg(), ToSpillAddress(source)); 1180 Exchange(destination.reg(), ToStackSlotAddress(source));
1165 } else if (source.IsSpillSlot() && destination.IsSpillSlot()) { 1181 } else if (source.IsStackSlot() && destination.IsStackSlot()) {
1166 Exchange(ToSpillAddress(destination), ToSpillAddress(source)); 1182 Exchange(ToStackSlotAddress(destination), ToStackSlotAddress(source));
1167 } else { 1183 } else {
1168 UNREACHABLE(); 1184 UNREACHABLE();
1169 } 1185 }
1170 1186
1171 // The swap of source and destination has executed a move from source to 1187 // The swap of source and destination has executed a move from source to
1172 // destination. 1188 // destination.
1173 move->Eliminate(); 1189 move->Eliminate();
1174 1190
1175 // Any unperformed (including pending) move with a source of either 1191 // Any unperformed (including pending) move with a source of either
1176 // this move's source or destination needs to have their source 1192 // this move's source or destination needs to have their source
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 __ popl(ECX); 1243 __ popl(ECX);
1228 __ popl(EAX); 1244 __ popl(EAX);
1229 } 1245 }
1230 1246
1231 1247
1232 #undef __ 1248 #undef __
1233 1249
1234 } // namespace dart 1250 } // namespace dart
1235 1251
1236 #endif // defined TARGET_ARCH_IA32 1252 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698