| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/crankshaft/mips64/lithium-gap-resolver-mips64.h" | 5 #include "src/crankshaft/mips64/lithium-gap-resolver-mips64.h" |
| 6 | 6 |
| 7 #include "src/crankshaft/mips64/lithium-codegen-mips64.h" | 7 #include "src/crankshaft/mips64/lithium-codegen-mips64.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // moves_[root_index]. After performing all moves in the tree rooted | 139 // moves_[root_index]. After performing all moves in the tree rooted |
| 140 // in that move, we save the value to that source. | 140 // in that move, we save the value to that source. |
| 141 DCHECK(moves_[index].destination()->Equals(moves_[root_index_].source())); | 141 DCHECK(moves_[index].destination()->Equals(moves_[root_index_].source())); |
| 142 DCHECK(!in_cycle_); | 142 DCHECK(!in_cycle_); |
| 143 in_cycle_ = true; | 143 in_cycle_ = true; |
| 144 LOperand* source = moves_[index].source(); | 144 LOperand* source = moves_[index].source(); |
| 145 saved_destination_ = moves_[index].destination(); | 145 saved_destination_ = moves_[index].destination(); |
| 146 if (source->IsRegister()) { | 146 if (source->IsRegister()) { |
| 147 __ mov(kLithiumScratchReg, cgen_->ToRegister(source)); | 147 __ mov(kLithiumScratchReg, cgen_->ToRegister(source)); |
| 148 } else if (source->IsStackSlot()) { | 148 } else if (source->IsStackSlot()) { |
| 149 __ ld(kLithiumScratchReg, cgen_->ToMemOperand(source)); | 149 __ Ld(kLithiumScratchReg, cgen_->ToMemOperand(source)); |
| 150 } else if (source->IsDoubleRegister()) { | 150 } else if (source->IsDoubleRegister()) { |
| 151 __ mov_d(kLithiumScratchDouble, cgen_->ToDoubleRegister(source)); | 151 __ mov_d(kLithiumScratchDouble, cgen_->ToDoubleRegister(source)); |
| 152 } else if (source->IsDoubleStackSlot()) { | 152 } else if (source->IsDoubleStackSlot()) { |
| 153 __ ldc1(kLithiumScratchDouble, cgen_->ToMemOperand(source)); | 153 __ Ldc1(kLithiumScratchDouble, cgen_->ToMemOperand(source)); |
| 154 } else { | 154 } else { |
| 155 UNREACHABLE(); | 155 UNREACHABLE(); |
| 156 } | 156 } |
| 157 // This move will be done by restoring the saved value to the destination. | 157 // This move will be done by restoring the saved value to the destination. |
| 158 moves_[index].Eliminate(); | 158 moves_[index].Eliminate(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 | 161 |
| 162 void LGapResolver::RestoreValue() { | 162 void LGapResolver::RestoreValue() { |
| 163 DCHECK(in_cycle_); | 163 DCHECK(in_cycle_); |
| 164 DCHECK(saved_destination_ != NULL); | 164 DCHECK(saved_destination_ != NULL); |
| 165 | 165 |
| 166 // Spilled value is in kLithiumScratchReg or kLithiumScratchDouble. | 166 // Spilled value is in kLithiumScratchReg or kLithiumScratchDouble. |
| 167 if (saved_destination_->IsRegister()) { | 167 if (saved_destination_->IsRegister()) { |
| 168 __ mov(cgen_->ToRegister(saved_destination_), kLithiumScratchReg); | 168 __ mov(cgen_->ToRegister(saved_destination_), kLithiumScratchReg); |
| 169 } else if (saved_destination_->IsStackSlot()) { | 169 } else if (saved_destination_->IsStackSlot()) { |
| 170 __ sd(kLithiumScratchReg, cgen_->ToMemOperand(saved_destination_)); | 170 __ Sd(kLithiumScratchReg, cgen_->ToMemOperand(saved_destination_)); |
| 171 } else if (saved_destination_->IsDoubleRegister()) { | 171 } else if (saved_destination_->IsDoubleRegister()) { |
| 172 __ mov_d(cgen_->ToDoubleRegister(saved_destination_), | 172 __ mov_d(cgen_->ToDoubleRegister(saved_destination_), |
| 173 kLithiumScratchDouble); | 173 kLithiumScratchDouble); |
| 174 } else if (saved_destination_->IsDoubleStackSlot()) { | 174 } else if (saved_destination_->IsDoubleStackSlot()) { |
| 175 __ sdc1(kLithiumScratchDouble, | 175 __ Sdc1(kLithiumScratchDouble, cgen_->ToMemOperand(saved_destination_)); |
| 176 cgen_->ToMemOperand(saved_destination_)); | |
| 177 } else { | 176 } else { |
| 178 UNREACHABLE(); | 177 UNREACHABLE(); |
| 179 } | 178 } |
| 180 | 179 |
| 181 in_cycle_ = false; | 180 in_cycle_ = false; |
| 182 saved_destination_ = NULL; | 181 saved_destination_ = NULL; |
| 183 } | 182 } |
| 184 | 183 |
| 185 | 184 |
| 186 void LGapResolver::EmitMove(int index) { | 185 void LGapResolver::EmitMove(int index) { |
| 187 LOperand* source = moves_[index].source(); | 186 LOperand* source = moves_[index].source(); |
| 188 LOperand* destination = moves_[index].destination(); | 187 LOperand* destination = moves_[index].destination(); |
| 189 | 188 |
| 190 // Dispatch on the source and destination operand kinds. Not all | 189 // Dispatch on the source and destination operand kinds. Not all |
| 191 // combinations are possible. | 190 // combinations are possible. |
| 192 | 191 |
| 193 if (source->IsRegister()) { | 192 if (source->IsRegister()) { |
| 194 Register source_register = cgen_->ToRegister(source); | 193 Register source_register = cgen_->ToRegister(source); |
| 195 if (destination->IsRegister()) { | 194 if (destination->IsRegister()) { |
| 196 __ mov(cgen_->ToRegister(destination), source_register); | 195 __ mov(cgen_->ToRegister(destination), source_register); |
| 197 } else { | 196 } else { |
| 198 DCHECK(destination->IsStackSlot()); | 197 DCHECK(destination->IsStackSlot()); |
| 199 __ sd(source_register, cgen_->ToMemOperand(destination)); | 198 __ Sd(source_register, cgen_->ToMemOperand(destination)); |
| 200 } | 199 } |
| 201 } else if (source->IsStackSlot()) { | 200 } else if (source->IsStackSlot()) { |
| 202 MemOperand source_operand = cgen_->ToMemOperand(source); | 201 MemOperand source_operand = cgen_->ToMemOperand(source); |
| 203 if (destination->IsRegister()) { | 202 if (destination->IsRegister()) { |
| 204 __ ld(cgen_->ToRegister(destination), source_operand); | 203 __ Ld(cgen_->ToRegister(destination), source_operand); |
| 205 } else { | 204 } else { |
| 206 DCHECK(destination->IsStackSlot()); | 205 DCHECK(destination->IsStackSlot()); |
| 207 MemOperand destination_operand = cgen_->ToMemOperand(destination); | 206 MemOperand destination_operand = cgen_->ToMemOperand(destination); |
| 208 if (in_cycle_) { | 207 if (in_cycle_) { |
| 209 if (!destination_operand.OffsetIsInt16Encodable()) { | 208 if (!destination_operand.OffsetIsInt16Encodable()) { |
| 210 // 'at' is overwritten while saving the value to the destination. | 209 // 'at' is overwritten while saving the value to the destination. |
| 211 // Therefore we can't use 'at'. It is OK if the read from the source | 210 // Therefore we can't use 'at'. It is OK if the read from the source |
| 212 // destroys 'at', since that happens before the value is read. | 211 // destroys 'at', since that happens before the value is read. |
| 213 // This uses only a single reg of the double reg-pair. | 212 // This uses only a single reg of the double reg-pair. |
| 214 __ ldc1(kLithiumScratchDouble, source_operand); | 213 __ Ldc1(kLithiumScratchDouble, source_operand); |
| 215 __ sdc1(kLithiumScratchDouble, destination_operand); | 214 __ Sdc1(kLithiumScratchDouble, destination_operand); |
| 216 } else { | 215 } else { |
| 217 __ ld(at, source_operand); | 216 __ Ld(at, source_operand); |
| 218 __ sd(at, destination_operand); | 217 __ Sd(at, destination_operand); |
| 219 } | 218 } |
| 220 } else { | 219 } else { |
| 221 __ ld(kLithiumScratchReg, source_operand); | 220 __ Ld(kLithiumScratchReg, source_operand); |
| 222 __ sd(kLithiumScratchReg, destination_operand); | 221 __ Sd(kLithiumScratchReg, destination_operand); |
| 223 } | 222 } |
| 224 } | 223 } |
| 225 | 224 |
| 226 } else if (source->IsConstantOperand()) { | 225 } else if (source->IsConstantOperand()) { |
| 227 LConstantOperand* constant_source = LConstantOperand::cast(source); | 226 LConstantOperand* constant_source = LConstantOperand::cast(source); |
| 228 if (destination->IsRegister()) { | 227 if (destination->IsRegister()) { |
| 229 Register dst = cgen_->ToRegister(destination); | 228 Register dst = cgen_->ToRegister(destination); |
| 230 if (cgen_->IsSmi(constant_source)) { | 229 if (cgen_->IsSmi(constant_source)) { |
| 231 __ li(dst, Operand(cgen_->ToSmi(constant_source))); | 230 __ li(dst, Operand(cgen_->ToSmi(constant_source))); |
| 232 } else if (cgen_->IsInteger32(constant_source)) { | 231 } else if (cgen_->IsInteger32(constant_source)) { |
| 233 __ li(dst, Operand(cgen_->ToInteger32(constant_source))); | 232 __ li(dst, Operand(cgen_->ToInteger32(constant_source))); |
| 234 } else { | 233 } else { |
| 235 __ li(dst, cgen_->ToHandle(constant_source)); | 234 __ li(dst, cgen_->ToHandle(constant_source)); |
| 236 } | 235 } |
| 237 } else if (destination->IsDoubleRegister()) { | 236 } else if (destination->IsDoubleRegister()) { |
| 238 DoubleRegister result = cgen_->ToDoubleRegister(destination); | 237 DoubleRegister result = cgen_->ToDoubleRegister(destination); |
| 239 double v = cgen_->ToDouble(constant_source); | 238 double v = cgen_->ToDouble(constant_source); |
| 240 __ Move(result, v); | 239 __ Move(result, v); |
| 241 } else { | 240 } else { |
| 242 DCHECK(destination->IsStackSlot()); | 241 DCHECK(destination->IsStackSlot()); |
| 243 DCHECK(!in_cycle_); // Constant moves happen after all cycles are gone. | 242 DCHECK(!in_cycle_); // Constant moves happen after all cycles are gone. |
| 244 if (cgen_->IsSmi(constant_source)) { | 243 if (cgen_->IsSmi(constant_source)) { |
| 245 __ li(kLithiumScratchReg, Operand(cgen_->ToSmi(constant_source))); | 244 __ li(kLithiumScratchReg, Operand(cgen_->ToSmi(constant_source))); |
| 246 __ sd(kLithiumScratchReg, cgen_->ToMemOperand(destination)); | 245 __ Sd(kLithiumScratchReg, cgen_->ToMemOperand(destination)); |
| 247 } else if (cgen_->IsInteger32(constant_source)) { | 246 } else if (cgen_->IsInteger32(constant_source)) { |
| 248 __ li(kLithiumScratchReg, Operand(cgen_->ToInteger32(constant_source))); | 247 __ li(kLithiumScratchReg, Operand(cgen_->ToInteger32(constant_source))); |
| 249 __ sd(kLithiumScratchReg, cgen_->ToMemOperand(destination)); | 248 __ Sd(kLithiumScratchReg, cgen_->ToMemOperand(destination)); |
| 250 } else { | 249 } else { |
| 251 __ li(kLithiumScratchReg, cgen_->ToHandle(constant_source)); | 250 __ li(kLithiumScratchReg, cgen_->ToHandle(constant_source)); |
| 252 __ sd(kLithiumScratchReg, cgen_->ToMemOperand(destination)); | 251 __ Sd(kLithiumScratchReg, cgen_->ToMemOperand(destination)); |
| 253 } | 252 } |
| 254 } | 253 } |
| 255 | 254 |
| 256 } else if (source->IsDoubleRegister()) { | 255 } else if (source->IsDoubleRegister()) { |
| 257 DoubleRegister source_register = cgen_->ToDoubleRegister(source); | 256 DoubleRegister source_register = cgen_->ToDoubleRegister(source); |
| 258 if (destination->IsDoubleRegister()) { | 257 if (destination->IsDoubleRegister()) { |
| 259 __ mov_d(cgen_->ToDoubleRegister(destination), source_register); | 258 __ mov_d(cgen_->ToDoubleRegister(destination), source_register); |
| 260 } else { | 259 } else { |
| 261 DCHECK(destination->IsDoubleStackSlot()); | 260 DCHECK(destination->IsDoubleStackSlot()); |
| 262 MemOperand destination_operand = cgen_->ToMemOperand(destination); | 261 MemOperand destination_operand = cgen_->ToMemOperand(destination); |
| 263 __ sdc1(source_register, destination_operand); | 262 __ Sdc1(source_register, destination_operand); |
| 264 } | 263 } |
| 265 | 264 |
| 266 } else if (source->IsDoubleStackSlot()) { | 265 } else if (source->IsDoubleStackSlot()) { |
| 267 MemOperand source_operand = cgen_->ToMemOperand(source); | 266 MemOperand source_operand = cgen_->ToMemOperand(source); |
| 268 if (destination->IsDoubleRegister()) { | 267 if (destination->IsDoubleRegister()) { |
| 269 __ ldc1(cgen_->ToDoubleRegister(destination), source_operand); | 268 __ Ldc1(cgen_->ToDoubleRegister(destination), source_operand); |
| 270 } else { | 269 } else { |
| 271 DCHECK(destination->IsDoubleStackSlot()); | 270 DCHECK(destination->IsDoubleStackSlot()); |
| 272 MemOperand destination_operand = cgen_->ToMemOperand(destination); | 271 MemOperand destination_operand = cgen_->ToMemOperand(destination); |
| 273 if (in_cycle_) { | 272 if (in_cycle_) { |
| 274 // kLithiumScratchDouble was used to break the cycle, | 273 // kLithiumScratchDouble was used to break the cycle, |
| 275 // but kLithiumScratchReg is free. | 274 // but kLithiumScratchReg is free. |
| 276 MemOperand source_high_operand = | 275 MemOperand source_high_operand = |
| 277 cgen_->ToHighMemOperand(source); | 276 cgen_->ToHighMemOperand(source); |
| 278 MemOperand destination_high_operand = | 277 MemOperand destination_high_operand = |
| 279 cgen_->ToHighMemOperand(destination); | 278 cgen_->ToHighMemOperand(destination); |
| 280 __ lw(kLithiumScratchReg, source_operand); | 279 __ Lw(kLithiumScratchReg, source_operand); |
| 281 __ sw(kLithiumScratchReg, destination_operand); | 280 __ Sw(kLithiumScratchReg, destination_operand); |
| 282 __ lw(kLithiumScratchReg, source_high_operand); | 281 __ Lw(kLithiumScratchReg, source_high_operand); |
| 283 __ sw(kLithiumScratchReg, destination_high_operand); | 282 __ Sw(kLithiumScratchReg, destination_high_operand); |
| 284 } else { | 283 } else { |
| 285 __ ldc1(kLithiumScratchDouble, source_operand); | 284 __ Ldc1(kLithiumScratchDouble, source_operand); |
| 286 __ sdc1(kLithiumScratchDouble, destination_operand); | 285 __ Sdc1(kLithiumScratchDouble, destination_operand); |
| 287 } | 286 } |
| 288 } | 287 } |
| 289 } else { | 288 } else { |
| 290 UNREACHABLE(); | 289 UNREACHABLE(); |
| 291 } | 290 } |
| 292 | 291 |
| 293 moves_[index].Eliminate(); | 292 moves_[index].Eliminate(); |
| 294 } | 293 } |
| 295 | 294 |
| 296 | 295 |
| 297 #undef __ | 296 #undef __ |
| 298 | 297 |
| 299 } // namespace internal | 298 } // namespace internal |
| 300 } // namespace v8 | 299 } // namespace v8 |
| OLD | NEW |