Skip to content

Commit f6501a9

Browse files
authored
Fix converge option (#1250)
1 parent 6ebbedc commit f6501a9

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

src/module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ export class Module {
16291629
binaryen._BinaryenModuleInterpret(this.ref);
16301630
}
16311631

1632-
toBinary(sourceMapUrl: string | null): BinaryModule {
1632+
toBinary(sourceMapUrl: string | null = null): BinaryModule {
16331633
var out = this.lit; // safe to reuse as long as..
16341634
assert(binaryen._BinaryenSizeofLiteral() >= 12);
16351635
var cStr = allocString(sourceMapUrl);
@@ -1642,7 +1642,7 @@ export class Module {
16421642
var ret = new BinaryModule();
16431643
ret.output = readBuffer(binaryPtr, binaryLen);
16441644
ret.sourceMap = readString(sourceMapPtr);
1645-
binaryen._free(cStr);
1645+
if (cStr) binaryen._free(cStr);
16461646
binaryen._free(binaryPtr);
16471647
if (sourceMapPtr) binaryen._free(sourceMapPtr);
16481648
return ret;

tests/compiler/converge.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"asc_flags": [
3+
"--runtime none",
4+
"--converge"
5+
]
6+
}

tests/compiler/converge.optimized.wat

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(module
2+
(type $none_=>_none (func))
3+
(memory $0 0)
4+
(export "memory" (memory $0))
5+
(export "test" (func $converge/test))
6+
(func $converge/test
7+
nop
8+
)
9+
)

tests/compiler/converge.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export function test(): void {}

tests/compiler/converge.untouched.wat

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(module
2+
(type $none_=>_none (func))
3+
(memory $0 0)
4+
(table $0 1 funcref)
5+
(export "memory" (memory $0))
6+
(export "test" (func $converge/test))
7+
(func $converge/test
8+
nop
9+
)
10+
)

0 commit comments

Comments
 (0)