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

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

Issue 11363141: Improve smi shift operations and avoid repeated deoptimizations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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/raw_object.h ('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) 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 // Dart test program to test arithmetic operations. 4 // Dart test program to test arithmetic operations.
5 5
6 #library('arithmetic_test'); 6 #library('arithmetic_test');
7 #import('dart:math'); 7 #import('dart:math');
8 8
9 class ArithmeticTest { 9 class ArithmeticTest {
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 Expect.equals(5.5, a / b); 48 Expect.equals(5.5, a / b);
49 Expect.equals(2.0, 10 / 5); 49 Expect.equals(2.0, 10 / 5);
50 Expect.equals(2, a % b); 50 Expect.equals(2, a % b);
51 Expect.equals(2, a.remainder(b)); 51 Expect.equals(2, a.remainder(b));
52 // Smi corner cases. 52 // Smi corner cases.
53 for (int i = 0; i < 80; i++) { 53 for (int i = 0; i < 80; i++) {
54 a = -(1 << i); 54 a = -(1 << i);
55 b = -1; 55 b = -1;
56 Expect.equals(1 << i, a ~/ b); 56 Expect.equals(1 << i, a ~/ b);
57 } 57 }
58 for (int i = 0; i < 80; i++) {
59 a = -1 << i;
60 b = -1;
61 Expect.equals(1 << i, a ~/ b);
62 }
58 a = 22; 63 a = 22;
59 b = 4.0; 64 b = 4.0;
60 // Smi & double. 65 // Smi & double.
61 Expect.equals(26.0, a + b); 66 Expect.equals(26.0, a + b);
62 Expect.equals(18.0, a - b); 67 Expect.equals(18.0, a - b);
63 Expect.equals(88.0, a * b); 68 Expect.equals(88.0, a * b);
64 Expect.equals(5.0, a ~/ b); 69 Expect.equals(5.0, a ~/ b);
65 Expect.equals(5.5, a / b); 70 Expect.equals(5.5, a / b);
66 Expect.equals(2.0, a % b); 71 Expect.equals(2.0, a % b);
67 Expect.equals(2.0, a.remainder(b)); 72 Expect.equals(2.0, a.remainder(b));
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 Expect.equals(false, 1.0 < min(1.0, 12.0)); 410 Expect.equals(false, 1.0 < min(1.0, 12.0));
406 Expect.equals(true, 1.0 < max(1.0, 12.0)); 411 Expect.equals(true, 1.0 < max(1.0, 12.0));
407 412
408 // Hashcode 413 // Hashcode
409 Expect.equals(false, (3.4).hashCode == (1.2).hashCode); 414 Expect.equals(false, (3.4).hashCode == (1.2).hashCode);
410 Expect.equals(true, (1.2).hashCode == (1.2).hashCode); 415 Expect.equals(true, (1.2).hashCode == (1.2).hashCode);
411 Expect.equals(false, (3).hashCode == (1).hashCode); 416 Expect.equals(false, (3).hashCode == (1).hashCode);
412 Expect.equals(true, (10).hashCode == (10).hashCode); 417 Expect.equals(true, (10).hashCode == (10).hashCode);
413 } 418 }
414 419
420 static int div(a, b) => a ~/ b;
421
422 static void testSmiDivDeopt() {
423 var a = -0x40000000;
424 var b = -1;
425 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, div(a, b));
426 }
427
415 static testMain() { 428 static testMain() {
416 for (int i = 0; i < 1500; i++) { 429 for (int i = 0; i < 1500; i++) {
417 runOne(); 430 runOne();
431 testSmiDivDeopt();
418 } 432 }
419 } 433 }
420 } 434 }
421 435
422 main() { 436 main() {
423 ArithmeticTest.testMain(); 437 ArithmeticTest.testMain();
424 } 438 }
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698