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

Side by Side Diff: src/mips/lithium-gap-resolver-mips.cc

Issue 9689069: MIPS: Remove static initializers in v8. (Closed)
Patch Set: rebased on r11230 Created 8 years, 8 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
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "mips/lithium-gap-resolver-mips.h" 30 #include "mips/lithium-gap-resolver-mips.h"
31 #include "mips/lithium-codegen-mips.h" 31 #include "mips/lithium-codegen-mips.h"
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 static const Register kSavedValueRegister = kLithiumScratchReg;
37
38 LGapResolver::LGapResolver(LCodeGen* owner) 36 LGapResolver::LGapResolver(LCodeGen* owner)
39 : cgen_(owner), 37 : cgen_(owner),
40 moves_(32), 38 moves_(32),
41 root_index_(0), 39 root_index_(0),
42 in_cycle_(false), 40 in_cycle_(false),
43 saved_destination_(NULL) {} 41 saved_destination_(NULL) {}
44 42
45 43
46 void LGapResolver::Resolve(LParallelMove* parallel_move) { 44 void LGapResolver::Resolve(LParallelMove* parallel_move) {
47 ASSERT(moves_.is_empty()); 45 ASSERT(moves_.is_empty());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 void LGapResolver::BreakCycle(int index) { 161 void LGapResolver::BreakCycle(int index) {
164 // We save in a register the value that should end up in the source of 162 // We save in a register the value that should end up in the source of
165 // moves_[root_index]. After performing all moves in the tree rooted 163 // moves_[root_index]. After performing all moves in the tree rooted
166 // in that move, we save the value to that source. 164 // in that move, we save the value to that source.
167 ASSERT(moves_[index].destination()->Equals(moves_[root_index_].source())); 165 ASSERT(moves_[index].destination()->Equals(moves_[root_index_].source()));
168 ASSERT(!in_cycle_); 166 ASSERT(!in_cycle_);
169 in_cycle_ = true; 167 in_cycle_ = true;
170 LOperand* source = moves_[index].source(); 168 LOperand* source = moves_[index].source();
171 saved_destination_ = moves_[index].destination(); 169 saved_destination_ = moves_[index].destination();
172 if (source->IsRegister()) { 170 if (source->IsRegister()) {
173 __ mov(kSavedValueRegister, cgen_->ToRegister(source)); 171 __ mov(kLithiumScratchReg, cgen_->ToRegister(source));
174 } else if (source->IsStackSlot()) { 172 } else if (source->IsStackSlot()) {
175 __ lw(kSavedValueRegister, cgen_->ToMemOperand(source)); 173 __ lw(kLithiumScratchReg, cgen_->ToMemOperand(source));
176 } else if (source->IsDoubleRegister()) { 174 } else if (source->IsDoubleRegister()) {
177 __ mov_d(kLithiumScratchDouble, cgen_->ToDoubleRegister(source)); 175 __ mov_d(kLithiumScratchDouble, cgen_->ToDoubleRegister(source));
178 } else if (source->IsDoubleStackSlot()) { 176 } else if (source->IsDoubleStackSlot()) {
179 __ ldc1(kLithiumScratchDouble, cgen_->ToMemOperand(source)); 177 __ ldc1(kLithiumScratchDouble, cgen_->ToMemOperand(source));
180 } else { 178 } else {
181 UNREACHABLE(); 179 UNREACHABLE();
182 } 180 }
183 // This move will be done by restoring the saved value to the destination. 181 // This move will be done by restoring the saved value to the destination.
184 moves_[index].Eliminate(); 182 moves_[index].Eliminate();
185 } 183 }
186 184
187 185
188 void LGapResolver::RestoreValue() { 186 void LGapResolver::RestoreValue() {
189 ASSERT(in_cycle_); 187 ASSERT(in_cycle_);
190 ASSERT(saved_destination_ != NULL); 188 ASSERT(saved_destination_ != NULL);
191 189
192 // Spilled value is in kSavedValueRegister or kLithiumScratchDouble. 190 // Spilled value is in kLithiumScratchReg or kLithiumScratchDouble.
193 if (saved_destination_->IsRegister()) { 191 if (saved_destination_->IsRegister()) {
194 __ mov(cgen_->ToRegister(saved_destination_), kSavedValueRegister); 192 __ mov(cgen_->ToRegister(saved_destination_), kLithiumScratchReg);
195 } else if (saved_destination_->IsStackSlot()) { 193 } else if (saved_destination_->IsStackSlot()) {
196 __ sw(kSavedValueRegister, cgen_->ToMemOperand(saved_destination_)); 194 __ sw(kLithiumScratchReg, cgen_->ToMemOperand(saved_destination_));
197 } else if (saved_destination_->IsDoubleRegister()) { 195 } else if (saved_destination_->IsDoubleRegister()) {
198 __ mov_d(cgen_->ToDoubleRegister(saved_destination_), 196 __ mov_d(cgen_->ToDoubleRegister(saved_destination_),
199 kLithiumScratchDouble); 197 kLithiumScratchDouble);
200 } else if (saved_destination_->IsDoubleStackSlot()) { 198 } else if (saved_destination_->IsDoubleStackSlot()) {
201 __ sdc1(kLithiumScratchDouble, 199 __ sdc1(kLithiumScratchDouble,
202 cgen_->ToMemOperand(saved_destination_)); 200 cgen_->ToMemOperand(saved_destination_));
203 } else { 201 } else {
204 UNREACHABLE(); 202 UNREACHABLE();
205 } 203 }
206 204
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // Therefore we can't use 'at'. It is OK if the read from the source 236 // Therefore we can't use 'at'. It is OK if the read from the source
239 // destroys 'at', since that happens before the value is read. 237 // destroys 'at', since that happens before the value is read.
240 // This uses only a single reg of the double reg-pair. 238 // This uses only a single reg of the double reg-pair.
241 __ lwc1(kLithiumScratchDouble, source_operand); 239 __ lwc1(kLithiumScratchDouble, source_operand);
242 __ swc1(kLithiumScratchDouble, destination_operand); 240 __ swc1(kLithiumScratchDouble, destination_operand);
243 } else { 241 } else {
244 __ lw(at, source_operand); 242 __ lw(at, source_operand);
245 __ sw(at, destination_operand); 243 __ sw(at, destination_operand);
246 } 244 }
247 } else { 245 } else {
248 __ lw(kSavedValueRegister, source_operand); 246 __ lw(kLithiumScratchReg, source_operand);
249 __ sw(kSavedValueRegister, destination_operand); 247 __ sw(kLithiumScratchReg, destination_operand);
250 } 248 }
251 } 249 }
252 250
253 } else if (source->IsConstantOperand()) { 251 } else if (source->IsConstantOperand()) {
254 LConstantOperand* constant_source = LConstantOperand::cast(source); 252 LConstantOperand* constant_source = LConstantOperand::cast(source);
255 if (destination->IsRegister()) { 253 if (destination->IsRegister()) {
256 Register dst = cgen_->ToRegister(destination); 254 Register dst = cgen_->ToRegister(destination);
257 if (cgen_->IsInteger32(constant_source)) { 255 if (cgen_->IsInteger32(constant_source)) {
258 __ li(dst, Operand(cgen_->ToInteger32(constant_source))); 256 __ li(dst, Operand(cgen_->ToInteger32(constant_source)));
259 } else { 257 } else {
260 __ LoadObject(dst, cgen_->ToHandle(constant_source)); 258 __ LoadObject(dst, cgen_->ToHandle(constant_source));
261 } 259 }
262 } else { 260 } else {
263 ASSERT(destination->IsStackSlot()); 261 ASSERT(destination->IsStackSlot());
264 ASSERT(!in_cycle_); // Constant moves happen after all cycles are gone. 262 ASSERT(!in_cycle_); // Constant moves happen after all cycles are gone.
265 if (cgen_->IsInteger32(constant_source)) { 263 if (cgen_->IsInteger32(constant_source)) {
266 __ li(kSavedValueRegister, 264 __ li(kLithiumScratchReg,
267 Operand(cgen_->ToInteger32(constant_source))); 265 Operand(cgen_->ToInteger32(constant_source)));
268 } else { 266 } else {
269 __ LoadObject(kSavedValueRegister, 267 __ LoadObject(kLithiumScratchReg,
270 cgen_->ToHandle(constant_source)); 268 cgen_->ToHandle(constant_source));
271 } 269 }
272 __ sw(kSavedValueRegister, cgen_->ToMemOperand(destination)); 270 __ sw(kLithiumScratchReg, cgen_->ToMemOperand(destination));
273 } 271 }
274 272
275 } else if (source->IsDoubleRegister()) { 273 } else if (source->IsDoubleRegister()) {
276 DoubleRegister source_register = cgen_->ToDoubleRegister(source); 274 DoubleRegister source_register = cgen_->ToDoubleRegister(source);
277 if (destination->IsDoubleRegister()) { 275 if (destination->IsDoubleRegister()) {
278 __ mov_d(cgen_->ToDoubleRegister(destination), source_register); 276 __ mov_d(cgen_->ToDoubleRegister(destination), source_register);
279 } else { 277 } else {
280 ASSERT(destination->IsDoubleStackSlot()); 278 ASSERT(destination->IsDoubleStackSlot());
281 MemOperand destination_operand = cgen_->ToMemOperand(destination); 279 MemOperand destination_operand = cgen_->ToMemOperand(destination);
282 __ sdc1(source_register, destination_operand); 280 __ sdc1(source_register, destination_operand);
283 } 281 }
284 282
285 } else if (source->IsDoubleStackSlot()) { 283 } else if (source->IsDoubleStackSlot()) {
286 MemOperand source_operand = cgen_->ToMemOperand(source); 284 MemOperand source_operand = cgen_->ToMemOperand(source);
287 if (destination->IsDoubleRegister()) { 285 if (destination->IsDoubleRegister()) {
288 __ ldc1(cgen_->ToDoubleRegister(destination), source_operand); 286 __ ldc1(cgen_->ToDoubleRegister(destination), source_operand);
289 } else { 287 } else {
290 ASSERT(destination->IsDoubleStackSlot()); 288 ASSERT(destination->IsDoubleStackSlot());
291 MemOperand destination_operand = cgen_->ToMemOperand(destination); 289 MemOperand destination_operand = cgen_->ToMemOperand(destination);
292 if (in_cycle_) { 290 if (in_cycle_) {
293 // kLithiumScratchDouble was used to break the cycle, 291 // kLithiumScratchDouble was used to break the cycle,
294 // but kSavedValueRegister is free. 292 // but kLithiumScratchReg is free.
295 MemOperand source_high_operand = 293 MemOperand source_high_operand =
296 cgen_->ToHighMemOperand(source); 294 cgen_->ToHighMemOperand(source);
297 MemOperand destination_high_operand = 295 MemOperand destination_high_operand =
298 cgen_->ToHighMemOperand(destination); 296 cgen_->ToHighMemOperand(destination);
299 __ lw(kSavedValueRegister, source_operand); 297 __ lw(kLithiumScratchReg, source_operand);
300 __ sw(kSavedValueRegister, destination_operand); 298 __ sw(kLithiumScratchReg, destination_operand);
301 __ lw(kSavedValueRegister, source_high_operand); 299 __ lw(kLithiumScratchReg, source_high_operand);
302 __ sw(kSavedValueRegister, destination_high_operand); 300 __ sw(kLithiumScratchReg, destination_high_operand);
303 } else { 301 } else {
304 __ ldc1(kLithiumScratchDouble, source_operand); 302 __ ldc1(kLithiumScratchDouble, source_operand);
305 __ sdc1(kLithiumScratchDouble, destination_operand); 303 __ sdc1(kLithiumScratchDouble, destination_operand);
306 } 304 }
307 } 305 }
308 } else { 306 } else {
309 UNREACHABLE(); 307 UNREACHABLE();
310 } 308 }
311 309
312 moves_[index].Eliminate(); 310 moves_[index].Eliminate();
313 } 311 }
314 312
315 313
316 #undef __ 314 #undef __
317 315
318 } } // namespace v8::internal 316 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698