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

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: xxx Created 4 years, 6 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 | « runtime/lib/integers.cc ('k') | runtime/vm/bootstrap_natives.h » ('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 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 class _Smi extends _IntegerImplementation implements int { 406 class _Smi extends _IntegerImplementation implements int {
406 factory _Smi._uninstantiable() { 407 factory _Smi._uninstantiable() {
407 throw new UnsupportedError( 408 throw new UnsupportedError(
408 "_Smi can only be allocated by the VM"); 409 "_Smi can only be allocated by the VM");
409 } 410 }
410 int get _identityHashCode => this; 411 int get _identityHashCode => this;
411 int get hashCode => this; 412 int get hashCode => this;
412 int operator ~() native "Smi_bitNegate"; 413 int operator ~() native "Smi_bitNegate";
413 int get bitLength native "Smi_bitLength"; 414 int get bitLength native "Smi_bitLength";
414 415
416 int operator &(int other) => other._bitAndFromSmi(this);
417
418 int _bitAndFromSmi(int other) native "Smi_bitAndFromSmi";
415 int _shrFromInt(int other) native "Smi_shrFromInt"; 419 int _shrFromInt(int other) native "Smi_shrFromInt";
416 int _shlFromInt(int other) native "Smi_shlFromInt"; 420 int _shlFromInt(int other) native "Smi_shlFromInt";
417 421
418 /** 422 /**
419 * The digits of '00', '01', ... '99' as a single array. 423 * The digits of '00', '01', ... '99' as a single array.
420 * 424 *
421 * Get the digits of `n`, with `0 <= n < 100`, as 425 * Get the digits of `n`, with `0 <= n < 100`, as
422 * `_digitTable[n * 2]` and `_digitTable[n * 2 + 1]`. 426 * `_digitTable[n * 2]` and `_digitTable[n * 2 + 1]`.
423 */ 427 */
424 static const _digitTable = const [ 428 static const _digitTable = const [
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 class _Mint extends _IntegerImplementation implements int { 606 class _Mint extends _IntegerImplementation implements int {
603 factory _Mint._uninstantiable() { 607 factory _Mint._uninstantiable() {
604 throw new UnsupportedError( 608 throw new UnsupportedError(
605 "_Mint can only be allocated by the VM"); 609 "_Mint can only be allocated by the VM");
606 } 610 }
607 int get _identityHashCode => this; 611 int get _identityHashCode => this;
608 int get hashCode => this; 612 int get hashCode => this;
609 int operator ~() native "Mint_bitNegate"; 613 int operator ~() native "Mint_bitNegate";
610 int get bitLength native "Mint_bitLength"; 614 int get bitLength native "Mint_bitLength";
611 615
616 int _bitAndFromSmi(int other) => _bitAndFromInteger(other);
617
612 // Shift by mint exceeds range that can be handled by the VM. 618 // Shift by mint exceeds range that can be handled by the VM.
613 int _shrFromInt(int other) { 619 int _shrFromInt(int other) {
614 if (other < 0) { 620 if (other < 0) {
615 return -1; 621 return -1;
616 } else { 622 } else {
617 return 0; 623 return 0;
618 } 624 }
619 } 625 }
620 int _shlFromInt(int other) native "Mint_shlFromInt"; 626 int _shlFromInt(int other) native "Mint_shlFromInt";
621 } 627 }
OLDNEW
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698