Chromium Code Reviews| Index: test/mjsunit/regress/poly_count_operation.js |
| diff --git a/test/mjsunit/regress/regress-crbug-243868.js b/test/mjsunit/regress/poly_count_operation.js |
| similarity index 55% |
| copy from test/mjsunit/regress/regress-crbug-243868.js |
| copy to test/mjsunit/regress/poly_count_operation.js |
| index 106d9cc78bce7795cd450fa0d07794f9f004a3af..13bd921f6da658cb83be1143f0c0ebbd44773c25 100644 |
| --- a/test/mjsunit/regress/regress-crbug-243868.js |
| +++ b/test/mjsunit/regress/poly_count_operation.js |
| @@ -27,20 +27,82 @@ |
| // Flags: --allow-natives-syntax |
| -var non_const_true = true; |
| +var o1 = {x:1}; |
| +var o2 = {}; |
| +var deopt = false; |
| -function f(o) { |
| - return (non_const_true && (o.val == null || false)); |
| +function f_mono(o) { |
| + return 5 + o.x++; |
| } |
| -// Create an object with a constant function in another realm. |
| -var realm = Realm.create(); |
| -var realmObject = Realm.eval(realm, "function g() {}; var o = { val:g }; o;") |
| +var to_deopt = f_mono; |
| -// Make the CompareNil IC in the function monomorphic. |
| -assertFalse(f(realmObject)); |
| -assertFalse(f(realmObject)); |
| +var v = 1; |
| +var s = 0; |
| -// Optimize the function containing the CompareNil IC. |
| -%OptimizeFunctionOnNextCall(f); |
| -assertFalse(f(realmObject)); |
| +Object.defineProperty(o2, "x", |
| + {get:function() { return v; }, |
| + set:function(new_v) { |
|
titzer
2013/07/19 07:23:05
Do we need a version of this test that deopts on g
Toon Verwaest
2013/07/19 08:44:16
Although a bit convoluted perhaps, that's exactly
|
| + v = new_v; |
| + s++; |
| + if (deopt) { |
| + deopt = false; |
| + %DeoptimizeFunction(to_deopt); |
| + } |
| + }}); |
| + |
| +assertEquals(0, s); |
| +assertEquals(6, f_mono(o2)); |
| +assertEquals(1, s); |
| +assertEquals(7, f_mono(o2)); |
| +assertEquals(2, s); |
| +%OptimizeFunctionOnNextCall(f_mono); |
| +deopt = true; |
| +assertEquals(8, f_mono(o2)); |
| +assertEquals(3, s); |
| + |
| +function f_poly(o) { |
| + return 5 + o.x++; |
| +} |
| + |
| +v = 1; |
| +to_deopt = f_poly; |
| + |
| +f_poly(o1); |
| +f_poly(o1); |
| +assertEquals(6, f_poly(o2)); |
| +assertEquals(4, s); |
| +assertEquals(7, f_poly(o2)); |
| +assertEquals(5, s); |
| +%OptimizeFunctionOnNextCall(f_poly); |
| +deopt = true; |
| +assertEquals(8, f_poly(o2)); |
| +assertEquals(6, s); |
| + |
| +%OptimizeFunctionOnNextCall(f_poly); |
| +v = undefined; |
| +assertEquals(NaN, f_poly(o2)); |
| +assertEquals(7, s); |
| + |
| +function f_pre(o) { |
| + return 5 + ++o.x |
| +} |
| + |
| +v = 1; |
| +to_deopt = f_pre; |
| + |
| +f_pre(o1); |
| +f_pre(o1); |
| +assertEquals(7, f_pre(o2)); |
| +assertEquals(8, s); |
| +assertEquals(8, f_pre(o2)); |
| +assertEquals(9, s); |
| +%OptimizeFunctionOnNextCall(f_pre); |
| +deopt = true; |
| +assertEquals(9, f_pre(o2)); |
| +assertEquals(10, s); |
| + |
| +%OptimizeFunctionOnNextCall(f_pre); |
| +v = undefined; |
| +assertEquals(NaN, f_pre(o2)); |
| +assertEquals(11, s); |