Commit 9e1ecccf authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[loong64][mips64][builtins] Streamline API calls

Port commit 1e5c03c7

Bug: v8:11880
Change-Id: I706056509c2d23e6d57203aba7adcbcbe22607cf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3859164Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Auto-Submit: Liu Yu <liuyu@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#82740}
parent 2298b35f
......@@ -2969,26 +2969,6 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
DCHECK(function_address == a1 || function_address == a2);
Label profiler_enabled, end_profiler_check;
__ li(t7, ExternalReference::is_profiling_address(isolate));
__ Ld_b(t7, MemOperand(t7, 0));
__ Branch(&profiler_enabled, ne, t7, Operand(zero_reg));
__ li(t7, ExternalReference::address_of_runtime_stats_flag());
__ Ld_w(t7, MemOperand(t7, 0));
__ Branch(&profiler_enabled, ne, t7, Operand(zero_reg));
{
// Call the api function directly.
__ mov(t7, function_address);
__ Branch(&end_profiler_check);
}
__ bind(&profiler_enabled);
{
// Additional parameter is the address of the actual callback.
__ li(t7, thunk_ref);
}
__ bind(&end_profiler_check);
// Allocate HandleScope in callee-save registers.
__ li(s5, next_address);
__ Ld_d(s0, MemOperand(s5, kNextOffset));
......@@ -2997,7 +2977,20 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ Add_w(s2, s2, Operand(1));
__ St_w(s2, MemOperand(s5, kLevelOffset));
Label profiler_enabled, done_api_call;
__ li(t7, ExternalReference::is_profiling_address(isolate));
__ Ld_b(t7, MemOperand(t7, 0));
__ Branch(&profiler_enabled, ne, t7, Operand(zero_reg));
#ifdef V8_RUNTIME_CALL_STATS
__ li(t7, ExternalReference::address_of_runtime_stats_flag());
__ Ld_w(t7, MemOperand(t7, 0));
__ Branch(&profiler_enabled, ne, t7, Operand(zero_reg));
#endif // V8_RUNTIME_CALL_STATS
// Call the api function directly.
__ mov(t7, function_address);
__ StoreReturnAddressAndCall(t7);
__ bind(&done_api_call);
Label promote_scheduled_exception;
Label delete_allocated_handles;
......@@ -3045,6 +3038,13 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ Ret();
// Call the api function via thunk wrapper.
__ bind(&profiler_enabled);
// Additional parameter is the address of the actual callback.
__ li(t7, thunk_ref);
__ StoreReturnAddressAndCall(t7);
__ Branch(&done_api_call);
// Re-throw by promoting a scheduled exception.
__ bind(&promote_scheduled_exception);
__ TailCallRuntime(Runtime::kPromoteScheduledException);
......
......@@ -2986,26 +2986,6 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
DCHECK(function_address == a1 || function_address == a2);
Label profiler_enabled, end_profiler_check;
__ li(t9, ExternalReference::is_profiling_address(isolate));
__ Lb(t9, MemOperand(t9, 0));
__ Branch(&profiler_enabled, ne, t9, Operand(zero_reg));
__ li(t9, ExternalReference::address_of_runtime_stats_flag());
__ Lw(t9, MemOperand(t9, 0));
__ Branch(&profiler_enabled, ne, t9, Operand(zero_reg));
{
// Call the api function directly.
__ mov(t9, function_address);
__ Branch(&end_profiler_check);
}
__ bind(&profiler_enabled);
{
// Additional parameter is the address of the actual callback.
__ li(t9, thunk_ref);
}
__ bind(&end_profiler_check);
// Allocate HandleScope in callee-save registers.
__ li(s5, next_address);
__ Ld(s0, MemOperand(s5, kNextOffset));
......@@ -3014,7 +2994,20 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ Addu(s2, s2, Operand(1));
__ Sw(s2, MemOperand(s5, kLevelOffset));
Label profiler_enabled, done_api_call;
__ li(t9, ExternalReference::is_profiling_address(isolate));
__ Lb(t9, MemOperand(t9, 0));
__ Branch(&profiler_enabled, ne, t9, Operand(zero_reg));
#ifdef V8_RUNTIME_CALL_STATS
__ li(t9, ExternalReference::address_of_runtime_stats_flag());
__ Lw(t9, MemOperand(t9, 0));
__ Branch(&profiler_enabled, ne, t9, Operand(zero_reg));
#endif // V8_RUNTIME_CALL_STATS
// Call the api function directly.
__ mov(t9, function_address);
__ StoreReturnAddressAndCall(t9);
__ bind(&done_api_call);
Label promote_scheduled_exception;
Label delete_allocated_handles;
......@@ -3063,6 +3056,13 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ Ret();
// Call the api function via thunk wrapper.
__ bind(&profiler_enabled);
// Additional parameter is the address of the actual callback.
__ li(t9, thunk_ref);
__ StoreReturnAddressAndCall(t9);
__ Branch(&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