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

Side by Side Diff: tests/language/bit_operations_test.dart

Issue 11085004: Faster 64-bit left-shift for ia32. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments. Created 8 years, 2 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
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Dart test for testing bitwise operations. 4 // Dart test for testing bitwise operations.
5 5
6 class BitOperationsTest { 6 class BitOperationsTest {
7 static testMain() { 7 static testMain() {
8 for (int i = 0; i < 4; i++) { 8 for (int i = 0; i < 4; i++) {
9 testOne(); 9 testOne();
10 } 10 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 Expect.equals(0xF0000000000000000F0, 0xF0000000000000000F << 4); 50 Expect.equals(0xF0000000000000000F0, 0xF0000000000000000F << 4);
51 Expect.equals(0xF00000000, 15 << 32); 51 Expect.equals(0xF00000000, 15 << 32);
52 52
53 TestNegativeValueShifts(); 53 TestNegativeValueShifts();
54 TestPositiveValueShifts(); 54 TestPositiveValueShifts();
55 TestNoMaskingOfShiftCount(); 55 TestNoMaskingOfShiftCount();
56 TestNegativeCountShifts(); 56 TestNegativeCountShifts();
57 for (int i = 0; i < 10000; i++) { 57 for (int i = 0; i < 10000; i++) {
58 TestCornerCasesRightShifts(); 58 TestCornerCasesRightShifts();
59 TestRightShift64Bit(); 59 TestRightShift64Bit();
60 TestLeftShift64Bit();
61 TestLeftShift64BitWithOverflow1();
62 TestLeftShift64BitWithOverflow2();
63 TestLeftShift64BitWithOverflow3();
60 } 64 }
61 } 65 }
62 66
63 static void TestCornerCasesRightShifts() { 67 static void TestCornerCasesRightShifts() {
64 var v32 = 0xFF000000; 68 var v32 = 0xFF000000;
65 var v64 = 0xFF00000000000000; 69 var v64 = 0xFF00000000000000;
66 Expect.equals(0x3, v32 >> 0x1E); 70 Expect.equals(0x3, v32 >> 0x1E);
67 Expect.equals(0x1, v32 >> 0x1F); 71 Expect.equals(0x1, v32 >> 0x1F);
68 Expect.equals(0x0, v32 >> 0x20); 72 Expect.equals(0x0, v32 >> 0x20);
69 Expect.equals(0x3, v64 >> 0x3E); 73 Expect.equals(0x3, v64 >> 0x3E);
70 Expect.equals(0x1, v64 >> 0x3F); 74 Expect.equals(0x1, v64 >> 0x3F);
71 Expect.equals(0x0, v64 >> 0x40); 75 Expect.equals(0x0, v64 >> 0x40);
72 } 76 }
73 77
74 static void TestRightShift64Bit() { 78 static void TestRightShift64Bit() {
75 var t = 0x1ffffffff; 79 var t = 0x1ffffffff;
76 Expect.equals(0xffffffff, t >> 1); 80 Expect.equals(0xffffffff, t >> 1);
77 } 81 }
78 82
83 static void TestLeftShift64Bit() {
84 var t = 0xffffffff;
85 Expect.equals(0xffffffff, t << 0);
86 Expect.equals(0x1fffffffe, t << 1);
87 Expect.equals(0x7fffffff80000000, t << 31);
88 Expect.equals(0x10000000000000000, 2*(t+1) << 31);
89 Expect.equals(0x20000000000000000, 4*(t+1) << 31);
90 Expect.equals(0x8000000000000000, (t+1) << 31);
91 }
92
93 static void TestLeftShift64BitWithOverflow1() {
94 var t = 0xffffffff;
95 Expect.equals(0x10000000000000000, 2*(t+1) << 31);
96 }
97
98 static void TestLeftShift64BitWithOverflow2() {
99 var t = 0xffffffff;
100 Expect.equals(0x20000000000000000, 4*(t+1) << 31);
101 }
102
103 static void TestLeftShift64BitWithOverflow3() {
104 var t = 0xffffffff;
105 Expect.equals(0x8000000000000000, (t+1) << 31);
106 }
107
79 static void TestNegativeCountShifts() { 108 static void TestNegativeCountShifts() {
80 bool throwOnLeft(a, b) { 109 bool throwOnLeft(a, b) {
81 try { 110 try {
82 var x = a << b; 111 var x = a << b;
83 return false; 112 return false;
84 } catch (e) { 113 } catch (e) {
85 return true; 114 return true;
86 } 115 }
87 } 116 }
88 117
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 167 }
139 } 168 }
140 169
141 static int ShiftLeft(int a, int b) { return a << b; } 170 static int ShiftLeft(int a, int b) { return a << b; }
142 static int ShiftRight(int a, int b) { return a >> b; } 171 static int ShiftRight(int a, int b) { return a >> b; }
143 } 172 }
144 173
145 main() { 174 main() {
146 BitOperationsTest.testMain(); 175 BitOperationsTest.testMain();
147 } 176 }
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698