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

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

Issue 348623004: Double constants in code should be canonical. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
« 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 } else if ((from == kTagged) && (to == kUnboxedDouble)) { 632 } else if ((from == kTagged) && (to == kUnboxedDouble)) {
633 ASSERT(CanUnboxDouble()); 633 ASSERT(CanUnboxDouble());
634 ASSERT((deopt_target != NULL) || 634 ASSERT((deopt_target != NULL) ||
635 (use->Type()->ToCid() == kDoubleCid)); 635 (use->Type()->ToCid() == kDoubleCid));
636 const intptr_t deopt_id = (deopt_target != NULL) ? 636 const intptr_t deopt_id = (deopt_target != NULL) ?
637 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; 637 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId;
638 ConstantInstr* constant = use->definition()->AsConstant(); 638 ConstantInstr* constant = use->definition()->AsConstant();
639 if ((constant != NULL) && constant->value().IsSmi()) { 639 if ((constant != NULL) && constant->value().IsSmi()) {
640 const double dbl_val = Smi::Cast(constant->value()).AsDoubleValue(); 640 const double dbl_val = Smi::Cast(constant->value()).AsDoubleValue();
641 const Double& dbl_obj = 641 const Double& dbl_obj =
642 Double::ZoneHandle(I, Double::New(dbl_val, Heap::kOld)); 642 Double::ZoneHandle(I, Double::NewCanonical(dbl_val));
643 ConstantInstr* double_const = flow_graph()->GetConstant(dbl_obj); 643 ConstantInstr* double_const = flow_graph()->GetConstant(dbl_obj);
644 converted = new(I) UnboxDoubleInstr(new(I) Value(double_const), deopt_id); 644 converted = new(I) UnboxDoubleInstr(new(I) Value(double_const), deopt_id);
645 } else { 645 } else {
646 converted = new(I) UnboxDoubleInstr(use->CopyWithType(), deopt_id); 646 converted = new(I) UnboxDoubleInstr(use->CopyWithType(), deopt_id);
647 } 647 }
648 } else if ((from == kTagged) && (to == kUnboxedFloat32x4)) { 648 } else if ((from == kTagged) && (to == kUnboxedFloat32x4)) {
649 ASSERT((deopt_target != NULL) || 649 ASSERT((deopt_target != NULL) ||
650 (use->Type()->ToCid() == kFloat32x4Cid)); 650 (use->Type()->ToCid() == kFloat32x4Cid));
651 const intptr_t deopt_id = (deopt_target != NULL) ? 651 const intptr_t deopt_id = (deopt_target != NULL) ?
652 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; 652 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId;
(...skipping 9150 matching lines...) Expand 10 before | Expand all | Expand 10 after
9803 } 9803 }
9804 9804
9805 // Insert materializations at environment uses. 9805 // Insert materializations at environment uses.
9806 for (intptr_t i = 0; i < exits.length(); i++) { 9806 for (intptr_t i = 0; i < exits.length(); i++) {
9807 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); 9807 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots);
9808 } 9808 }
9809 } 9809 }
9810 9810
9811 9811
9812 } // namespace dart 9812 } // 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