Skip to content

Commit

Permalink
Add the ability to call directly through a register.
Browse files Browse the repository at this point in the history
Simplify some code a little using it.
  • Loading branch information
nlewycky committed Feb 1, 2021
1 parent 05f356f commit 6336627
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
16 changes: 2 additions & 14 deletions lib/compiler-singlepass/src/codegen_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5674,13 +5674,7 @@ impl<'a> FuncGen<'a> {
);
self.emit_call_sysv(
|this| {
let label = this.assembler.get_label();
let after = this.assembler.get_label();
this.assembler.emit_jmp(Condition::None, after);
this.assembler.emit_label(label);
this.assembler.emit_host_redirection(GPR::RAX);
this.assembler.emit_label(after);
this.assembler.emit_call_label(label);
this.assembler.emit_call_register(GPR::RAX);
},
// [vmctx, memory_index]
iter::once(Location::Imm32(memory_index.index() as u32)),
Expand Down Expand Up @@ -5719,13 +5713,7 @@ impl<'a> FuncGen<'a> {

self.emit_call_sysv(
|this| {
let label = this.assembler.get_label();
let after = this.assembler.get_label();
this.assembler.emit_jmp(Condition::None, after);
this.assembler.emit_label(label);
this.assembler.emit_host_redirection(GPR::RAX);
this.assembler.emit_label(after);
this.assembler.emit_call_label(label);
this.assembler.emit_call_register(GPR::RAX);
},
// [vmctx, val, memory_index]
iter::once(param_pages)
Expand Down
6 changes: 6 additions & 0 deletions lib/compiler-singlepass/src/emitter_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ pub trait Emitter {
fn emit_call_label(&mut self, label: Self::Label);
fn emit_call_location(&mut self, loc: Location);

fn emit_call_register(&mut self, reg: GPR);

fn emit_bkpt(&mut self);

fn emit_host_redirection(&mut self, target: GPR);
Expand Down Expand Up @@ -1389,6 +1391,10 @@ impl Emitter for Assembler {
}
}

fn emit_call_register(&mut self, reg: GPR) {
dynasm!(self ; call Rq(reg as u8));
}

fn emit_bkpt(&mut self) {
dynasm!(self ; int 0x3);
}
Expand Down

0 comments on commit 6336627

Please sign in to comment.