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

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

Issue 10698153: Change comparison-to-branch fusion to actually remove comparison from the graph. (Closed) Base URL: https://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
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/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_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 void CreateArrayComp::SetInputAt(intptr_t i, Value* value) { 163 void CreateArrayComp::SetInputAt(intptr_t i, Value* value) {
164 if (i == 0) { 164 if (i == 0) {
165 inputs_[0] = value; 165 inputs_[0] = value;
166 } else { 166 } else {
167 (*elements_)[i - 1] = value; 167 (*elements_)[i - 1] = value;
168 } 168 }
169 } 169 }
170 170
171 171
172 intptr_t BranchInstr::InputCount() const { 172 intptr_t BranchInstr::InputCount() const {
173 return 1; 173 return is_fused_with_comparison() ? fused_with_comparison_->InputCount() : 1;
174 } 174 }
175 175
176 176
177 Value* BranchInstr::InputAt(intptr_t i) const { 177 Value* BranchInstr::InputAt(intptr_t i) const {
178 if (is_fused_with_comparison()) {
179 return fused_with_comparison_->InputAt(i);
180 }
178 if (i == 0) return value(); 181 if (i == 0) return value();
179 UNREACHABLE(); 182 UNREACHABLE();
180 return NULL; 183 return NULL;
181 } 184 }
182 185
183 186
184 void BranchInstr::SetInputAt(intptr_t i, Value* value) { 187 void BranchInstr::SetInputAt(intptr_t i, Value* value) {
188 ASSERT(!is_fused_with_comparison());
185 if (i == 0) { 189 if (i == 0) {
186 value_ = value; 190 value_ = value;
187 return; 191 return;
188 } 192 }
189 UNREACHABLE(); 193 UNREACHABLE();
190 } 194 }
191 195
192 196
193 intptr_t ParallelMoveInstr::InputCount() const { 197 intptr_t ParallelMoveInstr::InputCount() const {
194 UNREACHABLE(); 198 UNREACHABLE();
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 compiler->GenerateCallRuntime(cid(), 982 compiler->GenerateCallRuntime(cid(),
979 token_pos(), 983 token_pos(),
980 try_index(), 984 try_index(),
981 kReThrowRuntimeEntry); 985 kReThrowRuntimeEntry);
982 __ int3(); 986 __ int3();
983 } 987 }
984 988
985 989
986 LocationSummary* BranchInstr::MakeLocationSummary() const { 990 LocationSummary* BranchInstr::MakeLocationSummary() const {
987 if (is_fused_with_comparison()) { 991 if (is_fused_with_comparison()) {
988 return LocationSummary::Make(0, 992 return fused_with_comparison_->locs();
989 Location::NoLocation(),
990 LocationSummary::kNoCall,
991 LocationSummary::kBranch);
992 } else { 993 } else {
993 const int kNumInputs = 1; 994 const int kNumInputs = 1;
994 const int kNumTemps = 0; 995 const int kNumTemps = 0;
995 LocationSummary* locs = new LocationSummary(kNumInputs, 996 LocationSummary* locs = new LocationSummary(kNumInputs,
996 kNumTemps, 997 kNumTemps,
997 LocationSummary::kNoCall, 998 LocationSummary::kNoCall);
998 LocationSummary::kBranch);
999 locs->set_in(0, Location::RequiresRegister()); 999 locs->set_in(0, Location::RequiresRegister());
1000 return locs; 1000 return locs;
1001 } 1001 }
1002 } 1002 }
1003 1003
1004 1004
1005 void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1005 void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1006 // If branch was fused with a comparision then no code needs to be emitted. 1006 if (is_fused_with_comparison()) {
1007 if (!is_fused_with_comparison()) { 1007 fused_with_comparison_->EmitNativeCode(compiler);
1008 } else {
1008 Register value = locs()->in(0).reg(); 1009 Register value = locs()->in(0).reg();
1009 __ CompareObject(value, compiler->bool_true()); 1010 __ CompareObject(value, compiler->bool_true());
1010 EmitBranchOnCondition(compiler, EQUAL); 1011 EmitBranchOnCondition(compiler, EQUAL);
1011 } 1012 }
1012 } 1013 }
1013 1014
1014 1015
1015 static Condition NegateCondition(Condition condition) { 1016 static Condition NegateCondition(Condition condition) {
1016 switch (condition) { 1017 switch (condition) {
1017 case EQUAL: return NOT_EQUAL; 1018 case EQUAL: return NOT_EQUAL;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 ASSERT(locs()->in(0).reg() == CTX); 1075 ASSERT(locs()->in(0).reg() == CTX);
1075 } 1076 }
1076 1077
1077 1078
1078 LocationSummary* StrictCompareComp::MakeLocationSummary() const { 1079 LocationSummary* StrictCompareComp::MakeLocationSummary() const {
1079 if (is_fused_with_branch()) { 1080 if (is_fused_with_branch()) {
1080 const intptr_t kNumInputs = 2; 1081 const intptr_t kNumInputs = 2;
1081 const intptr_t kNumTemps = 0; 1082 const intptr_t kNumTemps = 0;
1082 LocationSummary* locs = new LocationSummary(kNumInputs, 1083 LocationSummary* locs = new LocationSummary(kNumInputs,
1083 kNumTemps, 1084 kNumTemps,
1084 LocationSummary::kNoCall, 1085 LocationSummary::kNoCall);
1085 LocationSummary::kBranch);
1086 locs->set_in(0, Location::RequiresRegister()); 1086 locs->set_in(0, Location::RequiresRegister());
1087 locs->set_in(1, Location::RequiresRegister()); 1087 locs->set_in(1, Location::RequiresRegister());
1088 return locs; 1088 return locs;
1089 } else { 1089 } else {
1090 return LocationSummary::Make(2, Location::SameAsFirstInput()); 1090 return LocationSummary::Make(2, Location::SameAsFirstInput());
1091 } 1091 }
1092 } 1092 }
1093 1093
1094 1094
1095 void StrictCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1095 void StrictCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); 1308 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint());
1309 compiler->GenerateCall(token_pos(), try_index(), &label, 1309 compiler->GenerateCall(token_pos(), try_index(), &label,
1310 PcDescriptors::kOther); 1310 PcDescriptors::kOther);
1311 __ Drop(2); // Discard type arguments and receiver. 1311 __ Drop(2); // Discard type arguments and receiver.
1312 } 1312 }
1313 1313
1314 1314
1315 #undef __ 1315 #undef __
1316 1316
1317 } // namespace dart 1317 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698