WASM runtime switch to import memory (#4737)

* WASM runtime switch to import memory

Up to now runtimes have exported their memory. To unify it with
sandboxing, this pr switches runtimes to import memory as well.

From a functional perspective, exporting/importing memory makes no
difference to the runtime.

To provide backwards compatibility, WASM exported memory is still supported.

* Revert debug stuff

* Revert some stuff
This commit is contained in:
Bastian Köcher
2020-01-28 09:36:57 +01:00
committed by GitHub
parent 5c8743510e
commit 793a1eb053
15 changed files with 603 additions and 428 deletions
+8 -13
View File
@@ -14,22 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use wasm_builder_runner::{build_current_project_with_rustflags, WasmBuilderSource};
use wasm_builder_runner::WasmBuilder;
fn main() {
build_current_project_with_rustflags(
"wasm_binary.rs",
WasmBuilderSource::CratesOrPath {
path: "../../utils/wasm-builder",
version: "1.0.9",
},
WasmBuilder::new()
.with_current_project()
.with_wasm_builder_from_crates_or_path("1.0.9", "../../utils/wasm-builder")
.export_heap_base()
// Note that we set the stack-size to 1MB explicitly even though it is set
// to this value by default. This is because some of our tests (`restoration_of_globals`)
// depend on the stack-size.
//
// The --export=__heap_base instructs LLD to export __heap_base as a global variable, which
// is used by the external memory allocator.
"-Clink-arg=-zstack-size=1048576 \
-Clink-arg=--export=__heap_base",
);
.append_to_rust_flags("-Clink-arg=-zstack-size=1048576")
.import_memory()
.build()
}