From 96ad5ab39d04c3427733900f636d1876ab03f375 Mon Sep 17 00:00:00 2001 From: Igor Sheludko Date: Fri, 3 Dec 2021 17:04:24 +0100 Subject: [PATCH] [test] Fix %PrepareFunctionForOptimization() vs bytecode flushing Ensure the bytecode array is available, before we put it to the PendingOptimizationTable. Bug: v8:12416 Change-Id: Ie4eb1a8a2ebdcdc0cfbfd7884eb081e156635a59 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3313108 Auto-Submit: Igor Sheludko Reviewed-by: Toon Verwaest Commit-Queue: Toon Verwaest Cr-Commit-Position: refs/heads/main@{#78293} --- src/codegen/pending-optimization-table.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/codegen/pending-optimization-table.cc b/src/codegen/pending-optimization-table.cc index 6f51cc43af..5e88b1e456 100644 --- a/src/codegen/pending-optimization-table.cc +++ b/src/codegen/pending-optimization-table.cc @@ -30,6 +30,11 @@ void PendingOptimizationTable::PreparedForOptimization( if (allow_heuristic_optimization) { status |= FunctionStatus::kAllowHeuristicOptimization; } + Handle shared_info(function->shared(), isolate); + + IsCompiledScope is_compiled_scope; + SharedFunctionInfo::EnsureBytecodeArrayAvailable(isolate, shared_info, + &is_compiled_scope); Handle table = isolate->heap()->pending_optimize_for_test_bytecode().IsUndefined() @@ -38,7 +43,7 @@ void PendingOptimizationTable::PreparedForOptimization( isolate->heap()->pending_optimize_for_test_bytecode()), isolate); Handle tuple = isolate->factory()->NewTuple2( - handle(function->shared().GetBytecodeArray(isolate), isolate), + handle(shared_info->GetBytecodeArray(isolate), isolate), handle(Smi::FromInt(status), isolate), AllocationType::kYoung); table = ObjectHashTable::Put(table, handle(function->shared(), isolate), tuple);