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

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

Issue 10874071: Eliminate interface bool (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
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/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/cha.h" 7 #include "vm/cha.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/hash_map.h" 9 #include "vm/hash_map.h"
10 #include "vm/il_printer.h" 10 #include "vm/il_printer.h"
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 // below to also eliminate the test for non-null and non-constant value. 780 // below to also eliminate the test for non-null and non-constant value.
781 781
782 // We can only eliminate an 'assert boolean' test when the checked value is 782 // We can only eliminate an 'assert boolean' test when the checked value is
783 // a constant time constant. Indeed, a variable of the proper compile time 783 // a constant time constant. Indeed, a variable of the proper compile time
784 // type (bool) may still hold null at run time and therefore fail the test. 784 // type (bool) may still hold null at run time and therefore fail the test.
785 if (FLAG_eliminate_type_checks && 785 if (FLAG_eliminate_type_checks &&
786 !comp->is_eliminated() && 786 !comp->is_eliminated() &&
787 comp->value()->BindsToConstant() && 787 comp->value()->BindsToConstant() &&
788 !comp->value()->BindsToConstantNull() && 788 !comp->value()->BindsToConstantNull() &&
789 comp->value()->CompileTypeIsMoreSpecificThan( 789 comp->value()->CompileTypeIsMoreSpecificThan(
790 Type::Handle(Type::BoolInterface()))) { 790 Type::Handle(Type::BoolType()))) {
791 // TODO(regis): Remove is_eliminated_ field and support. 791 // TODO(regis): Remove is_eliminated_ field and support.
792 comp->eliminate(); 792 comp->eliminate();
793 793
794 UseVal* use = comp->value()->AsUse(); 794 UseVal* use = comp->value()->AsUse();
795 ASSERT(use != NULL); 795 ASSERT(use != NULL);
796 Definition* result = use->definition(); 796 Definition* result = use->definition();
797 ASSERT(result != NULL); 797 ASSERT(result != NULL);
798 // Replace uses and remove the current instructions via the iterator. 798 // Replace uses and remove the current instructions via the iterator.
799 instr->ReplaceUsesWith(result); 799 instr->ReplaceUsesWith(result);
800 ASSERT(current_iterator()->Current() == instr); 800 ASSERT(current_iterator()->Current() == instr);
801 current_iterator()->RemoveCurrentFromGraph(); 801 current_iterator()->RemoveCurrentFromGraph();
802 if (FLAG_trace_optimization) { 802 if (FLAG_trace_optimization) {
803 OS::Print("Replacing v%d with v%d\n", 803 OS::Print("Replacing v%d with v%d\n",
804 instr->ssa_temp_index(), 804 instr->ssa_temp_index(),
805 result->ssa_temp_index()); 805 result->ssa_temp_index());
806 } 806 }
807 807
808 if (FLAG_trace_type_check_elimination) { 808 if (FLAG_trace_type_check_elimination) {
809 const String& name = String::Handle(Symbols::New("boolean expression")); 809 const String& name = String::Handle(Symbols::New("boolean expression"));
810 FlowGraphPrinter::PrintTypeCheck(parsed_function(), 810 FlowGraphPrinter::PrintTypeCheck(parsed_function(),
811 comp->token_pos(), 811 comp->token_pos(),
812 comp->value(), 812 comp->value(),
813 Type::Handle(Type::BoolInterface()), 813 Type::Handle(Type::BoolType()),
814 name, 814 name,
815 comp->is_eliminated()); 815 comp->is_eliminated());
816 } 816 }
817 } 817 }
818 } 818 }
819 819
820 820
821 void FlowGraphTypePropagator::VisitInstanceOf(InstanceOfComp* comp, 821 void FlowGraphTypePropagator::VisitInstanceOf(InstanceOfComp* comp,
822 BindInstr* instr) { 822 BindInstr* instr) {
823 // TODO(regis): Propagate NullType as well and revise the comment and code 823 // TODO(regis): Propagate NullType as well and revise the comment and code
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. 1052 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map.
1053 OptimizeRecursive(child, &child_map); 1053 OptimizeRecursive(child, &child_map);
1054 } else { 1054 } else {
1055 OptimizeRecursive(child, map); // Reuse map for the last child. 1055 OptimizeRecursive(child, map); // Reuse map for the last child.
1056 } 1056 }
1057 } 1057 }
1058 } 1058 }
1059 1059
1060 1060
1061 } // namespace dart 1061 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698