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

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

Issue 12827027: Revert "Compute local variable liveness before translation to SSA." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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/intermediate_language.h ('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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 451
452 452
453 intptr_t JoinEntryInstr::IndexOfPredecessor(BlockEntryInstr* pred) const { 453 intptr_t JoinEntryInstr::IndexOfPredecessor(BlockEntryInstr* pred) const {
454 for (intptr_t i = 0; i < predecessors_.length(); ++i) { 454 for (intptr_t i = 0; i < predecessors_.length(); ++i) {
455 if (predecessors_[i] == pred) return i; 455 if (predecessors_[i] == pred) return i;
456 } 456 }
457 return -1; 457 return -1;
458 } 458 }
459 459
460 460
461 // ==== Recording assigned variables.
462 void Definition::RecordAssignedVars(BitVector* assigned_vars,
463 intptr_t fixed_parameter_count) {
464 // Nothing to do for the base class.
465 }
466
467
468 void StoreLocalInstr::RecordAssignedVars(BitVector* assigned_vars,
469 intptr_t fixed_parameter_count) {
470 if (!local().is_captured()) {
471 assigned_vars->Add(local().BitIndexIn(fixed_parameter_count));
472 }
473 }
474
475
476 void Instruction::RecordAssignedVars(BitVector* assigned_vars,
477 intptr_t fixed_parameter_count) {
478 // Nothing to do for the base class.
479 }
480
481
461 void Value::AddToList(Value* value, Value** list) { 482 void Value::AddToList(Value* value, Value** list) {
462 Value* next = *list; 483 Value* next = *list;
463 *list = value; 484 *list = value;
464 value->set_next_use(next); 485 value->set_next_use(next);
465 value->set_previous_use(NULL); 486 value->set_previous_use(NULL);
466 if (next != NULL) next->set_previous_use(value); 487 if (next != NULL) next->set_previous_use(value);
467 } 488 }
468 489
469 490
470 void Value::RemoveFromUseList() { 491 void Value::RemoveFromUseList() {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 return (i >= 0) && (i < preorder->length()) && ((*preorder)[i] == block); 651 return (i >= 0) && (i < preorder->length()) && ((*preorder)[i] == block);
631 } 652 }
632 653
633 654
634 // Base class implementation used for JoinEntry and TargetEntry. 655 // Base class implementation used for JoinEntry and TargetEntry.
635 void BlockEntryInstr::DiscoverBlocks( 656 void BlockEntryInstr::DiscoverBlocks(
636 BlockEntryInstr* predecessor, 657 BlockEntryInstr* predecessor,
637 GrowableArray<BlockEntryInstr*>* preorder, 658 GrowableArray<BlockEntryInstr*>* preorder,
638 GrowableArray<BlockEntryInstr*>* postorder, 659 GrowableArray<BlockEntryInstr*>* postorder,
639 GrowableArray<intptr_t>* parent, 660 GrowableArray<intptr_t>* parent,
661 GrowableArray<BitVector*>* assigned_vars,
640 intptr_t variable_count, 662 intptr_t variable_count,
641 intptr_t fixed_parameter_count) { 663 intptr_t fixed_parameter_count) {
642 // If this block has a predecessor (i.e., is not the graph entry) we can 664 // If this block has a predecessor (i.e., is not the graph entry) we can
643 // assume the preorder array is non-empty. 665 // assume the preorder array is non-empty.
644 ASSERT((predecessor == NULL) || !preorder->is_empty()); 666 ASSERT((predecessor == NULL) || !preorder->is_empty());
645 // Blocks with a single predecessor cannot have been reached before. 667 // Blocks with a single predecessor cannot have been reached before.
646 ASSERT(IsJoinEntry() || !IsMarked(this, preorder)); 668 ASSERT(IsJoinEntry() || !IsMarked(this, preorder));
647 669
648 // 1. If the block has already been reached, add current_block as a 670 // 1. If the block has already been reached, add current_block as a
649 // basic-block predecessor and we are done. 671 // basic-block predecessor and we are done.
650 if (IsMarked(this, preorder)) { 672 if (IsMarked(this, preorder)) {
651 ASSERT(predecessor != NULL); 673 ASSERT(predecessor != NULL);
652 AddPredecessor(predecessor); 674 AddPredecessor(predecessor);
653 return; 675 return;
654 } 676 }
655 677
656 // 2. Otherwise, clear the predecessors which might have been computed on 678 // 2. Otherwise, clear the predecessors which might have been computed on
657 // some earlier call to DiscoverBlocks and record this predecessor. 679 // some earlier call to DiscoverBlocks and record this predecessor.
658 ClearPredecessors(); 680 ClearPredecessors();
659 if (predecessor != NULL) AddPredecessor(predecessor); 681 if (predecessor != NULL) AddPredecessor(predecessor);
660 682
661 // 3. The predecessor is the spanning-tree parent. The graph entry has no 683 // 3. The predecessor is the spanning-tree parent. The graph entry has no
662 // parent, indicated by -1. 684 // parent, indicated by -1.
663 intptr_t parent_number = 685 intptr_t parent_number =
664 (predecessor == NULL) ? -1 : predecessor->preorder_number(); 686 (predecessor == NULL) ? -1 : predecessor->preorder_number();
665 parent->Add(parent_number); 687 parent->Add(parent_number);
666 688
667 // 4. Assign the preorder number and add the block entry to the list. 689 // 4. Assign the preorder number and add the block entry to the list.
690 // Allocate an empty set of assigned variables for the block.
668 set_preorder_number(preorder->length()); 691 set_preorder_number(preorder->length());
669 preorder->Add(this); 692 preorder->Add(this);
670 693 BitVector* vars =
671 // The preorder and parent arrays are indexed by 694 (variable_count == 0) ? NULL : new BitVector(variable_count);
695 assigned_vars->Add(vars);
696 // The preorder, parent, and assigned_vars arrays are all indexed by
672 // preorder block number, so they should stay in lockstep. 697 // preorder block number, so they should stay in lockstep.
673 ASSERT(preorder->length() == parent->length()); 698 ASSERT(preorder->length() == parent->length());
699 ASSERT(preorder->length() == assigned_vars->length());
674 700
675 // 5. Iterate straight-line successors to record assigned variables and 701 // 5. Iterate straight-line successors to record assigned variables and
676 // find the last instruction in the block. The graph entry block consists 702 // find the last instruction in the block. The graph entry block consists
677 // of only the entry instruction, so that is the last instruction in the 703 // of only the entry instruction, so that is the last instruction in the
678 // block. 704 // block.
679 Instruction* last = this; 705 Instruction* last = this;
680 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) { 706 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) {
681 last = it.Current(); 707 last = it.Current();
708 if (vars != NULL) {
709 last->RecordAssignedVars(vars, fixed_parameter_count);
710 }
682 } 711 }
683 set_last_instruction(last); 712 set_last_instruction(last);
684 713
685 // Visit the block's successors in reverse so that they appear forwards 714 // Visit the block's successors in reverse so that they appear forwards
686 // the reverse postorder block ordering. 715 // the reverse postorder block ordering.
687 for (intptr_t i = last->SuccessorCount() - 1; i >= 0; --i) { 716 for (intptr_t i = last->SuccessorCount() - 1; i >= 0; --i) {
688 last->SuccessorAt(i)->DiscoverBlocks(this, 717 last->SuccessorAt(i)->DiscoverBlocks(this, preorder, postorder,
689 preorder, 718 parent, assigned_vars,
690 postorder, 719 variable_count, fixed_parameter_count);
691 parent,
692 variable_count,
693 fixed_parameter_count);
694 } 720 }
695 721
696 // 6. Assign postorder number and add the block entry to the list. 722 // 6. Assign postorder number and add the block entry to the list.
697 set_postorder_number(postorder->length()); 723 set_postorder_number(postorder->length());
698 postorder->Add(this); 724 postorder->Add(this);
699 } 725 }
700 726
701 727
702 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const { 728 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const {
703 // TODO(fschneider): Make this faster by e.g. storing dominators for each 729 // TODO(fschneider): Make this faster by e.g. storing dominators for each
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 default: 2338 default:
2313 UNREACHABLE(); 2339 UNREACHABLE();
2314 } 2340 }
2315 return kPowRuntimeEntry; 2341 return kPowRuntimeEntry;
2316 } 2342 }
2317 2343
2318 2344
2319 #undef __ 2345 #undef __
2320 2346
2321 } // namespace dart 2347 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698