Skip to content

Commit b652b46

Browse files
authored
Update binaryen (#2029)
1 parent ee6144c commit b652b46

File tree

99 files changed

+23771
-25118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+23771
-25118
lines changed

cli/asc.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ export interface CompilerOptions {
139139
maximumMemory?: number;
140140
/** Declare memory as shared. Requires maximumMemory. */
141141
sharedMemory?: boolean;
142+
/** Assume that imported memory is zero filled. Requires importMemory. */
143+
zeroFilledMemory?: boolean;
142144
/** Sets the start offset of compiler-generated static memory. */
143145
memoryBase?: number;
144146
/** Imports the function table provided as 'env.table'. */

cli/asc.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,10 @@ exports.main = function main(argv, options, callback) {
943943
// Optimize the module
944944
const debugInfo = opts.debug;
945945
const converge = opts.converge;
946+
const zeroFilledMemory = opts.importMemory
947+
? opts.zeroFilledMemory
948+
: false;
949+
946950
const runPasses = [];
947951
if (opts.runPasses) {
948952
if (typeof opts.runPasses === "string") {
@@ -960,7 +964,7 @@ exports.main = function main(argv, options, callback) {
960964
stats.optimizeTime += measure(() => {
961965
stats.optimizeCount++;
962966
try {
963-
module.optimize(optimizeLevel, shrinkLevel, debugInfo);
967+
module.optimize(optimizeLevel, shrinkLevel, debugInfo, zeroFilledMemory);
964968
} catch (e) {
965969
crash("optimize", e);
966970
}
@@ -979,7 +983,7 @@ exports.main = function main(argv, options, callback) {
979983
do {
980984
stats.optimizeCount++;
981985
try {
982-
module.optimize(optimizeLevel, shrinkLevel, debugInfo);
986+
module.optimize(optimizeLevel, shrinkLevel, debugInfo, zeroFilledMemory);
983987
} catch (e) {
984988
crash("optimize (converge)", e);
985989
}

cli/asc.json

+6
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@
156156
"type": "b",
157157
"default": false
158158
},
159+
"zeroFilledMemory": {
160+
"category": "Features",
161+
"description": "Assume that imported memory is zero filled. Requires importMemory.",
162+
"type": "b",
163+
"default": false
164+
},
159165
"importTable": {
160166
"category": "Features",
161167
"description": "Imports the function table from 'env.table'.",

package-lock.json

+37-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"url": "https://github.com/AssemblyScript/assemblyscript/issues"
2222
},
2323
"dependencies": {
24-
"binaryen": "101.0.0-nightly.20210723",
24+
"binaryen": "101.0.0-nightly.20210904",
2525
"long": "^4.0.0",
2626
"source-map-support": "^0.5.19",
2727
"ts-node": "^6.2.0"

src/compiler.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ export class Options {
225225
maximumMemory: u32 = 0;
226226
/** If true, memory is declared as shared. */
227227
sharedMemory: bool = false;
228+
/** If true, imported memory is zero filled. */
229+
zeroFilledMemory: bool = false;
228230
/** If true, imports the function table provided by the embedder. */
229231
importTable: bool = false;
230232
/** If true, exports the function table. */
@@ -425,9 +427,9 @@ export class Compiler extends DiagnosticEmitter {
425427
var featureFlags: FeatureFlags = 0;
426428
if (options.hasFeature(Feature.SIGN_EXTENSION)) featureFlags |= FeatureFlags.SignExt;
427429
if (options.hasFeature(Feature.MUTABLE_GLOBALS)) featureFlags |= FeatureFlags.MutableGloabls;
428-
if (options.hasFeature(Feature.NONTRAPPING_F2I)) featureFlags |= FeatureFlags.NontrappingFPToInt;
430+
if (options.hasFeature(Feature.NONTRAPPING_F2I)) featureFlags |= FeatureFlags.TruncSat;
429431
if (options.hasFeature(Feature.BULK_MEMORY)) featureFlags |= FeatureFlags.BulkMemory;
430-
if (options.hasFeature(Feature.SIMD)) featureFlags |= FeatureFlags.SIMD128;
432+
if (options.hasFeature(Feature.SIMD)) featureFlags |= FeatureFlags.SIMD;
431433
if (options.hasFeature(Feature.THREADS)) featureFlags |= FeatureFlags.Atomics;
432434
if (options.hasFeature(Feature.EXCEPTION_HANDLING)) featureFlags |= FeatureFlags.ExceptionHandling;
433435
if (options.hasFeature(Feature.TAIL_CALLS)) featureFlags |= FeatureFlags.TailCall;
@@ -7232,7 +7234,7 @@ export class Compiler extends DiagnosticEmitter {
72327234
// We know the last operand is optional and omitted, so inject setting
72337235
// ~argumentsLength into that operand, which is always safe.
72347236
let lastOperand = operands[maxOperands - 1];
7235-
assert(!(getSideEffects(lastOperand) & SideEffects.WritesGlobal));
7237+
assert(!(getSideEffects(lastOperand, module.ref) & SideEffects.WritesGlobal));
72367238
let lastOperandType = parameterTypes[maxArguments - 1];
72377239
operands[maxOperands - 1] = module.block(null, [
72387240
module.global_set(this.ensureArgumentsLength(), module.i32(numArguments)),
@@ -7339,7 +7341,7 @@ export class Compiler extends DiagnosticEmitter {
73397341
// into the index argument, which becomes executed last after any operands.
73407342
var argumentsLength = this.ensureArgumentsLength();
73417343
var sizeTypeRef = this.options.sizeTypeRef;
7342-
if (getSideEffects(functionArg) & SideEffects.WritesGlobal) {
7344+
if (getSideEffects(functionArg, module.ref) & SideEffects.WritesGlobal) {
73437345
let flow = this.currentFlow;
73447346
let temp = flow.getTempLocal(this.options.usizeType, findUsedLocals(functionArg));
73457347
functionArg = module.block(null, [

src/glue/binaryen.d.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ export declare function _BinaryenTagGetName(tag: TagRef): StringRef;
531531
export declare function _BinaryenTagGetParams(tag: TagRef): TypeRef;
532532
export declare function _BinaryenTagGetResults(tag: TagRef): TypeRef;
533533

534-
export declare function _BinaryenAddTable(module: ModuleRef, name: StringRef, initial: Index, maximum: Index): TableRef;
534+
export declare function _BinaryenAddTable(module: ModuleRef, name: StringRef, initial: Index, maximum: Index, type: TypeRef): TableRef;
535535
export declare function _BinaryenRemoveTable(module: ModuleRef, table: StringRef): void;
536536
export declare function _BinaryenGetNumTables(module: ModuleRef): Index;
537537
export declare function _BinaryenGetTable(module: ModuleRef, name: StringRef): TableRef;
@@ -577,7 +577,7 @@ export declare function _BinaryenModuleSetFeatures(module: ModuleRef, featureFla
577577

578578
export declare function _BinaryenAddCustomSection(module: ModuleRef, name: StringRef, contents: ArrayRef<u8>, contentsSize: Index): void;
579579

580-
export declare function _BinaryenExpressionGetSideEffects(expr: ExpressionRef, features: FeatureFlags): SideEffects;
580+
export declare function _BinaryenExpressionGetSideEffects(expr: ExpressionRef, module: ModuleRef): SideEffects;
581581

582582
export declare function _RelooperCreate(module: ModuleRef): RelooperRef;
583583
export declare function _RelooperAddBlock(relooper: RelooperRef, code: ExpressionRef): RelooperBlockRef;
@@ -599,6 +599,8 @@ export declare function _BinaryenGetDebugInfo(): bool;
599599
export declare function _BinaryenSetDebugInfo(on: bool): void;
600600
export declare function _BinaryenGetLowMemoryUnused(): bool;
601601
export declare function _BinaryenSetLowMemoryUnused(on: bool): void;
602+
export declare function _BinaryenGetZeroFilledMemory(): bool;
603+
export declare function _BinaryenSetZeroFilledMemory(on: bool): void;
602604
export declare function _BinaryenGetFastMath(): bool;
603605
export declare function _BinaryenSetFastMath(on: bool): void;
604606
export declare function _BinaryenGetPassArgument(key: StringRef): StringRef;

0 commit comments

Comments
 (0)