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

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

Issue 11573044: Inline Doubles truncate and round. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.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 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 1220
1221 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && 1221 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) &&
1222 (class_ids[0] == kSmiCid)) { 1222 (class_ids[0] == kSmiCid)) {
1223 SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call); 1223 SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call);
1224 call->ReplaceWith(s2d_instr, current_iterator()); 1224 call->ReplaceWith(s2d_instr, current_iterator());
1225 // Pushed arguments are not removed because SmiToDouble is implemented 1225 // Pushed arguments are not removed because SmiToDouble is implemented
1226 // as a call. 1226 // as a call.
1227 return true; 1227 return true;
1228 } 1228 }
1229 1229
1230 if ((recognized_kind == MethodRecognizer::kDoubleToInteger) && 1230 if (class_ids[0] == kDoubleCid) {
1231 (class_ids[0] == kDoubleCid)) { 1231 if (recognized_kind == MethodRecognizer::kDoubleToInteger) {
1232 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); 1232 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy());
1233 ASSERT(call->HasICData()); 1233 ASSERT(call->HasICData());
1234 const ICData& ic_data = *call->ic_data(); 1234 const ICData& ic_data = *call->ic_data();
1235 Definition* d2i_instr = NULL; 1235 Definition* d2i_instr = NULL;
1236 if (ic_data.deopt_reason() == kDeoptDoubleToSmi) { 1236 if (ic_data.deopt_reason() == kDeoptDoubleToSmi) {
1237 // Do not repeatedly deoptimize because result didn't fit into Smi. 1237 // Do not repeatedly deoptimize because result didn't fit into Smi.
1238 d2i_instr = new DoubleToIntegerInstr(call->ArgumentAt(0)->value(), call); 1238 d2i_instr = new DoubleToIntegerInstr(call->ArgumentAt(0)->value(),
1239 } else { 1239 call);
1240 // Optimistically assume result fits into Smi. 1240 } else {
1241 d2i_instr = new DoubleToSmiInstr(call->ArgumentAt(0)->value(), call); 1241 // Optimistically assume result fits into Smi.
1242 d2i_instr = new DoubleToSmiInstr(call->ArgumentAt(0)->value(), call);
1243 }
1244 call->ReplaceWith(d2i_instr, current_iterator());
1245 RemovePushArguments(call);
1246 return true;
1242 } 1247 }
1243 call->ReplaceWith(d2i_instr, current_iterator()); 1248 if ((recognized_kind == MethodRecognizer::kDoubleTruncate) ||
1244 RemovePushArguments(call); 1249 (recognized_kind == MethodRecognizer::kDoubleRound)) {
1245 return true; 1250 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy());
1251 DoubleToDoubleInstr* d2d_instr =
1252 new DoubleToDoubleInstr(call->ArgumentAt(0)->value(),
1253 call,
1254 recognized_kind);
1255 call->ReplaceWith(d2d_instr, current_iterator());
1256 RemovePushArguments(call);
1257 return true;
1258 }
1246 } 1259 }
1247 1260
1248 return false; 1261 return false;
1249 } 1262 }
1250 1263
1251 1264
1252 // TODO(srdjan): Use ICData to check if always true or false. 1265 // TODO(srdjan): Use ICData to check if always true or false.
1253 void FlowGraphOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) { 1266 void FlowGraphOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) {
1254 ASSERT(Token::IsTypeTestOperator(call->token_kind())); 1267 ASSERT(Token::IsTypeTestOperator(call->token_kind()));
1255 Value* left_val = call->ArgumentAt(0)->value(); 1268 Value* left_val = call->ArgumentAt(0)->value();
(...skipping 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after
4150 SetValue(instr, non_constant_); 4163 SetValue(instr, non_constant_);
4151 } 4164 }
4152 4165
4153 4166
4154 void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* instr) { 4167 void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* instr) {
4155 // TODO(kmillikin): Handle conversion. 4168 // TODO(kmillikin): Handle conversion.
4156 SetValue(instr, non_constant_); 4169 SetValue(instr, non_constant_);
4157 } 4170 }
4158 4171
4159 4172
4173 void ConstantPropagator::VisitDoubleToDouble(DoubleToDoubleInstr* instr) {
4174 // TODO(kmillikin): Handle conversion.
4175 SetValue(instr, non_constant_);
4176 }
4177
4178
4160 void ConstantPropagator::VisitConstant(ConstantInstr* instr) { 4179 void ConstantPropagator::VisitConstant(ConstantInstr* instr) {
4161 SetValue(instr, instr->value()); 4180 SetValue(instr, instr->value());
4162 } 4181 }
4163 4182
4164 4183
4165 void ConstantPropagator::VisitConstraint(ConstraintInstr* instr) { 4184 void ConstantPropagator::VisitConstraint(ConstraintInstr* instr) {
4166 // Should not be used outside of range analysis. 4185 // Should not be used outside of range analysis.
4167 UNREACHABLE(); 4186 UNREACHABLE();
4168 } 4187 }
4169 4188
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
4377 4396
4378 if (FLAG_trace_constant_propagation) { 4397 if (FLAG_trace_constant_propagation) {
4379 OS::Print("\n==== After constant propagation ====\n"); 4398 OS::Print("\n==== After constant propagation ====\n");
4380 FlowGraphPrinter printer(*graph_); 4399 FlowGraphPrinter printer(*graph_);
4381 printer.PrintBlocks(); 4400 printer.PrintBlocks();
4382 } 4401 }
4383 } 4402 }
4384 4403
4385 4404
4386 } // namespace dart 4405 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698