From 7f3841f055bd1a53c8f1a318e20051cad69da26f Mon Sep 17 00:00:00 2001 From: Jan Bujak Date: Thu, 14 Nov 2024 11:38:07 +0000 Subject: [PATCH] Add `is_64_bit` to `RawInstance` and `Module` --- crates/polkavm/src/api.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/polkavm/src/api.rs b/crates/polkavm/src/api.rs index 7bd13caa..cd77c8ff 100644 --- a/crates/polkavm/src/api.rs +++ b/crates/polkavm/src/api.rs @@ -596,6 +596,11 @@ impl Module { Ok(Module(Some(module))) } + /// Returns whether the module is 64-bit. + pub fn is_64_bit(&self) -> bool { + self.state().blob.is_64_bit() + } + /// Fetches a cached module for the given `blob`. #[cfg_attr(not(feature = "module-cache"), allow(unused_variables))] pub fn from_cache(engine: &Engine, config: &ModuleConfig, blob: &ProgramBlob) -> Option { @@ -902,6 +907,11 @@ impl RawInstance { &self.module } + /// Returns whether we're running a 64-bit program. + pub fn is_64_bit(&self) -> bool { + self.module.is_64_bit() + } + /// Starts or resumes the execution. pub fn run(&mut self) -> Result { if self.next_program_counter().is_none() {