Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor - reduce usage of REGISTER_OTHER_SCRATCH #596

Merged
merged 8 commits into from
Sep 26, 2024

Conversation

Lichtso
Copy link

@Lichtso Lichtso commented Sep 25, 2024

Reduces the machinecode emitted for:

  • internal immediate calls from 60 to 47 (-22%)
  • internal register calls from 67 to 36 (-46%)

@Lichtso Lichtso requested a review from LucasSte September 25, 2024 07:56
self.emit_ins(X86Instruction::store(OperandSize::S64, REGISTER_MAP[0], REGISTER_OTHER_SCRATCH, X86IndirectAccess::Offset(std::mem::size_of::<u64>() as i32))); // result.return_value = R0;
self.emit_ins(X86Instruction::load_immediate(OperandSize::S64, REGISTER_MAP[0], 0));
if self.config.enable_instruction_meter {
self.emit_ins(X86Instruction::alu(OperandSize::S64, 0x29, REGISTER_SCRATCH, REGISTER_INSTRUCTION_METER, 0, None)); // REGISTER_INSTRUCTION_METER -= pc;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This operation is re-emitted in ANCHOR_EXIT, even though REGISTER_SCRATCH is zero.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked the other PR for removing REGISTER_OTHER_SCRATCH yet, so, please, ignore this comment if this is solved there.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the code for the instruction metering is redundant to that in ANCHOR_EPILOGUE, which is on purpose. Because REGISTER_SCRATCH is clobbered here and then zeroed out so that it is not double metered later.

@Lichtso Lichtso merged commit 9d1a9a0 into main Sep 26, 2024
12 checks passed
@Lichtso Lichtso deleted the refactor/free_second_scratch_register branch September 26, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants