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

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

Issue 10559072: Fuse Comparison->BooleanNegate->Branch. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/flow_graph_compiler.h" 9 #include "vm/flow_graph_compiler.h"
10 #include "vm/locations.h" 10 #include "vm/locations.h"
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 default: 1009 default:
1010 OS::Print("Error %d\n", condition); 1010 OS::Print("Error %d\n", condition);
1011 UNIMPLEMENTED(); 1011 UNIMPLEMENTED();
1012 return EQUAL; 1012 return EQUAL;
1013 } 1013 }
1014 } 1014 }
1015 1015
1016 1016
1017 void BranchInstr::EmitBranchOnCondition(FlowGraphCompiler* compiler, 1017 void BranchInstr::EmitBranchOnCondition(FlowGraphCompiler* compiler,
1018 Condition true_condition) { 1018 Condition true_condition) {
1019 if (is_negated()) {
1020 true_condition = NegateCondition(true_condition);
1021 }
1019 if (compiler->IsNextBlock(false_successor())) { 1022 if (compiler->IsNextBlock(false_successor())) {
1020 // If the next block is the false successor we will fall through to it. 1023 // If the next block is the false successor we will fall through to it.
1021 __ j(true_condition, compiler->GetBlockLabel(true_successor())); 1024 __ j(true_condition, compiler->GetBlockLabel(true_successor()));
1022 } else { 1025 } else {
1023 // If the next block is the true successor we negate comparison and fall 1026 // If the next block is the true successor we negate comparison and fall
1024 // through to it. 1027 // through to it.
1025 ASSERT(compiler->IsNextBlock(true_successor())); 1028 ASSERT(compiler->IsNextBlock(true_successor()));
1026 Condition false_condition = NegateCondition(true_condition); 1029 Condition false_condition = NegateCondition(true_condition);
1027 __ j(false_condition, compiler->GetBlockLabel(false_successor())); 1030 __ j(false_condition, compiler->GetBlockLabel(false_successor()));
1028 } 1031 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 1067
1065 1068
1066 void StrictCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1069 void StrictCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1067 Register left = locs()->in(0).reg(); 1070 Register left = locs()->in(0).reg();
1068 Register right = locs()->in(1).reg(); 1071 Register right = locs()->in(1).reg();
1069 1072
1070 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); 1073 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
1071 Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQUAL : NOT_EQUAL; 1074 Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQUAL : NOT_EQUAL;
1072 __ CompareRegisters(left, right); 1075 __ CompareRegisters(left, right);
1073 1076
1074 if (!is_fused_with_branch()) { 1077 if (is_fused_with_branch()) {
1078 fused_with_branch()->EmitBranchOnCondition(compiler, true_condition);
1079 } else {
1075 Register result = locs()->out().reg(); 1080 Register result = locs()->out().reg();
1076 Label load_true, done; 1081 Label load_true, done;
1077 __ j(true_condition, &load_true, Assembler::kNearJump); 1082 __ j(true_condition, &load_true, Assembler::kNearJump);
1078 __ LoadObject(result, compiler->bool_false()); 1083 __ LoadObject(result, compiler->bool_false());
1079 __ jmp(&done, Assembler::kNearJump); 1084 __ jmp(&done, Assembler::kNearJump);
1080 __ Bind(&load_true); 1085 __ Bind(&load_true);
1081 __ LoadObject(result, compiler->bool_true()); 1086 __ LoadObject(result, compiler->bool_true());
1082 __ Bind(&done); 1087 __ Bind(&done);
1083 } else {
1084 fused_with_branch()->EmitBranchOnCondition(compiler, true_condition);
1085 } 1088 }
1086 } 1089 }
1087 1090
1088 1091
1089 void ClosureCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1092 void ClosureCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1090 ASSERT(VerifyCallComputation(this)); 1093 ASSERT(VerifyCallComputation(this));
1091 // The arguments to the stub include the closure. The arguments 1094 // The arguments to the stub include the closure. The arguments
1092 // descriptor describes the closure's arguments (and so does not include 1095 // descriptor describes the closure's arguments (and so does not include
1093 // the closure). 1096 // the closure).
1094 Register temp_reg = locs()->temp(0).reg(); 1097 Register temp_reg = locs()->temp(0).reg();
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); 1282 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint());
1280 compiler->GenerateCall(token_index(), try_index(), &label, 1283 compiler->GenerateCall(token_index(), try_index(), &label,
1281 PcDescriptors::kOther); 1284 PcDescriptors::kOther);
1282 __ Drop(2); // Discard type arguments and receiver. 1285 __ Drop(2); // Discard type arguments and receiver.
1283 } 1286 }
1284 1287
1285 1288
1286 #undef __ 1289 #undef __
1287 1290
1288 } // namespace dart 1291 } // namespace dart
OLDNEW
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698