Struct sc_executor_common::runtime_blob::RuntimeBlob
source · pub struct RuntimeBlob { /* private fields */ }
Expand description
A bunch of information collected from a WebAssembly module.
Implementations§
source§impl RuntimeBlob
impl RuntimeBlob
sourcepub fn uncompress_if_needed(wasm_code: &[u8]) -> Result<Self, WasmError>
pub fn uncompress_if_needed(wasm_code: &[u8]) -> Result<Self, WasmError>
Create RuntimeBlob
from the given wasm code. Will attempt to decompress the code before
deserializing it.
See sp_maybe_compressed_blob
for details about decompression.
sourcepub fn new(wasm_code: &[u8]) -> Result<Self, WasmError>
pub fn new(wasm_code: &[u8]) -> Result<Self, WasmError>
Create RuntimeBlob
from the given wasm code.
Returns Err
if the wasm code cannot be deserialized.
sourcepub fn declared_globals_count(&self) -> u32
pub fn declared_globals_count(&self) -> u32
The number of globals defined in locally in this module.
sourcepub fn imported_globals_count(&self) -> u32
pub fn imported_globals_count(&self) -> u32
The number of imports of globals.
sourcepub fn expose_mutable_globals(&mut self)
pub fn expose_mutable_globals(&mut self)
Perform an instrumentation that makes sure that the mutable globals are exported.
sourcepub fn inject_stack_depth_metering(
self,
stack_depth_limit: u32
) -> Result<Self, WasmError>
pub fn inject_stack_depth_metering( self, stack_depth_limit: u32 ) -> Result<Self, WasmError>
Run a pass that instrument this module so as to introduce a deterministic stack height limit.
It will introduce a global mutable counter. The instrumentation will increase the counter
according to the “cost” of the callee. If the cost exceeds the stack_depth_limit
constant,
the instrumentation will trap. The counter will be decreased as soon as the the callee
returns.
The stack cost of a function is computed based on how much locals there are and the maximum depth of the wasm operand stack.
sourcepub fn entry_point_exists(&self, entry_point: &str) -> bool
pub fn entry_point_exists(&self, entry_point: &str) -> bool
Perform an instrumentation that makes sure that a specific function entry_point
is
exported
sourcepub fn convert_memory_import_into_export(&mut self) -> Result<(), WasmError>
pub fn convert_memory_import_into_export(&mut self) -> Result<(), WasmError>
Converts a WASM memory import into a memory section and exports it.
Does nothing if there’s no memory import.
May return an error in case the WASM module is invalid.
sourcepub fn setup_memory_according_to_heap_alloc_strategy(
&mut self,
heap_alloc_strategy: HeapAllocStrategy
) -> Result<(), WasmError>
pub fn setup_memory_according_to_heap_alloc_strategy( &mut self, heap_alloc_strategy: HeapAllocStrategy ) -> Result<(), WasmError>
Modifies the blob’s memory section according to the given heap_alloc_strategy
.
Will return an error in case there is no memory section present, or if the memory section is empty.
sourcepub fn custom_section_contents(&self, section_name: &str) -> Option<&[u8]>
pub fn custom_section_contents(&self, section_name: &str) -> Option<&[u8]>
Scans the wasm blob for the first section with the name that matches the given. Returns the
contents of the custom section if found or None
otherwise.
sourcepub fn into_inner(self) -> Module
pub fn into_inner(self) -> Module
Destructure this structure into the underlying parity-wasm Module.
Trait Implementations§
source§impl Clone for RuntimeBlob
impl Clone for RuntimeBlob
source§fn clone(&self) -> RuntimeBlob
fn clone(&self) -> RuntimeBlob
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl RefUnwindSafe for RuntimeBlob
impl Send for RuntimeBlob
impl Sync for RuntimeBlob
impl Unpin for RuntimeBlob
impl UnwindSafe for RuntimeBlob
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.