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

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

Issue 11568044: Add DoubleToSmi optimistically, preventing boxing/unboxing of doubles and propagate smi-nessof the … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/code_generator.h ('k') | runtime/vm/intermediate_language.h » ('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/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 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call); 1196 SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call);
1197 call->ReplaceWith(s2d_instr, current_iterator()); 1197 call->ReplaceWith(s2d_instr, current_iterator());
1198 // Pushed arguments are not removed because SmiToDouble is implemented 1198 // Pushed arguments are not removed because SmiToDouble is implemented
1199 // as a call. 1199 // as a call.
1200 return true; 1200 return true;
1201 } 1201 }
1202 1202
1203 if ((recognized_kind == MethodRecognizer::kDoubleToInteger) && 1203 if ((recognized_kind == MethodRecognizer::kDoubleToInteger) &&
1204 (class_ids[0] == kDoubleCid)) { 1204 (class_ids[0] == kDoubleCid)) {
1205 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); 1205 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy());
1206 DoubleToIntegerInstr* d2int_instr = 1206 ASSERT(call->HasICData());
1207 new DoubleToIntegerInstr(call->ArgumentAt(0)->value(), call); 1207 const ICData& ic_data = *call->ic_data();
1208 call->ReplaceWith(d2int_instr, current_iterator()); 1208 Definition* d2i_instr = NULL;
1209 if (ic_data.deopt_reason() == kDeoptDoubleToSmi) {
1210 // Do not repeatedly deoptimize because result didn't fit into Smi.
1211 d2i_instr = new DoubleToIntegerInstr(call->ArgumentAt(0)->value(), call);
1212 } else {
1213 // Optimistically assume result fits into Smi.
1214 d2i_instr = new DoubleToSmiInstr(call->ArgumentAt(0)->value(), call);
1215 }
1216 call->ReplaceWith(d2i_instr, current_iterator());
1209 RemovePushArguments(call); 1217 RemovePushArguments(call);
1210 return true; 1218 return true;
1211 } 1219 }
1212 1220
1213 return false; 1221 return false;
1214 } 1222 }
1215 1223
1216 1224
1217 // Tries to optimize instance call by replacing it with a faster instruction 1225 // Tries to optimize instance call by replacing it with a faster instruction
1218 // (e.g, binary op, field load, ..). 1226 // (e.g, binary op, field load, ..).
(...skipping 2821 matching lines...) Expand 10 before | Expand all | Expand 10 after
4040 SetValue(instr, non_constant_); 4048 SetValue(instr, non_constant_);
4041 } 4049 }
4042 4050
4043 4051
4044 void ConstantPropagator::VisitDoubleToInteger(DoubleToIntegerInstr* instr) { 4052 void ConstantPropagator::VisitDoubleToInteger(DoubleToIntegerInstr* instr) {
4045 // TODO(kmillikin): Handle conversion. 4053 // TODO(kmillikin): Handle conversion.
4046 SetValue(instr, non_constant_); 4054 SetValue(instr, non_constant_);
4047 } 4055 }
4048 4056
4049 4057
4058 void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* instr) {
4059 // TODO(kmillikin): Handle conversion.
4060 SetValue(instr, non_constant_);
4061 }
4062
4063
4050 void ConstantPropagator::VisitConstant(ConstantInstr* instr) { 4064 void ConstantPropagator::VisitConstant(ConstantInstr* instr) {
4051 SetValue(instr, instr->value()); 4065 SetValue(instr, instr->value());
4052 } 4066 }
4053 4067
4054 4068
4055 void ConstantPropagator::VisitConstraint(ConstraintInstr* instr) { 4069 void ConstantPropagator::VisitConstraint(ConstraintInstr* instr) {
4056 // Should not be used outside of range analysis. 4070 // Should not be used outside of range analysis.
4057 UNREACHABLE(); 4071 UNREACHABLE();
4058 } 4072 }
4059 4073
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
4269 4283
4270 if (FLAG_trace_constant_propagation) { 4284 if (FLAG_trace_constant_propagation) {
4271 OS::Print("\n==== After constant propagation ====\n"); 4285 OS::Print("\n==== After constant propagation ====\n");
4272 FlowGraphPrinter printer(*graph_); 4286 FlowGraphPrinter printer(*graph_);
4273 printer.PrintBlocks(); 4287 printer.PrintBlocks();
4274 } 4288 }
4275 } 4289 }
4276 4290
4277 4291
4278 } // namespace dart 4292 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698