Commit d4cc38a4 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[sparkplug] Extract optimization marker checks to helper

Bug: v8:11420,v8:11429
Change-Id: Id2680baf5d7db7eee342ca7b3c0cb636cacf1560
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2715194
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72966}
parent cd7f5afb
...@@ -1161,6 +1161,23 @@ static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm, ...@@ -1161,6 +1161,23 @@ static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm,
__ Bind(&end); __ Bind(&end);
} }
// Read off the optimization state in the feedback vector and check if there
// is optimized code or a optimization marker that needs to be processed.
static void LoadOptimizationStateAndJumpIfNeedsProcessing(
MacroAssembler* masm, Register optimization_state, Register feedback_vector,
Label* has_optimized_code_or_marker) {
__ RecordComment("[ Check optimization state");
__ Ldr(optimization_state,
FieldMemOperand(feedback_vector, FeedbackVector::kFlagsOffset));
__ TestAndBranchIfAnySet(
optimization_state,
FeedbackVector::kHasOptimizedCodeOrCompileOptimizedMarkerMask,
has_optimized_code_or_marker);
__ RecordComment("]");
}
static void MaybeOptimizeCodeOrTailCallOptimizedCodeSlot( static void MaybeOptimizeCodeOrTailCallOptimizedCodeSlot(
MacroAssembler* masm, Register optimization_state, MacroAssembler* masm, Register optimization_state,
Register feedback_vector) { Register feedback_vector) {
...@@ -1208,18 +1225,11 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) { ...@@ -1208,18 +1225,11 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
__ RecordComment("[ Check optimization state"); __ RecordComment("[ Check optimization state");
// Read off the optimization state in the feedback vector. // Check for an optimization marker.
Register optimization_state = temps.AcquireW();
__ Ldr(optimization_state,
FieldMemOperand(feedback_vector, FeedbackVector::kFlagsOffset));
// Check if there is optimized code or a optimization marker that needs to
// be processed.
Label has_optimized_code_or_marker; Label has_optimized_code_or_marker;
__ TestAndBranchIfAnySet( Register optimization_state = temps.AcquireW();
optimization_state, LoadOptimizationStateAndJumpIfNeedsProcessing(
FeedbackVector::kHasOptimizedCodeOrCompileOptimizedMarkerMask, masm, optimization_state, feedback_vector, &has_optimized_code_or_marker);
&has_optimized_code_or_marker);
// Increment invocation count for the function. // Increment invocation count for the function.
{ {
...@@ -1388,19 +1398,11 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1388,19 +1398,11 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ Cmp(x7, FEEDBACK_VECTOR_TYPE); __ Cmp(x7, FEEDBACK_VECTOR_TYPE);
__ B(ne, &push_stack_frame); __ B(ne, &push_stack_frame);
// Read off the optimized state in the feedback vector, and if there // Check for an optimization marker.
// is optimized code or an optimization marker, call that instead.
Register optimization_state = w7;
__ Ldr(optimization_state,
FieldMemOperand(feedback_vector, FeedbackVector::kFlagsOffset));
// Check if there is optimized code or a optimization marker that needes to be
// processed.
Label has_optimized_code_or_marker; Label has_optimized_code_or_marker;
__ TestAndBranchIfAnySet( Register optimization_state = w7;
optimization_state, LoadOptimizationStateAndJumpIfNeedsProcessing(
FeedbackVector::kHasOptimizedCodeOrCompileOptimizedMarkerMask, masm, optimization_state, feedback_vector, &has_optimized_code_or_marker);
&has_optimized_code_or_marker);
Label not_optimized; Label not_optimized;
__ bind(&not_optimized); __ bind(&not_optimized);
...@@ -1577,6 +1579,11 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1577,6 +1579,11 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ Cmp(x7, FEEDBACK_VECTOR_TYPE); __ Cmp(x7, FEEDBACK_VECTOR_TYPE);
__ B(ne, &install_baseline_code); __ B(ne, &install_baseline_code);
// Check for an optimization marker.
LoadOptimizationStateAndJumpIfNeedsProcessing(
masm, optimization_state, feedback_vector,
&has_optimized_code_or_marker);
// Read off the optimization state in the feedback vector. // Read off the optimization state in the feedback vector.
// TODO(v8:11429): Is this worth doing here? Baseline code will check it // TODO(v8:11429): Is this worth doing here? Baseline code will check it
// anyway... // anyway...
......
...@@ -1040,6 +1040,23 @@ static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm, ...@@ -1040,6 +1040,23 @@ static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm,
__ bind(&end); __ bind(&end);
} }
// Read off the optimization state in the feedback vector and check if there
// is optimized code or a optimization marker that needs to be processed.
static void LoadOptimizationStateAndJumpIfNeedsProcessing(
MacroAssembler* masm, Register optimization_state, Register feedback_vector,
Label* has_optimized_code_or_marker) {
__ RecordComment("[ Check optimization state");
__ movl(optimization_state,
FieldOperand(feedback_vector, FeedbackVector::kFlagsOffset));
__ testl(
optimization_state,
Immediate(FeedbackVector::kHasOptimizedCodeOrCompileOptimizedMarkerMask));
__ j(not_zero, has_optimized_code_or_marker);
__ RecordComment("]");
}
static void MaybeOptimizeCodeOrTailCallOptimizedCodeSlot( static void MaybeOptimizeCodeOrTailCallOptimizedCodeSlot(
MacroAssembler* masm, Register optimization_state, Register feedback_vector, MacroAssembler* masm, Register optimization_state, Register feedback_vector,
JumpMode jump_mode = JumpMode::kJump) { JumpMode jump_mode = JumpMode::kJump) {
...@@ -1112,18 +1129,11 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1112,18 +1129,11 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ CmpInstanceType(rcx, FEEDBACK_VECTOR_TYPE); __ CmpInstanceType(rcx, FEEDBACK_VECTOR_TYPE);
__ j(not_equal, &push_stack_frame); __ j(not_equal, &push_stack_frame);
// Read off the optimization state in the feedback vector. // Check for an optimization marker.
Register optimization_state = rcx;
__ movl(optimization_state,
FieldOperand(feedback_vector, FeedbackVector::kFlagsOffset));
// Check if there is optimized code or a optimization marker that needs to be
// processed.
Label has_optimized_code_or_marker; Label has_optimized_code_or_marker;
__ testl( Register optimization_state = rcx;
optimization_state, LoadOptimizationStateAndJumpIfNeedsProcessing(
Immediate(FeedbackVector::kHasOptimizedCodeOrCompileOptimizedMarkerMask)); masm, optimization_state, feedback_vector, &has_optimized_code_or_marker);
__ j(not_zero, &has_optimized_code_or_marker);
Label not_optimized; Label not_optimized;
__ bind(&not_optimized); __ bind(&not_optimized);
...@@ -1294,20 +1304,10 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1294,20 +1304,10 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ CmpInstanceType(rcx, FEEDBACK_VECTOR_TYPE); __ CmpInstanceType(rcx, FEEDBACK_VECTOR_TYPE);
__ j(not_equal, &install_baseline_code); __ j(not_equal, &install_baseline_code);
// Read off the optimization state in the feedback vector. // Check for an optimization marker.
// TODO(v8:11429): Is this worth doing here? Baseline code will check it LoadOptimizationStateAndJumpIfNeedsProcessing(
// anyway... masm, optimization_state, feedback_vector,
optimization_state = rcx; &has_optimized_code_or_marker);
__ movl(optimization_state,
FieldOperand(feedback_vector, FeedbackVector::kFlagsOffset));
// Check if there is optimized code or a optimization marker that needs to
// be processed.
__ testl(
optimization_state,
Immediate(
FeedbackVector::kHasOptimizedCodeOrCompileOptimizedMarkerMask));
__ j(not_zero, &has_optimized_code_or_marker);
// Load the baseline code into the closure. // Load the baseline code into the closure.
__ LoadTaggedPointerField(rcx, __ LoadTaggedPointerField(rcx,
...@@ -1623,21 +1623,11 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) { ...@@ -1623,21 +1623,11 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
__ Assert(equal, AbortReason::kExpectedFeedbackVector); __ Assert(equal, AbortReason::kExpectedFeedbackVector);
} }
__ RecordComment("[ Check optimization state"); // Check for an optimization marker.
// Read off the optimization state in the feedback vector.
Register optimization_state = rcx; Register optimization_state = rcx;
__ movl(optimization_state,
FieldOperand(feedback_vector, FeedbackVector::kFlagsOffset));
// Check if there is optimized code or a optimization marker that needs to
// be processed.
Label has_optimized_code_or_marker; Label has_optimized_code_or_marker;
__ testl( LoadOptimizationStateAndJumpIfNeedsProcessing(
optimization_state, masm, optimization_state, feedback_vector, &has_optimized_code_or_marker);
Immediate(FeedbackVector::kHasOptimizedCodeOrCompileOptimizedMarkerMask));
__ j(not_zero, &has_optimized_code_or_marker);
__ RecordComment("]");
// Increment invocation count for the function. // Increment invocation count for the function.
__ incl( __ incl(
......
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