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

Side by Side Diff: runtime/lib/integers.dart

Issue 2794583002: Revert "Reland "VM: Handle null-comparisons in the flow graph type propagation"" (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | runtime/vm/flow_graph.cc » ('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 // This marker interface represents 64-bit integers in the compiler for type
6 // propagation and range analysis. It is implemented by _Smi and _Mint.
7 abstract class _int64 implements int {}
8
9 abstract class _IntegerImplementation { 5 abstract class _IntegerImplementation {
10 // The Dart class _Bigint extending _IntegerImplementation requires a 6 // The Dart class _Bigint extending _IntegerImplementation requires a
11 // default constructor. 7 // default constructor.
12 8
13 num operator +(num other) { 9 num operator +(num other) {
14 var result = other._addFromInteger(this); 10 var result = other._addFromInteger(this);
15 if (result != null) return result; 11 if (result != null) return result;
16 return other._toBigint()._addFromInteger(this); 12 return other._toBigint()._addFromInteger(this);
17 } 13 }
18 14
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (x == 0) return y; 447 if (x == 0) return y;
452 if (y == 0) return x; 448 if (y == 0) return x;
453 if ((x == 1) || (y == 1)) return 1; 449 if ((x == 1) || (y == 1)) return 1;
454 if (y is _Bigint) { 450 if (y is _Bigint) {
455 return x._toBigint().gcd(y); 451 return x._toBigint().gcd(y);
456 } 452 }
457 return _binaryGcd(x, y, false); 453 return _binaryGcd(x, y, false);
458 } 454 }
459 } 455 }
460 456
461 class _Smi extends _IntegerImplementation implements int, _int64 { 457 class _Smi extends _IntegerImplementation implements int {
462 factory _Smi._uninstantiable() { 458 factory _Smi._uninstantiable() {
463 throw new UnsupportedError("_Smi can only be allocated by the VM"); 459 throw new UnsupportedError("_Smi can only be allocated by the VM");
464 } 460 }
465 int get hashCode => this; 461 int get hashCode => this;
466 int get _identityHashCode => this; 462 int get _identityHashCode => this;
467 int operator ~() native "Smi_bitNegate"; 463 int operator ~() native "Smi_bitNegate";
468 int get bitLength native "Smi_bitLength"; 464 int get bitLength native "Smi_bitLength";
469 465
470 int operator &(int other) => other._bitAndFromSmi(this); 466 int operator &(int other) => other._bitAndFromSmi(this);
471 467
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 // No remainder necessary for this case. 647 // No remainder necessary for this case.
652 int digitIndex = -negSmi * 2; 648 int digitIndex = -negSmi * 2;
653 result._setAt(index, _digitTable[digitIndex + 1]); 649 result._setAt(index, _digitTable[digitIndex + 1]);
654 result._setAt(index - 1, _digitTable[digitIndex]); 650 result._setAt(index - 1, _digitTable[digitIndex]);
655 } 651 }
656 return result; 652 return result;
657 } 653 }
658 } 654 }
659 655
660 // Represents integers that cannot be represented by Smi but fit into 64bits. 656 // Represents integers that cannot be represented by Smi but fit into 64bits.
661 class _Mint extends _IntegerImplementation implements int, _int64 { 657 class _Mint extends _IntegerImplementation implements int {
662 factory _Mint._uninstantiable() { 658 factory _Mint._uninstantiable() {
663 throw new UnsupportedError("_Mint can only be allocated by the VM"); 659 throw new UnsupportedError("_Mint can only be allocated by the VM");
664 } 660 }
665 int get hashCode => this; 661 int get hashCode => this;
666 int get _identityHashCode => this; 662 int get _identityHashCode => this;
667 int operator ~() native "Mint_bitNegate"; 663 int operator ~() native "Mint_bitNegate";
668 int get bitLength native "Mint_bitLength"; 664 int get bitLength native "Mint_bitLength";
669 665
670 int _bitAndFromSmi(int other) => _bitAndFromInteger(other); 666 int _bitAndFromSmi(int other) => _bitAndFromInteger(other);
671 667
672 // Shift by mint exceeds range that can be handled by the VM. 668 // Shift by mint exceeds range that can be handled by the VM.
673 int _shrFromInt(int other) { 669 int _shrFromInt(int other) {
674 if (other < 0) { 670 if (other < 0) {
675 return -1; 671 return -1;
676 } else { 672 } else {
677 return 0; 673 return 0;
678 } 674 }
679 } 675 }
680 676
681 int _shlFromInt(int other) native "Mint_shlFromInt"; 677 int _shlFromInt(int other) native "Mint_shlFromInt";
682 } 678 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698