6d9b7988f7
This CL adds a mechanism that prevents the RuntimeProfiler from triggering optimization of a function after %PrepareFunctionForOptimization has been called. This is useful to prevent flakiness in tests, as sometimes a function that already got deoptimized would receive a new code object from a concurrent compile that was triggered by a heuristic just in the right moment for the assertUnoptimized test to fail. For example, the following was happening: PrepareFunctionForOptimization [marking `testAdd` for optimized recompilation, reason: small function] [concurrently compiling method `testAdd` using TurboFan] [manually marking `testAdd` for non-concurrent optimization] [synchonously compiling method `testAdd` using TurboFan] [synchonously optimizing `testAdd` produced code object 0xAAAA - took 1.638 ms] Runtime_GetOptimizationStatus OPTIMIZED `testAdd` (code object 0xAAAA) DeoptimizeFunction `testAdd` with Code Object 0xAAAA [concurrently optimizing `testAdd` produced code object 0xBBBB - took 3.377 ms] Runtime_GetOptimizationStatus OPTIMIZED `testAdd` (code object 0xBBBB) Bug: v8:9563 Change-Id: Ia4c846aba95281589317d43b82383e70fe0a35f5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1763546 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Cr-Commit-Position: refs/heads/master@{#63343}
20 lines
469 B
JavaScript
20 lines
469 B
JavaScript
// Copyright 2019 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: --opt --interrupt-budget=100 --budget-for-feedback-vector-allocation=10 --allow-natives-syntax
|
|
|
|
function f() {
|
|
let s = 0;
|
|
for (let i = 0; i < 10; i++) {
|
|
s += i;
|
|
}
|
|
return s;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(f, "allow heuristic optimization");
|
|
f();
|
|
f();
|
|
f();
|
|
assertOptimized(f);
|