-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement global.{get,set} instruction execution
- Loading branch information
Showing
2 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use super::Executor; | ||
use crate::engine::{ | ||
bytecode::GlobalIdx, | ||
bytecode2::{Const16, Register}, | ||
}; | ||
use wasmi_core::UntypedValue; | ||
|
||
#[cfg(doc)] | ||
use crate::engine::bytecode2::Instruction; | ||
|
||
impl<'ctx, 'engine> Executor<'ctx, 'engine> { | ||
/// Executes an [`Instruction::GlobalGet`]. | ||
#[inline(always)] | ||
pub fn execute_global_get(&mut self, result: Register, global: GlobalIdx) { | ||
todo!() | ||
} | ||
|
||
/// Executes an [`Instruction::GlobalSet`]. | ||
#[inline(always)] | ||
pub fn execute_global_set(&mut self, global: GlobalIdx, input: Register) { | ||
let input = self.get_register(input); | ||
self.execute_global_set_impl(global, input) | ||
} | ||
|
||
/// Executes an [`Instruction::GlobalSetI32Imm16`]. | ||
#[inline(always)] | ||
pub fn execute_global_set_i32imm16(&mut self, global: GlobalIdx, input: Const16<i32>) { | ||
let input = i32::from(input).into(); | ||
self.execute_global_set_impl(global, input) | ||
} | ||
|
||
/// Executes an [`Instruction::GlobalSetI64Imm16`]. | ||
#[inline(always)] | ||
pub fn execute_global_set_i64imm16(&mut self, global: GlobalIdx, input: Const16<i64>) { | ||
let input = i64::from(input).into(); | ||
self.execute_global_set_impl(global, input) | ||
} | ||
|
||
/// Executes a generic `global.set` instruction. | ||
fn execute_global_set_impl(&mut self, global: GlobalIdx, new_value: UntypedValue) { | ||
self.cache.set_global(self.ctx, global, new_value); | ||
self.next_instr() | ||
} | ||
} |