summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-08-14 00:56:18 +0300
committerGitHub <noreply@github.com>2021-08-13 14:56:18 -0700
commitd38c949bb3b9c4b6e0d1e2a19cc22ec933b4746e (patch)
treee207521edd9942bcc245403ab5dd05ef2fb74911 /src
parent96d2c946329f26bb742684a70cb48e98aa55083d (diff)
downloadbinaryen-d38c949bb3b9c4b6e0d1e2a19cc22ec933b4746e.tar.gz
binaryen-d38c949bb3b9c4b6e0d1e2a19cc22ec933b4746e.tar.bz2
binaryen-d38c949bb3b9c4b6e0d1e2a19cc22ec933b4746e.zip
[JS/C API] Expose zeroFilledMemory option for JS and C API (#4071)
Diffstat (limited to 'src')
-rw-r--r--src/binaryen-c.cpp8
-rw-r--r--src/binaryen-c.h7
-rw-r--r--src/js/binaryen.js-post.js10
3 files changed, 25 insertions, 0 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp
index 2260a93b1..7c826f0f2 100644
--- a/src/binaryen-c.cpp
+++ b/src/binaryen-c.cpp
@@ -3798,6 +3798,14 @@ void BinaryenSetLowMemoryUnused(bool on) {
globalPassOptions.lowMemoryUnused = on != 0;
}
+bool BinaryenGetZeroFilledMemory(void) {
+ return globalPassOptions.zeroFilledMemory;
+}
+
+void BinaryenSetZeroFilledMemory(bool on) {
+ globalPassOptions.zeroFilledMemory = on != 0;
+}
+
bool BinaryenGetFastMath(void) { return globalPassOptions.fastMath; }
void BinaryenSetFastMath(bool value) { globalPassOptions.fastMath = value; }
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index 8609496d0..08cf12b90 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -2284,6 +2284,13 @@ BINARYEN_API bool BinaryenGetLowMemoryUnused(void);
// when optimizing. Applies to all modules, globally.
BINARYEN_API void BinaryenSetLowMemoryUnused(bool on);
+// Gets whether to assume that an imported memory is zero-initialized.
+BINARYEN_API bool BinaryenGetZeroFilledMemory(void);
+
+// Enables or disables whether to assume that an imported memory is
+// zero-initialized.
+BINARYEN_API void BinaryenSetZeroFilledMemory(bool on);
+
// Gets whether fast math optimizations are enabled, ignoring for example
// corner cases of floating-point math like NaN changes.
// Applies to all modules, globally.
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index d86cb07af..8e41b4e7c 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -3303,6 +3303,16 @@ Module['setLowMemoryUnused'] = function(on) {
Module['_BinaryenSetLowMemoryUnused'](on);
};
+// Gets whether that an imported memory will be zero-initialized speculation.
+Module['getZeroFilledMemory'] = function() {
+ return Boolean(Module['_BinaryenGetZeroFilledMemory']());
+};
+
+// Enables or disables whether that an imported memory will be
+// zero-initialized speculation.
+Module['setZeroFilledMemory'] = function(on) {
+ Module['_BinaryenSetZeroFilledMemory'](on);
+};
// Gets whether fast math optimizations are enabled, ignoring for example
// corner cases of floating-point math like NaN changes.
Module['getFastMath'] = function() {