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

Side by Side Diff: tests/language/modulo_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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 optimization of modulo operator on Smi. 4 // Dart test optimization of modulo operator on Smi.
5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 9
10 main() { 10 main() {
11 // Prime IC cache.
12 noDom(1);
13 noDom(-1);
11 for (int i = -30; i < 30; i++) { 14 for (int i = -30; i < 30; i++) {
12 Expect.equals(i % 256, foo(i)); 15 Expect.equals(i % 256, foo(i));
13 Expect.equals(i % -256, boo(i)); 16 Expect.equals(i % -256, boo(i));
14 try { 17 Expect.throws(() => hoo(i), (e) => e is IntegerDivisionByZeroException);
15 hoo(i); 18
16 Expect.fail("Exception expected."); 19 Expect.equals(i ~/ 254 + i % 254, fooTwo(i));
17 } catch (e) {} 20 Expect.equals(i ~/ -254 + i % -254, booTwo(i));
21 Expect.throws(() => hooTwo(i), (e) => e is IntegerDivisionByZeroException);
22 if (i > 0) {
23 Expect.equals(i % 10, noDom(i));
24 } else {
25 Expect.equals(i ~/ 10, noDom(i));
26 }
18 } 27 }
19 } 28 }
20 29
21 foo(i) { 30 foo(i) => i % 256; // This will get optimized to AND instruction.
22 return i % 256; // This will get optimized to AND instruction. 31 boo(i) => i % -256;
23 } 32 hoo(i) => i % 0;
24 33
34 fooTwo(i) => i ~/ 254 + i % 254;
35 booTwo(i) => i ~/ -254 + i % -254;
36 hooTwo(i) => i ~/ 0 + i % 0;
25 37
26 boo(i) { 38 noDom(a) {
27 return i % -256; 39 var x;
28 } 40 if (a > 0) {
29 41 x = a % 10;
30 42 } else {
31 hoo(i) { 43 x = a ~/ 10;
32 return i % 0; 44 }
33 } 45 return x;
46 }
OLDNEW
« runtime/vm/intermediate_language_arm.cc ('K') | « tests/language/arithmetic_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698