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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart

Issue 17569004: Implement hashCode on objects stored in a set or used as map keys. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased on CL 17588005. Created 7 years, 5 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 part of ssa; 5 part of ssa;
6 6
7 7
8 class ValueRangeInfo { 8 class ValueRangeInfo {
9 final ConstantSystem constantSystem; 9 final ConstantSystem constantSystem;
10 10
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 Value max(other) { 141 Value max(other) {
142 if (other is !IntValue) return other.max(this); 142 if (other is !IntValue) return other.max(this);
143 return this.value < other.value ? other : this; 143 return this.value < other.value ? other : this;
144 } 144 }
145 145
146 bool operator ==(other) { 146 bool operator ==(other) {
147 if (other is !IntValue) return false; 147 if (other is !IntValue) return false;
148 return this.value == other.value; 148 return this.value == other.value;
149 } 149 }
150 150
151 int get hashCode => throw new UnsupportedError('IntValue.hashCode');
ngeoffray 2013/06/24 19:43:10 Changes in this file tend to show that it's not so
ahe 2013/06/24 20:18:54 You'd still get a warning. The rule is simple bec
sra1 2013/06/25 03:33:38 I don't like the changes in this file. There is n
ahe 2013/06/25 05:24:58 I find it peculiar that you would use this particu
152
151 String toString() => 'IntValue $value'; 153 String toString() => 'IntValue $value';
152 bool get isNegative => value < 0; 154 bool get isNegative => value < 0;
153 bool get isPositive => value >= 0; 155 bool get isPositive => value >= 0;
154 bool get isZero => value == 0; 156 bool get isZero => value == 0;
155 } 157 }
156 158
157 /** 159 /**
158 * The [MaxIntValue] represents the maximum value an integer can have, 160 * The [MaxIntValue] represents the maximum value an integer can have,
159 * which is currently +infinity. 161 * which is currently +infinity.
160 */ 162 */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 */ 209 */
208 class InstructionValue extends Value { 210 class InstructionValue extends Value {
209 final HInstruction instruction; 211 final HInstruction instruction;
210 InstructionValue(this.instruction, info) : super(info); 212 InstructionValue(this.instruction, info) : super(info);
211 213
212 bool operator ==(other) { 214 bool operator ==(other) {
213 if (other is !InstructionValue) return false; 215 if (other is !InstructionValue) return false;
214 return this.instruction == other.instruction; 216 return this.instruction == other.instruction;
215 } 217 }
216 218
219 int get hashCode => throw new UnsupportedError('InstructionValue.hashCode');
220
217 Value operator +(Value other) { 221 Value operator +(Value other) {
218 if (other.isZero) return this; 222 if (other.isZero) return this;
219 if (other is IntValue) { 223 if (other is IntValue) {
220 if (other.isNegative) { 224 if (other.isNegative) {
221 return info.newSubtractValue(this, -other); 225 return info.newSubtractValue(this, -other);
222 } 226 }
223 return info.newAddValue(this, other); 227 return info.newAddValue(this, other);
224 } 228 }
225 if (other is InstructionValue) { 229 if (other is InstructionValue) {
226 return info.newAddValue(this, other); 230 return info.newAddValue(this, other);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 280
277 class AddValue extends BinaryOperationValue { 281 class AddValue extends BinaryOperationValue {
278 AddValue(left, right, info) : super(left, right, info); 282 AddValue(left, right, info) : super(left, right, info);
279 283
280 bool operator ==(other) { 284 bool operator ==(other) {
281 if (other is !AddValue) return false; 285 if (other is !AddValue) return false;
282 return (left == other.left && right == other.right) 286 return (left == other.left && right == other.right)
283 || (left == other.right && right == other.left); 287 || (left == other.right && right == other.left);
284 } 288 }
285 289
290 int get hashCode => throw new UnsupportedError('AddValue.hashCode');
291
286 Value operator -() => -left - right; 292 Value operator -() => -left - right;
287 293
288 Value operator +(Value other) { 294 Value operator +(Value other) {
289 if (other.isZero) return this; 295 if (other.isZero) return this;
290 Value value = left + other; 296 Value value = left + other;
291 if (value != const UnknownValue() && value is! BinaryOperationValue) { 297 if (value != const UnknownValue() && value is! BinaryOperationValue) {
292 return value + right; 298 return value + right;
293 } 299 }
294 // If the result is not simple enough, we try the same approach 300 // If the result is not simple enough, we try the same approach
295 // with [right]. 301 // with [right].
(...skipping 25 matching lines...) Expand all
321 } 327 }
322 328
323 class SubtractValue extends BinaryOperationValue { 329 class SubtractValue extends BinaryOperationValue {
324 SubtractValue(left, right, info) : super(left, right, info); 330 SubtractValue(left, right, info) : super(left, right, info);
325 331
326 bool operator ==(other) { 332 bool operator ==(other) {
327 if (other is !SubtractValue) return false; 333 if (other is !SubtractValue) return false;
328 return left == other.left && right == other.right; 334 return left == other.left && right == other.right;
329 } 335 }
330 336
337 int get hashCode => throw new UnsupportedError('SubtractValue.hashCode');
338
331 Value operator -() => right - left; 339 Value operator -() => right - left;
332 340
333 Value operator +(Value other) { 341 Value operator +(Value other) {
334 if (other.isZero) return this; 342 if (other.isZero) return this;
335 Value value = left + other; 343 Value value = left + other;
336 if (value != const UnknownValue() && value is! BinaryOperationValue) { 344 if (value != const UnknownValue() && value is! BinaryOperationValue) {
337 return value - right; 345 return value - right;
338 } 346 }
339 // If the result is not simple enough, we try the same approach 347 // If the result is not simple enough, we try the same approach
340 // with [right]. 348 // with [right].
(...skipping 26 matching lines...) Expand all
367 375
368 class NegateValue extends Value { 376 class NegateValue extends Value {
369 final Value value; 377 final Value value;
370 NegateValue(this.value, info) : super(info); 378 NegateValue(this.value, info) : super(info);
371 379
372 bool operator ==(other) { 380 bool operator ==(other) {
373 if (other is !NegateValue) return false; 381 if (other is !NegateValue) return false;
374 return value == other.value; 382 return value == other.value;
375 } 383 }
376 384
385 int get hashCode => throw new UnsupportedError('Negate.hashCode');
386
377 Value operator +(other) { 387 Value operator +(other) {
378 if (other.isZero) return this; 388 if (other.isZero) return this;
379 if (other == value) return info.intZero; 389 if (other == value) return info.intZero;
380 if (other is NegateValue) return this - other.value; 390 if (other is NegateValue) return this - other.value;
381 if (other is IntValue) { 391 if (other is IntValue) {
382 if (other.isNegative) { 392 if (other.isNegative) {
383 return info.newSubtractValue(this, -other); 393 return info.newSubtractValue(this, -other);
384 } 394 }
385 return info.newSubtractValue(other, value); 395 return info.newSubtractValue(other, value);
386 } 396 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } else { 509 } else {
500 return info.newUnboundRange(); 510 return info.newUnboundRange();
501 } 511 }
502 } 512 }
503 513
504 bool operator ==(other) { 514 bool operator ==(other) {
505 if (other is! Range) return false; 515 if (other is! Range) return false;
506 return other.lower == lower && other.upper == upper; 516 return other.lower == lower && other.upper == upper;
507 } 517 }
508 518
519 int get hashCode => throw new UnsupportedError('Range.hashCode');
520
509 bool operator <(Range other) { 521 bool operator <(Range other) {
510 return upper != other.lower && upper.min(other.lower) == upper; 522 return upper != other.lower && upper.min(other.lower) == upper;
511 } 523 }
512 524
513 bool operator >(Range other) { 525 bool operator >(Range other) {
514 return lower != other.upper && lower.max(other.upper) == lower; 526 return lower != other.upper && lower.max(other.upper) == lower;
515 } 527 }
516 528
517 bool operator <=(Range other) { 529 bool operator <=(Range other) {
518 return upper.min(other.lower) == upper; 530 return upper.min(other.lower) == upper;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 if (instruction is HPhi && !instruction.block.isLoopHeader()) { 998 if (instruction is HPhi && !instruction.block.isLoopHeader()) {
987 HInstruction result = unwrap(instruction.inputs[0]); 999 HInstruction result = unwrap(instruction.inputs[0]);
988 for (int i = 1; i < instruction.inputs.length; i++) { 1000 for (int i = 1; i < instruction.inputs.length; i++) {
989 if (result != unwrap(instruction.inputs[i])) return instruction; 1001 if (result != unwrap(instruction.inputs[i])) return instruction;
990 } 1002 }
991 return result; 1003 return result;
992 } 1004 }
993 return instruction; 1005 return instruction;
994 } 1006 }
995 } 1007 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698