Commit cbbdb4df authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[builtins] Reverse arguments in builtins assembler x64

 - Create a PushArray to simplify code.
 - Adapt all the sites in builtins-x64.

Bug: v8:10201
Change-Id: I828f4d2e43373a4fe6380346c5628a345720fe38
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2083028Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66595}
parent 6f2c7b13
This diff is collapsed.
......@@ -1401,6 +1401,31 @@ void TurboAssembler::Push(Handle<HeapObject> source) {
Push(kScratchRegister);
}
void TurboAssembler::PushArray(Register array, Register size, Register scratch,
PushArrayOrder order) {
DCHECK(!AreAliased(array, size, scratch));
Register counter = scratch;
Label loop, entry;
if (order == PushArrayOrder::kReverse) {
Set(counter, 0);
jmp(&entry);
bind(&loop);
Push(Operand(array, counter, times_system_pointer_size, 0));
incq(counter);
bind(&entry);
cmpq(counter, size);
j(less, &loop, Label::kNear);
} else {
movq(counter, size);
jmp(&entry);
bind(&loop);
Push(Operand(array, counter, times_system_pointer_size, 0));
bind(&entry);
decq(counter);
j(greater_equal, &loop, Label::kNear);
}
}
void TurboAssembler::Move(Register result, Handle<HeapObject> object,
RelocInfo::Mode rmode) {
// TODO(jgruber,v8:8887): Also consider a root-relative load when generating
......
......@@ -281,6 +281,12 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Push(Smi smi);
void Push(Handle<HeapObject> source);
enum class PushArrayOrder { kNormal, kReverse };
// `array` points to the first element (the lowest address).
// `array` and `size` are not modified.
void PushArray(Register array, Register size, Register scratch,
PushArrayOrder order = PushArrayOrder::kNormal);
// Before calling a C-function from generated code, align arguments on stack.
// After aligning the frame, arguments must be stored in rsp[0], rsp[8],
// etc., not pushed. The argument count assumes all arguments are word sized.
......
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