Commit 443721bd authored by Mythri A's avatar Mythri A Committed by Commit Bot

Set bytecode budget to interrupt_budget when allocating feedback vector

We use the same interrupt to both allocate feedback vectors and
for updating the profiler ticks. If there is a feedback vector already
available, we just increment the profiler ticks that we use to mark
for optimizing function. Calling JSFunction::EnsureFeedbackVector
allocates a feedback vector, but doesn't reset the budget, so we
optimize much earlier than expected. This is currently only a problem
with %PrepareFunctionForOptimize that doesn't reset the budget. Other
code paths do also reset the interrupt budget.

Bug: chromium:10243
Change-Id: I611a9202e5e71077bf897def5959bcfe11b8fdf4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2064980
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66426}
parent 8a492221
...@@ -1343,7 +1343,7 @@ Handle<FeedbackCell> Factory::NewNoClosuresCell(Handle<HeapObject> value) { ...@@ -1343,7 +1343,7 @@ Handle<FeedbackCell> Factory::NewNoClosuresCell(Handle<HeapObject> value) {
AllocationType::kOld, *no_closures_cell_map()); AllocationType::kOld, *no_closures_cell_map());
Handle<FeedbackCell> cell(FeedbackCell::cast(result), isolate()); Handle<FeedbackCell> cell(FeedbackCell::cast(result), isolate());
cell->set_value(*value); cell->set_value(*value);
cell->set_interrupt_budget(FeedbackCell::GetInitialInterruptBudget()); cell->SetInitialInterruptBudget();
cell->clear_padding(); cell->clear_padding();
return cell; return cell;
} }
...@@ -1354,7 +1354,7 @@ Handle<FeedbackCell> Factory::NewOneClosureCell(Handle<HeapObject> value) { ...@@ -1354,7 +1354,7 @@ Handle<FeedbackCell> Factory::NewOneClosureCell(Handle<HeapObject> value) {
AllocationType::kOld, *one_closure_cell_map()); AllocationType::kOld, *one_closure_cell_map());
Handle<FeedbackCell> cell(FeedbackCell::cast(result), isolate()); Handle<FeedbackCell> cell(FeedbackCell::cast(result), isolate());
cell->set_value(*value); cell->set_value(*value);
cell->set_interrupt_budget(FeedbackCell::GetInitialInterruptBudget()); cell->SetInitialInterruptBudget();
cell->clear_padding(); cell->clear_padding();
return cell; return cell;
} }
...@@ -1365,7 +1365,7 @@ Handle<FeedbackCell> Factory::NewManyClosuresCell(Handle<HeapObject> value) { ...@@ -1365,7 +1365,7 @@ Handle<FeedbackCell> Factory::NewManyClosuresCell(Handle<HeapObject> value) {
*many_closures_cell_map()); *many_closures_cell_map());
Handle<FeedbackCell> cell(FeedbackCell::cast(result), isolate()); Handle<FeedbackCell> cell(FeedbackCell::cast(result), isolate());
cell->set_value(*value); cell->set_value(*value);
cell->set_interrupt_budget(FeedbackCell::GetInitialInterruptBudget()); cell->SetInitialInterruptBudget();
cell->clear_padding(); cell->clear_padding();
return cell; return cell;
} }
......
...@@ -104,10 +104,6 @@ size_t Interpreter::GetDispatchTableIndex(Bytecode bytecode, ...@@ -104,10 +104,6 @@ size_t Interpreter::GetDispatchTableIndex(Bytecode bytecode,
kEntriesPerOperandScale; kEntriesPerOperandScale;
} }
int Interpreter::InterruptBudget() {
return FLAG_interrupt_budget;
}
namespace { namespace {
void MaybePrintAst(ParseInfo* parse_info, void MaybePrintAst(ParseInfo* parse_info,
......
...@@ -38,9 +38,6 @@ class Interpreter { ...@@ -38,9 +38,6 @@ class Interpreter {
explicit Interpreter(Isolate* isolate); explicit Interpreter(Isolate* isolate);
virtual ~Interpreter() = default; virtual ~Interpreter() = default;
// Returns the interrupt budget which should be used for the profiler counter.
V8_EXPORT_PRIVATE static int InterruptBudget();
// Creates a compilation job which will generate bytecode for |literal|. // Creates a compilation job which will generate bytecode for |literal|.
// Additionally, if |eager_inner_literals| is not null, adds any eagerly // Additionally, if |eager_inner_literals| is not null, adds any eagerly
// compilable inner FunctionLiterals to this list. // compilable inner FunctionLiterals to this list.
......
...@@ -30,7 +30,7 @@ void FeedbackCell::reset_feedback_vector( ...@@ -30,7 +30,7 @@ void FeedbackCell::reset_feedback_vector(
base::Optional<std::function<void(HeapObject object, ObjectSlot slot, base::Optional<std::function<void(HeapObject object, ObjectSlot slot,
HeapObject target)>> HeapObject target)>>
gc_notify_updated_slot) { gc_notify_updated_slot) {
set_interrupt_budget(FeedbackCell::GetInitialInterruptBudget()); SetInitialInterruptBudget();
if (value().IsUndefined() || value().IsClosureFeedbackCellArray()) return; if (value().IsUndefined() || value().IsClosureFeedbackCellArray()) return;
CHECK(value().IsFeedbackVector()); CHECK(value().IsFeedbackVector());
...@@ -43,6 +43,18 @@ void FeedbackCell::reset_feedback_vector( ...@@ -43,6 +43,18 @@ void FeedbackCell::reset_feedback_vector(
} }
} }
void FeedbackCell::SetInitialInterruptBudget() {
if (FLAG_lazy_feedback_allocation) {
set_interrupt_budget(FLAG_budget_for_feedback_vector_allocation);
} else {
set_interrupt_budget(FLAG_interrupt_budget);
}
}
void FeedbackCell::SetInterruptBudget() {
set_interrupt_budget(FLAG_interrupt_budget);
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -20,13 +20,6 @@ namespace internal { ...@@ -20,13 +20,6 @@ namespace internal {
// a native context. // a native context.
class FeedbackCell : public TorqueGeneratedFeedbackCell<FeedbackCell, Struct> { class FeedbackCell : public TorqueGeneratedFeedbackCell<FeedbackCell, Struct> {
public: public:
static int GetInitialInterruptBudget() {
if (FLAG_lazy_feedback_allocation) {
return FLAG_budget_for_feedback_vector_allocation;
}
return FLAG_interrupt_budget;
}
// Dispatched behavior. // Dispatched behavior.
DECL_PRINTER(FeedbackCell) DECL_PRINTER(FeedbackCell)
...@@ -38,6 +31,8 @@ class FeedbackCell : public TorqueGeneratedFeedbackCell<FeedbackCell, Struct> { ...@@ -38,6 +31,8 @@ class FeedbackCell : public TorqueGeneratedFeedbackCell<FeedbackCell, Struct> {
base::Optional<std::function<void(HeapObject object, ObjectSlot slot, base::Optional<std::function<void(HeapObject object, ObjectSlot slot,
HeapObject target)>> HeapObject target)>>
gc_notify_updated_slot = base::nullopt); gc_notify_updated_slot = base::nullopt);
inline void SetInitialInterruptBudget();
inline void SetInterruptBudget();
using BodyDescriptor = using BodyDescriptor =
FixedBodyDescriptor<kValueOffset, kInterruptBudgetOffset, kAlignedSize>; FixedBodyDescriptor<kValueOffset, kInterruptBudgetOffset, kAlignedSize>;
......
...@@ -5039,6 +5039,7 @@ void JSFunction::EnsureFeedbackVector(Handle<JSFunction> function) { ...@@ -5039,6 +5039,7 @@ void JSFunction::EnsureFeedbackVector(Handle<JSFunction> function) {
DCHECK(function->raw_feedback_cell() != DCHECK(function->raw_feedback_cell() !=
isolate->heap()->many_closures_cell()); isolate->heap()->many_closures_cell());
function->raw_feedback_cell().set_value(*feedback_vector); function->raw_feedback_cell().set_value(*feedback_vector);
function->raw_feedback_cell().SetInterruptBudget();
} }
// static // static
......
...@@ -103,8 +103,7 @@ void PartialSerializer::SerializeObject(HeapObject obj) { ...@@ -103,8 +103,7 @@ void PartialSerializer::SerializeObject(HeapObject obj) {
// Clear InterruptBudget when serializing FeedbackCell. // Clear InterruptBudget when serializing FeedbackCell.
if (obj.IsFeedbackCell()) { if (obj.IsFeedbackCell()) {
FeedbackCell::cast(obj).set_interrupt_budget( FeedbackCell::cast(obj).SetInitialInterruptBudget();
FeedbackCell::GetInitialInterruptBudget());
} }
if (SerializeJSObjectWithEmbedderFields(obj)) { if (SerializeJSObjectWithEmbedderFields(obj)) {
......
...@@ -1134,6 +1134,9 @@ ...@@ -1134,6 +1134,9 @@
'compiler/opt-higher-order-functions': [SKIP], 'compiler/opt-higher-order-functions': [SKIP],
'regress/regress-1049982-1': [SKIP], 'regress/regress-1049982-1': [SKIP],
'regress/regress-1049982-2': [SKIP], 'regress/regress-1049982-2': [SKIP],
# interrupt_budget overrides don't work with TurboProp.
'interrupt-budget-override': [SKIP],
}], # variant == turboprop }], # variant == turboprop
############################################################################## ##############################################################################
......
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