From d4ec15f93eae5b2ecc005f5178ec456408c4de14 Mon Sep 17 00:00:00 2001 From: mtrofin Date: Thu, 15 Sep 2016 22:19:30 -0700 Subject: [PATCH] [wasm] additional serialization test Ensure we can serialize a wasm compiled module even after it was instantiated a few times. BUG= Review-Url: https://codereview.chromium.org/2339933003 Cr-Commit-Position: refs/heads/master@{#39463} --- .../wasm/compiled-module-serialization.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/mjsunit/wasm/compiled-module-serialization.js b/test/mjsunit/wasm/compiled-module-serialization.js index 94cc894275..00b9d19597 100644 --- a/test/mjsunit/wasm/compiled-module-serialization.js +++ b/test/mjsunit/wasm/compiled-module-serialization.js @@ -77,4 +77,24 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); assertFalse(clone == undefined); assertFalse(clone == compiled_module); assertEquals(clone.constructor, compiled_module.constructor); -})() +})(); + +(function SerializeAfterInstantiation() { + let builder = new WasmModuleBuilder(); + builder.addFunction("main", kSig_i) + .addBody([kExprI8Const, 42]) + .exportFunc(); + + var compiled_module = new WebAssembly.Module(builder.toBuffer()); + var instance1 = new WebAssembly.Instance(compiled_module); + var instance2 = new WebAssembly.Instance(compiled_module); + var serialized = %SerializeWasmModule(compiled_module); + var clone = %DeserializeWasmModule(serialized); + + assertNotNull(clone); + assertFalse(clone == undefined); + assertFalse(clone == compiled_module); + assertEquals(clone.constructor, compiled_module.constructor); + var instance3 = new WebAssembly.Instance(clone); + assertFalse(instance3 == undefined); +})();