From b9d83b4695d5f3f19eb660267aecd4783ec70c68 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Thu, 20 Apr 2017 17:00:52 +0300 Subject: [PATCH] contract3 with heap --- runner/index.html | 2 +- samples/contract3.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 samples/contract3.rs diff --git a/runner/index.html b/runner/index.html index c07a073..64eeb9b 100644 --- a/runner/index.html +++ b/runner/index.html @@ -80,7 +80,7 @@ imports.env.memory = new WebAssembly.Memory({ initial: 256, maximum: 256 }); } if (!imports.env.table) { - imports.env.table = new WebAssembly.Table({ initial: 8, maximum: 8, element: 'anyfunc' }); + imports.env.table = new WebAssembly.Table({ initial: 0, maximum: 0, element: 'anyfunc' }); } return new WebAssembly.Instance(module, imports); }); diff --git a/samples/contract3.rs b/samples/contract3.rs new file mode 100644 index 0000000..a03d6c0 --- /dev/null +++ b/samples/contract3.rs @@ -0,0 +1,16 @@ +#![feature(link_args)] +#![feature(drop_types_in_const)] +#![no_main] + +use std::slice; + +#[link_args = "-s WASM=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1"] +extern {} + +#[no_mangle] +pub fn call(input: *mut u8) { + let mut slice = unsafe { slice::from_raw_parts_mut(input, 8192) }; // 8kb input data + for i in 0..slice.len() { + slice[i] = slice[i] + 2; + } +} \ No newline at end of file