Skip to content

Commit

Permalink
Include growableHeap.js via the normal include mechanism. NFC
Browse files Browse the repository at this point in the history
Split out from emscripten-core#23261
  • Loading branch information
sbc100 committed Dec 30, 2024
1 parent 8a98ea5 commit 77d2c41
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ if (typeof WebAssembly != 'object') {
#include "runtime_safe_heap.js"
#endif

#if SHARED_MEMORY && ALLOW_MEMORY_GROWTH
#include "growableHeap.js"
#endif

#if USE_ASAN
#include "runtime_asan.js"
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/preamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "runtime_safe_heap.js"
#endif

#if SHARED_MEMORY && ALLOW_MEMORY_GROWTH
#include "growableHeap.js"
#endif

#if USE_ASAN
#include "runtime_asan.js"
#endif
Expand Down
6 changes: 6 additions & 0 deletions tools/acorn-optimizer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,12 @@ function littleEndianHeap(ast) {
// in each access), see #8365.
function growableHeap(ast) {
recursiveWalk(ast, {
FunctionDeclaration(node, c) {
// Do not recurse into to GROWABLE_HEAP_ helper functions themselves.
if (!(node.id.type === 'Identifier' && node.id.name.startsWith('GROWABLE_HEAP_'))) {
c(node.body);
}
},
AssignmentExpression: (node) => {
if (node.left.type === 'Identifier' && isEmscriptenHEAP(node.left.name)) {
// Don't transform initial setup of the arrays.
Expand Down
7 changes: 1 addition & 6 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,12 +1055,7 @@ def little_endian_heap(js_file):

def apply_wasm_memory_growth(js_file):
logger.debug('supporting wasm memory growth with pthreads')
fixed = acorn_optimizer(js_file, ['growableHeap'])
ret = js_file + '.pgrow.js'
fixed = utils.read_file(fixed)
support_code = utils.read_file(path_from_root('src/growableHeap.js'))
utils.write_file(ret, support_code + '\n' + fixed)
return ret
return acorn_optimizer(js_file, ['growableHeap'])


def use_unsigned_pointers_in_js(js_file):
Expand Down

0 comments on commit 77d2c41

Please sign in to comment.