Skip to content

Update binaryen #2029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bfdb91a
init
MaxGraey Aug 11, 2021
8f742c6
update
MaxGraey Aug 13, 2021
0a09da1
Merge branch 'main' into update-binaryen
MaxGraey Aug 13, 2021
ad62850
update fixtures
MaxGraey Aug 13, 2021
324ad40
update
MaxGraey Aug 14, 2021
bb820a9
add zero filled memory option
MaxGraey Aug 14, 2021
bbf18f4
better
MaxGraey Aug 14, 2021
d992804
update
MaxGraey Aug 18, 2021
7aebe31
update fixtures
MaxGraey Aug 18, 2021
2fa860f
better
MaxGraey Aug 18, 2021
00d52cb
better
MaxGraey Aug 18, 2021
44a6d58
fix
MaxGraey Aug 18, 2021
1a747c8
sync with master
MaxGraey Aug 18, 2021
0b09203
add ArrayCopy
MaxGraey Aug 18, 2021
54ccc1d
use local-cse only for optimizeLevel >= 2 || shrinkLevel >= 1
MaxGraey Aug 18, 2021
55a51b8
better?
MaxGraey Aug 18, 2021
2756d10
better
MaxGraey Aug 18, 2021
ff287cb
update
MaxGraey Aug 19, 2021
b0bdba5
better
MaxGraey Aug 20, 2021
6b6bb97
remove remove-unused-nonfunction-module-elements
MaxGraey Aug 20, 2021
d95e98d
better
MaxGraey Aug 21, 2021
4d66258
remove early merge blocks
MaxGraey Aug 21, 2021
b4c67fb
reorder
MaxGraey Aug 21, 2021
3600b92
simplify
MaxGraey Aug 21, 2021
ed131d8
remove "remove-unused-names"
MaxGraey Aug 22, 2021
a4f2b51
better?
MaxGraey Aug 22, 2021
bf9afc8
Revert "better?"
MaxGraey Aug 22, 2021
dcf21b3
update binaryen
MaxGraey Aug 28, 2021
0a2093c
update addTable
MaxGraey Aug 28, 2021
7f3c810
update
MaxGraey Aug 30, 2021
d6a882a
update
MaxGraey Sep 1, 2021
caf9e21
update
MaxGraey Sep 3, 2021
42a9aeb
update
MaxGraey Sep 4, 2021
2191fea
Merge branch 'main' into update-binaryen
MaxGraey Sep 4, 2021
1021f66
Merge branch 'main' into update-binaryen
MaxGraey Sep 4, 2021
55e920f
upd fixtures
MaxGraey Sep 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/asc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export interface CompilerOptions {
maximumMemory?: number;
/** Declare memory as shared. Requires maximumMemory. */
sharedMemory?: boolean;
/** Assume that imported memory is zero filled. Requires importMemory. */
zeroFilledMemory?: boolean;
/** Sets the start offset of compiler-generated static memory. */
memoryBase?: number;
/** Imports the function table provided as 'env.table'. */
Expand Down
8 changes: 6 additions & 2 deletions cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,10 @@ exports.main = function main(argv, options, callback) {
// Optimize the module
const debugInfo = opts.debug;
const converge = opts.converge;
const zeroFilledMemory = opts.importMemory
? opts.zeroFilledMemory
: false;

const runPasses = [];
if (opts.runPasses) {
if (typeof opts.runPasses === "string") {
Expand All @@ -960,7 +964,7 @@ exports.main = function main(argv, options, callback) {
stats.optimizeTime += measure(() => {
stats.optimizeCount++;
try {
module.optimize(optimizeLevel, shrinkLevel, debugInfo);
module.optimize(optimizeLevel, shrinkLevel, debugInfo, zeroFilledMemory);
} catch (e) {
crash("optimize", e);
}
Expand All @@ -979,7 +983,7 @@ exports.main = function main(argv, options, callback) {
do {
stats.optimizeCount++;
try {
module.optimize(optimizeLevel, shrinkLevel, debugInfo);
module.optimize(optimizeLevel, shrinkLevel, debugInfo, zeroFilledMemory);
} catch (e) {
crash("optimize (converge)", e);
}
Expand Down
6 changes: 6 additions & 0 deletions cli/asc.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
"type": "b",
"default": false
},
"zeroFilledMemory": {
"category": "Features",
"description": "Assume that imported memory is zero filled. Requires importMemory.",
"type": "b",
"default": false
},
"importTable": {
"category": "Features",
"description": "Imports the function table from 'env.table'.",
Expand Down
54 changes: 37 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"url": "https://github.com/AssemblyScript/assemblyscript/issues"
},
"dependencies": {
"binaryen": "101.0.0-nightly.20210723",
"binaryen": "101.0.0-nightly.20210904",
"long": "^4.0.0",
"source-map-support": "^0.5.19",
"ts-node": "^6.2.0"
Expand Down
10 changes: 6 additions & 4 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ export class Options {
maximumMemory: u32 = 0;
/** If true, memory is declared as shared. */
sharedMemory: bool = false;
/** If true, imported memory is zero filled. */
zeroFilledMemory: bool = false;
/** If true, imports the function table provided by the embedder. */
importTable: bool = false;
/** If true, exports the function table. */
Expand Down Expand Up @@ -425,9 +427,9 @@ export class Compiler extends DiagnosticEmitter {
var featureFlags: FeatureFlags = 0;
if (options.hasFeature(Feature.SIGN_EXTENSION)) featureFlags |= FeatureFlags.SignExt;
if (options.hasFeature(Feature.MUTABLE_GLOBALS)) featureFlags |= FeatureFlags.MutableGloabls;
if (options.hasFeature(Feature.NONTRAPPING_F2I)) featureFlags |= FeatureFlags.NontrappingFPToInt;
if (options.hasFeature(Feature.NONTRAPPING_F2I)) featureFlags |= FeatureFlags.TruncSat;
if (options.hasFeature(Feature.BULK_MEMORY)) featureFlags |= FeatureFlags.BulkMemory;
if (options.hasFeature(Feature.SIMD)) featureFlags |= FeatureFlags.SIMD128;
if (options.hasFeature(Feature.SIMD)) featureFlags |= FeatureFlags.SIMD;
if (options.hasFeature(Feature.THREADS)) featureFlags |= FeatureFlags.Atomics;
if (options.hasFeature(Feature.EXCEPTION_HANDLING)) featureFlags |= FeatureFlags.ExceptionHandling;
if (options.hasFeature(Feature.TAIL_CALLS)) featureFlags |= FeatureFlags.TailCall;
Expand Down Expand Up @@ -7232,7 +7234,7 @@ export class Compiler extends DiagnosticEmitter {
// We know the last operand is optional and omitted, so inject setting
// ~argumentsLength into that operand, which is always safe.
let lastOperand = operands[maxOperands - 1];
assert(!(getSideEffects(lastOperand) & SideEffects.WritesGlobal));
assert(!(getSideEffects(lastOperand, module.ref) & SideEffects.WritesGlobal));
let lastOperandType = parameterTypes[maxArguments - 1];
operands[maxOperands - 1] = module.block(null, [
module.global_set(this.ensureArgumentsLength(), module.i32(numArguments)),
Expand Down Expand Up @@ -7339,7 +7341,7 @@ export class Compiler extends DiagnosticEmitter {
// into the index argument, which becomes executed last after any operands.
var argumentsLength = this.ensureArgumentsLength();
var sizeTypeRef = this.options.sizeTypeRef;
if (getSideEffects(functionArg) & SideEffects.WritesGlobal) {
if (getSideEffects(functionArg, module.ref) & SideEffects.WritesGlobal) {
let flow = this.currentFlow;
let temp = flow.getTempLocal(this.options.usizeType, findUsedLocals(functionArg));
functionArg = module.block(null, [
Expand Down
6 changes: 4 additions & 2 deletions src/glue/binaryen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ export declare function _BinaryenTagGetName(tag: TagRef): StringRef;
export declare function _BinaryenTagGetParams(tag: TagRef): TypeRef;
export declare function _BinaryenTagGetResults(tag: TagRef): TypeRef;

export declare function _BinaryenAddTable(module: ModuleRef, name: StringRef, initial: Index, maximum: Index): TableRef;
export declare function _BinaryenAddTable(module: ModuleRef, name: StringRef, initial: Index, maximum: Index, type: TypeRef): TableRef;
export declare function _BinaryenRemoveTable(module: ModuleRef, table: StringRef): void;
export declare function _BinaryenGetNumTables(module: ModuleRef): Index;
export declare function _BinaryenGetTable(module: ModuleRef, name: StringRef): TableRef;
Expand Down Expand Up @@ -577,7 +577,7 @@ export declare function _BinaryenModuleSetFeatures(module: ModuleRef, featureFla

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

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

export declare function _RelooperCreate(module: ModuleRef): RelooperRef;
export declare function _RelooperAddBlock(relooper: RelooperRef, code: ExpressionRef): RelooperBlockRef;
Expand All @@ -599,6 +599,8 @@ export declare function _BinaryenGetDebugInfo(): bool;
export declare function _BinaryenSetDebugInfo(on: bool): void;
export declare function _BinaryenGetLowMemoryUnused(): bool;
export declare function _BinaryenSetLowMemoryUnused(on: bool): void;
export declare function _BinaryenGetZeroFilledMemory(): bool;
export declare function _BinaryenSetZeroFilledMemory(on: bool): void;
export declare function _BinaryenGetFastMath(): bool;
export declare function _BinaryenSetFastMath(on: bool): void;
export declare function _BinaryenGetPassArgument(key: StringRef): StringRef;
Expand Down
Loading