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

Side by Side Diff: test/mjsunit/asm/uint32mod.js

Issue 727673002: [turbofan] Optimize remainder of integer division by unknown power of two. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix broken Int32Mod on ARM Created 6 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
« no previous file with comments | « test/mjsunit/asm/int32mod-constant.js ('k') | test/mjsunit/asm/uint32mod-constant.js » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var stdlib = {}; 5 var stdlib = {};
6 var foreign = {}; 6 var foreign = {};
7 var heap = new ArrayBuffer(64 * 1024); 7 var heap = new ArrayBuffer(64 * 1024);
8 8
9 function Uint32Mod(divisor) { 9 var mod = (function Module(stdlib, foreign, heap) {
10 var name = "mod_"; 10 "use asm";
11 name += divisor; 11 function mod(dividend, divisor) {
12 var m = eval("function Module(stdlib, foreign, heap) {\n" 12 dividend = dividend >>> 0;
13 + " \"use asm\";\n" 13 divisor = divisor >>> 0;
14 + " function " + name + "(dividend) {\n" 14 return (dividend % divisor) >>> 0;
15 + " return ((dividend >>> 0) % " + divisor + ") >>> 0;\n" 15 }
16 + " }\n" 16 return { mod: mod };
17 + " return { f: " + name + "}\n" 17 })(stdlib, foreign, heap).mod;
18 + "}; Module");
19 return m(stdlib, foreign, heap).f;
20 }
21 18
22 var divisors = [0, 1, 3, 4, 10, 42, 64, 100, 1024, 2147483647, 4294967295]; 19 var divisors = [0, 1, 3, 4, 10, 42, 64, 100, 1024, 2147483647, 4294967295];
23 for (var i in divisors) { 20 for (var i in divisors) {
24 var divisor = divisors[i]; 21 var divisor = divisors[i];
25 var mod = Uint32Mod(divisor);
26 for (var dividend = 0; dividend < 4294967296; dividend += 3999773) { 22 for (var dividend = 0; dividend < 4294967296; dividend += 3999773) {
27 assertEquals((dividend % divisor) >>> 0, mod(dividend)); 23 assertEquals((dividend % divisor) >>> 0, mod(dividend, divisor));
28 } 24 }
29 } 25 }
OLDNEW
« no previous file with comments | « test/mjsunit/asm/int32mod-constant.js ('k') | test/mjsunit/asm/uint32mod-constant.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698