From 8154ac1468e769877b72324fb504137e3184b5a8 Mon Sep 17 00:00:00 2001 From: Milad Fa Date: Thu, 11 Aug 2022 10:32:50 -0400 Subject: [PATCH] PPC/s390: [compiler] Merge all CompileFoo_Bar runtime functions Port 8b4272c2cac4bc6eb8ba9bfc3f7da23828be699e Original Commit Message: There's no need to decode the tiering state in generated code - merge these runtime functions and decode in the new generic CompileOptimized runtime function instead. CompileMaglev_Synchronized CompileMaglev_Concurrent CompileTurbofan_Synchronized CompileTurbofan_Concurrent -> CompileOptimized R=jgruber@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com BUG= LOG=N Change-Id: Ia61852825fc747ad7fec9983a18bf4e9d4245ad0 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3826053 Commit-Queue: Milad Farazmand Reviewed-by: Junliang Yan Cr-Commit-Position: refs/heads/main@{#82417} --- src/codegen/ppc/macro-assembler-ppc.cc | 40 ++---------------------- src/codegen/s390/macro-assembler-s390.cc | 39 ++--------------------- 2 files changed, 4 insertions(+), 75 deletions(-) diff --git a/src/codegen/ppc/macro-assembler-ppc.cc b/src/codegen/ppc/macro-assembler-ppc.cc index 2a7ca1aba9..a198747cd7 100644 --- a/src/codegen/ppc/macro-assembler-ppc.cc +++ b/src/codegen/ppc/macro-assembler-ppc.cc @@ -1982,40 +1982,6 @@ void TurboAssembler::TryInlineTruncateDoubleToI(Register result, namespace { -// Tail-call |function_id| if |actual_state| == |expected_state| -static void TailCallRuntimeIfStateEquals(MacroAssembler* masm, - Register actual_state, - TieringState expected_state, - Runtime::FunctionId function_id) { - Label no_match; - __ cmpi(actual_state, Operand(static_cast(expected_state))); - __ bne(&no_match); - __ GenerateTailCallToReturnedCode(function_id); - __ bind(&no_match); -} - -void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector, - Register tiering_state) { - // ----------- S t a t e ------------- - // -- r3 : actual argument count - // -- r6 : new target (preserved for callee if needed, and caller) - // -- r4 : target function (preserved for callee if needed, and caller) - // -- feedback vector (preserved for caller if needed) - // -- tiering_state : a int32 containing a non-zero optimization - // marker. - // ----------------------------------- - DCHECK(!AreAliased(feedback_vector, r4, r6, tiering_state)); - - TailCallRuntimeIfStateEquals(masm, tiering_state, - TieringState::kRequestTurbofan_Synchronous, - Runtime::kCompileTurbofan_Synchronous); - TailCallRuntimeIfStateEquals(masm, tiering_state, - TieringState::kRequestTurbofan_Concurrent, - Runtime::kCompileTurbofan_Concurrent); - - __ stop(); -} - void TailCallOptimizedCodeSlot(MacroAssembler* masm, Register optimized_code_entry, Register scratch) { @@ -2143,13 +2109,11 @@ void MacroAssembler::MaybeOptimizeCodeOrTailCallOptimizedCodeSlot( r0); beq(&maybe_has_optimized_code, cr0); - Register tiering_state = optimization_state; - DecodeField(tiering_state); - MaybeOptimizeCode(this, feedback_vector, tiering_state); + GenerateTailCallToReturnedCode(Runtime::kCompileOptimized); bind(&maybe_has_optimized_code); Register optimized_code_entry = optimization_state; - LoadAnyTaggedField(tiering_state, + LoadAnyTaggedField(optimized_code_entry, FieldMemOperand(feedback_vector, FeedbackVector::kMaybeOptimizedCodeOffset), r0); diff --git a/src/codegen/s390/macro-assembler-s390.cc b/src/codegen/s390/macro-assembler-s390.cc index dc45e6f976..cc5eed48de 100644 --- a/src/codegen/s390/macro-assembler-s390.cc +++ b/src/codegen/s390/macro-assembler-s390.cc @@ -1986,39 +1986,6 @@ void TurboAssembler::TryInlineTruncateDoubleToI(Register result, namespace { -// Tail-call |function_id| if |actual_state| == |expected_state| -void TailCallRuntimeIfStateEquals(MacroAssembler* masm, Register actual_state, - TieringState expected_state, - Runtime::FunctionId function_id) { - Label no_match; - __ CmpS64(actual_state, Operand(static_cast(expected_state))); - __ bne(&no_match); - __ GenerateTailCallToReturnedCode(function_id); - __ bind(&no_match); -} - -void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector, - Register tiering_state) { - // ----------- S t a t e ------------- - // -- r2 : actual argument count - // -- r5 : new target (preserved for callee if needed, and caller) - // -- r3 : target function (preserved for callee if needed, and caller) - // -- feedback vector (preserved for caller if needed) - // -- tiering_state : a int32 containing a non-zero optimization - // marker. - // ----------------------------------- - DCHECK(!AreAliased(feedback_vector, r3, r5, tiering_state)); - - TailCallRuntimeIfStateEquals(masm, tiering_state, - TieringState::kRequestTurbofan_Synchronous, - Runtime::kCompileTurbofan_Synchronous); - TailCallRuntimeIfStateEquals(masm, tiering_state, - TieringState::kRequestTurbofan_Concurrent, - Runtime::kCompileTurbofan_Concurrent); - - __ stop(); -} - void TailCallOptimizedCodeSlot(MacroAssembler* masm, Register optimized_code_entry, Register scratch) { @@ -2144,14 +2111,12 @@ void MacroAssembler::MaybeOptimizeCodeOrTailCallOptimizedCodeSlot( r0); beq(&maybe_has_optimized_code); - Register tiering_state = optimization_state; - DecodeField(tiering_state); - MaybeOptimizeCode(this, feedback_vector, tiering_state); + GenerateTailCallToReturnedCode(Runtime::kCompileOptimized); bind(&maybe_has_optimized_code); Register optimized_code_entry = optimization_state; LoadAnyTaggedField( - tiering_state, + optimized_code_entry, FieldMemOperand(feedback_vector, FeedbackVector::kMaybeOptimizedCodeOffset)); TailCallOptimizedCodeSlot(this, optimized_code_entry, r8);