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

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

Issue 11645006: UnboxDouble: convert smi constants to doubles at compile time instead of at runtime. (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 | « no previous file | no next file » | 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 InsertBefore(instr, boxed, NULL, Definition::kValue); 185 InsertBefore(instr, boxed, NULL, Definition::kValue);
186 const intptr_t deopt_id = (deopt_target != NULL) ? 186 const intptr_t deopt_id = (deopt_target != NULL) ?
187 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; 187 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId;
188 converted = new UnboxDoubleInstr(new Value(boxed), deopt_id); 188 converted = new UnboxDoubleInstr(new Value(boxed), deopt_id);
189 } else if ((from == kUnboxedDouble) && (to == kTagged)) { 189 } else if ((from == kUnboxedDouble) && (to == kTagged)) {
190 converted = new BoxDoubleInstr(new Value(def), NULL); 190 converted = new BoxDoubleInstr(new Value(def), NULL);
191 } else if ((from == kTagged) && (to == kUnboxedDouble)) { 191 } else if ((from == kTagged) && (to == kUnboxedDouble)) {
192 const intptr_t deopt_id = (deopt_target != NULL) ? 192 const intptr_t deopt_id = (deopt_target != NULL) ?
193 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; 193 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId;
194 ASSERT((deopt_target != NULL) || (def->GetPropagatedCid() == kDoubleCid)); 194 ASSERT((deopt_target != NULL) || (def->GetPropagatedCid() == kDoubleCid));
195 converted = new UnboxDoubleInstr(new Value(def), deopt_id); 195 if (def->IsConstant() && def->AsConstant()->value().IsSmi()) {
196 const double dbl_val =
197 Smi::Cast(def->AsConstant()->value()).AsDoubleValue();
198 const Double& dbl_obj =
199 Double::ZoneHandle(Double::New(dbl_val, Heap::kOld));
200 ConstantInstr* double_const = new ConstantInstr(dbl_obj);
201 InsertBefore(instr, double_const, NULL, Definition::kValue);
202 converted = new UnboxDoubleInstr(new Value(double_const), deopt_id);
203 } else {
204 converted = new UnboxDoubleInstr(new Value(def), deopt_id);
205 }
196 } 206 }
197 ASSERT(converted != NULL); 207 ASSERT(converted != NULL);
198 InsertBefore(instr, converted, use->instruction()->env(), 208 InsertBefore(instr, converted, use->instruction()->env(),
199 Definition::kValue); 209 Definition::kValue);
200 use->set_definition(converted); 210 use->set_definition(converted);
201 } 211 }
202 212
203 213
204 void FlowGraphOptimizer::InsertConversionsFor(Definition* def) { 214 void FlowGraphOptimizer::InsertConversionsFor(Definition* def) {
205 const Representation from_rep = def->representation(); 215 const Representation from_rep = def->representation();
(...skipping 4077 matching lines...) Expand 10 before | Expand all | Expand 10 after
4283 4293
4284 if (FLAG_trace_constant_propagation) { 4294 if (FLAG_trace_constant_propagation) {
4285 OS::Print("\n==== After constant propagation ====\n"); 4295 OS::Print("\n==== After constant propagation ====\n");
4286 FlowGraphPrinter printer(*graph_); 4296 FlowGraphPrinter printer(*graph_);
4287 printer.PrintBlocks(); 4297 printer.PrintBlocks();
4288 } 4298 }
4289 } 4299 }
4290 4300
4291 4301
4292 } // namespace dart 4302 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698