v8/test/mjsunit/regress/regress-3176.js
Ross McIlroy d7a8170d2d [cleanup] Add missing %PrepareFunctionForOptimize in mjsunit tests
Bug: v8:8801,v8:8394,v8:9183
Change-Id: If482c6a14f389d54c6ca3891aa7b8475f7a1fce1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660617
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62192}
2019-06-14 17:03:41 +00:00

32 lines
647 B
JavaScript

// Copyright 2014 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 --opt
function foo(a) {
var sum = 0;
for (var i = 0; i < 10; i++) {
sum += a[i];
if (i > 6) {
sum -= a[i - 4];
sum -= a[i - 5];
}
}
return sum;
}
%PrepareFunctionForOptimization(foo);
var a = new Int32Array(10);
%PrepareFunctionForOptimization(foo);
foo(a);
foo(a);
%OptimizeFunctionOnNextCall(foo);
foo(a);
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
foo(a);
assertOptimized(foo);