diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 6776b785c57..db9258d59be 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -3528,11 +3528,11 @@ void BinaryenSetOneCallerInlineMaxSize(BinaryenIndex size) { globalPassOptions.inlining.oneCallerInlineMaxSize = size; } -bool BinaryenGetAllowHeavyweight(void) { +int BinaryenGetAllowHeavyweight(void) { return globalPassOptions.inlining.allowHeavyweight; } -void BinaryenSetAllowHeavyweight(bool enabled) { +void BinaryenSetAllowHeavyweight(int enabled) { globalPassOptions.inlining.allowHeavyweight = enabled; } diff --git a/src/binaryen-c.h b/src/binaryen-c.h index d064ceb5c2f..6239befd23a 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -2124,6 +2124,14 @@ BINARYEN_API BinaryenIndex BinaryenGetOneCallerInlineMaxSize(void); // Applies to all modules, globally. BINARYEN_API void BinaryenSetOneCallerInlineMaxSize(BinaryenIndex size); +// Gets whether heavyweight functions are allowed to be inlined. +// Applies to all modules, globally. +BINARYEN_API int BinaryenGetAllowHeavyweight(void); + +// Sets whether heavyweight functions are allowed to be inlined. +// Applies to all modules, globally. +BINARYEN_API void BinaryenSetAllowHeavyweight(int enabled); + // Runs the specified passes on the module. Uses the currently set global // optimize and shrink level. BINARYEN_API void BinaryenModuleRunPasses(BinaryenModuleRef module, diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index f8a0b85906b..057252f78f5 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -3032,7 +3032,7 @@ Module['setOneCallerInlineMaxSize'] = function(size) { // Gets the value which allow inline functions that are not "lightweight". Module['getAllowHeavyweight'] = function() { - return Module['_BinaryenGetAllowHeavyweight'](); + return Boolean(Module['_BinaryenGetAllowHeavyweight']()); }; // Sets the value which allow inline functions that are not "lightweight". diff --git a/test/binaryen.js/inlining-options.js b/test/binaryen.js/inlining-options.js index a228f3dc671..c2913e83d07 100644 --- a/test/binaryen.js/inlining-options.js +++ b/test/binaryen.js/inlining-options.js @@ -9,3 +9,7 @@ assert(binaryen.getFlexibleInlineMaxSize() == 22); console.log("// oneCallerInlineMaxSize=" + binaryen.getOneCallerInlineMaxSize()); binaryen.setOneCallerInlineMaxSize(33); assert(binaryen.getOneCallerInlineMaxSize() == 33); + +console.log("// allowHeavyweight=" + binaryen.getAllowHeavyweight()); +binaryen.setAllowHeavyweight(true); +assert(binaryen.getAllowHeavyweight() == true); diff --git a/test/binaryen.js/inlining-options.js.txt b/test/binaryen.js/inlining-options.js.txt index ab3821aeb20..8dc7d5cf1dd 100644 --- a/test/binaryen.js/inlining-options.js.txt +++ b/test/binaryen.js/inlining-options.js.txt @@ -1,3 +1,4 @@ // alwaysInlineMaxSize=2 // flexibleInlineMaxSize=20 // oneCallerInlineMaxSize=15 +// allowHeavyweight=false