Revision f230a1cf deps/v8/test/mjsunit/compiler/escape-analysis.js

View differences:

deps/v8/test/mjsunit/compiler/escape-analysis.js
271 271
  %OptimizeFunctionOnNextCall(oob);
272 272
  assertEquals(7, oob(cons2, true));
273 273
})();
274

  
275

  
276
// Test non-shallow nested graph of captured objects.
277
(function testDeep() {
278
  var deopt = { deopt:false };
279
  function constructor1() {
280
    this.x = 23;
281
  }
282
  function constructor2(nested) {
283
    this.a = 17;
284
    this.b = nested;
285
    this.c = 42;
286
  }
287
  function deep() {
288
    var o1 = new constructor1();
289
    var o2 = new constructor2(o1);
290
    assertEquals(17, o2.a);
291
    assertEquals(23, o2.b.x);
292
    assertEquals(42, o2.c);
293
    o1.x = 99;
294
    deopt.deopt;
295
    assertEquals(99, o1.x);
296
    assertEquals(99, o2.b.x);
297
  }
298
  deep(); deep();
299
  %OptimizeFunctionOnNextCall(deep);
300
  deep(); deep();
301
  delete deopt.deopt;
302
  deep(); deep();
303
})();
304

  
305

  
306
// Test materialization of a field that requires a Smi value.
307
(function testSmiField() {
308
  var deopt = { deopt:false };
309
  function constructor() {
310
    this.x = 1;
311
  }
312
  function field(x) {
313
    var o = new constructor();
314
    o.x = x;
315
    deopt.deopt
316
    assertEquals(x, o.x);
317
  }
318
  field(1); field(2);
319
  %OptimizeFunctionOnNextCall(field);
320
  field(3); field(4);
321
  delete deopt.deopt;
322
  field(5.5); field(6.5);
323
})();
324

  
325

  
326
// Test materialization of a field that requires a heap object value.
327
(function testHeapObjectField() {
328
  var deopt = { deopt:false };
329
  function constructor() {
330
    this.x = {};
331
  }
332
  function field(x) {
333
    var o = new constructor();
334
    o.x = x;
335
    deopt.deopt
336
    assertEquals(x, o.x);
337
  }
338
  field({}); field({});
339
  %OptimizeFunctionOnNextCall(field);
340
  field({}); field({});
341
  delete deopt.deopt;
342
  field(1); field(2);
343
})();

Also available in: Unified diff