[assembler][x64] Use higher-level Move instead of movq for code-size

Bug: v8:11879
Change-Id: I3f2f65d38fc656155b27b8835516cbf2832bf269
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2649032
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75143}
This commit is contained in:
Camillo Bruni 2021-06-14 11:42:43 +02:00 committed by V8 LUCI CQ
parent 4b4037308b
commit 019d459299
4 changed files with 42 additions and 43 deletions

View File

@ -400,7 +400,7 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// If the c_entry_fp is not already zero and we don't clear it, the
// SafeStackFrameIterator will assume we are executing C++ and miss the JS
// frames on top.
__ movq(c_entry_fp_operand, Immediate(0));
__ Move(c_entry_fp_operand, 0);
}
// Store the context address in the previously-reserved slot.
@ -1181,8 +1181,8 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
Immediate(0));
// Load initial bytecode offset.
__ movq(kInterpreterBytecodeOffsetRegister,
Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag));
__ Move(kInterpreterBytecodeOffsetRegister,
BytecodeArray::kHeaderSize - kHeapObjectTag);
// Push bytecode array and Smi tagged bytecode offset.
__ Push(kInterpreterBytecodeArrayRegister);
@ -1289,8 +1289,8 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// previous value.
__ movq(kInterpreterBytecodeArrayRegister,
Operand(rbp, InterpreterFrameConstants::kBytecodeArrayFromFp));
__ movq(kInterpreterBytecodeOffsetRegister,
Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag));
__ Move(kInterpreterBytecodeOffsetRegister,
BytecodeArray::kHeaderSize - kHeapObjectTag);
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ SmiTag(rcx, kInterpreterBytecodeArrayRegister);
@ -1612,8 +1612,8 @@ void Builtins::Generate_InterpreterEnterAtNextBytecode(MacroAssembler* masm) {
// check, it will have a bailout ID of kFunctionEntryBytecodeOffset, which is
// not a valid bytecode offset. Detect this case and advance to the first
// actual bytecode.
__ movq(kInterpreterBytecodeOffsetRegister,
Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag));
__ Move(kInterpreterBytecodeOffsetRegister,
BytecodeArray::kHeaderSize - kHeapObjectTag);
__ jmp(&enter_bytecode);
// We should never take the if_return path.
@ -2810,7 +2810,7 @@ void PrepareForBuiltinCall(MacroAssembler* masm, MemOperand GCScanSlotPlace,
Register wasm_instance, Register function_data) {
// Pushes and puts the values in order onto the stack before builtin calls for
// the GenericJSToWasmWrapper.
__ movq(GCScanSlotPlace, Immediate(GCScanSlotCount));
__ Move(GCScanSlotPlace, GCScanSlotCount);
__ pushq(current_param);
__ pushq(param_limit);
__ pushq(current_int_param_slot);
@ -3049,8 +3049,8 @@ void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
Register current_param = rbx;
Register param_limit = rdx;
constexpr int kReceiverOnStackSize = kSystemPointerSize;
__ movq(current_param,
Immediate(kFPOnStackSize + kPCOnStackSize + kReceiverOnStackSize));
__ Move(current_param,
kFPOnStackSize + kPCOnStackSize + kReceiverOnStackSize);
__ movq(param_limit, param_count);
__ shlq(param_limit, Immediate(kSystemPointerSizeLog2));
__ addq(param_limit,
@ -3273,8 +3273,7 @@ void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// We set the indicating value for the GC to the proper one for Wasm call.
constexpr int kWasmCallGCScanSlotCount = 0;
__ movq(MemOperand(rbp, kGCScanSlotCountOffset),
Immediate(kWasmCallGCScanSlotCount));
__ Move(MemOperand(rbp, kGCScanSlotCountOffset), kWasmCallGCScanSlotCount);
// -------------------------------------------
// Call the Wasm function.
@ -3516,7 +3515,7 @@ void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
__ bind(&compile_wrapper);
// Enable GC.
MemOperand GCScanSlotPlace = MemOperand(rbp, kGCScanSlotCountOffset);
__ movq(GCScanSlotPlace, Immediate(4));
__ Move(GCScanSlotPlace, 4);
// Save registers to the stack.
__ pushq(wasm_instance);
__ pushq(function_data);
@ -3538,7 +3537,7 @@ void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
void Builtins::Generate_WasmOnStackReplace(MacroAssembler* masm) {
MemOperand OSRTargetSlot(rbp, -wasm::kOSRTargetOffset);
__ movq(kScratchRegister, OSRTargetSlot);
__ movq(OSRTargetSlot, Immediate(0));
__ Move(OSRTargetSlot, 0);
__ jmp(kScratchRegister);
}
@ -3679,8 +3678,8 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
ExternalReference::Create(Runtime::kUnwindAndFindExceptionHandler);
{
FrameScope scope(masm, StackFrame::MANUAL);
__ movq(arg_reg_1, Immediate(0)); // argc.
__ movq(arg_reg_2, Immediate(0)); // argv.
__ Move(arg_reg_1, 0); // argc.
__ Move(arg_reg_2, 0); // argv.
__ Move(arg_reg_3, ExternalReference::isolate_address(masm->isolate()));
__ PrepareCallCFunction(3);
__ CallCFunction(find_handler, 3);
@ -4188,7 +4187,7 @@ void Generate_DeoptimizationEntry(MacroAssembler* masm,
// this on linux), since it is another parameter passing register on windows.
Register arg5 = r15;
__ movq(arg_reg_3, Immediate(Deoptimizer::kFixedExitSizeMarker));
__ Move(arg_reg_3, Deoptimizer::kFixedExitSizeMarker);
// Get the address of the location in the code object
// and compute the fp-to-sp delta in register arg5.
__ movq(arg_reg_4, Operand(rsp, kCurrentOffsetToReturnAddress));
@ -4199,7 +4198,7 @@ void Generate_DeoptimizationEntry(MacroAssembler* masm,
// Allocate a new deoptimizer object.
__ PrepareCallCFunction(6);
__ movq(rax, Immediate(0));
__ Move(rax, 0);
Label context_check;
__ movq(rdi, Operand(rbp, CommonFrameConstants::kContextOrFrameTypeOffset));
__ JumpIfSmi(rdi, &context_check);
@ -4471,7 +4470,7 @@ void Generate_BaselineEntry(MacroAssembler* masm, bool next_bytecode,
__ bind(&function_entry_bytecode);
// If the bytecode offset is kFunctionEntryOffset, get the start address of
// the first bytecode.
__ movq(kInterpreterBytecodeOffsetRegister, Immediate(0));
__ Move(kInterpreterBytecodeOffsetRegister, 0);
if (next_bytecode) {
__ LoadAddress(get_baseline_pc,
ExternalReference::baseline_pc_for_bytecode_offset());

View File

@ -623,7 +623,7 @@ void TurboAssembler::Abort(AbortReason reason) {
if (should_abort_hard()) {
// We don't care if we constructed a frame. Just pretend we did.
FrameScope assume_frame(this, StackFrame::NONE);
movl(arg_reg_1, Immediate(static_cast<int>(reason)));
Move(arg_reg_1, static_cast<int>(reason));
PrepareCallCFunction(1);
LoadAddress(rax, ExternalReference::abort_with_reason());
call(rax);
@ -2397,7 +2397,7 @@ void TurboAssembler::Lzcntl(Register dst, Register src) {
Label not_zero_src;
bsrl(dst, src);
j(not_zero, &not_zero_src, Label::kNear);
movl(dst, Immediate(63)); // 63^31 == 32
Move(dst, 63); // 63^31 == 32
bind(&not_zero_src);
xorl(dst, Immediate(31)); // for x in [0..31], 31^x == 31 - x
}
@ -2411,7 +2411,7 @@ void TurboAssembler::Lzcntl(Register dst, Operand src) {
Label not_zero_src;
bsrl(dst, src);
j(not_zero, &not_zero_src, Label::kNear);
movl(dst, Immediate(63)); // 63^31 == 32
Move(dst, 63); // 63^31 == 32
bind(&not_zero_src);
xorl(dst, Immediate(31)); // for x in [0..31], 31^x == 31 - x
}
@ -2425,7 +2425,7 @@ void TurboAssembler::Lzcntq(Register dst, Register src) {
Label not_zero_src;
bsrq(dst, src);
j(not_zero, &not_zero_src, Label::kNear);
movl(dst, Immediate(127)); // 127^63 == 64
Move(dst, 127); // 127^63 == 64
bind(&not_zero_src);
xorl(dst, Immediate(63)); // for x in [0..63], 63^x == 63 - x
}
@ -2439,7 +2439,7 @@ void TurboAssembler::Lzcntq(Register dst, Operand src) {
Label not_zero_src;
bsrq(dst, src);
j(not_zero, &not_zero_src, Label::kNear);
movl(dst, Immediate(127)); // 127^63 == 64
Move(dst, 127); // 127^63 == 64
bind(&not_zero_src);
xorl(dst, Immediate(63)); // for x in [0..63], 63^x == 63 - x
}
@ -2454,7 +2454,7 @@ void TurboAssembler::Tzcntq(Register dst, Register src) {
bsfq(dst, src);
j(not_zero, &not_zero_src, Label::kNear);
// Define the result of tzcnt(0) separately, because bsf(0) is undefined.
movl(dst, Immediate(64));
Move(dst, 64);
bind(&not_zero_src);
}
@ -2468,7 +2468,7 @@ void TurboAssembler::Tzcntq(Register dst, Operand src) {
bsfq(dst, src);
j(not_zero, &not_zero_src, Label::kNear);
// Define the result of tzcnt(0) separately, because bsf(0) is undefined.
movl(dst, Immediate(64));
Move(dst, 64);
bind(&not_zero_src);
}
@ -2481,7 +2481,7 @@ void TurboAssembler::Tzcntl(Register dst, Register src) {
Label not_zero_src;
bsfl(dst, src);
j(not_zero, &not_zero_src, Label::kNear);
movl(dst, Immediate(32)); // The result of tzcnt is 32 if src = 0.
Move(dst, 32); // The result of tzcnt is 32 if src = 0.
bind(&not_zero_src);
}
@ -2494,7 +2494,7 @@ void TurboAssembler::Tzcntl(Register dst, Operand src) {
Label not_zero_src;
bsfl(dst, src);
j(not_zero, &not_zero_src, Label::kNear);
movl(dst, Immediate(32)); // The result of tzcnt is 32 if src = 0.
Move(dst, 32); // The result of tzcnt is 32 if src = 0.
bind(&not_zero_src);
}
@ -3198,14 +3198,14 @@ void MacroAssembler::LeaveExitFrameEpilogue() {
Operand context_operand = ExternalReferenceAsOperand(context_address);
movq(rsi, context_operand);
#ifdef DEBUG
movq(context_operand, Immediate(Context::kInvalidContext));
Move(context_operand, Context::kInvalidContext);
#endif
// Clear the top frame.
ExternalReference c_entry_fp_address =
ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, isolate());
Operand c_entry_fp_operand = ExternalReferenceAsOperand(c_entry_fp_address);
movq(c_entry_fp_operand, Immediate(0));
Move(c_entry_fp_operand, 0);
}
#ifdef V8_TARGET_OS_WIN

View File

@ -957,7 +957,7 @@ void CodeGenerator::GenerateSpeculationPoisonFromCodeStartRegister() {
__ ComputeCodeStartAddress(rbx);
__ xorq(kSpeculationPoisonRegister, kSpeculationPoisonRegister);
__ cmpq(kJavaScriptCallCodeStartRegister, rbx);
__ movq(rbx, Immediate(-1));
__ Move(rbx, -1);
__ cmovq(equal, kSpeculationPoisonRegister, rbx);
}
@ -3521,7 +3521,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
uint8_t bmask = static_cast<uint8_t>(0xff << shift);
uint32_t mask = bmask << 24 | bmask << 16 | bmask << 8 | bmask;
__ movl(tmp, Immediate(mask));
__ Move(tmp, mask);
__ Movd(tmp_simd, tmp);
__ Pshufd(tmp_simd, tmp_simd, uint8_t{0});
__ Pand(dst, tmp_simd);
@ -3637,7 +3637,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
uint8_t bmask = 0xff >> shift;
uint32_t mask = bmask << 24 | bmask << 16 | bmask << 8 | bmask;
__ movl(tmp, Immediate(mask));
__ Move(tmp, mask);
__ Movd(tmp_simd, tmp);
__ Pshufd(tmp_simd, tmp_simd, byte{0});
__ Pand(dst, tmp_simd);
@ -4388,7 +4388,7 @@ void CodeGenerator::AssembleBranchPoisoning(FlagsCondition condition,
}
condition = NegateFlagsCondition(condition);
__ movl(kScratchRegister, Immediate(0));
__ Move(kScratchRegister, 0);
__ cmovq(FlagsConditionToCondition(condition), kSpeculationPoisonRegister,
kScratchRegister);
}
@ -4467,11 +4467,11 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr,
Register reg = i.OutputRegister(instr->OutputCount() - 1);
if (condition == kUnorderedEqual) {
__ j(parity_odd, &check, Label::kNear);
__ movl(reg, Immediate(0));
__ Move(reg, 0);
__ jmp(&done, Label::kNear);
} else if (condition == kUnorderedNotEqual) {
__ j(parity_odd, &check, Label::kNear);
__ movl(reg, Immediate(1));
__ Move(reg, 1);
__ jmp(&done, Label::kNear);
}
__ bind(&check);
@ -4872,7 +4872,7 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
if (value == 0) {
__ xorl(dst, dst);
} else {
__ movl(dst, Immediate(value));
__ Move(dst, value);
}
}
break;
@ -4928,7 +4928,7 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
if (!RelocInfo::IsWasmReference(src.rmode())) {
switch (src.type()) {
case Constant::kInt32:
__ movq(dst, Immediate(src.ToInt32()));
__ Move(dst, src.ToInt32());
return;
case Constant::kInt64:
__ Move(dst, src.ToInt64());
@ -5036,7 +5036,7 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
} else {
DCHECK(destination->IsFPStackSlot());
if (src.type() == Constant::kFloat32) {
__ movl(dst, Immediate(bit_cast<uint32_t>(src.ToFloat32())));
__ Move(dst, bit_cast<uint32_t>(src.ToFloat32()));
} else {
DCHECK_EQ(src.type(), Constant::kFloat64);
__ movq(kScratchRegister, src.ToFloat64().AsUint64());

View File

@ -476,7 +476,7 @@ void RegExpMacroAssemblerX64::CheckCharacterAfterAnd(uint32_t c,
if (c == 0) {
__ testl(current_character(), Immediate(mask));
} else {
__ movl(rax, Immediate(mask));
__ Move(rax, mask);
__ andq(rax, current_character());
__ cmpl(rax, Immediate(c));
}
@ -490,7 +490,7 @@ void RegExpMacroAssemblerX64::CheckNotCharacterAfterAnd(uint32_t c,
if (c == 0) {
__ testl(current_character(), Immediate(mask));
} else {
__ movl(rax, Immediate(mask));
__ Move(rax, mask);
__ andq(rax, current_character());
__ cmpl(rax, Immediate(c));
}
@ -895,7 +895,7 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
__ jmp(&load_char_start_regexp);
} else {
__ movq(rax, Immediate(SUCCESS));
__ Move(rax, SUCCESS);
}
}
@ -1108,7 +1108,7 @@ void RegExpMacroAssemblerX64::SetCurrentPositionFromEnd(int by) {
Label after_position;
__ cmpq(rdi, Immediate(-by * char_size()));
__ j(greater_equal, &after_position, Label::kNear);
__ movq(rdi, Immediate(-by * char_size()));
__ Move(rdi, -by * char_size());
// On RegExp code entry (where this operation is used), the character before
// the current position is expected to be already loaded.
// We have advanced the position, so it's safe to read backwards.