1196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org// Copyright 2014 the V8 project authors. All rights reserved.
2196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org// Use of this source code is governed by a BSD-style license that can be
3196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org// found in the LICENSE file.
4196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org// Flags: --allow-natives-syntax --nostress-opt
5196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org// Flags: --nouse-osr
6196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org
7196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.orgfunction foo(obj) {
8196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org  var counter = 1;
9196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org  for (var i = 0; i < obj.length; i++) {
10196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org    %OptimizeFunctionOnNextCall(foo, "osr");
11196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org  }
12196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org  counter += obj;
13196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org  return counter;
14196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org}
15196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org
16196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.orgfunction bar() {
17196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org  var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
18196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org  for (var i = 0; i < 100; i++ ) {
19196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org    foo(a);
20196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org  }
21196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org}
22196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org
23196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.orgtry {
24196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org  bar();
25196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org} catch (e) {
26196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org}
27