diff options
-rw-r--r-- | src/binaryen-c.cpp | 40 | ||||
-rw-r--r-- | src/binaryen-c.h | 46 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 61 | ||||
-rw-r--r-- | test/binaryen.js/closed-world.js | 3 | ||||
-rw-r--r-- | test/binaryen.js/closed-world.js.txt | 1 | ||||
-rw-r--r-- | test/binaryen.js/generate-stack-ir.js | 3 | ||||
-rw-r--r-- | test/binaryen.js/generate-stack-ir.js.txt | 1 | ||||
-rw-r--r-- | test/binaryen.js/optimize-stack-ir.js | 3 | ||||
-rw-r--r-- | test/binaryen.js/optimize-stack-ir.js.txt | 1 | ||||
-rw-r--r-- | test/binaryen.js/passes-to-skip.js | 7 | ||||
-rw-r--r-- | test/binaryen.js/passes-to-skip.js.txt | 0 | ||||
-rw-r--r-- | test/binaryen.js/traps-never-happen.js | 3 | ||||
-rw-r--r-- | test/binaryen.js/traps-never-happen.js.txt | 1 |
13 files changed, 170 insertions, 0 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 298a50233..afc3dbe54 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -5373,6 +5373,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; } @@ -5393,6 +5405,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; @@ -5415,6 +5443,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; } diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 35f1d8eb8..0b1319f30 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -2925,6 +2925,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); @@ -2950,6 +2968,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); @@ -2962,6 +2996,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); diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 097c28bc7..55e1a7ad7 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -3412,6 +3412,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']()); @@ -3445,6 +3469,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(() => { @@ -3464,6 +3508,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'](); diff --git a/test/binaryen.js/closed-world.js b/test/binaryen.js/closed-world.js new file mode 100644 index 000000000..7c0d50dd8 --- /dev/null +++ b/test/binaryen.js/closed-world.js @@ -0,0 +1,3 @@ +console.log("// closedWorld=" + binaryen.getClosedWorld()); +binaryen.setClosedWorld(true); +assert(binaryen.getClosedWorld() == true); diff --git a/test/binaryen.js/closed-world.js.txt b/test/binaryen.js/closed-world.js.txt new file mode 100644 index 000000000..1c2aa471b --- /dev/null +++ b/test/binaryen.js/closed-world.js.txt @@ -0,0 +1 @@ +// closedWorld=false diff --git a/test/binaryen.js/generate-stack-ir.js b/test/binaryen.js/generate-stack-ir.js new file mode 100644 index 000000000..8aac2ccd8 --- /dev/null +++ b/test/binaryen.js/generate-stack-ir.js @@ -0,0 +1,3 @@ +console.log("// generateStackIR=" + binaryen.getGenerateStackIR()); +binaryen.setGenerateStackIR(true); +assert(binaryen.getGenerateStackIR() == true); diff --git a/test/binaryen.js/generate-stack-ir.js.txt b/test/binaryen.js/generate-stack-ir.js.txt new file mode 100644 index 000000000..184febf82 --- /dev/null +++ b/test/binaryen.js/generate-stack-ir.js.txt @@ -0,0 +1 @@ +// generateStackIR=false diff --git a/test/binaryen.js/optimize-stack-ir.js b/test/binaryen.js/optimize-stack-ir.js new file mode 100644 index 000000000..ec3a7c54d --- /dev/null +++ b/test/binaryen.js/optimize-stack-ir.js @@ -0,0 +1,3 @@ +console.log("// optimizeStackIR=" + binaryen.getOptimizeStackIR()); +binaryen.setOptimizeStackIR(true); +assert(binaryen.getOptimizeStackIR() == true); diff --git a/test/binaryen.js/optimize-stack-ir.js.txt b/test/binaryen.js/optimize-stack-ir.js.txt new file mode 100644 index 000000000..07d1721b3 --- /dev/null +++ b/test/binaryen.js/optimize-stack-ir.js.txt @@ -0,0 +1 @@ +// optimizeStackIR=false diff --git a/test/binaryen.js/passes-to-skip.js b/test/binaryen.js/passes-to-skip.js new file mode 100644 index 000000000..c95bd5d47 --- /dev/null +++ b/test/binaryen.js/passes-to-skip.js @@ -0,0 +1,7 @@ +assert(!binaryen.hasPassToSkip("thePass")); + +binaryen.addPassToSkip("thePass"); +assert(binaryen.hasPassToSkip("thePass")); + +binaryen.clearPassesToSkip(); +assert(!binaryen.hasPassToSkip("thePass")); diff --git a/test/binaryen.js/passes-to-skip.js.txt b/test/binaryen.js/passes-to-skip.js.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/test/binaryen.js/passes-to-skip.js.txt diff --git a/test/binaryen.js/traps-never-happen.js b/test/binaryen.js/traps-never-happen.js new file mode 100644 index 000000000..d1c91bf04 --- /dev/null +++ b/test/binaryen.js/traps-never-happen.js @@ -0,0 +1,3 @@ +console.log("// trapsNeverHappen=" + binaryen.getTrapsNeverHappen()); +binaryen.setTrapsNeverHappen(true); +assert(binaryen.getTrapsNeverHappen() == true); diff --git a/test/binaryen.js/traps-never-happen.js.txt b/test/binaryen.js/traps-never-happen.js.txt new file mode 100644 index 000000000..586e4d25c --- /dev/null +++ b/test/binaryen.js/traps-never-happen.js.txt @@ -0,0 +1 @@ +// trapsNeverHappen=false |