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

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

Issue 10790086: Minor cleanups: use GrowableArray::is_empty instead of ::length() == 0 (Closed) Base URL: http://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
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 if (!blocked_registers[regno] && (registers_[regno] == NULL)) { 504 if (!blocked_registers[regno] && (registers_[regno] == NULL)) {
505 blocked_registers[regno] = true; 505 blocked_registers[regno] = true;
506 return static_cast<Register>(regno); 506 return static_cast<Register>(regno);
507 } 507 }
508 } 508 }
509 return SpillFirst(); 509 return SpillFirst();
510 } 510 }
511 511
512 512
513 Register FrameRegisterAllocator::SpillFirst() { 513 Register FrameRegisterAllocator::SpillFirst() {
514 ASSERT(stack_.length() > 0); 514 ASSERT(!stack_.is_empty());
515 Register reg = stack_[0]; 515 Register reg = stack_[0];
516 stack_.RemoveFirst(); 516 stack_.RemoveFirst();
517 compiler()->assembler()->PushRegister(reg); 517 compiler()->assembler()->PushRegister(reg);
518 registers_[reg] = NULL; 518 registers_[reg] = NULL;
519 return reg; 519 return reg;
520 } 520 }
521 521
522 522
523 void FrameRegisterAllocator::SpillRegister(Register reg) { 523 void FrameRegisterAllocator::SpillRegister(Register reg) {
524 while (registers_[reg] != NULL) SpillFirst(); 524 while (registers_[reg] != NULL) SpillFirst();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 } 582 }
583 583
584 // Allocate all unallocated input locations. 584 // Allocate all unallocated input locations.
585 for (intptr_t i = locs->input_count() - 1; i >= 0; i--) { 585 for (intptr_t i = locs->input_count() - 1; i >= 0; i--) {
586 Location loc = locs->in(i); 586 Location loc = locs->in(i);
587 Register reg = kNoRegister; 587 Register reg = kNoRegister;
588 if (loc.IsRegister()) { 588 if (loc.IsRegister()) {
589 reg = loc.reg(); 589 reg = loc.reg();
590 } else if (loc.IsUnallocated()) { 590 } else if (loc.IsUnallocated()) {
591 ASSERT(loc.policy() == Location::kRequiresRegister); 591 ASSERT(loc.policy() == Location::kRequiresRegister);
592 if ((stack_.length() > 0) && !blocked_temp_registers[stack_.Last()]) { 592 if (!stack_.is_empty() && !blocked_temp_registers[stack_.Last()]) {
593 reg = stack_.Last(); 593 reg = stack_.Last();
594 blocked_registers[reg] = true; 594 blocked_registers[reg] = true;
595 } else { 595 } else {
596 reg = AllocateFreeRegister(blocked_registers); 596 reg = AllocateFreeRegister(blocked_registers);
597 } 597 }
598 locs->set_in(i, Location::RegisterLocation(reg)); 598 locs->set_in(i, Location::RegisterLocation(reg));
599 } 599 }
600 600
601 Pop(reg, instr->InputAt(i)); 601 Pop(reg, instr->InputAt(i));
602 } 602 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 635
636 if (result_location.IsRegister()) { 636 if (result_location.IsRegister()) {
637 SpillRegister(result_location.reg()); 637 SpillRegister(result_location.reg());
638 } 638 }
639 } 639 }
640 640
641 641
642 void FrameRegisterAllocator::Pop(Register dst, Value* val) { 642 void FrameRegisterAllocator::Pop(Register dst, Value* val) {
643 if (is_ssa_) return; 643 if (is_ssa_) return;
644 644
645 if (stack_.length() > 0) { 645 if (!stack_.is_empty()) {
646 ASSERT(keep_values_in_registers_); 646 ASSERT(keep_values_in_registers_);
647 Register src = stack_.Last(); 647 Register src = stack_.Last();
648 ASSERT(val->AsUse()->definition() == registers_[src]); 648 ASSERT(val->AsUse()->definition() == registers_[src]);
649 stack_.RemoveLast(); 649 stack_.RemoveLast();
650 registers_[src] = NULL; 650 registers_[src] = NULL;
651 compiler()->assembler()->MoveRegister(dst, src); 651 compiler()->assembler()->MoveRegister(dst, src);
652 } else { 652 } else {
653 compiler()->assembler()->PopRegister(dst); 653 compiler()->assembler()->PopRegister(dst);
654 } 654 }
655 } 655 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 return; 791 return;
792 } 792 }
793 } 793 }
794 794
795 // This move is not blocked. 795 // This move is not blocked.
796 EmitMove(index); 796 EmitMove(index);
797 } 797 }
798 798
799 799
800 } // namespace dart 800 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698