Commit 97ae1010 authored by Mythri A's avatar Mythri A Committed by Commit Bot

Hold on to FeedbackMetadata when allocating feedback vectors

Allocating a new feedback vector happens in two steps: We create an
empty structure and then initialize the array based on the
FeedbackMetadata.When allocating a new feedback array we could trigger
a GC which might flush the bytecode and associated feedback metadata.
This shouldn't happen in normal cases, because we either allocate
feedback vector after compilation or when we reach the expected budget.
In both cases, the age of the feedback vector should be 0 and hence
bytecode shouldn't be flushed. However, with debugger enabled we may
allocate feedback vectors even when the bytecode array is old
for example: when we enable precise invocation counters. This also
causes issues in tests with --stress-flush-bytecode. In the stress mode
we flush bytecode without considering the age. Holding on to the
feedback metadata prevents crashes in such cases.

Bug: v8:10560
Change-Id: Ie806ff4102cb5fcf257c8683d5ca957853e38c05
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2218066
Commit-Queue: Mythri Alle <mythria@chromium.org>
Auto-Submit: Mythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68052}
parent 464ee4b7
......@@ -238,7 +238,13 @@ Handle<FeedbackVector> FeedbackVector::New(
Handle<ClosureFeedbackCellArray> closure_feedback_cell_array) {
Factory* factory = isolate->factory();
const int slot_count = shared->feedback_metadata().slot_count();
// Hold on to bytecode here. The allocation of a new feedback vector could
// trigger a GC and flush the bytecode and feedback metadata.
IsCompiledScope is_compiled_scope(*shared, isolate);
CHECK(is_compiled_scope.is_compiled());
Handle<FeedbackMetadata> feedback_metadata(shared->feedback_metadata(),
isolate);
const int slot_count = feedback_metadata->slot_count();
Handle<FeedbackVector> vector =
factory->NewFeedbackVector(shared, closure_feedback_cell_array);
......@@ -260,7 +266,7 @@ Handle<FeedbackVector> FeedbackVector::New(
*uninitialized_sentinel);
for (int i = 0; i < slot_count;) {
FeedbackSlot slot(i);
FeedbackSlotKind kind = shared->feedback_metadata().GetKind(slot);
FeedbackSlotKind kind = feedback_metadata->GetKind(slot);
int index = FeedbackVector::GetIndex(slot);
int entry_size = FeedbackMetadata::GetSlotSize(kind);
......
......@@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(mythria): Investigate why this is failing with stress-flush-bytecode and
// remove the --no-stress-flush-bytecode here.
// Flags: --allow-natives-syntax --no-stress-flush-bytecode
// Flags: --allow-natives-syntax
function f() {
function g(arg) { return arg; }
......
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