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

Side by Side Diff: test/mjsunit/div-mod.js

Issue 1118008: Fix an error in optimized modulus operator, add unit test. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 9 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 | « src/ia32/codegen-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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 var zero = 0; 162 var zero = 0;
163 var minsmi32 = -0x40000000; 163 var minsmi32 = -0x40000000;
164 var minsmi64 = -0x80000000; 164 var minsmi64 = -0x80000000;
165 var somenum = 3532; 165 var somenum = 3532;
166 assertEquals(-0, zero / -1, "0 / -1"); 166 assertEquals(-0, zero / -1, "0 / -1");
167 assertEquals(1, minsmi32 / -0x40000000, "minsmi/minsmi-32"); 167 assertEquals(1, minsmi32 / -0x40000000, "minsmi/minsmi-32");
168 assertEquals(1, minsmi64 / -0x80000000, "minsmi/minsmi-64"); 168 assertEquals(1, minsmi64 / -0x80000000, "minsmi/minsmi-64");
169 assertEquals(somenum, somenum % -0x40000000, "%minsmi-32"); 169 assertEquals(somenum, somenum % -0x40000000, "%minsmi-32");
170 assertEquals(somenum, somenum % -0x80000000, "%minsmi-64"); 170 assertEquals(somenum, somenum % -0x80000000, "%minsmi-64");
171 })(); 171 })();
172
173
174 // Side-effect-free expressions containing bit operations use
175 // an optimized compiler with int32 values. Ensure that modulus
176 // produces negative zeros correctly.
177 function negative_zero_modulus_test() {
178 var x = 4;
179 var y = -4;
180 x = x + x - x;
181 y = y + y - y;
182 var z = (y | y | y | y) % x;
183 assertEquals(-1 / 0, 1 / z);
184 z = (x | x | x | x) % x;
185 assertEquals(1 / 0, 1 / z);
186 z = (y | y | y | y) % y;
187 assertEquals(-1 / 0, 1 / z);
188 z = (x | x | x | x) % y;
189 assertEquals(1 / 0, 1 / z);
190 }
191
192 negative_zero_modulus_test();
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698