@ai-ecoverse/slicc-kernel 1.54.4 → 1.54.6

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.
@@ -5489,7 +5489,7 @@ function pollOneoff(deps, inPtr, outPtr, nsubs, neventsPtr) {
5489
5489
  const { events, read: read2, write: write2 } = classify(deps.fds, subs);
5490
5490
  let interrupted = false;
5491
5491
  const earliest = subs.reduce((min, s) => Math.min(min, s.deadline), Infinity);
5492
- const expired = () => performance.now() + CLOCK_SLACK_MS >= earliest;
5492
+ const expired = () => performance.now() >= earliest;
5493
5493
  if (read2.length > 0 || write2.length > 0 || events.length === 0) {
5494
5494
  do {
5495
5495
  let timeoutMs = -1;
@@ -5511,7 +5511,7 @@ function pollOneoff(deps, inPtr, outPtr, nsubs, neventsPtr) {
5511
5511
  }
5512
5512
  const after = performance.now();
5513
5513
  for (const s of subs) {
5514
- if (s.type === EVENTTYPE.CLOCK && (interrupted || s.deadline <= after + CLOCK_SLACK_MS)) {
5514
+ if (s.type === EVENTTYPE.CLOCK && (interrupted || s.deadline <= after)) {
5515
5515
  events.push({ userdata: s.userdata, error: E.SUCCESS, type: s.type });
5516
5516
  }
5517
5517
  }
@@ -5519,12 +5519,10 @@ function pollOneoff(deps, inPtr, outPtr, nsubs, neventsPtr) {
5519
5519
  mem.view().setUint32(neventsPtr, events.length, true);
5520
5520
  return E.SUCCESS;
5521
5521
  }
5522
- var CLOCK_SLACK_MS;
5523
5522
  var init_wasi_poll = __esm({
5524
5523
  "src/process/wasi/wasi-poll.ts"() {
5525
5524
  "use strict";
5526
5525
  init_wasi_abi();
5527
- CLOCK_SLACK_MS = 0.5;
5528
5526
  }
5529
5527
  });
5530
5528
 
@@ -7426,6 +7424,12 @@ function read(view, at, type) {
7426
7424
  if (type === "f32") return view.getFloat32(at, true);
7427
7425
  return view.getFloat64(at, true);
7428
7426
  }
7427
+ function readSome(view, at, end, type) {
7428
+ if (at + SIZE2[type] <= end) return read(view, at, type);
7429
+ const some = new DataView(new ArrayBuffer(8));
7430
+ for (let i = 0; at + i < end; i++) some.setUint8(i, view.getUint8(at + i));
7431
+ return read(some, 0, type);
7432
+ }
7429
7433
  function write(view, at, type, value2) {
7430
7434
  if (type === "i32") view.setInt32(at, Number(value2), true);
7431
7435
  else if (type === "i64") view.setBigInt64(at, BigInt(value2), true);
@@ -7436,7 +7440,8 @@ function scalars(types) {
7436
7440
  if (types.includes("other")) throw new WasiError("EINVAL");
7437
7441
  return types;
7438
7442
  }
7439
- function callDynamic(ctx, id, values, valuesLen, results, resultsLen, strict) {
7443
+ function callDynamic(ctx, ...operands) {
7444
+ const [id, values, valuesLen, results, resultsLen, strict] = operands.map((n) => n >>> 0);
7440
7445
  const table = ctx.table();
7441
7446
  if (!table) throw new WasiError("ENOTSUP");
7442
7447
  const fn = id < table.length ? table.get(id) : null;
@@ -7444,33 +7449,31 @@ function callDynamic(ctx, id, values, valuesLen, results, resultsLen, strict) {
7444
7449
  if (!fn || !sig) throw new WasiError("EINVAL");
7445
7450
  const params = scalars(sig.params);
7446
7451
  const outs = scalars(sig.results);
7452
+ const size = (types) => types.reduce((n, type) => n + SIZE2[type], 0);
7453
+ if (strict && (size(params) !== valuesLen || size(outs) !== resultsLen)) {
7454
+ throw new WasiError("EINVAL");
7455
+ }
7447
7456
  const view = ctx.mem.view();
7457
+ if (values + valuesLen > view.byteLength || results + resultsLen > view.byteLength) {
7458
+ throw new WasiError("EFAULT");
7459
+ }
7448
7460
  const end = values + valuesLen;
7449
7461
  let at = values;
7450
7462
  const args = params.map((type) => {
7451
- if (at + SIZE2[type] > end) {
7452
- if (strict) throw new WasiError("EINVAL");
7453
- return type === "i64" ? 0n : 0;
7454
- }
7455
- const v = read(view, at, type);
7463
+ const v = readSome(view, at, end, type);
7456
7464
  at += SIZE2[type];
7457
7465
  return v;
7458
7466
  });
7459
- if (strict && at !== end) throw new WasiError("EINVAL");
7460
7467
  const returned = fn(...args);
7461
7468
  const got = outs.length === 1 ? [returned] : returned ?? [];
7462
7469
  const after = ctx.mem.view();
7463
7470
  const stop = results + resultsLen;
7464
7471
  let out = results;
7465
7472
  outs.forEach((type, i) => {
7466
- if (out + SIZE2[type] > stop) {
7467
- if (strict) throw new WasiError("EINVAL");
7468
- return;
7469
- }
7473
+ if (out + SIZE2[type] > stop) return;
7470
7474
  write(after, out, type, got[i]);
7471
7475
  out += SIZE2[type];
7472
7476
  });
7473
- if (strict && out !== stop) throw new WasiError("EINVAL");
7474
7477
  }
7475
7478
  var SIZE2;
7476
7479
  var init_wasix_ffi = __esm({