OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 function crankshaft_test_2() { | 171 function crankshaft_test_2() { |
172 var v9 = {}; | 172 var v9 = {}; |
173 v9.valueOf = function() { return 6; } | 173 v9.valueOf = function() { return 6; } |
174 // Deopt expected due to non-heapnumber objects. | 174 // Deopt expected due to non-heapnumber objects. |
175 assertEquals(6, Math.min(v9, 12)); | 175 assertEquals(6, Math.min(v9, 12)); |
176 } | 176 } |
177 | 177 |
178 run(crankshaft_test_2); | 178 run(crankshaft_test_2); |
179 | 179 |
180 var o = { a: 1, b: 2 }; | |
181 | |
182 // Test smi-based Math.min. | |
183 function f(o) { | |
184 return Math.min(o.a, o.b); | |
185 } | |
186 | |
187 assertEquals(1, f(o)); | |
188 assertEquals(1, f(o)); | |
189 %OptimizeFunctionOnNextCall(f); | |
190 assertEquals(1, f(o)); | |
191 o.a = 5; | |
192 o.b = 4; | |
193 assertEquals(4, f(o)); | |
194 | |
195 // Test overriding Math.min and Math.max | 180 // Test overriding Math.min and Math.max |
196 Math.min = function(a, b) { return a + b; } | 181 Math.min = function(a, b) { return a + b; } |
197 Math.max = function(a, b) { return a - b; } | 182 Math.max = function(a, b) { return a - b; } |
198 | 183 |
199 function crankshaft_test_3() { | 184 function crankshaft_test_3() { |
200 assertEquals(8, Math.min(3, 5)); | 185 assertEquals(8, Math.min(3, 5)); |
201 assertEquals(3, Math.max(5, 2)); | 186 assertEquals(3, Math.max(5, 2)); |
202 } | 187 } |
203 | 188 |
204 run(crankshaft_test_3); | 189 run(crankshaft_test_3); |
OLD | NEW |