diff options
Diffstat (limited to 'deps/v8/test/mjsunit/compiler/escape-analysis.js')
-rw-r--r-- | deps/v8/test/mjsunit/compiler/escape-analysis.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis.js b/deps/v8/test/mjsunit/compiler/escape-analysis.js index 74e638a538..dccc476925 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis.js @@ -271,3 +271,73 @@ %OptimizeFunctionOnNextCall(oob); assertEquals(7, oob(cons2, true)); })(); + + +// Test non-shallow nested graph of captured objects. +(function testDeep() { + var deopt = { deopt:false }; + function constructor1() { + this.x = 23; + } + function constructor2(nested) { + this.a = 17; + this.b = nested; + this.c = 42; + } + function deep() { + var o1 = new constructor1(); + var o2 = new constructor2(o1); + assertEquals(17, o2.a); + assertEquals(23, o2.b.x); + assertEquals(42, o2.c); + o1.x = 99; + deopt.deopt; + assertEquals(99, o1.x); + assertEquals(99, o2.b.x); + } + deep(); deep(); + %OptimizeFunctionOnNextCall(deep); + deep(); deep(); + delete deopt.deopt; + deep(); deep(); +})(); + + +// Test materialization of a field that requires a Smi value. +(function testSmiField() { + var deopt = { deopt:false }; + function constructor() { + this.x = 1; + } + function field(x) { + var o = new constructor(); + o.x = x; + deopt.deopt + assertEquals(x, o.x); + } + field(1); field(2); + %OptimizeFunctionOnNextCall(field); + field(3); field(4); + delete deopt.deopt; + field(5.5); field(6.5); +})(); + + +// Test materialization of a field that requires a heap object value. +(function testHeapObjectField() { + var deopt = { deopt:false }; + function constructor() { + this.x = {}; + } + function field(x) { + var o = new constructor(); + o.x = x; + deopt.deopt + assertEquals(x, o.x); + } + field({}); field({}); + %OptimizeFunctionOnNextCall(field); + field({}); field({}); + delete deopt.deopt; + field(1); field(2); +})(); |