summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2020-08-28 16:23:32 +0300
committerGitHub <noreply@github.com>2020-08-28 15:23:32 +0200
commitfecfa92d71633f8bb28bb97a60adc9b54998456f (patch)
tree30418c26d7a3aa9aaedb25acc7ce4eca5be25be6
parent547e2be14d1f8f9b21905baee87b1946045b0fe7 (diff)
downloadbinaryen-fecfa92d71633f8bb28bb97a60adc9b54998456f.tar.gz
binaryen-fecfa92d71633f8bb28bb97a60adc9b54998456f.tar.bz2
binaryen-fecfa92d71633f8bb28bb97a60adc9b54998456f.zip
Add Binaryen(Get|Set)AllowHeavyweight to binaryen-c.h (#3082)
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.
-rw-r--r--src/binaryen-c.cpp4
-rw-r--r--src/binaryen-c.h8
-rw-r--r--src/js/binaryen.js-post.js2
-rw-r--r--test/binaryen.js/inlining-options.js4
-rw-r--r--test/binaryen.js/inlining-options.js.txt1
5 files changed, 16 insertions, 3 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp
index 6776b785c..db9258d59 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 d064ceb5c..6239befd2 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 f8a0b8590..057252f78 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 a228f3dc6..c2913e83d 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 ab3821aeb..8dc7d5cf1 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