summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2022-07-21 08:40:46 -0700
committerGitHub <noreply@github.com>2022-07-21 08:40:46 -0700
commit880e8352ee1fff828d15da5a7fe3a7932f577ef8 (patch)
tree74c1bbe5d1c8d962c57764dca29e28c6fa08412d
parentda5035f893ce9e046f99cf3ede92b576024aa9da (diff)
downloadbinaryen-880e8352ee1fff828d15da5a7fe3a7932f577ef8.tar.gz
binaryen-880e8352ee1fff828d15da5a7fe3a7932f577ef8.tar.bz2
binaryen-880e8352ee1fff828d15da5a7fe3a7932f577ef8.zip
Remove usage of emscripten's deprecated allocate runtime function (#4795)
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/js/binaryen.js-post.js8
2 files changed, 5 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad0d96bd8..afc483c27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -405,7 +405,6 @@ if(EMSCRIPTEN)
target_link_libraries(binaryen_wasm "-sEXPORT_NAME=Binaryen")
target_link_libraries(binaryen_wasm "-sNODERAWFS=0")
target_link_libraries(binaryen_wasm "-sEXPORT_ES6")
- target_link_libraries(binaryen_wasm "-sEXPORTED_RUNTIME_METHODS=allocate")
target_link_libraries(binaryen_wasm "--post-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
target_link_libraries(binaryen_wasm "--extern-pre-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-extern-pre.js")
target_link_libraries(binaryen_wasm "-msign-ext")
@@ -442,7 +441,6 @@ if(EMSCRIPTEN)
else()
target_link_libraries(binaryen_js "-sEXPORT_ES6=1")
endif()
- target_link_libraries(binaryen_js "-sEXPORTED_RUNTIME_METHODS=allocate")
target_link_libraries(binaryen_js "--post-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
# js_of_ocaml needs a specified variable with special comment to provide the library to consumers
if(JS_OF_OCAML)
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index f2e5c464e..0be7f6ebd 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -9,7 +9,7 @@ function preserveStack(func) {
}
function strToStack(str) {
- return str ? allocate(intArrayFromString(str), ALLOC_STACK) : 0;
+ return str ? allocateUTF8OnStack(str) : 0;
}
function i32sToStack(i32s) {
@@ -2484,7 +2484,8 @@ function wrapModule(module, self = {}) {
const segmentOffset = new Array(segmentsLen);
for (let i = 0; i < segmentsLen; i++) {
const { data, offset, passive } = segments[i];
- segmentData[i] = allocate(data, ALLOC_STACK);
+ segmentData[i] = stackAlloc(data.length);
+ HEAP8.set(data, segmentData[i]);
segmentDataLen[i] = data.length;
segmentPassive[i] = passive;
segmentOffset[i] = offset;
@@ -3323,7 +3324,8 @@ Module['emitText'] = function(expr) {
Object.defineProperty(Module, 'readBinary', { writable: true });
Module['readBinary'] = function(data) {
- const buffer = allocate(data, ALLOC_NORMAL);
+ const buffer = _malloc(data.length);
+ HEAP8.set(data, buffer);
const ptr = Module['_BinaryenModuleRead'](buffer, data.length);
_free(buffer);
return wrapModule(ptr);