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

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
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language.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/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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 // below to also eliminate the test for non-null and non-constant value. 784 // below to also eliminate the test for non-null and non-constant value.
785 785
786 // We can only eliminate an 'assert boolean' test when the checked value is 786 // We can only eliminate an 'assert boolean' test when the checked value is
787 // a constant time constant. Indeed, a variable of the proper compile time 787 // a constant time constant. Indeed, a variable of the proper compile time
788 // type (bool) may still hold null at run time and therefore fail the test. 788 // type (bool) may still hold null at run time and therefore fail the test.
789 if (FLAG_eliminate_type_checks && 789 if (FLAG_eliminate_type_checks &&
790 !comp->is_eliminated() && 790 !comp->is_eliminated() &&
791 comp->value()->BindsToConstant() && 791 comp->value()->BindsToConstant() &&
792 !comp->value()->BindsToConstantNull() && 792 !comp->value()->BindsToConstantNull() &&
793 comp->value()->CompileTypeIsMoreSpecificThan( 793 comp->value()->CompileTypeIsMoreSpecificThan(
794 Type::Handle(Type::BoolInterface()))) { 794 Type::Handle(Type::BoolType()))) {
795 // TODO(regis): Remove is_eliminated_ field and support. 795 // TODO(regis): Remove is_eliminated_ field and support.
796 comp->eliminate(); 796 comp->eliminate();
797 797
798 UseVal* use = comp->value()->AsUse(); 798 UseVal* use = comp->value()->AsUse();
799 ASSERT(use != NULL); 799 ASSERT(use != NULL);
800 Definition* result = use->definition(); 800 Definition* result = use->definition();
801 ASSERT(result != NULL); 801 ASSERT(result != NULL);
802 // Replace uses and remove the current instructions via the iterator. 802 // Replace uses and remove the current instructions via the iterator.
803 instr->ReplaceUsesWith(result); 803 instr->ReplaceUsesWith(result);
804 ASSERT(current_iterator()->Current() == instr); 804 ASSERT(current_iterator()->Current() == instr);
805 current_iterator()->RemoveCurrentFromGraph(); 805 current_iterator()->RemoveCurrentFromGraph();
806 if (FLAG_trace_optimization) { 806 if (FLAG_trace_optimization) {
807 OS::Print("Replacing v%d with v%d\n", 807 OS::Print("Replacing v%d with v%d\n",
808 instr->ssa_temp_index(), 808 instr->ssa_temp_index(),
809 result->ssa_temp_index()); 809 result->ssa_temp_index());
810 } 810 }
811 811
812 if (FLAG_trace_type_check_elimination) { 812 if (FLAG_trace_type_check_elimination) {
813 const String& name = String::Handle(Symbols::New("boolean expression")); 813 const String& name = String::Handle(Symbols::New("boolean expression"));
814 FlowGraphPrinter::PrintTypeCheck(parsed_function(), 814 FlowGraphPrinter::PrintTypeCheck(parsed_function(),
815 comp->token_pos(), 815 comp->token_pos(),
816 comp->value(), 816 comp->value(),
817 Type::Handle(Type::BoolInterface()), 817 Type::Handle(Type::BoolType()),
818 name, 818 name,
819 comp->is_eliminated()); 819 comp->is_eliminated());
820 } 820 }
821 } 821 }
822 } 822 }
823 823
824 824
825 void FlowGraphTypePropagator::VisitInstanceOf(InstanceOfComp* comp, 825 void FlowGraphTypePropagator::VisitInstanceOf(InstanceOfComp* comp,
826 BindInstr* instr) { 826 BindInstr* instr) {
827 // TODO(regis): Propagate NullType as well and revise the comment and code 827 // TODO(regis): Propagate NullType as well and revise the comment and code
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. 1056 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map.
1057 OptimizeRecursive(child, &child_map); 1057 OptimizeRecursive(child, &child_map);
1058 } else { 1058 } else {
1059 OptimizeRecursive(child, map); // Reuse map for the last child. 1059 OptimizeRecursive(child, map); // Reuse map for the last child.
1060 } 1060 }
1061 } 1061 }
1062 } 1062 }
1063 1063
1064 1064
1065 } // namespace dart 1065 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698