Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5371,6 +5371,18 @@ bool BinaryenGetDebugInfo(void) { return globalPassOptions.debugInfo; }

void BinaryenSetDebugInfo(bool on) { globalPassOptions.debugInfo = on != 0; }

bool BinaryenGetTrapsNeverHappen(void) {
return globalPassOptions.trapsNeverHappen;
}

void BinaryenSetTrapsNeverHappen(bool on) {
globalPassOptions.trapsNeverHappen = on;
}

bool BinaryenGetClosedWorld(void) { return globalPassOptions.closedWorld; }

void BinaryenSetClosedWorld(bool on) { globalPassOptions.closedWorld = on; }

bool BinaryenGetLowMemoryUnused(void) {
return globalPassOptions.lowMemoryUnused;
}
Expand All @@ -5391,6 +5403,22 @@ bool BinaryenGetFastMath(void) { return globalPassOptions.fastMath; }

void BinaryenSetFastMath(bool value) { globalPassOptions.fastMath = value; }

bool BinaryenGetGenerateStackIR(void) {
return globalPassOptions.generateStackIR;
}

void BinaryenSetGenerateStackIR(bool on) {
globalPassOptions.generateStackIR = on;
}

bool BinaryenGetOptimizeStackIR(void) {
return globalPassOptions.optimizeStackIR;
}

void BinaryenSetOptimizeStackIR(bool on) {
globalPassOptions.optimizeStackIR = on;
}

const char* BinaryenGetPassArgument(const char* key) {
assert(key);
const auto& args = globalPassOptions.arguments;
Expand All @@ -5413,6 +5441,18 @@ void BinaryenSetPassArgument(const char* key, const char* value) {

void BinaryenClearPassArguments(void) { globalPassOptions.arguments.clear(); }

bool BinaryenHasPassToSkip(const char* pass) {
assert(pass);
return globalPassOptions.passesToSkip.count(pass);
}

void BinaryenAddPassToSkip(const char* pass) {
assert(pass);
globalPassOptions.passesToSkip.insert(pass);
}

void BinaryenClearPassesToSkip(void) { globalPassOptions.passesToSkip.clear(); }

BinaryenIndex BinaryenGetAlwaysInlineMaxSize(void) {
return globalPassOptions.inlining.alwaysInlineMaxSize;
}
Expand Down
46 changes: 46 additions & 0 deletions src/binaryen-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -2923,6 +2923,24 @@ BINARYEN_API bool BinaryenGetDebugInfo(void);
// Applies to all modules, globally.
BINARYEN_API void BinaryenSetDebugInfo(bool on);

// Gets whether no traps can be considered reached at runtime when optimizing.
// Applies to all modules, globally.
BINARYEN_API bool BinaryenGetTrapsNeverHappen(void);

// Enables or disables whether no traps can be considered reached at
// runtime when optimizing. Applies to all modules, globally.
BINARYEN_API void BinaryenSetTrapsNeverHappen(bool on);

// Gets whether considering that the code outside of the module does
// not inspect or interact with GC and function references. Applies to
// all modules, globally.
BINARYEN_API bool BinaryenGetClosedWorld(void);

// Enables or disables whether considering that the code outside of
// the module does not inspect or interact with GC and function
// references. Applies to all modules, globally.
BINARYEN_API void BinaryenSetClosedWorld(bool on);

// Gets whether the low 1K of memory can be considered unused when optimizing.
// Applies to all modules, globally.
BINARYEN_API bool BinaryenGetLowMemoryUnused(void);
Expand All @@ -2948,6 +2966,22 @@ BINARYEN_API bool BinaryenGetFastMath(void);
// Applies to all modules, globally.
BINARYEN_API void BinaryenSetFastMath(bool value);

// Gets whether to generate StackIR during binary writing.
// Applies to all modules, globally.
BINARYEN_API bool BinaryenGetGenerateStackIR(void);

// Enable or disable StackIR generation during binary writing.
// Applies to all modules, globally.
BINARYEN_API void BinaryenSetGenerateStackIR(bool on);

// Gets whether to optimize StackIR during binary writing.
// Applies to all modules, globally.
BINARYEN_API bool BinaryenGetOptimizeStackIR(void);

// Enable or disable StackIR optimization during binary writing.
// Applies to all modules, globally.
BINARYEN_API void BinaryenSetOptimizeStackIR(bool on);

// Gets the value of the specified arbitrary pass argument.
// Applies to all modules, globally.
BINARYEN_API const char* BinaryenGetPassArgument(const char* name);
Expand All @@ -2960,6 +2994,18 @@ BINARYEN_API void BinaryenSetPassArgument(const char* name, const char* value);
// Applies to all modules, globally.
BINARYEN_API void BinaryenClearPassArguments();

// Gets whether a pass is in the set of passes to skip.
// Applies to all modules, globally.
BINARYEN_API bool BinaryenHasPassToSkip(const char* pass);

// Add a pass to the set of passes to skip.
// Applies to all modules, globally.
BINARYEN_API void BinaryenAddPassToSkip(const char* pass);

// Clears the set of passes to skip.
// Applies to all modules, globally.
BINARYEN_API void BinaryenClearPassesToSkip(void);

// Gets the function size at which we always inline.
// Applies to all modules, globally.
BINARYEN_API BinaryenIndex BinaryenGetAlwaysInlineMaxSize(void);
Expand Down
61 changes: 61 additions & 0 deletions src/js/binaryen.js-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -3410,6 +3410,30 @@ Module['setDebugInfo'] = function(on) {
Module['_BinaryenSetDebugInfo'](on);
};

// Gets whether no traps can be considered reached at runtime when optimizing.
Module['getTrapsNeverHappen'] = function() {
return Boolean(Module['_BinaryenGetTrapsNeverHappen']());
};

// Enables or disables whether no traps can be considered reached at
// runtime when optimizing.
Module['setTrapsNeverHappen'] = function(on) {
Module['_BinaryenSetTrapsNeverHappen'](on);
};

// Gets whether considering that the code outside of the module does
// not inspect or interact with GC and function references.
Module['getClosedWorld'] = function() {
return Boolean(Module['_BinaryenGetClosedWorld']());
};

// Enables or disables whether considering that the code outside of
// the module does not inspect or interact with GC and function
// references.
Module['setClosedWorld'] = function(on) {
Module['_BinaryenSetClosedWorld'](on);
};

// Gets whether the low 1K of memory can be considered unused when optimizing.
Module['getLowMemoryUnused'] = function() {
return Boolean(Module['_BinaryenGetLowMemoryUnused']());
Expand Down Expand Up @@ -3443,6 +3467,26 @@ Module['setFastMath'] = function(value) {
Module['_BinaryenSetFastMath'](value);
};

// Gets whether to generate StackIR during binary writing.
Module['getGenerateStackIR'] = function() {
return Boolean(Module['_BinaryenGetGenerateStackIR']());
};

// Enable or disable StackIR generation during binary writing.
Module['setGenerateStackIR'] = function(value) {
Module['_BinaryenSetGenerateStackIR'](value);
};

// Gets whether to optimize StackIR during binary writing.
Module['getOptimizeStackIR'] = function() {
return Boolean(Module['_BinaryenGetOptimizeStackIR']());
};

// Enable or disable StackIR optimisation during binary writing.
Module['setOptimizeStackIR'] = function(value) {
Module['_BinaryenSetOptimizeStackIR'](value);
};

// Gets the value of the specified arbitrary pass argument.
Module['getPassArgument'] = function(key) {
return preserveStack(() => {
Expand All @@ -3462,6 +3506,23 @@ Module['clearPassArguments'] = function() {
Module['_BinaryenClearPassArguments']();
};

// Gets whether a pass is in the set of passes to skip.
Module['hasPassToSkip'] = function(pass) {
return preserveStack(() => {
return Boolean(Module['_BinaryenHasPassToSkip'](strToStack(pass)));
});
};

// Add a pass to the set of passes to skip.
Module['addPassToSkip'] = function (pass) {
preserveStack(() => { Module['_BinaryenAddPassToSkip'](strToStack(pass)) });
};

// Clears the set of passes to skip.
Module['clearPassesToSkip'] = function() {
Module['_BinaryenClearPassesToSkip']();
};

// Gets the function size at which we always inline.
Module['getAlwaysInlineMaxSize'] = function() {
return Module['_BinaryenGetAlwaysInlineMaxSize']();
Expand Down
3 changes: 3 additions & 0 deletions test/binaryen.js/closed-world.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
console.log("// closedWorld=" + binaryen.getClosedWorld());
binaryen.setClosedWorld(true);
assert(binaryen.getClosedWorld() == true);
1 change: 1 addition & 0 deletions test/binaryen.js/closed-world.js.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// closedWorld=false
3 changes: 3 additions & 0 deletions test/binaryen.js/generate-stack-ir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
console.log("// generateStackIR=" + binaryen.getGenerateStackIR());
binaryen.setGenerateStackIR(true);
assert(binaryen.getGenerateStackIR() == true);
1 change: 1 addition & 0 deletions test/binaryen.js/generate-stack-ir.js.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// generateStackIR=false
3 changes: 3 additions & 0 deletions test/binaryen.js/optimize-stack-ir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
console.log("// optimizeStackIR=" + binaryen.getOptimizeStackIR());
binaryen.setOptimizeStackIR(true);
assert(binaryen.getOptimizeStackIR() == true);
1 change: 1 addition & 0 deletions test/binaryen.js/optimize-stack-ir.js.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// optimizeStackIR=false
7 changes: 7 additions & 0 deletions test/binaryen.js/passes-to-skip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
assert(!binaryen.hasPassToSkip("thePass"));

binaryen.addPassToSkip("thePass");
assert(binaryen.hasPassToSkip("thePass"));

binaryen.clearPassesToSkip();
assert(!binaryen.hasPassToSkip("thePass"));
Empty file.
3 changes: 3 additions & 0 deletions test/binaryen.js/traps-never-happen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
console.log("// trapsNeverHappen=" + binaryen.getTrapsNeverHappen());
binaryen.setTrapsNeverHappen(true);
assert(binaryen.getTrapsNeverHappen() == true);
1 change: 1 addition & 0 deletions test/binaryen.js/traps-never-happen.js.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// trapsNeverHappen=false