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

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

Issue 1913663002: vm: Generate 'and' instruction for Smi values. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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
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 _IntegerImplementation { 5 abstract class _IntegerImplementation {
6 // The Dart class _Bigint extending _IntegerImplementation requires a 6 // The Dart class _Bigint extending _IntegerImplementation requires a
7 // default constructor. 7 // default constructor.
8 8
9 Type get runtimeType => int; 9 Type get runtimeType => int;
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return other._toBigint()._bitOrFromInteger(this); 56 return other._toBigint()._bitOrFromInteger(this);
57 } 57 }
58 int operator ^(int other) { 58 int operator ^(int other) {
59 var result = other._bitXorFromInteger(this); 59 var result = other._bitXorFromInteger(this);
60 if (result != null) return result; 60 if (result != null) return result;
61 return other._toBigint()._bitXorFromInteger(this); 61 return other._toBigint()._bitXorFromInteger(this);
62 } 62 }
63 num remainder(num other) { 63 num remainder(num other) {
64 return other._remainderFromInteger(this); 64 return other._remainderFromInteger(this);
65 } 65 }
66 int _bitAndFromSmi(int other) native "Integer_bitAndFromInteger";
66 int _bitAndFromInteger(int other) native "Integer_bitAndFromInteger"; 67 int _bitAndFromInteger(int other) native "Integer_bitAndFromInteger";
67 int _bitOrFromInteger(int other) native "Integer_bitOrFromInteger"; 68 int _bitOrFromInteger(int other) native "Integer_bitOrFromInteger";
68 int _bitXorFromInteger(int other) native "Integer_bitXorFromInteger"; 69 int _bitXorFromInteger(int other) native "Integer_bitXorFromInteger";
69 int _addFromInteger(int other) native "Integer_addFromInteger"; 70 int _addFromInteger(int other) native "Integer_addFromInteger";
70 int _subFromInteger(int other) native "Integer_subFromInteger"; 71 int _subFromInteger(int other) native "Integer_subFromInteger";
71 int _mulFromInteger(int other) native "Integer_mulFromInteger"; 72 int _mulFromInteger(int other) native "Integer_mulFromInteger";
72 int _truncDivFromInteger(int other) native "Integer_truncDivFromInteger"; 73 int _truncDivFromInteger(int other) native "Integer_truncDivFromInteger";
73 int _moduloFromInteger(int other) native "Integer_moduloFromInteger"; 74 int _moduloFromInteger(int other) native "Integer_moduloFromInteger";
74 int _remainderFromInteger(int other) { 75 int _remainderFromInteger(int other) {
75 return other - (other ~/ this) * this; 76 return other - (other ~/ this) * this;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 class _Smi extends _IntegerImplementation implements int { 407 class _Smi extends _IntegerImplementation implements int {
407 factory _Smi._uninstantiable() { 408 factory _Smi._uninstantiable() {
408 throw new UnsupportedError( 409 throw new UnsupportedError(
409 "_Smi can only be allocated by the VM"); 410 "_Smi can only be allocated by the VM");
410 } 411 }
411 int get _identityHashCode => this; 412 int get _identityHashCode => this;
412 int get hashCode => this; 413 int get hashCode => this;
413 int operator ~() native "Smi_bitNegate"; 414 int operator ~() native "Smi_bitNegate";
414 int get bitLength native "Smi_bitLength"; 415 int get bitLength native "Smi_bitLength";
415 416
417 int operator &(int other) => other._bitAndFromSmi(this);
418
419 int _bitAndFromSmi(int other) native "Smi_bitAndFromSmi";
416 int _shrFromInt(int other) native "Smi_shrFromInt"; 420 int _shrFromInt(int other) native "Smi_shrFromInt";
417 int _shlFromInt(int other) native "Smi_shlFromInt"; 421 int _shlFromInt(int other) native "Smi_shlFromInt";
418 422
419 /** 423 /**
420 * The digits of '00', '01', ... '99' as a single array. 424 * The digits of '00', '01', ... '99' as a single array.
421 * 425 *
422 * Get the digits of `n`, with `0 <= n < 100`, as 426 * Get the digits of `n`, with `0 <= n < 100`, as
423 * `_digitTable[n * 2]` and `_digitTable[n * 2 + 1]`. 427 * `_digitTable[n * 2]` and `_digitTable[n * 2 + 1]`.
424 */ 428 */
425 static const _digitTable = const [ 429 static const _digitTable = const [
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 class _Mint extends _IntegerImplementation implements int { 607 class _Mint extends _IntegerImplementation implements int {
604 factory _Mint._uninstantiable() { 608 factory _Mint._uninstantiable() {
605 throw new UnsupportedError( 609 throw new UnsupportedError(
606 "_Mint can only be allocated by the VM"); 610 "_Mint can only be allocated by the VM");
607 } 611 }
608 int get _identityHashCode => this; 612 int get _identityHashCode => this;
609 int get hashCode => this; 613 int get hashCode => this;
610 int operator ~() native "Mint_bitNegate"; 614 int operator ~() native "Mint_bitNegate";
611 int get bitLength native "Mint_bitLength"; 615 int get bitLength native "Mint_bitLength";
612 616
617 int _bitAndFromSmi(int other) => _bitAndFromInteger(other);
618
613 // Shift by mint exceeds range that can be handled by the VM. 619 // Shift by mint exceeds range that can be handled by the VM.
614 int _shrFromInt(int other) { 620 int _shrFromInt(int other) {
615 if (other < 0) { 621 if (other < 0) {
616 return -1; 622 return -1;
617 } else { 623 } else {
618 return 0; 624 return 0;
619 } 625 }
620 } 626 }
621 int _shlFromInt(int other) native "Mint_shlFromInt"; 627 int _shlFromInt(int other) native "Mint_shlFromInt";
622 } 628 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698