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

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

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

Powered by Google App Engine
This is Rietveld 408576698