Skip to content

Commit

Permalink
remove memory_consumption_compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
yjhmelody committed Sep 13, 2023
1 parent d797adb commit 288d7fa
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 227 deletions.
17 changes: 0 additions & 17 deletions substrate/client/executor/common/src/wasm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,6 @@ pub trait WasmInstance: Send {
self.call(method.into(), data)
}

/// **Testing Only**. This function also returns the base address of the linear memory.
///
/// This is meant to be the starting address of the memory mapped area for the linear memory.
/// This function is intended only for a specific test that measures physical memory
/// consumption.
///
/// Call an exported method on this WASM instance.
///
/// Before execution, instance is reset.
///
/// Returns the encoded result on success.
fn call_export_with_base_ptr(
&mut self,
method: &str,
data: &[u8],
) -> Result<(Vec<u8>, Option<*const u8>), Error>;

/// Get the value from a global with the given `name`.
///
/// This method is only suitable for getting immutable globals.
Expand Down
84 changes: 0 additions & 84 deletions substrate/client/executor/src/integration_tests/linux.rs

This file was deleted.

82 changes: 0 additions & 82 deletions substrate/client/executor/src/integration_tests/linux/smaps.rs

This file was deleted.

3 changes: 0 additions & 3 deletions substrate/client/executor/src/integration_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#[cfg(target_os = "linux")]
mod linux;

use assert_matches::assert_matches;
use codec::{Decode, Encode};
use sc_executor_common::{
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/executor/wasmtime/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::{instance_wrapper::MemoryWrapper, runtime::StoreData, util};
pub struct HostState {
/// The allocator instance to keep track of allocated memory.
///
/// This is stored as an `Option` as we need to temporarly set this to `None` when we are
/// This is stored as an `Option` as we need to temporarily set this to `None` when we are
/// allocating/deallocating memory. The problem being that we can only mutable access `caller`
/// once.
allocator: Option<FreeingBumpHeapAllocator>,
Expand Down
6 changes: 0 additions & 6 deletions substrate/client/executor/wasmtime/src/instance_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@ impl InstanceWrapper {
Ok(InstanceWrapper { instance, store })
}

/// **Testing Only**.
pub(crate) fn base_ptr(&mut self) -> *const u8 {
let mem = self.store.data().memory();
mem.data_ptr(&self.store)
}

/// Resolves a substrate entrypoint by the given name.
///
/// An entrypoint must have a signature `(i32, i32) -> i64`, otherwise this function will return
Expand Down
39 changes: 5 additions & 34 deletions substrate/client/executor/wasmtime/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ enum Strategy {
}

struct InstanceCreator {
engine: wasmtime::Engine,
engine: Engine,
instance_pre: Arc<wasmtime::InstancePre<StoreData>>,
}

Expand All @@ -84,7 +84,7 @@ impl InstanceCreator {
/// A `WasmModule` implementation using wasmtime to compile the runtime module to machine code
/// and execute the compiled code.
pub struct WasmtimeRuntime {
engine: wasmtime::Engine,
engine: Engine,
instance_pre: Arc<wasmtime::InstancePre<StoreData>>,
instantiation_strategy: InternalInstantiationStrategy,
}
Expand Down Expand Up @@ -126,26 +126,6 @@ impl WasmtimeInstance {
},
}
}

/// **Testing Only**.
fn call_impl_with_base_ptr(
&mut self,
method: InvokeMethod,
data: &[u8],
) -> Result<(Vec<u8>, Option<*const u8>)> {
match &mut self.strategy {
Strategy::RecreateInstance(ref mut instance_creator) => {
let mut instance_wrapper = instance_creator.instantiate()?;
let heap_base = instance_wrapper.extract_heap_base()?;
let entrypoint = instance_wrapper.resolve_entrypoint(method)?;
let allocator = FreeingBumpHeapAllocator::new(heap_base);
let bytes =
perform_call(data, &mut instance_wrapper, entrypoint, allocator, &mut None)?;

Ok((bytes, Some(instance_wrapper.base_ptr())))
},
}
}
}

impl WasmInstance for WasmtimeInstance {
Expand All @@ -159,19 +139,10 @@ impl WasmInstance for WasmtimeInstance {
(result, allocation_stats)
}

fn call_export_with_base_ptr(
&mut self,
method: &str,
data: &[u8],
) -> std::result::Result<(Vec<u8>, Option<*const u8>), Error> {
self.call_impl_with_base_ptr(method.into(), data)
}

fn get_global_const(&mut self, name: &str) -> Result<Option<Value>> {
match &mut self.strategy {
Strategy::RecreateInstance(ref mut instance_creator) => {
instance_creator.instantiate()?.get_global_val(name)
},
Strategy::RecreateInstance(ref mut instance_creator) =>
instance_creator.instantiate()?.get_global_val(name),
}
}
}
Expand Down Expand Up @@ -338,7 +309,7 @@ fn common_config(semantics: &Semantics) -> std::result::Result<wasmtime::Config,
///
/// See [here][stack_height] for more details of the instrumentation
///
/// [stack_height]: https://github.com/paritytech/wasm-utils/blob/d9432baf/src/stack_height/mod.rs#L1-L50
/// [stack_height]: https://github.com/paritytech/wasm-instrument/blob/master/src/stack_limiter/mod.rs
#[derive(Clone)]
pub struct DeterministicStackLimit {
/// A number of logical "values" that can be pushed on the wasm stack. A trap will be triggered
Expand Down

0 comments on commit 288d7fa

Please sign in to comment.