1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax --block-concurrent-recompilation
6// Flags: --no-concurrent-osr
7
8function Ctor() {
9  this.a = 1;
10}
11
12function get_closure() {
13  return function add_field(obj, osr) {
14    obj.c = 3;
15    var x = 0;
16    if (osr) {
17      %OptimizeFunctionOnNextCall(add_field, "osr");
18    }
19    for (var i = 0; i < 10; i++) {
20      x = i + 1;
21    }
22    return x;
23  }
24}
25
26var f1 = get_closure();
27f1(new Ctor(), false);
28f1(new Ctor(), false);
29
30%OptimizeFunctionOnNextCall(f1, "concurrent");
31
32// Kick off concurrent recompilation and OSR.
33var o = new Ctor();
34f1(o, true);
35assertOptimized(f1, "no sync");
36
37// Flush the optimizing compiler's queue.
38%NotifyContextDisposed();
39assertUnoptimized(f1, "no sync");
40
41// Trigger deopt.
42o.c = 2.2;
43
44var f2 = get_closure();
45f2(new Ctor(), true);
46