Commit 84e9de32 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC/s390: [builtins] Streamline API calls

Port 1e5c03c7

Original Commit Message:

    This CL simplifies the API calls by removing some instructions from
    the most common path.

R=ishell@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
BUG=
LOG=N

Change-Id: I989c7da21347dc8a081b55ecea6374d3415d4aa3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3857444Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82734}
parent 4b14efad
......@@ -3190,33 +3190,6 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
DCHECK(function_address == r4 || function_address == r5);
Register scratch = r6;
__ Move(scratch, ExternalReference::is_profiling_address(isolate));
__ lbz(scratch, MemOperand(scratch, 0));
__ cmpi(scratch, Operand::Zero());
if (CpuFeatures::IsSupported(PPC_7_PLUS)) {
__ Move(scratch, thunk_ref);
__ isel(eq, scratch, function_address, scratch);
} else {
Label profiler_enabled, end_profiler_check;
__ bne(&profiler_enabled);
__ Move(scratch, ExternalReference::address_of_runtime_stats_flag());
__ lwz(scratch, MemOperand(scratch, 0));
__ cmpi(scratch, Operand::Zero());
__ bne(&profiler_enabled);
{
// Call the api function directly.
__ mr(scratch, function_address);
__ b(&end_profiler_check);
}
__ bind(&profiler_enabled);
{
// Additional parameter is the address of the actual callback.
__ Move(scratch, thunk_ref);
}
__ bind(&end_profiler_check);
}
// Allocate HandleScope in callee-save registers.
// r17 - next_address
// r14 - next_address->kNextOffset
......@@ -3229,7 +3202,21 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ addi(r16, r16, Operand(1));
__ stw(r16, MemOperand(r17, kLevelOffset));
__ StoreReturnAddressAndCall(scratch);
Label profiler_enabled, done_api_call;
__ Move(scratch, ExternalReference::is_profiling_address(isolate));
__ lbz(scratch, MemOperand(scratch, 0));
__ cmpi(scratch, Operand::Zero());
__ bne(&profiler_enabled);
#ifdef V8_RUNTIME_CALL_STATS
__ Move(scratch, ExternalReference::address_of_runtime_stats_flag());
__ lwz(scratch, MemOperand(scratch, 0));
__ cmpi(scratch, Operand::Zero());
__ bne(&profiler_enabled);
#endif // V8_RUNTIME_CALL_STATS
// Call the api function directly.
__ StoreReturnAddressAndCall(function_address);
__ bind(&done_api_call);
Label promote_scheduled_exception;
Label delete_allocated_handles;
......@@ -3272,6 +3259,14 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ blr();
// Call the api function via thunk wrapper.
__ bind(&profiler_enabled);
// Additional parameter is the address of the actual callback.
__ Move(r6, function_address);
__ Move(ip, thunk_ref);
__ StoreReturnAddressAndCall(ip);
__ b(&done_api_call);
// Re-throw by promoting a scheduled exception.
__ bind(&promote_scheduled_exception);
__ TailCallRuntime(Runtime::kPromoteScheduledException);
......
......@@ -3177,28 +3177,6 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
DCHECK(function_address == r3 || function_address == r4);
Register scratch = r5;
__ Move(scratch, ExternalReference::is_profiling_address(isolate));
__ LoadU8(scratch, MemOperand(scratch, 0));
__ CmpS64(scratch, Operand::Zero());
Label profiler_enabled, end_profiler_check;
__ bne(&profiler_enabled, Label::kNear);
__ Move(scratch, ExternalReference::address_of_runtime_stats_flag());
__ LoadU32(scratch, MemOperand(scratch, 0));
__ CmpS64(scratch, Operand::Zero());
__ bne(&profiler_enabled, Label::kNear);
{
// Call the api function directly.
__ mov(scratch, function_address);
__ b(&end_profiler_check, Label::kNear);
}
__ bind(&profiler_enabled);
{
// Additional parameter is the address of the actual callback.
__ Move(scratch, thunk_ref);
}
__ bind(&end_profiler_check);
// Allocate HandleScope in callee-save registers.
// r9 - next_address
// r6 - next_address->kNextOffset
......@@ -3211,7 +3189,21 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ AddS64(r8, Operand(1));
__ StoreU32(r8, MemOperand(r9, kLevelOffset));
__ StoreReturnAddressAndCall(scratch);
Label profiler_enabled, done_api_call;
__ Move(scratch, ExternalReference::is_profiling_address(isolate));
__ LoadU8(scratch, MemOperand(scratch, 0));
__ CmpS64(scratch, Operand::Zero());
__ bne(&profiler_enabled, Label::kNear);
#ifdef V8_RUNTIME_CALL_STATS
__ Move(scratch, ExternalReference::address_of_runtime_stats_flag());
__ LoadU32(scratch, MemOperand(scratch, 0));
__ CmpS64(scratch, Operand::Zero());
__ bne(&profiler_enabled, Label::kNear);
#endif // V8_RUNTIME_CALL_STATS
// Call the api function directly.
__ StoreReturnAddressAndCall(function_address);
__ bind(&done_api_call);
Label promote_scheduled_exception;
Label delete_allocated_handles;
......@@ -3254,6 +3246,14 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ b(r14);
// Call the api function via thunk wrapper.
__ bind(&profiler_enabled);
// Additional parameter is the address of the actual callback.
__ Move(r5, function_address);
__ Move(ip, thunk_ref);
__ StoreReturnAddressAndCall(ip);
__ b(&done_api_call);
// Re-throw by promoting a scheduled exception.
__ bind(&promote_scheduled_exception);
__ TailCallRuntime(Runtime::kPromoteScheduledException);
......
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