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) %OptimizeOsr();
17    for (var i = 0; i < 10; i++) {
18      x = i + 1;
19    }
20    return x;
21  }
22}
23
24var f1 = get_closure();
25f1(new Ctor(), false);
26f1(new Ctor(), false);
27
28%OptimizeFunctionOnNextCall(f1, "concurrent");
29
30// Kick off concurrent recompilation and OSR.
31var o = new Ctor();
32f1(o, true);
33assertOptimized(f1, "no sync");
34
35// Flush the optimizing compiler's queue.
36%NotifyContextDisposed();
37assertUnoptimized(f1, "no sync");
38
39// Trigger deopt.
40o.c = 2.2;
41
42var f2 = get_closure();
43f2(new Ctor(), true);
44