From 802f3e23eb731a3a707af639d618205308f09eb5 Mon Sep 17 00:00:00 2001 From: Mythri A Date: Fri, 14 Jun 2019 16:44:18 +0100 Subject: [PATCH] [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 Commit-Queue: Ross McIlroy Reviewed-by: Ross McIlroy Cr-Commit-Position: refs/heads/master@{#62190} --- src/runtime/runtime-test.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc index 6308fc469e..96ace5792b 100644 --- a/src/runtime/runtime-test.cc +++ b/src/runtime/runtime-test.cc @@ -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.