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

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

Issue 12218181: Recognize pattern (a << b) & c with c being a positive Smi and allow left shift to truncate the res… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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) 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/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/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 129
130 bool StrictCompareInstr::AttributesEqual(Instruction* other) const { 130 bool StrictCompareInstr::AttributesEqual(Instruction* other) const {
131 StrictCompareInstr* other_op = other->AsStrictCompare(); 131 StrictCompareInstr* other_op = other->AsStrictCompare();
132 ASSERT(other_op != NULL); 132 ASSERT(other_op != NULL);
133 return kind() == other_op->kind(); 133 return kind() == other_op->kind();
134 } 134 }
135 135
136 136
137 bool BinarySmiOpInstr::AttributesEqual(Instruction* other) const { 137 bool BinarySmiOpInstr::AttributesEqual(Instruction* other) const {
138 BinarySmiOpInstr* other_op = other->AsBinarySmiOp(); 138 BinarySmiOpInstr* other_op = other->AsBinarySmiOp();
Vyacheslav Egorov (Google) 2013/02/20 00:37:06 I think this should check for equality of the trun
srdjan 2013/02/21 00:47:17 Done.
139 ASSERT(other_op != NULL); 139 ASSERT(other_op != NULL);
140 return (op_kind() == other_op->op_kind()) && 140 return (op_kind() == other_op->op_kind()) &&
141 (overflow_ == other_op->overflow_); 141 (overflow_ == other_op->overflow_);
142 } 142 }
143 143
144 144
145 bool LoadFieldInstr::AttributesEqual(Instruction* other) const { 145 bool LoadFieldInstr::AttributesEqual(Instruction* other) const {
146 LoadFieldInstr* other_load = other->AsLoadField(); 146 LoadFieldInstr* other_load = other->AsLoadField();
147 ASSERT(other_load != NULL); 147 ASSERT(other_load != NULL);
148 ASSERT((offset_in_bytes() != other_load->offset_in_bytes()) || 148 ASSERT((offset_in_bytes() != other_load->offset_in_bytes()) ||
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 case Token::kBIT_AND: 843 case Token::kBIT_AND:
844 case Token::kBIT_OR: 844 case Token::kBIT_OR:
845 case Token::kBIT_XOR: 845 case Token::kBIT_XOR:
846 return false; 846 return false;
847 case Token::kSHR: { 847 case Token::kSHR: {
848 // Can't deopt if shift-count is known positive. 848 // Can't deopt if shift-count is known positive.
849 Range* right_range = this->right()->definition()->range(); 849 Range* right_range = this->right()->definition()->range();
850 return (right_range == NULL) 850 return (right_range == NULL)
851 || !right_range->IsWithin(0, RangeBoundary::kPlusInfinity); 851 || !right_range->IsWithin(0, RangeBoundary::kPlusInfinity);
852 } 852 }
853 case Token::kSHL: {
854 Range* right_range = this->right()->definition()->range();
855 if ((right_range != NULL) && is_truncating()) {
856 // Can deoptimize if right can be negative.
857 return !right_range->IsWithin(0, RangeBoundary::kPlusInfinity);
858 }
859 return overflow_;
Vyacheslav Egorov (Google) 2013/02/20 00:37:06 I think this can be just return true;
srdjan 2013/02/21 00:47:17 Done.
860 }
853 default: 861 default:
854 return overflow_; 862 return overflow_;
855 } 863 }
856 } 864 }
857 865
858 866
859 bool BinarySmiOpInstr::RightIsPowerOfTwoConstant() const { 867 bool BinarySmiOpInstr::RightIsPowerOfTwoConstant() const {
860 if (!right()->definition()->IsConstant()) return false; 868 if (!right()->definition()->IsConstant()) return false;
861 const Object& constant = right()->definition()->AsConstant()->value(); 869 const Object& constant = right()->definition()->AsConstant()->value();
862 if (!constant.IsSmi()) return false; 870 if (!constant.IsSmi()) return false;
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2201 default: 2209 default:
2202 UNREACHABLE(); 2210 UNREACHABLE();
2203 } 2211 }
2204 return kPowRuntimeEntry; 2212 return kPowRuntimeEntry;
2205 } 2213 }
2206 2214
2207 2215
2208 #undef __ 2216 #undef __
2209 2217
2210 } // namespace dart 2218 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698