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

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

Issue 10805053: Add spill slot locations. (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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 __ SmiUntag(temp); 1105 __ SmiUntag(temp);
1106 __ cvtsi2sd(result, temp); 1106 __ cvtsi2sd(result, temp);
1107 __ Bind(&done); 1107 __ Bind(&done);
1108 } 1108 }
1109 1109
1110 1110
1111 #undef __ 1111 #undef __
1112 #define __ compiler_->assembler()-> 1112 #define __ compiler_->assembler()->
1113 1113
1114 1114
1115 static Address ToAddress(Location loc) {
1116 ASSERT(loc.IsSpillSlot());
1117 const intptr_t offset =
1118 (ParsedFunction::kFirstLocalSlotIndex - loc.spill_index()) * kWordSize;
1119 return Address(RBP, offset);
1120 }
1121
1122
1115 void ParallelMoveResolver::EmitMove(int index) { 1123 void ParallelMoveResolver::EmitMove(int index) {
1116 MoveOperands* move = moves_[index]; 1124 MoveOperands* move = moves_[index];
1117 const Location source = move->src(); 1125 const Location source = move->src();
1118 const Location destination = move->dest(); 1126 const Location destination = move->dest();
1119 1127
1120 ASSERT(destination.IsRegister());
1121 if (source.IsRegister()) { 1128 if (source.IsRegister()) {
1122 __ movq(destination.reg(), source.reg()); 1129 if (destination.IsRegister()) {
1130 __ movq(destination.reg(), source.reg());
1131 } else {
1132 ASSERT(destination.IsSpillSlot());
1133 __ movq(ToAddress(destination), source.reg());
1134 }
1135 } else if (source.IsSpillSlot()) {
1136 if (destination.IsRegister()) {
1137 __ movq(destination.reg(), ToAddress(source));
1138 } else {
1139 ASSERT(destination.IsSpillSlot());
1140 __ MoveMemory(ToAddress(destination), ToAddress(source));
1141 }
1123 } else { 1142 } else {
1124 ASSERT(source.IsConstant()); 1143 ASSERT(source.IsConstant());
1125 __ LoadObject(destination.reg(), source.constant()); 1144 if (destination.IsRegister()) {
1145 __ LoadObject(destination.reg(), source.constant());
1146 } else {
1147 ASSERT(destination.IsSpillSlot());
1148 __ StoreObject(ToAddress(destination), source.constant());
1149 }
1126 } 1150 }
1151
1127 move->Eliminate(); 1152 move->Eliminate();
1128 } 1153 }
1129 1154
1130 1155
1131 void ParallelMoveResolver::EmitSwap(int index) { 1156 void ParallelMoveResolver::EmitSwap(int index) {
1132 MoveOperands* move = moves_[index]; 1157 MoveOperands* move = moves_[index];
1133 const Location source = move->src(); 1158 const Location source = move->src();
1134 const Location destination = move->dest(); 1159 const Location destination = move->dest();
1135 1160
1136 ASSERT(source.IsRegister() && destination.IsRegister()); 1161 if (source.IsRegister() && destination.IsRegister()) {
1137 __ xchgq(destination.reg(), source.reg()); 1162 __ xchgq(destination.reg(), source.reg());
1163 } else if (source.IsRegister() && destination.IsSpillSlot()) {
1164 __ Exchange(source.reg(), ToAddress(destination));
1165 } else if (source.IsSpillSlot() && destination.IsRegister()) {
1166 __ Exchange(destination.reg(), ToAddress(source));
1167 } else if (source.IsSpillSlot() && destination.IsSpillSlot()) {
1168 __ Exchange(ToAddress(destination), ToAddress(source));
1169 } else {
1170 UNREACHABLE();
1171 }
1138 1172
1139 // The swap of source and destination has executed a move from source to 1173 // The swap of source and destination has executed a move from source to
1140 // destination. 1174 // destination.
1141 move->Eliminate(); 1175 move->Eliminate();
1142 1176
1143 // Any unperformed (including pending) move with a source of either 1177 // Any unperformed (including pending) move with a source of either
1144 // this move's source or destination needs to have their source 1178 // this move's source or destination needs to have their source
1145 // changed to reflect the state of affairs after the swap. 1179 // changed to reflect the state of affairs after the swap.
1146 for (int i = 0; i < moves_.length(); ++i) { 1180 for (int i = 0; i < moves_.length(); ++i) {
1147 const MoveOperands& other_move = *moves_[i]; 1181 const MoveOperands& other_move = *moves_[i];
1148 if (other_move.Blocks(source)) { 1182 if (other_move.Blocks(source)) {
1149 moves_[i]->set_src(destination); 1183 moves_[i]->set_src(destination);
1150 } else if (other_move.Blocks(destination)) { 1184 } else if (other_move.Blocks(destination)) {
1151 moves_[i]->set_src(source); 1185 moves_[i]->set_src(source);
1152 } 1186 }
1153 } 1187 }
1154 } 1188 }
1155 1189
1156 1190
1157 #undef __ 1191 #undef __
1158 1192
1159 } // namespace dart 1193 } // namespace dart
1160 1194
1161 #endif // defined TARGET_ARCH_X64 1195 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698