Skip to content

Commit

Permalink
Add Binaryen(Get|Set)AllowHeavyweight to binaryen-c.h (WebAssembly#3082)
Browse files Browse the repository at this point in the history
These declarations were previously missing causing the respective APIs to be not exposed. Also makes sure that a Boolean is returned by the JS API and adds a test to verify that it is working now.
  • Loading branch information
MaxGraey committed Aug 28, 2020
1 parent 547e2be commit fecfa92
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/binaryen-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/js/binaryen.js-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
4 changes: 4 additions & 0 deletions test/binaryen.js/inlining-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
1 change: 1 addition & 0 deletions test/binaryen.js/inlining-options.js.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// alwaysInlineMaxSize=2
// flexibleInlineMaxSize=20
// oneCallerInlineMaxSize=15
// allowHeavyweight=false

0 comments on commit fecfa92

Please sign in to comment.