Skip to content

Commit b7c7be1

Browse files
nidindcodeIO
authored andcommitted
Add shared memory definitions and initial API (AssemblyScript#435)
1 parent c744106 commit b7c7be1

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

NOTICE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ under the licensing terms detailed in LICENSE:
1111
* Palmer <pengliao@live.cn>
1212
* Linus Unnebäck <linus@folkdatorn.se>
1313
* Joshua Tenner <tenner.joshua@gmail.com>
14+
* Nidin Vinayakan <01@01alchemist.com>
1415

1516
Portions of this software are derived from third-party works licensed under
1617
the following terms:

src/glue/binaryen.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ declare type BinaryenImportRef = usize;
552552

553553
declare function _BinaryenAddFunctionImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize, functionType: BinaryenFunctionTypeRef): BinaryenImportRef;
554554
declare function _BinaryenAddTableImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize): BinaryenImportRef;
555-
declare function _BinaryenAddMemoryImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize): BinaryenImportRef;
555+
declare function _BinaryenAddMemoryImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize, shared:bool): BinaryenImportRef;
556556
declare function _BinaryenAddGlobalImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize, globalType: BinaryenType): BinaryenImportRef;
557557

558558
declare type BinaryenExportRef = usize;
@@ -570,7 +570,7 @@ declare function _BinaryenRemoveGlobal(module: BinaryenModuleRef, name: usize):
570570

571571
declare function _BinaryenSetFunctionTable(module: BinaryenModuleRef, initial: BinaryenIndex, maximum: BinaryenIndex, funcs: usize, numFuncs: BinaryenIndex): void;
572572

573-
declare function _BinaryenSetMemory(module: BinaryenModuleRef, initial: BinaryenIndex, maximum: BinaryenIndex, exportName: usize, segments: usize, segmentOffsets: usize, segmentSizes: usize, numSegments: BinaryenIndex): void;
573+
declare function _BinaryenSetMemory(module: BinaryenModuleRef, initial: BinaryenIndex, maximum: BinaryenIndex, exportName: usize, segments: usize, segmentOffsets: usize, segmentSizes: usize, numSegments: BinaryenIndex, shared: bool): void;
574574

575575
declare function _BinaryenSetStart(module: BinaryenModuleRef, start: BinaryenFunctionRef): void;
576576

src/module.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,13 +905,14 @@ export class Module {
905905
addMemoryImport(
906906
internalName: string,
907907
externalModuleName: string,
908-
externalBaseName: string
908+
externalBaseName: string,
909+
shared: bool = false,
909910
): ImportRef {
910911
var cStr1 = allocString(internalName);
911912
var cStr2 = allocString(externalModuleName);
912913
var cStr3 = allocString(externalBaseName);
913914
try {
914-
return _BinaryenAddMemoryImport(this.ref, cStr1, cStr2, cStr3);
915+
return _BinaryenAddMemoryImport(this.ref, cStr1, cStr2, cStr3, shared);
915916
} finally {
916917
memory.free(cStr3);
917918
memory.free(cStr2);
@@ -945,7 +946,8 @@ export class Module {
945946
maximum: Index,
946947
segments: MemorySegment[],
947948
target: Target,
948-
exportName: string | null = null
949+
exportName: string | null = null,
950+
shared: bool = false
949951
): void {
950952
var cStr = allocString(exportName);
951953
var k = segments.length;
@@ -965,7 +967,7 @@ export class Module {
965967
var cArr2 = allocI32Array(offs);
966968
var cArr3 = allocI32Array(sizs);
967969
try {
968-
_BinaryenSetMemory(this.ref, initial, maximum, cStr, cArr1, cArr2, cArr3, k);
970+
_BinaryenSetMemory(this.ref, initial, maximum, cStr, cArr1, cArr2, cArr3, k, shared);
969971
} finally {
970972
memory.free(cArr3);
971973
memory.free(cArr2);

0 commit comments

Comments
 (0)