Commit 545df256 authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[builtins][arm64] Reverse JS arguments for arm64

Change-Id: Ib9a14265692dbcdce05accb78b753d268e77ad9e
Bug: v8:10201
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2150587Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67525}
parent 780665ad
This diff is collapsed.
......@@ -1306,7 +1306,14 @@ void TurboAssembler::CopyDoubleWords(Register dst, Register src, Register count,
static_assert(kSystemPointerSize == kDRegSize,
"pointers must be the same size as doubles");
int direction = (mode == kDstLessThanSrc) ? 1 : -1;
if (mode == kDstLessThanSrcAndReverse) {
Add(src, src, Operand(count, LSL, kSystemPointerSizeLog2));
Sub(src, src, kSystemPointerSize);
}
int src_direction = (mode == kDstLessThanSrc) ? 1 : -1;
int dst_direction = (mode == kSrcLessThanDst) ? -1 : 1;
UseScratchRegisterScope scope(this);
VRegister temp0 = scope.AcquireD();
VRegister temp1 = scope.AcquireD();
......@@ -1314,23 +1321,30 @@ void TurboAssembler::CopyDoubleWords(Register dst, Register src, Register count,
Label pairs, loop, done;
Tbz(count, 0, &pairs);
Ldr(temp0, MemOperand(src, direction * kSystemPointerSize, PostIndex));
Ldr(temp0, MemOperand(src, src_direction * kSystemPointerSize, PostIndex));
Sub(count, count, 1);
Str(temp0, MemOperand(dst, direction * kSystemPointerSize, PostIndex));
Str(temp0, MemOperand(dst, dst_direction * kSystemPointerSize, PostIndex));
Bind(&pairs);
if (mode == kSrcLessThanDst) {
// Adjust pointers for post-index ldp/stp with negative offset:
Sub(dst, dst, kSystemPointerSize);
Sub(src, src, kSystemPointerSize);
} else if (mode == kDstLessThanSrcAndReverse) {
Sub(src, src, kSystemPointerSize);
}
Bind(&loop);
Cbz(count, &done);
Ldp(temp0, temp1,
MemOperand(src, 2 * direction * kSystemPointerSize, PostIndex));
MemOperand(src, 2 * src_direction * kSystemPointerSize, PostIndex));
Sub(count, count, 2);
Stp(temp0, temp1,
MemOperand(dst, 2 * direction * kSystemPointerSize, PostIndex));
if (mode == kDstLessThanSrcAndReverse) {
Stp(temp1, temp0,
MemOperand(dst, 2 * dst_direction * kSystemPointerSize, PostIndex));
} else {
Stp(temp0, temp1,
MemOperand(dst, 2 * dst_direction * kSystemPointerSize, PostIndex));
}
B(&loop);
// TODO(all): large copies may benefit from using temporary Q registers
......@@ -2093,7 +2107,7 @@ void MacroAssembler::CallDebugOnFunctionCall(Register fun, Register new_target,
Register expected_parameter_count,
Register actual_parameter_count) {
// Load receiver to pass it later to DebugOnFunctionCall hook.
Ldr(x4, MemOperand(sp, actual_parameter_count, LSL, kSystemPointerSizeLog2));
Peek(x4, ReceiverOperand(actual_parameter_count));
FrameScope frame(this, has_frame() ? StackFrame::NONE : StackFrame::INTERNAL);
if (!new_target.is_valid()) new_target = padreg;
......@@ -2165,6 +2179,14 @@ void MacroAssembler::InvokeFunctionCode(Register function, Register new_target,
Bind(&done);
}
Operand MacroAssembler::ReceiverOperand(Register arg_count) {
#ifdef V8_REVERSE_JSARGS
return Operand(0);
#else
return Operand(arg_count, LSL, kXRegSizeLog2);
#endif
}
void MacroAssembler::InvokeFunctionWithNewTarget(
Register function, Register new_target, Register actual_parameter_count,
InvokeFlag flag) {
......
......@@ -703,7 +703,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void CopySlots(Register dst, Register src, Register slot_count);
// Copy count double words from the address in register src to the address
// in register dst. There are two modes for this function:
// in register dst. There are three modes for this function:
// 1) Address dst must be less than src, or the gap between them must be
// greater than or equal to count double words, otherwise the result is
// unpredictable. This is the default mode.
......@@ -711,10 +711,15 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// greater than or equal to count double words, otherwise the result is
// undpredictable. In this mode, src and dst specify the last (highest)
// address of the regions to copy from and to.
// 3) The same as mode 1, but the words are copied in the reversed order.
// The case where src == dst is not supported.
// The function may corrupt its register arguments. The registers must not
// alias each other.
enum CopyDoubleWordsMode { kDstLessThanSrc, kSrcLessThanDst };
enum CopyDoubleWordsMode {
kDstLessThanSrc,
kSrcLessThanDst,
kDstLessThanSrcAndReverse
};
void CopyDoubleWords(Register dst, Register src, Register count,
CopyDoubleWordsMode mode = kDstLessThanSrc);
......@@ -1762,6 +1767,10 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
DecodeField<Field>(reg, reg);
}
// TODO(victorgomes): inline this function once we remove V8_REVERSE_JSARGS
// flag.
Operand ReceiverOperand(const Register arg_count);
// ---- SMI and Number Utilities ----
inline void SmiTag(Register dst, Register src);
......
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