From d043adf7b302da014f10fd036141459450a5a332 Mon Sep 17 00:00:00 2001 From: Nidin Vinayakan <01@01alchemist.com> Date: Thu, 24 Jan 2019 13:02:44 +0100 Subject: [PATCH 1/3] Added shared memory support in binaryen definition Extended `_BinaryenAddMemoryImport` and `_BinaryenSetMemory` functions with `shared: bool` argument This will configure WASM memory as shared. --- src/glue/binaryen.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glue/binaryen.d.ts b/src/glue/binaryen.d.ts index 8a5cf1a183..4924bce473 100644 --- a/src/glue/binaryen.d.ts +++ b/src/glue/binaryen.d.ts @@ -552,7 +552,7 @@ declare type BinaryenImportRef = usize; declare function _BinaryenAddFunctionImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize, functionType: BinaryenFunctionTypeRef): BinaryenImportRef; declare function _BinaryenAddTableImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize): BinaryenImportRef; -declare function _BinaryenAddMemoryImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize): BinaryenImportRef; +declare function _BinaryenAddMemoryImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize, shared:bool): BinaryenImportRef; declare function _BinaryenAddGlobalImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize, globalType: BinaryenType): BinaryenImportRef; declare type BinaryenExportRef = usize; @@ -570,7 +570,7 @@ declare function _BinaryenRemoveGlobal(module: BinaryenModuleRef, name: usize): declare function _BinaryenSetFunctionTable(module: BinaryenModuleRef, initial: BinaryenIndex, maximum: BinaryenIndex, funcs: usize, numFuncs: BinaryenIndex): void; -declare function _BinaryenSetMemory(module: BinaryenModuleRef, initial: BinaryenIndex, maximum: BinaryenIndex, exportName: usize, segments: usize, segmentOffsets: usize, segmentSizes: usize, numSegments: BinaryenIndex): void; +declare function _BinaryenSetMemory(module: BinaryenModuleRef, initial: BinaryenIndex, maximum: BinaryenIndex, exportName: usize, segments: usize, segmentOffsets: usize, segmentSizes: usize, numSegments: BinaryenIndex, shared: bool): void; declare function _BinaryenSetStart(module: BinaryenModuleRef, start: BinaryenFunctionRef): void; From a0a6aaf70be4550a90f5596c7c77f188cc109540 Mon Sep 17 00:00:00 2001 From: Nidin Vinayakan <01@01alchemist.com> Date: Fri, 25 Jan 2019 10:37:37 +0100 Subject: [PATCH 2/3] NOTICE File updated Updated AssemblyScript contributions author list --- NOTICE | 1 + 1 file changed, 1 insertion(+) diff --git a/NOTICE b/NOTICE index cf9d101463..9861af34ae 100644 --- a/NOTICE +++ b/NOTICE @@ -11,6 +11,7 @@ under the licensing terms detailed in LICENSE: * Palmer * Linus Unnebäck * Joshua Tenner +* Nidin Vinayakan <01@01alchemist.com> Portions of this software are derived from third-party works licensed under the following terms: From 75d7bc513906bebe71eb183f2f839234bba9f235 Mon Sep 17 00:00:00 2001 From: Nidin Vinayakan <01@01alchemist.com> Date: Fri, 25 Jan 2019 10:41:37 +0100 Subject: [PATCH 3/3] Module.ts updated with binaryen shared memory arguments `shared:bool` argument added to `addMemoryImport` and `setMemory` functions --- src/module.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/module.ts b/src/module.ts index bdff2d24e3..f4e223fd1d 100644 --- a/src/module.ts +++ b/src/module.ts @@ -905,13 +905,14 @@ export class Module { addMemoryImport( internalName: string, externalModuleName: string, - externalBaseName: string + externalBaseName: string, + shared: bool = false, ): ImportRef { var cStr1 = allocString(internalName); var cStr2 = allocString(externalModuleName); var cStr3 = allocString(externalBaseName); try { - return _BinaryenAddMemoryImport(this.ref, cStr1, cStr2, cStr3); + return _BinaryenAddMemoryImport(this.ref, cStr1, cStr2, cStr3, shared); } finally { memory.free(cStr3); memory.free(cStr2); @@ -945,7 +946,8 @@ export class Module { maximum: Index, segments: MemorySegment[], target: Target, - exportName: string | null = null + exportName: string | null = null, + shared: bool = false ): void { var cStr = allocString(exportName); var k = segments.length; @@ -965,7 +967,7 @@ export class Module { var cArr2 = allocI32Array(offs); var cArr3 = allocI32Array(sizs); try { - _BinaryenSetMemory(this.ref, initial, maximum, cStr, cArr1, cArr2, cArr3, k); + _BinaryenSetMemory(this.ref, initial, maximum, cStr, cArr1, cArr2, cArr3, k, shared); } finally { memory.free(cArr3); memory.free(cArr2);