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

Side by Side Diff: test/mjsunit/shift-for-integer-div.js

Issue 166793002: Fixed and improved code for integral division. Fixed and extended tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A64 fixes and cleanup Created 6 years, 10 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
« src/arm/lithium-codegen-arm.cc ('K') | « src/x64/lithium-x64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // Check for (kMinInt / -1) 53 // Check for (kMinInt / -1)
54 function divn1(x) { 54 function divn1(x) {
55 return x / (-1); 55 return x / (-1);
56 } 56 }
57 57
58 var two_31 = 1 << 31; 58 var two_31 = 1 << 31;
59 divn1(2); 59 divn1(2);
60 divn1(2); 60 divn1(2);
61 %OptimizeFunctionOnNextCall(divn1); 61 %OptimizeFunctionOnNextCall(divn1);
62 assertEquals(-2, divn1(2)); 62 assertEquals(-2, divn1(2));
63 assertEquals(two_31, divn1(-two_31)); 63 assertEquals(-two_31, divn1(two_31));
64 64
65 65
66 //Check for truncating to int32 case 66 //Check for truncating to int32 case
67 function divp4t(x) { 67 function divp4t(x) {
68 return (x / 4) | 0; 68 return (x / 4) | 0;
69 } 69 }
70 70
71 divp4t(8); 71 divp4t(8);
72 divp4t(8); 72 divp4t(8);
73 %OptimizeFunctionOnNextCall(divp4t); 73 %OptimizeFunctionOnNextCall(divp4t);
74 assertEquals(-1, divp4t(-5)); 74 assertEquals(-1, divp4t(-5));
75 assertEquals(1, divp4t(5)); 75 assertEquals(1, divp4t(5));
76 assertOptimized(divp4t); 76 assertOptimized(divp4t);
77 77
78 function divn4t(x) { 78 function divn4t(x) {
79 return (x / -4) | 0; 79 return (x / -4) | 0;
80 } 80 }
81 81
82 divn4t(8); 82 divn4t(8);
83 divn4t(8); 83 divn4t(8);
84 %OptimizeFunctionOnNextCall(divn4t); 84 %OptimizeFunctionOnNextCall(divn4t);
85 assertEquals(1, divn4t(-5)); 85 assertEquals(1, divn4t(-5));
86 assertEquals(-1, divn4t(5)); 86 assertEquals(-1, divn4t(5));
87 assertOptimized(divn4t); 87 assertOptimized(divn4t);
88
89 // Check kMinInt case.
90 function div_by_two(x) {
91 return (x / 2) | 0;
92 }
93
94 div_by_two(12);
95 div_by_two(34);
96 %OptimizeFunctionOnNextCall(div_by_two);
97 div_by_two(56);
98 assertEquals(-(1 << 30), div_by_two(1 << 31));
OLDNEW
« src/arm/lithium-codegen-arm.cc ('K') | « src/x64/lithium-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698