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

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

Issue 79653002: Merge TRUNCDIV and MOD into one instruction. Icorporated feedback from CL https://codereview.chromi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/intermediate_language_x64.cc ('k') | tests/language/modulo_test.dart » ('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 // Dart test program to test arithmetic operations. 4 // Dart test program to test arithmetic operations.
5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
6 6
7 library arithmetic_test; 7 library arithmetic_test;
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:math'; 9 import 'dart:math';
10 10
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 Expect.equals(true, (10).hashCode == (10).hashCode); 416 Expect.equals(true, (10).hashCode == (10).hashCode);
417 } 417 }
418 418
419 static int div(a, b) => a ~/ b; 419 static int div(a, b) => a ~/ b;
420 420
421 static void testSmiDivDeopt() { 421 static void testSmiDivDeopt() {
422 var a = -0x40000000; 422 var a = -0x40000000;
423 var b = -1; 423 var b = -1;
424 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, div(a, b)); 424 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, div(a, b));
425 } 425 }
426
427
428 static int divMod(a, b) => a ~/ b + a % b;
429
430 static void testSmiDivModDeopt() {
431 var a = -0x40000000;
432 var b = -1;
433 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, divMod(a, b));
434 }
426 435
427 static mySqrt(var x) => sqrt(x); 436 static mySqrt(var x) => sqrt(x);
428 437
429 static testSqrtDeopt() { 438 static testSqrtDeopt() {
430 for (var i = 0; i < 10; i++) mySqrt(4.0); 439 for (var i = 0; i < 10; i++) mySqrt(4.0);
431 Expect.equals(2.0, mySqrt(4.0)); 440 Expect.equals(2.0, mySqrt(4.0));
432 Expect.throws(() => mySqrt("abc")); 441 Expect.throws(() => mySqrt("abc"));
433 } 442 }
434 443
435 static self_equality(x) { 444 static self_equality(x) {
436 return x == x; 445 return x == x;
437 } 446 }
438 447
439 static testDoubleEquality() { 448 static testDoubleEquality() {
440 Expect.isFalse(self_equality(double.NAN)); 449 Expect.isFalse(self_equality(double.NAN));
441 for (int i = 0; i < 20; i++) { 450 for (int i = 0; i < 20; i++) {
442 self_equality(3.0); 451 self_equality(3.0);
443 } 452 }
444 Expect.isFalse(self_equality(double.NAN)); 453 Expect.isFalse(self_equality(double.NAN));
445 } 454 }
446 455
447 static testMain() { 456 static testMain() {
448 for (int i = 0; i < 20; i++) { 457 for (int i = 0; i < 20; i++) {
449 runOne(); 458 runOne();
450 testSmiDivDeopt(); 459 testSmiDivDeopt();
460 testSmiDivModDeopt();
451 testSqrtDeopt(); 461 testSqrtDeopt();
452 testDoubleEquality(); 462 testDoubleEquality();
453 } 463 }
454 } 464 }
455 } 465 }
456 466
457 main() { 467 main() {
458 ArithmeticTest.testMain(); 468 ArithmeticTest.testMain();
459 } 469 }
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | tests/language/modulo_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698