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

Side by Side Diff: src/ia32/virtual-frame-ia32.cc

Issue 113451: Polish code of VirtualFrame::MoveMemoryToRegister (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 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
« no previous file with comments | « no previous file | 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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 void VirtualFrame::MergeMoveMemoryToRegisters(VirtualFrame* expected) { 417 void VirtualFrame::MergeMoveMemoryToRegisters(VirtualFrame* expected) {
418 // Move memory, constants, and copies to registers. This is the 418 // Move memory, constants, and copies to registers. This is the
419 // final step and is done from the bottom up so that the backing 419 // final step and is done from the bottom up so that the backing
420 // elements of copies are in their correct locations when we 420 // elements of copies are in their correct locations when we
421 // encounter the copies. 421 // encounter the copies.
422 for (int i = 0; i < kNumRegisters; i++) { 422 for (int i = 0; i < kNumRegisters; i++) {
423 int index = expected->register_locations_[i]; 423 int index = expected->register_locations_[i];
424 if (index != kIllegalIndex) { 424 if (index != kIllegalIndex) {
425 FrameElement source = elements_[index]; 425 FrameElement source = elements_[index];
426 FrameElement target = expected->elements_[index]; 426 FrameElement target = expected->elements_[index];
427 Register target_reg = { i };
428 ASSERT(expected->elements_[index].reg().is(target_reg));
427 switch (source.type()) { 429 switch (source.type()) {
428 case FrameElement::INVALID: // Fall through. 430 case FrameElement::INVALID: // Fall through.
429 UNREACHABLE(); 431 UNREACHABLE();
430 break; 432 break;
431 case FrameElement::REGISTER: 433 case FrameElement::REGISTER:
432 ASSERT(source.reg().is(target.reg())); 434 ASSERT(source.reg().is(target_reg));
433 continue; // Go to next iteration. Skips Use(target.reg()) below. 435 continue; // Go to next iteration. Skips Use(target_reg) below.
434 break; 436 break;
435 case FrameElement::MEMORY: 437 case FrameElement::MEMORY:
436 ASSERT(index <= stack_pointer_); 438 ASSERT(index <= stack_pointer_);
437 __ mov(target.reg(), Operand(ebp, fp_relative(index))); 439 __ mov(target_reg, Operand(ebp, fp_relative(index)));
438 break; 440 break;
439 441
440 case FrameElement::CONSTANT: 442 case FrameElement::CONSTANT:
441 if (cgen_->IsUnsafeSmi(source.handle())) { 443 if (cgen_->IsUnsafeSmi(source.handle())) {
442 cgen_->LoadUnsafeSmi(target.reg(), source.handle()); 444 cgen_->LoadUnsafeSmi(target_reg, source.handle());
443 } else { 445 } else {
444 __ Set(target.reg(), Immediate(source.handle())); 446 __ Set(target_reg, Immediate(source.handle()));
445 } 447 }
446 break; 448 break;
447 449
448 case FrameElement::COPY: { 450 case FrameElement::COPY: {
449 int backing_index = source.index(); 451 int backing_index = source.index();
450 FrameElement backing = elements_[backing_index]; 452 FrameElement backing = elements_[backing_index];
451 ASSERT(backing.is_memory() || backing.is_register()); 453 ASSERT(backing.is_memory() || backing.is_register());
452 if (backing.is_memory()) { 454 if (backing.is_memory()) {
453 ASSERT(backing_index <= stack_pointer_); 455 ASSERT(backing_index <= stack_pointer_);
454 // Code optimization if backing store should also move 456 // Code optimization if backing store should also move
455 // to a register: move backing store to its register first. 457 // to a register: move backing store to its register first.
456 if (expected->elements_[backing_index].is_register()) { 458 if (expected->elements_[backing_index].is_register()) {
457 FrameElement new_backing = expected->elements_[backing_index]; 459 FrameElement new_backing = expected->elements_[backing_index];
458 Register new_backing_reg = new_backing.reg(); 460 Register new_backing_reg = new_backing.reg();
459 ASSERT(!is_used(new_backing_reg)); 461 ASSERT(!is_used(new_backing_reg));
460 elements_[backing_index] = new_backing; 462 elements_[backing_index] = new_backing;
461 Use(new_backing_reg, backing_index); 463 Use(new_backing_reg, backing_index);
462 __ mov(new_backing_reg, 464 __ mov(new_backing_reg,
463 Operand(ebp, fp_relative(backing_index))); 465 Operand(ebp, fp_relative(backing_index)));
464 __ mov(target.reg(), new_backing_reg); 466 __ mov(target_reg, new_backing_reg);
465 } else { 467 } else {
466 __ mov(target.reg(), Operand(ebp, fp_relative(backing_index))); 468 __ mov(target_reg, Operand(ebp, fp_relative(backing_index)));
467 } 469 }
468 } else { 470 } else {
469 __ mov(target.reg(), backing.reg()); 471 __ mov(target_reg, backing.reg());
470 } 472 }
471 } 473 }
472 } 474 }
473 // Ensure the proper sync state. If the source was memory no 475 // Ensure the proper sync state. If the source was memory no
474 // code needs to be emitted. 476 // code needs to be emitted.
475 if (target.is_synced() && !source.is_synced()) { 477 if (target.is_synced() && !source.is_synced()) {
476 __ mov(Operand(ebp, fp_relative(index)), target.reg()); 478 __ mov(Operand(ebp, fp_relative(index)), target_reg);
477 } 479 }
478 Use(target.reg(), index); 480 Use(target_reg, index);
479 elements_[index] = target; 481 elements_[index] = target;
480 } 482 }
481 } 483 }
482 } 484 }
483 485
484 486
485 void VirtualFrame::Enter() { 487 void VirtualFrame::Enter() {
486 // Registers live on entry: esp, ebp, esi, edi. 488 // Registers live on entry: esp, ebp, esi, edi.
487 Comment cmnt(masm_, "[ Enter JS frame"); 489 Comment cmnt(masm_, "[ Enter JS frame");
488 490
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 ASSERT(stack_pointer_ == elements_.length() - 1); 1121 ASSERT(stack_pointer_ == elements_.length() - 1);
1120 elements_.Add(FrameElement::MemoryElement()); 1122 elements_.Add(FrameElement::MemoryElement());
1121 stack_pointer_++; 1123 stack_pointer_++;
1122 __ push(immediate); 1124 __ push(immediate);
1123 } 1125 }
1124 1126
1125 1127
1126 #undef __ 1128 #undef __
1127 1129
1128 } } // namespace v8::internal 1130 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698