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

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

Issue 654833002: [turbofan] Optimize division/modulus by constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « test/cctest/compiler/test-run-machops.cc ('k') | test/mjsunit/asm/int32mod.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 var stdlib = {};
6 var foreign = {};
7 var heap = new ArrayBuffer(64 * 1024);
8
9 function Int32Div(divisor) {
10 var name = "div_";
11 if (divisor < 0) {
12 name += "minus_";
13 }
14 name += Math.abs(divisor);
15 var m = eval("function Module(stdlib, foreign, heap) {\n"
16 + " \"use asm\";\n"
17 + " function " + name + "(dividend) {\n"
18 + " return ((dividend | 0) / " + divisor + ") | 0;\n"
19 + " }\n"
20 + " return { f: " + name + "}\n"
21 + "}; Module");
22 return m(stdlib, foreign, heap).f;
23 }
24
25 var divisors = [-2147483648, -32 * 1024, -1000, -16, -7, -2, -1, 0,
26 1, 3, 4, 10, 64, 100, 1024, 2147483647];
27 for (var i in divisors) {
28 var divisor = divisors[i];
29 var div = Int32Div(divisor);
30 for (var dividend = -2147483648; dividend < 2147483648; dividend += 3999773) {
31 assertEquals((dividend / divisor) | 0, div(dividend));
32 }
33 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-machops.cc ('k') | test/mjsunit/asm/int32mod.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698