sql.js 1.9.0 → 1.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1177,6 +1177,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
1177
1177
  var binaryDb = FS.readFile(this.filename, { encoding: "binary" });
1178
1178
  this.handleError(sqlite3_open(this.filename, apiTemp));
1179
1179
  this.db = getValue(apiTemp, "i32");
1180
+ registerExtensionFunctions(this.db);
1180
1181
  return binaryDb;
1181
1182
  };
1182
1183
 
@@ -1877,10 +1878,10 @@ function writeStackCookie() {
1877
1878
  // The stack grow downwards towards _emscripten_stack_get_end.
1878
1879
  // We write cookies to the final two words in the stack and detect if they are
1879
1880
  // ever overwritten.
1880
- HEAPU32[((max)>>2)] = 0x02135467;
1881
- HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
1881
+ HEAPU32[((max)>>2)] = 0x02135467;checkInt32(0x02135467);
1882
+ HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;checkInt32(0x89BACDFE);
1882
1883
  // Also test the global address 0 for integrity.
1883
- HEAPU32[((0)>>2)] = 1668509029;
1884
+ HEAPU32[((0)>>2)] = 1668509029;checkInt32(1668509029);
1884
1885
  }
1885
1886
 
1886
1887
  function checkStackCookie() {
@@ -1934,6 +1935,8 @@ function initRuntime() {
1934
1935
 
1935
1936
  checkStackCookie();
1936
1937
 
1938
+ setStackLimits();
1939
+
1937
1940
 
1938
1941
  if (!Module["noFSInit"] && !FS.init.initialized)
1939
1942
  FS.init();
@@ -2008,9 +2011,7 @@ function getUniqueRunDependency(id) {
2008
2011
  function addRunDependency(id) {
2009
2012
  runDependencies++;
2010
2013
 
2011
- if (Module['monitorRunDependencies']) {
2012
- Module['monitorRunDependencies'](runDependencies);
2013
- }
2014
+ Module['monitorRunDependencies']?.(runDependencies);
2014
2015
 
2015
2016
  if (id) {
2016
2017
  assert(!runDependencyTracking[id]);
@@ -2044,9 +2045,7 @@ function addRunDependency(id) {
2044
2045
  function removeRunDependency(id) {
2045
2046
  runDependencies--;
2046
2047
 
2047
- if (Module['monitorRunDependencies']) {
2048
- Module['monitorRunDependencies'](runDependencies);
2049
- }
2048
+ Module['monitorRunDependencies']?.(runDependencies);
2050
2049
 
2051
2050
  if (id) {
2052
2051
  assert(runDependencyTracking[id]);
@@ -2069,9 +2068,7 @@ function removeRunDependency(id) {
2069
2068
 
2070
2069
  /** @param {string|number=} what */
2071
2070
  function abort(what) {
2072
- if (Module['onAbort']) {
2073
- Module['onAbort'](what);
2074
- }
2071
+ Module['onAbort']?.(what);
2075
2072
 
2076
2073
  what = 'Aborted(' + what + ')';
2077
2074
  // TODO(sbc): Should we remove printing and leave it up to whoever
@@ -2399,6 +2396,31 @@ function unexportedRuntimeSymbol(sym) {
2399
2396
  }
2400
2397
  }
2401
2398
 
2399
+ var MAX_UINT8 = (2 ** 8) - 1;
2400
+ var MAX_UINT16 = (2 ** 16) - 1;
2401
+ var MAX_UINT32 = (2 ** 32) - 1;
2402
+ var MAX_UINT53 = (2 ** 53) - 1;
2403
+ var MAX_UINT64 = (2 ** 64) - 1;
2404
+
2405
+ var MIN_INT8 = - (2 ** ( 8 - 1)) + 1;
2406
+ var MIN_INT16 = - (2 ** (16 - 1)) + 1;
2407
+ var MIN_INT32 = - (2 ** (32 - 1)) + 1;
2408
+ var MIN_INT53 = - (2 ** (53 - 1)) + 1;
2409
+ var MIN_INT64 = - (2 ** (64 - 1)) + 1;
2410
+
2411
+ function checkInt(value, bits, min, max) {
2412
+ assert(Number.isInteger(Number(value)), `attempt to write non-integer (${value}) into integer heap`);
2413
+ assert(value <= max, `value (${value}) too large to write as ${bits}-bit value`);
2414
+ assert(value >= min, `value (${value}) too small to write as ${bits}-bit value`);
2415
+ }
2416
+
2417
+ var checkInt1 = (value) => checkInt(value, 1, 1);
2418
+ var checkInt8 = (value) => checkInt(value, 8, MIN_INT8, MAX_UINT8);
2419
+ var checkInt16 = (value) => checkInt(value, 16, MIN_INT16, MAX_UINT16);
2420
+ var checkInt32 = (value) => checkInt(value, 32, MIN_INT32, MAX_UINT32);
2421
+ var checkInt53 = (value) => checkInt(value, 53, MIN_INT53, MAX_UINT53);
2422
+ var checkInt64 = (value) => checkInt(value, 64, MIN_INT64, MAX_UINT64);
2423
+
2402
2424
  // Used by XXXXX_DEBUG settings to output debug messages.
2403
2425
  function dbg(text) {
2404
2426
  // TODO(sbc): Make this configurable somehow. Its not always convenient for
@@ -2453,6 +2475,12 @@ function dbg(text) {
2453
2475
  return '0x' + ptr.toString(16).padStart(8, '0');
2454
2476
  };
2455
2477
 
2478
+ var setStackLimits = () => {
2479
+ var stackLow = _emscripten_stack_get_base();
2480
+ var stackHigh = _emscripten_stack_get_end();
2481
+ ___set_stack_limits(stackLow, stackHigh);
2482
+ };
2483
+
2456
2484
 
2457
2485
  /**
2458
2486
  * @param {number} ptr
@@ -2462,10 +2490,10 @@ function dbg(text) {
2462
2490
  function setValue(ptr, value, type = 'i8') {
2463
2491
  if (type.endsWith('*')) type = '*';
2464
2492
  switch (type) {
2465
- case 'i1': HEAP8[((ptr)>>0)] = value; break;
2466
- case 'i8': HEAP8[((ptr)>>0)] = value; break;
2467
- case 'i16': HEAP16[((ptr)>>1)] = value; break;
2468
- case 'i32': HEAP32[((ptr)>>2)] = value; break;
2493
+ case 'i1': HEAP8[((ptr)>>0)] = value;checkInt8(value); break;
2494
+ case 'i8': HEAP8[((ptr)>>0)] = value;checkInt8(value); break;
2495
+ case 'i16': HEAP16[((ptr)>>1)] = value;checkInt16(value); break;
2496
+ case 'i32': HEAP32[((ptr)>>2)] = value;checkInt32(value); break;
2469
2497
  case 'i64': abort('to do setValue(i64) use WASM_BIGINT');
2470
2498
  case 'float': HEAPF32[((ptr)>>2)] = value; break;
2471
2499
  case 'double': HEAPF64[((ptr)>>3)] = value; break;
@@ -2475,7 +2503,7 @@ function dbg(text) {
2475
2503
  }
2476
2504
 
2477
2505
  var warnOnce = (text) => {
2478
- if (!warnOnce.shown) warnOnce.shown = {};
2506
+ warnOnce.shown ||= {};
2479
2507
  if (!warnOnce.shown[text]) {
2480
2508
  warnOnce.shown[text] = 1;
2481
2509
  if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
@@ -2560,6 +2588,16 @@ function dbg(text) {
2560
2588
  abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
2561
2589
  };
2562
2590
 
2591
+
2592
+
2593
+ var ___handle_stack_overflow = (requested) => {
2594
+ var base = _emscripten_stack_get_base();
2595
+ var end = _emscripten_stack_get_end();
2596
+ abort(`stack overflow (Attempt to set SP to ${ptrToString(requested)}` +
2597
+ `, with stack limits [${ptrToString(end)} - ${ptrToString(base)}` +
2598
+ ']). If you require more stack space build with -sSTACK_SIZE=<bytes>');
2599
+ };
2600
+
2563
2601
  var PATH = {
2564
2602
  isAbs:(path) => path.charAt(0) === '/',
2565
2603
  splitPath:(filename) => {
@@ -3023,55 +3061,53 @@ function dbg(text) {
3023
3061
  // no supported
3024
3062
  throw new FS.ErrnoError(63);
3025
3063
  }
3026
- if (!MEMFS.ops_table) {
3027
- MEMFS.ops_table = {
3028
- dir: {
3029
- node: {
3030
- getattr: MEMFS.node_ops.getattr,
3031
- setattr: MEMFS.node_ops.setattr,
3032
- lookup: MEMFS.node_ops.lookup,
3033
- mknod: MEMFS.node_ops.mknod,
3034
- rename: MEMFS.node_ops.rename,
3035
- unlink: MEMFS.node_ops.unlink,
3036
- rmdir: MEMFS.node_ops.rmdir,
3037
- readdir: MEMFS.node_ops.readdir,
3038
- symlink: MEMFS.node_ops.symlink
3039
- },
3040
- stream: {
3041
- llseek: MEMFS.stream_ops.llseek
3042
- }
3064
+ MEMFS.ops_table ||= {
3065
+ dir: {
3066
+ node: {
3067
+ getattr: MEMFS.node_ops.getattr,
3068
+ setattr: MEMFS.node_ops.setattr,
3069
+ lookup: MEMFS.node_ops.lookup,
3070
+ mknod: MEMFS.node_ops.mknod,
3071
+ rename: MEMFS.node_ops.rename,
3072
+ unlink: MEMFS.node_ops.unlink,
3073
+ rmdir: MEMFS.node_ops.rmdir,
3074
+ readdir: MEMFS.node_ops.readdir,
3075
+ symlink: MEMFS.node_ops.symlink
3043
3076
  },
3044
- file: {
3045
- node: {
3046
- getattr: MEMFS.node_ops.getattr,
3047
- setattr: MEMFS.node_ops.setattr
3048
- },
3049
- stream: {
3050
- llseek: MEMFS.stream_ops.llseek,
3051
- read: MEMFS.stream_ops.read,
3052
- write: MEMFS.stream_ops.write,
3053
- allocate: MEMFS.stream_ops.allocate,
3054
- mmap: MEMFS.stream_ops.mmap,
3055
- msync: MEMFS.stream_ops.msync
3056
- }
3057
- },
3058
- link: {
3059
- node: {
3060
- getattr: MEMFS.node_ops.getattr,
3061
- setattr: MEMFS.node_ops.setattr,
3062
- readlink: MEMFS.node_ops.readlink
3063
- },
3064
- stream: {}
3077
+ stream: {
3078
+ llseek: MEMFS.stream_ops.llseek
3079
+ }
3080
+ },
3081
+ file: {
3082
+ node: {
3083
+ getattr: MEMFS.node_ops.getattr,
3084
+ setattr: MEMFS.node_ops.setattr
3065
3085
  },
3066
- chrdev: {
3067
- node: {
3068
- getattr: MEMFS.node_ops.getattr,
3069
- setattr: MEMFS.node_ops.setattr
3070
- },
3071
- stream: FS.chrdev_stream_ops
3086
+ stream: {
3087
+ llseek: MEMFS.stream_ops.llseek,
3088
+ read: MEMFS.stream_ops.read,
3089
+ write: MEMFS.stream_ops.write,
3090
+ allocate: MEMFS.stream_ops.allocate,
3091
+ mmap: MEMFS.stream_ops.mmap,
3092
+ msync: MEMFS.stream_ops.msync
3072
3093
  }
3073
- };
3074
- }
3094
+ },
3095
+ link: {
3096
+ node: {
3097
+ getattr: MEMFS.node_ops.getattr,
3098
+ setattr: MEMFS.node_ops.setattr,
3099
+ readlink: MEMFS.node_ops.readlink
3100
+ },
3101
+ stream: {}
3102
+ },
3103
+ chrdev: {
3104
+ node: {
3105
+ getattr: MEMFS.node_ops.getattr,
3106
+ setattr: MEMFS.node_ops.setattr
3107
+ },
3108
+ stream: FS.chrdev_stream_ops
3109
+ }
3110
+ };
3075
3111
  var node = FS.createNode(parent, name, mode, dev);
3076
3112
  if (FS.isDir(node.mode)) {
3077
3113
  node.node_ops = MEMFS.ops_table.dir.node;
@@ -3214,10 +3250,7 @@ function dbg(text) {
3214
3250
  },
3215
3251
  readdir(node) {
3216
3252
  var entries = ['.', '..'];
3217
- for (var key in node.contents) {
3218
- if (!node.contents.hasOwnProperty(key)) {
3219
- continue;
3220
- }
3253
+ for (var key of Object.keys(node.contents)) {
3221
3254
  entries.push(key);
3222
3255
  }
3223
3256
  return entries;
@@ -3392,15 +3425,15 @@ function dbg(text) {
3392
3425
  var dep = getUniqueRunDependency(`cp ${fullname}`); // might have several active requests for the same fullname
3393
3426
  function processData(byteArray) {
3394
3427
  function finish(byteArray) {
3395
- if (preFinish) preFinish();
3428
+ preFinish?.();
3396
3429
  if (!dontCreateFile) {
3397
3430
  FS_createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
3398
3431
  }
3399
- if (onload) onload();
3432
+ onload?.();
3400
3433
  removeRunDependency(dep);
3401
3434
  }
3402
3435
  if (FS_handledByPreloadPlugin(byteArray, fullname, finish, () => {
3403
- if (onerror) onerror();
3436
+ onerror?.();
3404
3437
  removeRunDependency(dep);
3405
3438
  })) {
3406
3439
  return;
@@ -4016,9 +4049,7 @@ function dbg(text) {
4016
4049
  // override node's stream ops with the device's
4017
4050
  stream.stream_ops = device.stream_ops;
4018
4051
  // forward the open call
4019
- if (stream.stream_ops.open) {
4020
- stream.stream_ops.open(stream);
4021
- }
4052
+ stream.stream_ops.open?.(stream);
4022
4053
  },
4023
4054
  llseek() {
4024
4055
  throw new FS.ErrnoError(70);
@@ -5040,7 +5071,7 @@ function dbg(text) {
5040
5071
  },
5041
5072
  close(stream) {
5042
5073
  // flush any pending line data
5043
- if (output && output.buffer && output.buffer.length) {
5074
+ if (output?.buffer?.length) {
5044
5075
  output(10);
5045
5076
  }
5046
5077
  },
@@ -5319,25 +5350,25 @@ function dbg(text) {
5319
5350
  }
5320
5351
  throw e;
5321
5352
  }
5322
- HEAP32[((buf)>>2)] = stat.dev;
5323
- HEAP32[(((buf)+(4))>>2)] = stat.mode;
5324
- HEAPU32[(((buf)+(8))>>2)] = stat.nlink;
5325
- HEAP32[(((buf)+(12))>>2)] = stat.uid;
5326
- HEAP32[(((buf)+(16))>>2)] = stat.gid;
5327
- HEAP32[(((buf)+(20))>>2)] = stat.rdev;
5328
- (tempI64 = [stat.size>>>0,(tempDouble = stat.size,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(24))>>2)] = tempI64[0],HEAP32[(((buf)+(28))>>2)] = tempI64[1]);
5329
- HEAP32[(((buf)+(32))>>2)] = 4096;
5330
- HEAP32[(((buf)+(36))>>2)] = stat.blocks;
5353
+ HEAP32[((buf)>>2)] = stat.dev;checkInt32(stat.dev);
5354
+ HEAP32[(((buf)+(4))>>2)] = stat.mode;checkInt32(stat.mode);
5355
+ HEAPU32[(((buf)+(8))>>2)] = stat.nlink;checkInt32(stat.nlink);
5356
+ HEAP32[(((buf)+(12))>>2)] = stat.uid;checkInt32(stat.uid);
5357
+ HEAP32[(((buf)+(16))>>2)] = stat.gid;checkInt32(stat.gid);
5358
+ HEAP32[(((buf)+(20))>>2)] = stat.rdev;checkInt32(stat.rdev);
5359
+ (tempI64 = [stat.size>>>0,(tempDouble = stat.size,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(24))>>2)] = tempI64[0],HEAP32[(((buf)+(28))>>2)] = tempI64[1]);checkInt64(stat.size);
5360
+ HEAP32[(((buf)+(32))>>2)] = 4096;checkInt32(4096);
5361
+ HEAP32[(((buf)+(36))>>2)] = stat.blocks;checkInt32(stat.blocks);
5331
5362
  var atime = stat.atime.getTime();
5332
5363
  var mtime = stat.mtime.getTime();
5333
5364
  var ctime = stat.ctime.getTime();
5334
- (tempI64 = [Math.floor(atime / 1000)>>>0,(tempDouble = Math.floor(atime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(40))>>2)] = tempI64[0],HEAP32[(((buf)+(44))>>2)] = tempI64[1]);
5335
- HEAPU32[(((buf)+(48))>>2)] = (atime % 1000) * 1000;
5336
- (tempI64 = [Math.floor(mtime / 1000)>>>0,(tempDouble = Math.floor(mtime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(56))>>2)] = tempI64[0],HEAP32[(((buf)+(60))>>2)] = tempI64[1]);
5337
- HEAPU32[(((buf)+(64))>>2)] = (mtime % 1000) * 1000;
5338
- (tempI64 = [Math.floor(ctime / 1000)>>>0,(tempDouble = Math.floor(ctime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(72))>>2)] = tempI64[0],HEAP32[(((buf)+(76))>>2)] = tempI64[1]);
5339
- HEAPU32[(((buf)+(80))>>2)] = (ctime % 1000) * 1000;
5340
- (tempI64 = [stat.ino>>>0,(tempDouble = stat.ino,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(88))>>2)] = tempI64[0],HEAP32[(((buf)+(92))>>2)] = tempI64[1]);
5365
+ (tempI64 = [Math.floor(atime / 1000)>>>0,(tempDouble = Math.floor(atime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(40))>>2)] = tempI64[0],HEAP32[(((buf)+(44))>>2)] = tempI64[1]);checkInt64(Math.floor(atime / 1000));
5366
+ HEAPU32[(((buf)+(48))>>2)] = (atime % 1000) * 1000;checkInt32((atime % 1000) * 1000);
5367
+ (tempI64 = [Math.floor(mtime / 1000)>>>0,(tempDouble = Math.floor(mtime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(56))>>2)] = tempI64[0],HEAP32[(((buf)+(60))>>2)] = tempI64[1]);checkInt64(Math.floor(mtime / 1000));
5368
+ HEAPU32[(((buf)+(64))>>2)] = (mtime % 1000) * 1000;checkInt32((mtime % 1000) * 1000);
5369
+ (tempI64 = [Math.floor(ctime / 1000)>>>0,(tempDouble = Math.floor(ctime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(72))>>2)] = tempI64[0],HEAP32[(((buf)+(76))>>2)] = tempI64[1]);checkInt64(Math.floor(ctime / 1000));
5370
+ HEAPU32[(((buf)+(80))>>2)] = (ctime % 1000) * 1000;checkInt32((ctime % 1000) * 1000);
5371
+ (tempI64 = [stat.ino>>>0,(tempDouble = stat.ino,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(88))>>2)] = tempI64[0],HEAP32[(((buf)+(92))>>2)] = tempI64[1]);checkInt64(stat.ino);
5341
5372
  return 0;
5342
5373
  },
5343
5374
  doMsync(addr, stream, len, flags, offset) {
@@ -5433,7 +5464,7 @@ function dbg(text) {
5433
5464
  }
5434
5465
 
5435
5466
  var setErrNo = (value) => {
5436
- HEAP32[((___errno_location())>>2)] = value;
5467
+ HEAP32[((___errno_location())>>2)] = value;checkInt32(value);
5437
5468
  return value;
5438
5469
  };
5439
5470
 
@@ -5469,7 +5500,7 @@ function dbg(text) {
5469
5500
  var arg = SYSCALLS.getp();
5470
5501
  var offset = 0;
5471
5502
  // We're always unlocked.
5472
- HEAP16[(((arg)+(offset))>>1)] = 2;
5503
+ HEAP16[(((arg)+(offset))>>1)] = 2;checkInt16(2);
5473
5504
  return 0;
5474
5505
  }
5475
5506
  case 6:
@@ -5720,24 +5751,24 @@ function dbg(text) {
5720
5751
 
5721
5752
 
5722
5753
  var date = new Date(time*1000);
5723
- HEAP32[((tmPtr)>>2)] = date.getSeconds();
5724
- HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes();
5725
- HEAP32[(((tmPtr)+(8))>>2)] = date.getHours();
5726
- HEAP32[(((tmPtr)+(12))>>2)] = date.getDate();
5727
- HEAP32[(((tmPtr)+(16))>>2)] = date.getMonth();
5728
- HEAP32[(((tmPtr)+(20))>>2)] = date.getFullYear()-1900;
5729
- HEAP32[(((tmPtr)+(24))>>2)] = date.getDay();
5754
+ HEAP32[((tmPtr)>>2)] = date.getSeconds();checkInt32(date.getSeconds());
5755
+ HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes();checkInt32(date.getMinutes());
5756
+ HEAP32[(((tmPtr)+(8))>>2)] = date.getHours();checkInt32(date.getHours());
5757
+ HEAP32[(((tmPtr)+(12))>>2)] = date.getDate();checkInt32(date.getDate());
5758
+ HEAP32[(((tmPtr)+(16))>>2)] = date.getMonth();checkInt32(date.getMonth());
5759
+ HEAP32[(((tmPtr)+(20))>>2)] = date.getFullYear()-1900;checkInt32(date.getFullYear()-1900);
5760
+ HEAP32[(((tmPtr)+(24))>>2)] = date.getDay();checkInt32(date.getDay());
5730
5761
 
5731
5762
  var yday = ydayFromDate(date)|0;
5732
- HEAP32[(((tmPtr)+(28))>>2)] = yday;
5733
- HEAP32[(((tmPtr)+(36))>>2)] = -(date.getTimezoneOffset() * 60);
5763
+ HEAP32[(((tmPtr)+(28))>>2)] = yday;checkInt32(yday);
5764
+ HEAP32[(((tmPtr)+(36))>>2)] = -(date.getTimezoneOffset() * 60);checkInt32(-(date.getTimezoneOffset() * 60));
5734
5765
 
5735
5766
  // Attention: DST is in December in South, and some regions don't have DST at all.
5736
5767
  var start = new Date(date.getFullYear(), 0, 1);
5737
5768
  var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
5738
5769
  var winterOffset = start.getTimezoneOffset();
5739
5770
  var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset))|0;
5740
- HEAP32[(((tmPtr)+(32))>>2)] = dst;
5771
+ HEAP32[(((tmPtr)+(32))>>2)] = dst;checkInt32(dst);
5741
5772
  ;
5742
5773
  }
5743
5774
 
@@ -5756,7 +5787,7 @@ function dbg(text) {
5756
5787
  var stream = SYSCALLS.getStreamFromFD(fd);
5757
5788
  var res = FS.mmap(stream, len, offset, prot, flags);
5758
5789
  var ptr = res.ptr;
5759
- HEAP32[((allocated)>>2)] = res.allocated;
5790
+ HEAP32[((allocated)>>2)] = res.allocated;checkInt32(res.allocated);
5760
5791
  HEAPU32[((addr)>>2)] = ptr;
5761
5792
  return 0;
5762
5793
  } catch (e) {
@@ -5815,9 +5846,9 @@ function dbg(text) {
5815
5846
  // Coordinated Universal Time (UTC) and local standard time."), the same
5816
5847
  // as returned by stdTimezoneOffset.
5817
5848
  // See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
5818
- HEAPU32[((timezone)>>2)] = stdTimezoneOffset * 60;
5849
+ HEAPU32[((timezone)>>2)] = stdTimezoneOffset * 60;checkInt32(stdTimezoneOffset * 60);
5819
5850
 
5820
- HEAP32[((daylight)>>2)] = Number(winterOffset != summerOffset);
5851
+ HEAP32[((daylight)>>2)] = Number(winterOffset != summerOffset);checkInt32(Number(winterOffset != summerOffset));
5821
5852
 
5822
5853
  function extractZone(date) {
5823
5854
  var match = date.toTimeString().match(/\(([A-Za-z ]+)\)$/);
@@ -5829,14 +5860,18 @@ function dbg(text) {
5829
5860
  var summerNamePtr = stringToNewUTF8(summerName);
5830
5861
  if (summerOffset < winterOffset) {
5831
5862
  // Northern hemisphere
5832
- HEAPU32[((tzname)>>2)] = winterNamePtr;
5833
- HEAPU32[(((tzname)+(4))>>2)] = summerNamePtr;
5863
+ HEAPU32[((tzname)>>2)] = winterNamePtr;checkInt32(winterNamePtr);
5864
+ HEAPU32[(((tzname)+(4))>>2)] = summerNamePtr;checkInt32(summerNamePtr);
5834
5865
  } else {
5835
- HEAPU32[((tzname)>>2)] = summerNamePtr;
5836
- HEAPU32[(((tzname)+(4))>>2)] = winterNamePtr;
5866
+ HEAPU32[((tzname)>>2)] = summerNamePtr;checkInt32(summerNamePtr);
5867
+ HEAPU32[(((tzname)+(4))>>2)] = winterNamePtr;checkInt32(winterNamePtr);
5837
5868
  }
5838
5869
  };
5839
5870
 
5871
+ var _abort = () => {
5872
+ abort('native code called abort()');
5873
+ };
5874
+
5840
5875
  var _emscripten_date_now = () => Date.now();
5841
5876
 
5842
5877
  var getHeapMax = () =>
@@ -5857,6 +5892,7 @@ function dbg(text) {
5857
5892
  var _emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
5858
5893
 
5859
5894
 
5895
+
5860
5896
  var growMemory = (size) => {
5861
5897
  var b = wasmMemory.buffer;
5862
5898
  var pages = (size - b.byteLength + 65535) / 65536;
@@ -5916,7 +5952,10 @@ function dbg(text) {
5916
5952
 
5917
5953
  var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
5918
5954
 
5955
+ var t0 = _emscripten_get_now();
5919
5956
  var replacement = growMemory(newSize);
5957
+ var t1 = _emscripten_get_now();
5958
+ dbg(`Heap resize call from ${oldSize} to ${newSize} took ${(t1 - t0)} msecs. Success: ${!!replacement}`);
5920
5959
  if (replacement) {
5921
5960
 
5922
5961
  return true;
@@ -5966,17 +6005,17 @@ function dbg(text) {
5966
6005
  var stringToAscii = (str, buffer) => {
5967
6006
  for (var i = 0; i < str.length; ++i) {
5968
6007
  assert(str.charCodeAt(i) === (str.charCodeAt(i) & 0xff));
5969
- HEAP8[((buffer++)>>0)] = str.charCodeAt(i);
6008
+ HEAP8[((buffer++)>>0)] = str.charCodeAt(i);checkInt8(str.charCodeAt(i));
5970
6009
  }
5971
6010
  // Null-terminate the string
5972
- HEAP8[((buffer)>>0)] = 0;
6011
+ HEAP8[((buffer)>>0)] = 0;checkInt8(0);
5973
6012
  };
5974
6013
 
5975
6014
  var _environ_get = (__environ, environ_buf) => {
5976
6015
  var bufSize = 0;
5977
6016
  getEnvStrings().forEach((string, i) => {
5978
6017
  var ptr = environ_buf + bufSize;
5979
- HEAPU32[(((__environ)+(i*4))>>2)] = ptr;
6018
+ HEAPU32[(((__environ)+(i*4))>>2)] = ptr;checkInt32(ptr);
5980
6019
  stringToAscii(string, ptr);
5981
6020
  bufSize += string.length + 1;
5982
6021
  });
@@ -5986,10 +6025,10 @@ function dbg(text) {
5986
6025
 
5987
6026
  var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
5988
6027
  var strings = getEnvStrings();
5989
- HEAPU32[((penviron_count)>>2)] = strings.length;
6028
+ HEAPU32[((penviron_count)>>2)] = strings.length;checkInt32(strings.length);
5990
6029
  var bufSize = 0;
5991
6030
  strings.forEach((string) => bufSize += string.length + 1);
5992
- HEAPU32[((penviron_buf_size)>>2)] = bufSize;
6031
+ HEAPU32[((penviron_buf_size)>>2)] = bufSize;checkInt32(bufSize);
5993
6032
  return 0;
5994
6033
  };
5995
6034
 
@@ -6020,10 +6059,10 @@ function dbg(text) {
6020
6059
  FS.isLink(stream.mode) ? 7 :
6021
6060
  4;
6022
6061
  }
6023
- HEAP8[((pbuf)>>0)] = type;
6024
- HEAP16[(((pbuf)+(2))>>1)] = flags;
6025
- (tempI64 = [rightsBase>>>0,(tempDouble = rightsBase,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((pbuf)+(8))>>2)] = tempI64[0],HEAP32[(((pbuf)+(12))>>2)] = tempI64[1]);
6026
- (tempI64 = [rightsInheriting>>>0,(tempDouble = rightsInheriting,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((pbuf)+(16))>>2)] = tempI64[0],HEAP32[(((pbuf)+(20))>>2)] = tempI64[1]);
6062
+ HEAP8[((pbuf)>>0)] = type;checkInt8(type);
6063
+ HEAP16[(((pbuf)+(2))>>1)] = flags;checkInt16(flags);
6064
+ (tempI64 = [rightsBase>>>0,(tempDouble = rightsBase,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((pbuf)+(8))>>2)] = tempI64[0],HEAP32[(((pbuf)+(12))>>2)] = tempI64[1]);checkInt64(rightsBase);
6065
+ (tempI64 = [rightsInheriting>>>0,(tempDouble = rightsInheriting,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((pbuf)+(16))>>2)] = tempI64[0],HEAP32[(((pbuf)+(20))>>2)] = tempI64[1]);checkInt64(rightsInheriting);
6027
6066
  return 0;
6028
6067
  } catch (e) {
6029
6068
  if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
@@ -6054,7 +6093,7 @@ function dbg(text) {
6054
6093
 
6055
6094
  var stream = SYSCALLS.getStreamFromFD(fd);
6056
6095
  var num = doReadv(stream, iov, iovcnt);
6057
- HEAPU32[((pnum)>>2)] = num;
6096
+ HEAPU32[((pnum)>>2)] = num;checkInt32(num);
6058
6097
  return 0;
6059
6098
  } catch (e) {
6060
6099
  if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
@@ -6072,7 +6111,7 @@ function dbg(text) {
6072
6111
  if (isNaN(offset)) return 61;
6073
6112
  var stream = SYSCALLS.getStreamFromFD(fd);
6074
6113
  FS.llseek(stream, offset, whence);
6075
- (tempI64 = [stream.position>>>0,(tempDouble = stream.position,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[((newOffset)>>2)] = tempI64[0],HEAP32[(((newOffset)+(4))>>2)] = tempI64[1]);
6114
+ (tempI64 = [stream.position>>>0,(tempDouble = stream.position,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[((newOffset)>>2)] = tempI64[0],HEAP32[(((newOffset)+(4))>>2)] = tempI64[1]);checkInt64(stream.position);
6076
6115
  if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state
6077
6116
  return 0;
6078
6117
  } catch (e) {
@@ -6086,7 +6125,7 @@ function dbg(text) {
6086
6125
  try {
6087
6126
 
6088
6127
  var stream = SYSCALLS.getStreamFromFD(fd);
6089
- if (stream.stream_ops && stream.stream_ops.fsync) {
6128
+ if (stream.stream_ops?.fsync) {
6090
6129
  return stream.stream_ops.fsync(stream);
6091
6130
  }
6092
6131
  return 0; // we can't do anything synchronously; the in-memory FS is already synced to
@@ -6118,7 +6157,7 @@ function dbg(text) {
6118
6157
 
6119
6158
  var stream = SYSCALLS.getStreamFromFD(fd);
6120
6159
  var num = doWritev(stream, iov, iovcnt);
6121
- HEAPU32[((pnum)>>2)] = num;
6160
+ HEAPU32[((pnum)>>2)] = num;checkInt32(num);
6122
6161
  return 0;
6123
6162
  } catch (e) {
6124
6163
  if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
@@ -6423,6 +6462,7 @@ function dbg(text) {
6423
6462
 
6424
6463
 
6425
6464
 
6465
+
6426
6466
  /** @param {string=} sig */
6427
6467
  var addFunction = (func, sig) => {
6428
6468
  assert(typeof func != 'undefined');
@@ -6435,6 +6475,13 @@ function dbg(text) {
6435
6475
 
6436
6476
  // It's not in the table, add it now.
6437
6477
 
6478
+ // Make sure functionsInTableMap is actually up to date, that is, that this
6479
+ // function is not actually in the wasm Table despite not being tracked in
6480
+ // functionsInTableMap.
6481
+ for (var i = 0; i < wasmTable.length; i++) {
6482
+ assert(getWasmTableEntry(i) != func, 'function in Table but not functionsInTableMap');
6483
+ }
6484
+
6438
6485
  var ret = getEmptyTableSlot();
6439
6486
 
6440
6487
  // Set the new value.
@@ -6509,6 +6556,8 @@ var wasmImports = {
6509
6556
  /** @export */
6510
6557
  __assert_fail: ___assert_fail,
6511
6558
  /** @export */
6559
+ __handle_stack_overflow: ___handle_stack_overflow,
6560
+ /** @export */
6512
6561
  __syscall_chmod: ___syscall_chmod,
6513
6562
  /** @export */
6514
6563
  __syscall_faccessat: ___syscall_faccessat,
@@ -6553,6 +6602,8 @@ var wasmImports = {
6553
6602
  /** @export */
6554
6603
  _tzset_js: __tzset_js,
6555
6604
  /** @export */
6605
+ abort: _abort,
6606
+ /** @export */
6556
6607
  emscripten_date_now: _emscripten_date_now,
6557
6608
  /** @export */
6558
6609
  emscripten_get_heap_max: _emscripten_get_heap_max,
@@ -6637,6 +6688,7 @@ var stackSave = createExportWrapper('stackSave');
6637
6688
  var stackRestore = createExportWrapper('stackRestore');
6638
6689
  var stackAlloc = createExportWrapper('stackAlloc');
6639
6690
  var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
6691
+ var ___set_stack_limits = Module['___set_stack_limits'] = createExportWrapper('__set_stack_limits');
6640
6692
  var dynCall_iiiij = Module['dynCall_iiiij'] = createExportWrapper('dynCall_iiiij');
6641
6693
  var dynCall_iij = Module['dynCall_iij'] = createExportWrapper('dynCall_iij');
6642
6694
  var dynCall_iijii = Module['dynCall_iijii'] = createExportWrapper('dynCall_iijii');
@@ -6752,6 +6804,7 @@ var missingLibrarySymbols = [
6752
6804
  'registerTouchEventCallback',
6753
6805
  'fillGamepadEventData',
6754
6806
  'registerGamepadEventCallback',
6807
+ 'disableGamepadApiIfItThrows',
6755
6808
  'registerBeforeUnloadEventCallback',
6756
6809
  'fillBatteryEventData',
6757
6810
  'battery',
@@ -6774,6 +6827,7 @@ var missingLibrarySymbols = [
6774
6827
  'makePromiseCallback',
6775
6828
  'ExceptionInfo',
6776
6829
  'findMatchingCatch',
6830
+ 'Browser_asyncPrepareDataCounter',
6777
6831
  'setMainLoop',
6778
6832
  'getSocketFromFD',
6779
6833
  'getSocketAddress',
@@ -6840,6 +6894,7 @@ var unexportedSymbols = [
6840
6894
  'getHeapMax',
6841
6895
  'growMemory',
6842
6896
  'ENV',
6897
+ 'setStackLimits',
6843
6898
  'MONTH_DAYS_REGULAR',
6844
6899
  'MONTH_DAYS_LEAP',
6845
6900
  'MONTH_DAYS_REGULAR_CUMULATIVE',
@@ -7030,7 +7085,7 @@ function checkUnflushedContent() {
7030
7085
  var stream = info.object;
7031
7086
  var rdev = stream.rdev;
7032
7087
  var tty = TTY.ttys[rdev];
7033
- if (tty && tty.output && tty.output.length) {
7088
+ if (tty?.output?.length) {
7034
7089
  has = true;
7035
7090
  }
7036
7091
  });
Binary file