@@ -1177,6 +1177,8 @@ def access_quote(prop):
1177
1177
# calculate exports
1178
1178
exported_implemented_functions = list (exported_implemented_functions ) + metadata ['initializers' ]
1179
1179
exported_implemented_functions .append ('runPostSets' )
1180
+ if settings ['ALLOW_MEMORY_GROWTH' ]:
1181
+ exported_implemented_functions .append ('_emscripten_replace_memory' )
1180
1182
exports = []
1181
1183
for export in exported_implemented_functions + asm_runtime_funcs + function_tables :
1182
1184
exports .append (quote (export ) + ": " + export )
@@ -1287,7 +1289,21 @@ def math_fix(g):
1287
1289
var nan = +env.NaN, inf = +env.Infinity;
1288
1290
var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
1289
1291
''' + '' .join (['''
1290
- var tempRet%d = 0;''' % i for i in range (10 )]) + '\n ' + asm_global_funcs ] + [' var tempFloat = %s;\n ' % ('Math_fround(0)' if settings .get ('PRECISE_F32' ) else '0.0' )] + ([' const f0 = Math_fround(0);\n ' ] if settings .get ('PRECISE_F32' ) else []) + ['''
1292
+ var tempRet%d = 0;''' % i for i in range (10 )]) + '\n ' + asm_global_funcs ] + [' var tempFloat = %s;\n ' % ('Math_fround(0)' if settings .get ('PRECISE_F32' ) else '0.0' )] + ([' const f0 = Math_fround(0);\n ' ] if settings .get ('PRECISE_F32' ) else []) + ['' if not settings ['ALLOW_MEMORY_GROWTH' ] else '''
1293
+ function _emscripten_replace_memory(newBuffer) {
1294
+ if ((byteLength(newBuffer) & 0xffffff || byteLength(newBuffer) <= 0xffffff)) return false;
1295
+ HEAP8 = new Int8View(newBuffer);
1296
+ HEAP16 = new Int16View(newBuffer);
1297
+ HEAP32 = new Int32View(newBuffer);
1298
+ HEAPU8 = new Uint8View(newBuffer);
1299
+ HEAPU16 = new Uint16View(newBuffer);
1300
+ HEAPU32 = new Uint32View(newBuffer);
1301
+ HEAPF32 = new Float32View(newBuffer);
1302
+ HEAPF64 = new Float64View(newBuffer);
1303
+ buffer = newBuffer;
1304
+ return true;
1305
+ }
1306
+ ''' ] + ['''
1291
1307
// EMSCRIPTEN_START_FUNCS
1292
1308
function stackAlloc(size) {
1293
1309
size = size|0;
0 commit comments