regress-888923.js 744 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax

(function() {
  function f(o) {
    o.x;
    Object.create(o);
    return o.y.a;
  }

14
  %PrepareFunctionForOptimization(f);
15 16 17 18 19 20 21 22 23 24 25 26 27
  f({ x : 0, y : { a : 1 } });
  f({ x : 0, y : { a : 2 } });
  %OptimizeFunctionOnNextCall(f);
  assertEquals(3, f({ x : 0, y : { a : 3 } }));
})();

(function() {
  function f(o) {
    let a = o.y;
    Object.create(o);
    return o.x + a;
  }

28
  %PrepareFunctionForOptimization(f);
29 30 31 32 33
  f({ x : 42, y : 21 });
  f({ x : 42, y : 21 });
  %OptimizeFunctionOnNextCall(f);
  assertEquals(63, f({ x : 42, y : 21 }));
})();