Reland "[maglev] Fix %OptimizeOsr when called from Maglev frames"
This is a reland of commit833731b20b
Original change's description: > [maglev] Fix %OptimizeOsr when called from Maglev frames > > This (test-only) runtime function only supported unoptimized frames as > callers. Add support for Maglev frames as well by extracting the > relevant BytecodeArray and bytecode offset. > > This reverts commit955de73ee5
. > > Bug: chromium:1400549,v8:7700 > Change-Id: I80f80f8736ff0400d6d47e355add2a07cdc4559e > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4111851 > Reviewed-by: Victor Gomes <victorgomes@chromium.org> > Commit-Queue: Jakob Linke <jgruber@chromium.org> > Cr-Commit-Position: refs/heads/main@{#84931} Bug: chromium:1400549,v8:7700 Change-Id: I79fadaa0a82314a3fdd4970e9429d83ab06aff09 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4111950 Auto-Submit: Jakob Linke <jgruber@chromium.org> Reviewed-by: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Jakob Linke <jgruber@chromium.org> Cr-Commit-Position: refs/heads/main@{#84938}
This commit is contained in:
parent
1f4ad47be7
commit
0b9fa062f0
@ -554,10 +554,9 @@ void FinalizeOptimization(Isolate* isolate) {
|
||||
#endif // V8_ENABLE_MAGLEV
|
||||
}
|
||||
|
||||
BytecodeOffset OffsetOfNextJumpLoop(Isolate* isolate, UnoptimizedFrame* frame) {
|
||||
Handle<BytecodeArray> bytecode_array(frame->GetBytecodeArray(), isolate);
|
||||
const int current_offset = frame->GetBytecodeOffset();
|
||||
|
||||
BytecodeOffset OffsetOfNextJumpLoop(Isolate* isolate,
|
||||
Handle<BytecodeArray> bytecode_array,
|
||||
int current_offset) {
|
||||
interpreter::BytecodeArrayIterator it(bytecode_array, current_offset);
|
||||
|
||||
// First, look for a loop that contains the current bytecode offset.
|
||||
@ -632,8 +631,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
}
|
||||
|
||||
DCHECK(it.frame()->is_java_script());
|
||||
if (it.frame()->is_turbofan()) {
|
||||
if (!it.frame()->is_unoptimized() && !it.frame()->is_maglev()) {
|
||||
// Nothing to be done.
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
}
|
||||
@ -653,11 +651,23 @@ RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
|
||||
// If not (e.g. because we enter a nested loop first), the next JumpLoop will
|
||||
// see the cached OSR code with a mismatched offset, and trigger
|
||||
// non-concurrent OSR compilation and installation.
|
||||
// TODO(v8:7700): Support spawning a concurrent job when OSRing from Maglev.
|
||||
if (it.frame()->is_unoptimized() &&
|
||||
isolate->concurrent_recompilation_enabled() && v8_flags.concurrent_osr) {
|
||||
const BytecodeOffset osr_offset =
|
||||
OffsetOfNextJumpLoop(isolate, UnoptimizedFrame::cast(it.frame()));
|
||||
if (isolate->concurrent_recompilation_enabled() && v8_flags.concurrent_osr) {
|
||||
BytecodeOffset osr_offset = BytecodeOffset::None();
|
||||
if (it.frame()->is_unoptimized()) {
|
||||
UnoptimizedFrame* frame = UnoptimizedFrame::cast(it.frame());
|
||||
Handle<BytecodeArray> bytecode_array(frame->GetBytecodeArray(), isolate);
|
||||
const int current_offset = frame->GetBytecodeOffset();
|
||||
osr_offset =
|
||||
OffsetOfNextJumpLoop(isolate, bytecode_array, current_offset);
|
||||
} else {
|
||||
MaglevFrame* frame = MaglevFrame::cast(it.frame());
|
||||
Handle<BytecodeArray> bytecode_array(
|
||||
frame->function().shared().GetBytecodeArray(isolate), isolate);
|
||||
const int current_offset = frame->GetBytecodeOffsetForOSR().ToInt();
|
||||
osr_offset =
|
||||
OffsetOfNextJumpLoop(isolate, bytecode_array, current_offset);
|
||||
}
|
||||
|
||||
if (osr_offset.IsNone()) {
|
||||
// The loop may have been elided by bytecode generation (e.g. for
|
||||
// patterns such as `do { ... } while (false);`.
|
||||
|
Loading…
Reference in New Issue
Block a user