osr-one.js 441 Bytes
Newer Older
1
// Copyright 2013 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5
// Flags: --use-osr --allow-natives-syntax
6

7
function f(x) {
8
  var sum = 0;
9
  var count = 10;
10 11 12
  while (count > 0) {
    sum += x;
    count--;
13 14 15
    if (count == 5) {
      %OptimizeOsr();
    }
16 17 18
  }
  return sum;
}
19
%PrepareFunctionForOptimization(f);
20

21
assertEquals(50, f(5));