OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 PushRangeSymmetric(values, 100000, 100009); | 94 PushRangeSymmetric(values, 100000, 100009); |
95 PushRangeSymmetric(values, 1000000, 1000009); | 95 PushRangeSymmetric(values, 1000000, 1000009); |
96 PushRangeSymmetric(values, 10000000, 10000009); | 96 PushRangeSymmetric(values, 10000000, 10000009); |
97 PushRangeSymmetric(values, 100000000, 100000009); | 97 PushRangeSymmetric(values, 100000000, 100000009); |
98 PushRangeSymmetric(values, 1000000000, 1000000009); | 98 PushRangeSymmetric(values, 1000000000, 1000000009); |
99 return values; | 99 return values; |
100 } | 100 } |
101 | 101 |
102 // ----------------------------------------------------------------------------- | 102 // ----------------------------------------------------------------------------- |
103 | 103 |
| 104 |
104 function TestDivisionLike(ref, construct, values, divisor) { | 105 function TestDivisionLike(ref, construct, values, divisor) { |
105 // Define the function to test. | 106 // Define the function to test. |
106 var OptFun = new Function("dividend", construct(divisor)); | 107 var OptFun = new Function("dividend", construct(divisor)); |
107 | 108 |
108 // Warm up type feedback. | 109 // Warm up type feedback. |
109 OptFun(7); | 110 OptFun(7); |
110 OptFun(11); | 111 OptFun(11); |
111 %OptimizeFunctionOnNextCall(OptFun); | 112 %OptimizeFunctionOnNextCall(OptFun); |
112 OptFun(13); | 113 OptFun(13); |
113 | 114 |
114 // Check results. | 115 function dude(dividend) { |
115 values.forEach(function(dividend) { | |
116 // Avoid deopt caused by overflow, we do not want to test this here. | 116 // Avoid deopt caused by overflow, we do not want to test this here. |
117 if (dividend === -2147483648 && divisor === -1) return; | 117 if (dividend === -2147483648 && divisor === -1) return; |
118 assertEquals(ref(dividend, divisor), OptFun(dividend)); | 118 assertEquals(ref(dividend, divisor), OptFun(dividend)); |
119 }); | 119 } |
| 120 |
| 121 // Check results. |
| 122 values.forEach(dude); |
120 } | 123 } |
121 | 124 |
122 function Test(ref, construct) { | 125 function Test(ref, construct) { |
123 var values = CreateTestValues(); | 126 var values = CreateTestValues(); |
124 values.forEach(function(divisor) { | 127 values.forEach(function(divisor) { |
125 TestDivisionLike(ref, construct, values, divisor); | 128 TestDivisionLike(ref, construct, values, divisor); |
126 }); | 129 }); |
127 } | 130 } |
128 | 131 |
129 Test(RefDivByConstI, ConstructDiv); | 132 Test(RefDivByConstI, ConstructDiv); |
130 Test(RefModByConstI, ConstructMod); | 133 Test(RefModByConstI, ConstructMod); |
131 Test(RefFlooringDivByConstI, ConstructFlooringDiv); | 134 Test(RefFlooringDivByConstI, ConstructFlooringDiv); |
OLD | NEW |