Commit 6693641e authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[runtime] Check AvailableOptimizedCode in DisassembleFunction

In DisassembleFunction runtime, function may have available
optimized code and we could directly set the optimized code
for the function like in CompileLazy if it's not compiled,
which avoids calling Compiler::Compile and failed in
DCHECK(!function->HasAvailableOptimizedCode()).

Bug: v8:12762
Change-Id: I00001fc598f3fc96dfe86b2367e8ba88f0085fd3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3563448Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79722}
parent b214cb7d
......@@ -1116,6 +1116,9 @@ RUNTIME_FUNCTION(Runtime_DisassembleFunction) {
// Get the function and make sure it is compiled.
Handle<JSFunction> func = args.at<JSFunction>(0);
IsCompiledScope is_compiled_scope;
if (!func->is_compiled() && func->HasAvailableOptimizedCode()) {
func->set_code(func->feedback_vector().optimized_code());
}
CHECK(func->is_compiled() ||
Compiler::Compile(isolate, func, Compiler::KEEP_EXCEPTION,
&is_compiled_scope));
......
// Copyright 2022 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
function func() {
function foo() {}
return foo;
}
function bar(foo) {
%DisassembleFunction(foo);
foo();
%PrepareFunctionForOptimization(foo);
foo();
%OptimizeFunctionOnNextCall(foo);
foo();
}
bar(func());
bar(func());
bar(func());
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment