| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 function inc1(x) { x++; o.x = x; } | 34 function inc1(x) { x++; o.x = x; } |
| 35 inc1(max_smi); | 35 inc1(max_smi); |
| 36 assertEquals(max_smi + 1, o.x); | 36 assertEquals(max_smi + 1, o.x); |
| 37 | 37 |
| 38 inc1(1.1); | 38 inc1(1.1); |
| 39 assertEquals(2.1, o.x); | 39 assertEquals(2.1, o.x); |
| 40 | 40 |
| 41 | 41 |
| 42 // Test deopt with count operation on named property. | 42 // Test deopt with count operation on named property. |
| 43 function inc2(p) { p.x++ } | 43 function inc2(p) { p.x++; } |
| 44 | 44 |
| 45 o.x = "42"; | 45 o.x = "42"; |
| 46 inc2(o); | 46 inc2(o); |
| 47 assertEquals(43, o.x); | 47 assertEquals(43, o.x); |
| 48 | 48 |
| 49 var s = max_smi - 10; | 49 var s = max_smi - 10; |
| 50 o.x = s; | 50 o.x = s; |
| 51 for(var i = 0; i < 20; i++) { | 51 for(var i = 0; i < 20; i++) { |
| 52 inc2(o); | 52 inc2(o); |
| 53 if (i == 4) { | 53 if (i == 4) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 %OptimizeFunctionOnNextCall(inc9); | 152 %OptimizeFunctionOnNextCall(inc9); |
| 153 q[0] = 42; | 153 q[0] = 42; |
| 154 assertEquals(44, inc9(q, 1)); | 154 assertEquals(44, inc9(q, 1)); |
| 155 q[0] = 42; | 155 q[0] = 42; |
| 156 assertEquals(44.1, inc9(q, 1.1)); | 156 assertEquals(44.1, inc9(q, 1.1)); |
| 157 q[0] = 42.1; | 157 q[0] = 42.1; |
| 158 assertEquals(44.1, inc9(q, 1)); | 158 assertEquals(44.1, inc9(q, 1)); |
| 159 | 159 |
| 160 // Test deopt because of a failed map check. | 160 // Test deopt because of a failed map check. |
| 161 function inc10(p) { return p.x++ } | 161 function inc10(p) { return p.x++; } |
| 162 var g1 = {x:0}; | 162 var g1 = {x:0}; |
| 163 var g2 = {y:0, x:42} | 163 var g2 = {y:0, x:42}; |
| 164 for (var i = 0; i < 5; ++i) { | 164 for (var i = 0; i < 5; ++i) { |
| 165 g1.x = 42; | 165 g1.x = 42; |
| 166 assertEquals(42, inc10(g1)); | 166 assertEquals(42, inc10(g1)); |
| 167 assertEquals(43, g1.x); | 167 assertEquals(43, g1.x); |
| 168 } | 168 } |
| 169 %OptimizeFunctionOnNextCall(inc10); | 169 %OptimizeFunctionOnNextCall(inc10); |
| 170 g1.x = 42; | 170 g1.x = 42; |
| 171 assertEquals(42, inc10(g1)); | 171 assertEquals(42, inc10(g1)); |
| 172 assertEquals(43, g1.x); | 172 assertEquals(43, g1.x); |
| 173 assertEquals(42, inc10(g2)); | 173 assertEquals(42, inc10(g2)); |
| 174 assertEquals(43, g2.x); | 174 assertEquals(43, g2.x); |
| 175 | 175 |
| 176 // Test deoptimization with postfix operation in a value context. | 176 // Test deoptimization with postfix operation in a value context. |
| 177 function inc11(a) { return a[this.x++]; } | 177 function inc11(a) { return a[this.x++]; } |
| 178 var g3 = {x:null, f:inc11}; | 178 var g3 = {x:null, f:inc11}; |
| 179 var g4 = [42]; | 179 var g4 = [42]; |
| 180 assertEquals(42, g3.f(g4)); | 180 assertEquals(42, g3.f(g4)); |
| OLD | NEW |