[runtime] Move the check in %OptimizeFunctionOnNextCall to a later point

Bug: v8:8394, v8:9183, v8:8803
Change-Id: Icd52eaaae28f605b14c0e63d3aca18541e3c8f6e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660616
Commit-Queue: Mythri Alle <mythria@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62190}
This commit is contained in:
Mythri A 2019-06-14 16:44:18 +01:00 committed by Commit Bot
parent 8cbbc2e809
commit 802f3e23eb

View File

@ -280,6 +280,16 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
return ReadOnlyRoots(isolate).undefined_value();
}
if (function->HasOptimizedCode()) {
DCHECK(function->IsOptimized() || function->ChecksOptimizationMarker());
// If function is already optimized, remove the bytecode array from the
// pending optimize for test table and return. It is OK if there is no
// entry in the table since if the function got optimized before executing
// %OptimizeFunctionOnNextCall the entry would have been removed.
RemoveBytecodeFromPendingOptimizeTable(isolate, function);
return ReadOnlyRoots(isolate).undefined_value();
}
// Check we called PrepareFunctionForOptimization and hold the bytecode
// array to prevent it from getting flushed.
// TODO(mythria): Enable this check once we add PrepareForOptimization in all
@ -289,14 +299,6 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
// ->Lookup(handle(function->shared(), isolate))
// ->IsTheHole());
if (function->HasOptimizedCode()) {
DCHECK(function->IsOptimized() || function->ChecksOptimizationMarker());
// If function is already optimized, remove the bytecode array from the
// pending optimize for test table and return.
RemoveBytecodeFromPendingOptimizeTable(isolate, function);
return ReadOnlyRoots(isolate).undefined_value();
}
ConcurrencyMode concurrency_mode = ConcurrencyMode::kNotConcurrent;
if (args.length() == 2) {
// Ignore invalid inputs produced by fuzzers.