@bytecodealliance/jco 1.13.0 → 1.13.1-rc.3
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.
- package/obj/js-component-bindgen-component.core.wasm +0 -0
- package/obj/js-component-bindgen-component.js +884 -10
- package/obj/wasm-tools.core.wasm +0 -0
- package/obj/wasm-tools.js +984 -30
- package/package.json +3 -3
- package/src/cmd/transpile.js +20 -13
- package/src/jco.js +1 -1
|
@@ -75,10 +75,580 @@ function rscTableRemove (table, handle) {
|
|
|
75
75
|
|
|
76
76
|
let curResourceBorrows = [];
|
|
77
77
|
|
|
78
|
+
let NEXT_TASK_ID = 0n;
|
|
79
|
+
function startCurrentTask(componentIdx, isAsync, entryFnName) {
|
|
80
|
+
_debugLog('[startCurrentTask()] args', { componentIdx, isAsync });
|
|
81
|
+
if (componentIdx === undefined || componentIdx === null) {
|
|
82
|
+
throw new Error('missing/invalid component instance index while starting task');
|
|
83
|
+
}
|
|
84
|
+
const tasks = ASYNC_TASKS_BY_COMPONENT_IDX.get(componentIdx);
|
|
85
|
+
|
|
86
|
+
const nextId = ++NEXT_TASK_ID;
|
|
87
|
+
const newTask = new AsyncTask({ id: nextId, componentIdx, isAsync, entryFnName });
|
|
88
|
+
const newTaskMeta = { id: nextId, componentIdx, task: newTask };
|
|
89
|
+
|
|
90
|
+
ASYNC_CURRENT_TASK_ID = nextId;
|
|
91
|
+
ASYNC_CURRENT_COMPONENT_IDX = componentIdx;
|
|
92
|
+
|
|
93
|
+
if (!tasks) {
|
|
94
|
+
ASYNC_TASKS_BY_COMPONENT_IDX.set(componentIdx, [newTaskMeta]);
|
|
95
|
+
return nextId;
|
|
96
|
+
} else {
|
|
97
|
+
tasks.push(newTaskMeta);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return nextId;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function endCurrentTask(componentIdx, taskId) {
|
|
104
|
+
_debugLog('[endCurrentTask()] args', { componentIdx });
|
|
105
|
+
if (componentIdx === undefined || componentIdx === null) {
|
|
106
|
+
throw new Error('missing/invalid component instance index while ending current task');
|
|
107
|
+
}
|
|
108
|
+
const tasks = ASYNC_TASKS_BY_COMPONENT_IDX.get(componentIdx);
|
|
109
|
+
if (!tasks || !Array.isArray(tasks)) {
|
|
110
|
+
throw new Error('missing/invalid tasks for component instance while ending task');
|
|
111
|
+
}
|
|
112
|
+
if (tasks.length == 0) {
|
|
113
|
+
throw new Error('no current task(s) for component instance while ending task');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (taskId) {
|
|
117
|
+
const last = tasks[tasks.length - 1];
|
|
118
|
+
if (last.id !== taskId) {
|
|
119
|
+
throw new Error('current task does not match expected task ID');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
ASYNC_CURRENT_TASK_ID = null;
|
|
124
|
+
ASYNC_CURRENT_COMPONENT_IDX = null;
|
|
125
|
+
|
|
126
|
+
return tasks.pop();
|
|
127
|
+
}
|
|
128
|
+
const ASYNC_TASKS_BY_COMPONENT_IDX = new Map();
|
|
129
|
+
let ASYNC_CURRENT_TASK_ID = null;
|
|
130
|
+
let ASYNC_CURRENT_COMPONENT_IDX = null;
|
|
131
|
+
|
|
132
|
+
class AsyncTask {
|
|
133
|
+
static State = {
|
|
134
|
+
INITIAL: 'initial',
|
|
135
|
+
CANCELLED: 'cancelled',
|
|
136
|
+
CANCEL_PENDING: 'cancel-pending',
|
|
137
|
+
CANCEL_DELIVERED: 'cancel-delivered',
|
|
138
|
+
RESOLVED: 'resolved',
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static BlockResult = {
|
|
142
|
+
CANCELLED: 'block.cancelled',
|
|
143
|
+
NOT_CANCELLED: 'block.not-cancelled',
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
#id;
|
|
147
|
+
#componentIdx;
|
|
148
|
+
#state;
|
|
149
|
+
#isAsync;
|
|
150
|
+
#onResolve = null;
|
|
151
|
+
#returnedResults = null;
|
|
152
|
+
#entryFnName = null;
|
|
153
|
+
|
|
154
|
+
cancelled = false;
|
|
155
|
+
requested = false;
|
|
156
|
+
alwaysTaskReturn = false;
|
|
157
|
+
|
|
158
|
+
returnCalls = 0;
|
|
159
|
+
storage = [0, 0];
|
|
160
|
+
borrowedHandles = {};
|
|
161
|
+
|
|
162
|
+
awaitableResume = null;
|
|
163
|
+
awaitableCancel = null;
|
|
164
|
+
|
|
165
|
+
constructor(opts) {
|
|
166
|
+
if (opts?.id === undefined) { throw new TypeError('missing task ID during task creation'); }
|
|
167
|
+
this.#id = opts.id;
|
|
168
|
+
if (opts?.componentIdx === undefined) {
|
|
169
|
+
throw new TypeError('missing component id during task creation');
|
|
170
|
+
}
|
|
171
|
+
this.#componentIdx = opts.componentIdx;
|
|
172
|
+
this.#state = AsyncTask.State.INITIAL;
|
|
173
|
+
this.#isAsync = opts?.isAsync ?? false;
|
|
174
|
+
this.#entryFnName = opts.entryFnName;
|
|
175
|
+
|
|
176
|
+
this.#onResolve = (results) => {
|
|
177
|
+
this.#returnedResults = results;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
taskState() { return this.#state.slice(); }
|
|
182
|
+
id() { return this.#id; }
|
|
183
|
+
componentIdx() { return this.#componentIdx; }
|
|
184
|
+
isAsync() { return this.#isAsync; }
|
|
185
|
+
getEntryFnName() { return this.#entryFnName; }
|
|
186
|
+
|
|
187
|
+
takeResults() {
|
|
188
|
+
const results = this.#returnedResults;
|
|
189
|
+
this.#returnedResults = null;
|
|
190
|
+
return results;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
mayEnter(task) {
|
|
194
|
+
const cstate = getOrCreateAsyncState(this.#componentIdx);
|
|
195
|
+
if (!cstate.backpressure) {
|
|
196
|
+
_debugLog('[AsyncTask#mayEnter()] disallowed due to backpressure', { taskID: this.#id });
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
if (!cstate.callingSyncImport()) {
|
|
200
|
+
_debugLog('[AsyncTask#mayEnter()] disallowed due to sync import call', { taskID: this.#id });
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
const callingSyncExportWithSyncPending = cstate.callingSyncExport && !task.isAsync;
|
|
204
|
+
if (!callingSyncExportWithSyncPending) {
|
|
205
|
+
_debugLog('[AsyncTask#mayEnter()] disallowed due to sync export w/ sync pending', { taskID: this.#id });
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async enter() {
|
|
212
|
+
_debugLog('[AsyncTask#enter()] args', { taskID: this.#id });
|
|
213
|
+
|
|
214
|
+
// TODO: assert scheduler locked
|
|
215
|
+
// TODO: trap if on the stack
|
|
216
|
+
|
|
217
|
+
const cstate = getOrCreateAsyncState(this.#componentIdx);
|
|
218
|
+
|
|
219
|
+
let mayNotEnter = !this.mayEnter(this);
|
|
220
|
+
const componentHasPendingTasks = cstate.pendingTasks > 0;
|
|
221
|
+
if (mayNotEnter || componentHasPendingTasks) {
|
|
222
|
+
|
|
223
|
+
throw new Error('in enter()'); // TODO: remove
|
|
224
|
+
cstate.pendingTasks.set(this.#id, new Awaitable(new Promise()));
|
|
225
|
+
|
|
226
|
+
const blockResult = await this.onBlock(awaitable);
|
|
227
|
+
if (blockResult) {
|
|
228
|
+
// TODO: find this pending task in the component
|
|
229
|
+
const pendingTask = cstate.pendingTasks.get(this.#id);
|
|
230
|
+
if (!pendingTask) {
|
|
231
|
+
throw new Error('pending task [' + this.#id + '] not found for component instance');
|
|
232
|
+
}
|
|
233
|
+
cstate.pendingTasks.remove(this.#id);
|
|
234
|
+
this.#onResolve([]);
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
mayNotEnter = !this.mayEnter(this);
|
|
239
|
+
if (!mayNotEnter || !cstate.startPendingTask) {
|
|
240
|
+
throw new Error('invalid component entrance/pending task resolution');
|
|
241
|
+
}
|
|
242
|
+
cstate.startPendingTask = false;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (!this.isAsync) { cstate.callingSyncExport = true; }
|
|
246
|
+
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async waitForEvent(opts) {
|
|
251
|
+
const { waitableSetRep, isAsync } = opts;
|
|
252
|
+
_debugLog('[AsyncTask#waitForEvent()] args', { taskID: this.#id, waitableSetRep, isAsync });
|
|
253
|
+
|
|
254
|
+
if (this.#isAsync !== isAsync) {
|
|
255
|
+
throw new Error('async waitForEvent called on non-async task');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (this.status === AsyncTask.State.CANCEL_PENDING) {
|
|
259
|
+
this.#state = AsyncTask.State.CANCEL_DELIVERED;
|
|
260
|
+
return {
|
|
261
|
+
code: ASYNC_EVENT_CODE.TASK_CANCELLED,
|
|
262
|
+
something: 0,
|
|
263
|
+
something: 0,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const state = getOrCreateAsyncState(this.#componentIdx);
|
|
268
|
+
const waitableSet = state.waitableSets.get(waitableSetRep);
|
|
269
|
+
if (!waitableSet) { throw new Error('missing/invalid waitable set'); }
|
|
270
|
+
|
|
271
|
+
waitableSet.numWaiting += 1;
|
|
272
|
+
let event = null;
|
|
273
|
+
|
|
274
|
+
while (event == null) {
|
|
275
|
+
const awaitable = new Awaitable(waitableSet.getPendingEvent());
|
|
276
|
+
const waited = await this.blockOn({ awaitable, isAsync, isCancellable: true });
|
|
277
|
+
if (waited) {
|
|
278
|
+
if (this.#state !== AsyncTask.State.INITIAL) {
|
|
279
|
+
throw new Error('task should be in initial state found [' + this.#state + ']');
|
|
280
|
+
}
|
|
281
|
+
this.#state = AsyncTask.State.CANCELLED;
|
|
282
|
+
return {
|
|
283
|
+
code: ASYNC_EVENT_CODE.TASK_CANCELLED,
|
|
284
|
+
something: 0,
|
|
285
|
+
something: 0,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
event = waitableSet.poll();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
waitableSet.numWaiting -= 1;
|
|
293
|
+
return event;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
waitForEventSync(opts) {
|
|
297
|
+
throw new Error('AsyncTask#yieldSync() not implemented')
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async pollForEvent(opts) {
|
|
301
|
+
const { waitableSetRep, isAsync } = opts;
|
|
302
|
+
_debugLog('[AsyncTask#pollForEvent()] args', { taskID: this.#id, waitableSetRep, isAsync });
|
|
303
|
+
|
|
304
|
+
if (this.#isAsync !== isAsync) {
|
|
305
|
+
throw new Error('async pollForEvent called on non-async task');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
throw new Error('AsyncTask#pollForEvent() not implemented');
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
pollForEventSync(opts) {
|
|
312
|
+
throw new Error('AsyncTask#yieldSync() not implemented')
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
async blockOn(opts) {
|
|
316
|
+
const { awaitable, isCancellable, forCallback } = opts;
|
|
317
|
+
_debugLog('[AsyncTask#blockOn()] args', { taskID: this.#id, awaitable, isCancellable, forCallback });
|
|
318
|
+
|
|
319
|
+
if (awaitable.resolved() && !ASYNC_DETERMINISM && _coinFlip()) {
|
|
320
|
+
return AsyncTask.BlockResult.NOT_CANCELLED;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const cstate = getOrCreateAsyncState(this.#componentIdx);
|
|
324
|
+
if (forCallback) { cstate.exclusiveRelease(); }
|
|
325
|
+
|
|
326
|
+
let cancelled = await this.onBlock(awaitable);
|
|
327
|
+
if (cancelled === AsyncTask.BlockResult.CANCELLED && !isCancellable) {
|
|
328
|
+
const secondCancel = await this.onBlock(awaitable);
|
|
329
|
+
if (secondCancel !== AsyncTask.BlockResult.NOT_CANCELLED) {
|
|
330
|
+
throw new Error('uncancellable task was canceled despite second onBlock()');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (forCallback) {
|
|
335
|
+
const acquired = new Awaitable(cstate.exclusiveLock());
|
|
336
|
+
cancelled = await this.onBlock(acquired);
|
|
337
|
+
if (cancelled === AsyncTask.BlockResult.CANCELLED) {
|
|
338
|
+
const secondCancel = await this.onBlock(acquired);
|
|
339
|
+
if (secondCancel !== AsyncTask.BlockResult.NOT_CANCELLED) {
|
|
340
|
+
throw new Error('uncancellable callback task was canceled despite second onBlock()');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (cancelled === AsyncTask.BlockResult.CANCELLED) {
|
|
346
|
+
if (this.#state !== AsyncTask.State.INITIAL) {
|
|
347
|
+
throw new Error('cancelled task is not at initial state');
|
|
348
|
+
}
|
|
349
|
+
if (isCancellable) {
|
|
350
|
+
this.#state = AsyncTask.State.CANCELLED;
|
|
351
|
+
return AsyncTask.BlockResult.CANCELLED;
|
|
352
|
+
} else {
|
|
353
|
+
this.#state = AsyncTask.State.CANCEL_PENDING;
|
|
354
|
+
return AsyncTask.BlockResult.NOT_CANCELLED;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return AsyncTask.BlockResult.NOT_CANCELLED;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async onBlock(awaitable) {
|
|
362
|
+
_debugLog('[AsyncTask#onBlock()] args', { taskID: this.#id, awaitable });
|
|
363
|
+
if (!(awaitable instanceof Awaitable)) {
|
|
364
|
+
throw new Error('invalid awaitable during onBlock');
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Build a promise that this task can await on which resolves when it is awoken
|
|
368
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
369
|
+
this.awaitableResume = () => {
|
|
370
|
+
_debugLog('[AsyncTask] resuming after onBlock', { taskID: this.#id });
|
|
371
|
+
resolve();
|
|
372
|
+
};
|
|
373
|
+
this.awaitableCancel = (err) => {
|
|
374
|
+
_debugLog('[AsyncTask] rejecting after onBlock', { taskID: this.#id, err });
|
|
375
|
+
reject(err);
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// Park this task/execution to be handled later
|
|
379
|
+
const state = getOrCreateAsyncState(this.#componentIdx);
|
|
380
|
+
state.parkTaskOnAwaitable({ awaitable, task: this });
|
|
381
|
+
|
|
382
|
+
try {
|
|
383
|
+
await promise;
|
|
384
|
+
return AsyncTask.BlockResult.NOT_CANCELLED;
|
|
385
|
+
} catch (err) {
|
|
386
|
+
// rejection means task cancellation
|
|
387
|
+
return AsyncTask.BlockResult.CANCELLED;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// NOTE: this should likely be moved to a SubTask class
|
|
392
|
+
async asyncOnBlock(awaitable) {
|
|
393
|
+
_debugLog('[AsyncTask#asyncOnBlock()] args', { taskID: this.#id, awaitable });
|
|
394
|
+
if (!(awaitable instanceof Awaitable)) {
|
|
395
|
+
throw new Error('invalid awaitable during onBlock');
|
|
396
|
+
}
|
|
397
|
+
// TODO: watch for waitable AND cancellation
|
|
398
|
+
// TODO: if it WAS cancelled:
|
|
399
|
+
// - return true
|
|
400
|
+
// - only once per subtask
|
|
401
|
+
// - do not wait on the scheduler
|
|
402
|
+
// - control flow should go to the subtask (only once)
|
|
403
|
+
// - Once subtask blocks/resolves, reqlinquishControl() will tehn resolve request_cancel_end (without scheduler lock release)
|
|
404
|
+
// - control flow goes back to request_cancel
|
|
405
|
+
//
|
|
406
|
+
// Subtask cancellation should work similarly to an async import call -- runs sync up until
|
|
407
|
+
// the subtask blocks or resolves
|
|
408
|
+
//
|
|
409
|
+
throw new Error('AsyncTask#asyncOnBlock() not yet implemented');
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
async yield(opts) {
|
|
413
|
+
const { isCancellable, forCallback } = opts;
|
|
414
|
+
_debugLog('[AsyncTask#yield()] args', { taskID: this.#id, isCancellable, forCallback });
|
|
415
|
+
|
|
416
|
+
if (isCancellable && this.status === AsyncTask.State.CANCEL_PENDING) {
|
|
417
|
+
this.#state = AsyncTask.State.CANCELLED;
|
|
418
|
+
return {
|
|
419
|
+
code: ASYNC_EVENT_CODE.TASK_CANCELLED,
|
|
420
|
+
payload: [0, 0],
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// TODO: Awaitables need to *always* trigger the parking mechanism when they're done...?
|
|
425
|
+
// TODO: Component async state should remember which awaitables are done and work to clear tasks waiting
|
|
426
|
+
|
|
427
|
+
const blockResult = await this.blockOn({
|
|
428
|
+
awaitable: new Awaitable(new Promise(resolve => setTimeout(resolve, 0))),
|
|
429
|
+
isCancellable,
|
|
430
|
+
forCallback,
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
if (blockResult === AsyncTask.BlockResult.CANCELLED) {
|
|
434
|
+
if (this.#state !== AsyncTask.State.INITIAL) {
|
|
435
|
+
throw new Error('task should be in initial state found [' + this.#state + ']');
|
|
436
|
+
}
|
|
437
|
+
this.#state = AsyncTask.State.CANCELLED;
|
|
438
|
+
return {
|
|
439
|
+
code: ASYNC_EVENT_CODE.TASK_CANCELLED,
|
|
440
|
+
payload: [0, 0],
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return {
|
|
445
|
+
code: ASYNC_EVENT_CODE.NONE,
|
|
446
|
+
payload: [0, 0],
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
yieldSync(opts) {
|
|
451
|
+
throw new Error('AsyncTask#yieldSync() not implemented')
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
cancel() {
|
|
455
|
+
_debugLog('[AsyncTask#cancel()] args', { });
|
|
456
|
+
if (!this.taskState() !== AsyncTask.State.CANCEL_DELIVERED) {
|
|
457
|
+
throw new Error('invalid task state for cancellation');
|
|
458
|
+
}
|
|
459
|
+
if (this.borrowedHandles.length > 0) { throw new Error('task still has borrow handles'); }
|
|
460
|
+
|
|
461
|
+
this.#onResolve([]);
|
|
462
|
+
this.#state = AsyncTask.State.RESOLVED;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
resolve(result) {
|
|
466
|
+
if (this.#state === AsyncTask.State.RESOLVED) {
|
|
467
|
+
throw new Error('task is already resolved');
|
|
468
|
+
}
|
|
469
|
+
if (this.borrowedHandles.length > 0) { throw new Error('task still has borrow handles'); }
|
|
470
|
+
this.#onResolve(result);
|
|
471
|
+
this.#state = AsyncTask.State.RESOLVED;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
exit() {
|
|
475
|
+
// TODO: ensure there is only one task at a time (scheduler.lock() functionality)
|
|
476
|
+
if (this.#state !== AsyncTask.State.RESOLVED) {
|
|
477
|
+
throw new Error('task exited without resolution');
|
|
478
|
+
}
|
|
479
|
+
if (this.borrowedHandles > 0) {
|
|
480
|
+
throw new Error('task exited without clearing borrowed handles');
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
const state = getOrCreateAsyncState(this.#componentIdx);
|
|
484
|
+
if (!state) { throw new Error('missing async state for component [' + this.#componentIdx + ']'); }
|
|
485
|
+
if (!this.#isAsync && !state.inSyncExportCall) {
|
|
486
|
+
throw new Error('sync task must be run from components known to be in a sync export call');
|
|
487
|
+
}
|
|
488
|
+
state.inSyncExportCall = false;
|
|
489
|
+
|
|
490
|
+
this.startPendingTask();
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
startPendingTask(opts) {
|
|
494
|
+
// TODO: implement
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function unpackCallbackResult(result) {
|
|
500
|
+
_debugLog('[unpackCallbackResult()] args', { result });
|
|
501
|
+
if (!(_typeCheckValidI32(result))) { throw new Error('invalid callback return value [' + result + '], not a valid i32'); }
|
|
502
|
+
const eventCode = result & 0xF;
|
|
503
|
+
if (eventCode < 0 || eventCode > 3) {
|
|
504
|
+
throw new Error('invalid async return value [' + eventCode + '], outside callback code range');
|
|
505
|
+
}
|
|
506
|
+
if (result < 0 || result >= 2**32) { throw new Error('invalid callback result'); }
|
|
507
|
+
// TODO: table max length check?
|
|
508
|
+
const waitableSetIdx = result >> 4;
|
|
509
|
+
return [eventCode, waitableSetIdx];
|
|
510
|
+
}
|
|
511
|
+
const ASYNC_STATE = new Map();
|
|
512
|
+
|
|
513
|
+
function getOrCreateAsyncState(componentIdx, init) {
|
|
514
|
+
if (!ASYNC_STATE.has(componentIdx)) {
|
|
515
|
+
ASYNC_STATE.set(componentIdx, new ComponentAsyncState());
|
|
516
|
+
}
|
|
517
|
+
return ASYNC_STATE.get(componentIdx);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
class ComponentAsyncState {
|
|
521
|
+
#callingAsyncImport = false;
|
|
522
|
+
#syncImportWait = Promise.withResolvers();
|
|
523
|
+
#lock = null;
|
|
524
|
+
|
|
525
|
+
mayLeave = false;
|
|
526
|
+
waitableSets = new RepTable();
|
|
527
|
+
waitables = new RepTable();
|
|
528
|
+
|
|
529
|
+
#parkedTasks = new Map();
|
|
530
|
+
|
|
531
|
+
callingSyncImport(val) {
|
|
532
|
+
if (val === undefined) { return this.#callingAsyncImport; }
|
|
533
|
+
if (typeof val !== 'boolean') { throw new TypeError('invalid setting for async import'); }
|
|
534
|
+
const prev = this.#callingAsyncImport;
|
|
535
|
+
this.#callingAsyncImport = val;
|
|
536
|
+
if (prev === true && this.#callingAsyncImport === false) {
|
|
537
|
+
this.#notifySyncImportEnd();
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
#notifySyncImportEnd() {
|
|
542
|
+
const existing = this.#syncImportWait;
|
|
543
|
+
this.#syncImportWait = Promise.withResolvers();
|
|
544
|
+
existing.resolve();
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
async waitForSyncImportCallEnd() {
|
|
548
|
+
await this.#syncImportWait.promise;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
parkTaskOnAwaitable(args) {
|
|
552
|
+
if (!args.awaitable) { throw new TypeError('missing awaitable when trying to park'); }
|
|
553
|
+
if (!args.task) { throw new TypeError('missing task when trying to park'); }
|
|
554
|
+
const { awaitable, task } = args;
|
|
555
|
+
|
|
556
|
+
let taskList = this.#parkedTasks.get(awaitable.id());
|
|
557
|
+
if (!taskList) {
|
|
558
|
+
taskList = [];
|
|
559
|
+
this.#parkedTasks.set(awaitable.id(), taskList);
|
|
560
|
+
}
|
|
561
|
+
taskList.push(task);
|
|
562
|
+
|
|
563
|
+
this.wakeNextTaskForAwaitable(awaitable);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
wakeNextTaskForAwaitable(awaitable) {
|
|
567
|
+
if (!awaitable) { throw new TypeError('missing awaitable when waking next task'); }
|
|
568
|
+
const awaitableID = awaitable.id();
|
|
569
|
+
|
|
570
|
+
const taskList = this.#parkedTasks.get(awaitableID);
|
|
571
|
+
if (!taskList || taskList.length === 0) {
|
|
572
|
+
_debugLog('[ComponentAsyncState] no tasks waiting for awaitable', { awaitableID: awaitable.id() });
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
let task = taskList.shift(); // todo(perf)
|
|
577
|
+
if (!task) { throw new Error('no task in parked list despite previous check'); }
|
|
578
|
+
|
|
579
|
+
if (!task.awaitableResume) {
|
|
580
|
+
throw new Error('task ready due to awaitable is missing resume', { taskID: task.id(), awaitableID });
|
|
581
|
+
}
|
|
582
|
+
task.awaitableResume();
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
async exclusiveLock() { // TODO: use atomics
|
|
586
|
+
if (this.#lock === null) {
|
|
587
|
+
this.#lock = { ticket: 0n };
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Take a ticket for the next valid usage
|
|
591
|
+
const ticket = ++this.#lock.ticket;
|
|
592
|
+
|
|
593
|
+
_debugLog('[ComponentAsyncState#exclusiveLock()] locking', {
|
|
594
|
+
currentTicket: ticket - 1n,
|
|
595
|
+
ticket
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
// If there is an active promise, then wait for it
|
|
599
|
+
while (this.#lock.promise) {
|
|
600
|
+
const finishedTicket = await this.#lock.promise;
|
|
601
|
+
finishedTicket = await this.#lock.promise;
|
|
602
|
+
if (finishedTicket === ticket - 1n) { break; }
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
606
|
+
this.#lock = {
|
|
607
|
+
ticket,
|
|
608
|
+
promise,
|
|
609
|
+
resolve,
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
return this.#lock.promise;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
exclusiveRelease() {
|
|
616
|
+
_debugLog('[ComponentAsyncState#exclusiveRelease()] releasing', {
|
|
617
|
+
currentTicket: this.#lock === null ? 'none' : this.#lock.ticket,
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
if (this.#lock === null) { return; }
|
|
621
|
+
|
|
622
|
+
const existingLock = this.#lock;
|
|
623
|
+
this.#lock = null;
|
|
624
|
+
existingLock.resolve(existingLock.ticket);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
isExclusivelyLocked() { return this.#lock !== null; }
|
|
628
|
+
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (!Promise.withResolvers) {
|
|
632
|
+
Promise.withResolvers = () => {
|
|
633
|
+
let resolve;
|
|
634
|
+
let reject;
|
|
635
|
+
const promise = new Promise((res, rej) => {
|
|
636
|
+
resolve = res;
|
|
637
|
+
reject = rej;
|
|
638
|
+
});
|
|
639
|
+
return { promise, resolve, reject };
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
|
|
78
643
|
const _debugLog = (...args) => {
|
|
79
644
|
if (!globalThis?.process?.env?.JCO_DEBUG) { return; }
|
|
80
645
|
console.debug(...args);
|
|
81
646
|
}
|
|
647
|
+
const ASYNC_DETERMINISM = 'random';
|
|
648
|
+
const _coinFlip = () => { return Math.random() > 0.5; };
|
|
649
|
+
const I32_MAX = 2_147_483_647;
|
|
650
|
+
const I32_MIN = -2_147_483_648;
|
|
651
|
+
const _typeCheckValidI32 = (n) => typeof n === 'number' && n >= I32_MIN && n <= I32_MAX;
|
|
82
652
|
|
|
83
653
|
const base64Compile = str => WebAssembly.compile(typeof Buffer !== 'undefined' ? Buffer.from(str, 'base64') : Uint8Array.from(atob(str), b => b.charCodeAt(0)));
|
|
84
654
|
|
|
@@ -116,6 +686,54 @@ function getErrorPayload(e) {
|
|
|
116
686
|
return e;
|
|
117
687
|
}
|
|
118
688
|
|
|
689
|
+
class RepTable {
|
|
690
|
+
#data = [0, null];
|
|
691
|
+
|
|
692
|
+
insert(val) {
|
|
693
|
+
_debugLog('[RepTable#insert()] args', { val });
|
|
694
|
+
const freeIdx = this.#data[0];
|
|
695
|
+
if (freeIdx === 0) {
|
|
696
|
+
this.#data.push(val);
|
|
697
|
+
this.#data.push(null);
|
|
698
|
+
return (this.#data.length >> 1) - 1;
|
|
699
|
+
}
|
|
700
|
+
this.#data[0] = this.#data[freeIdx];
|
|
701
|
+
const newFreeIdx = freeIdx << 1;
|
|
702
|
+
this.#data[newFreeIdx] = val;
|
|
703
|
+
this.#data[newFreeIdx + 1] = null;
|
|
704
|
+
return free;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
get(rep) {
|
|
708
|
+
_debugLog('[RepTable#insert()] args', { rep });
|
|
709
|
+
const baseIdx = idx << 1;
|
|
710
|
+
const val = this.#data[baseIdx];
|
|
711
|
+
return val;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
contains(rep) {
|
|
715
|
+
_debugLog('[RepTable#insert()] args', { rep });
|
|
716
|
+
const baseIdx = idx << 1;
|
|
717
|
+
return !!this.#data[baseIdx];
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
remove(rep) {
|
|
721
|
+
_debugLog('[RepTable#insert()] args', { idx });
|
|
722
|
+
if (this.#data.length === 2) { throw new Error('invalid'); }
|
|
723
|
+
|
|
724
|
+
const baseIdx = idx << 1;
|
|
725
|
+
const val = this.#data[baseIdx];
|
|
726
|
+
if (val === 0) { throw new Error('invalid resource rep (cannot be 0)'); }
|
|
727
|
+
this.#data[baseIdx] = this.#data[0];
|
|
728
|
+
this.#data[0] = idx;
|
|
729
|
+
return val;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
clear() {
|
|
733
|
+
this.#data = [0, null];
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
119
737
|
function throwUninitialized() {
|
|
120
738
|
throw new TypeError('Wasm uninitialized use `await $init` first');
|
|
121
739
|
}
|
|
@@ -133,7 +751,10 @@ let captureCnt2 = 0;
|
|
|
133
751
|
handleTables[2] = handleTable2;
|
|
134
752
|
|
|
135
753
|
function trampoline5() {
|
|
754
|
+
_debugLog('[iface="wasi:cli/stderr@0.2.3", function="get-stderr"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
755
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'get-stderr');
|
|
136
756
|
const ret = getStderr();
|
|
757
|
+
_debugLog('[iface="wasi:cli/stderr@0.2.3", function="get-stderr"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
137
758
|
if (!(ret instanceof OutputStream)) {
|
|
138
759
|
throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
|
|
139
760
|
}
|
|
@@ -143,6 +764,11 @@ function trampoline5() {
|
|
|
143
764
|
captureTable2.set(rep, ret);
|
|
144
765
|
handle0 = rscTableCreateOwn(handleTable2, rep);
|
|
145
766
|
}
|
|
767
|
+
_debugLog('[iface="wasi:cli/stderr@0.2.3", function="get-stderr"][Instruction::Return]', {
|
|
768
|
+
funcName: 'get-stderr',
|
|
769
|
+
paramCount: 1,
|
|
770
|
+
postReturn: false
|
|
771
|
+
});
|
|
146
772
|
return handle0;
|
|
147
773
|
}
|
|
148
774
|
|
|
@@ -152,7 +778,10 @@ let captureCnt1 = 0;
|
|
|
152
778
|
handleTables[1] = handleTable1;
|
|
153
779
|
|
|
154
780
|
function trampoline8() {
|
|
781
|
+
_debugLog('[iface="wasi:cli/stdin@0.2.3", function="get-stdin"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
782
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'get-stdin');
|
|
155
783
|
const ret = getStdin();
|
|
784
|
+
_debugLog('[iface="wasi:cli/stdin@0.2.3", function="get-stdin"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
156
785
|
if (!(ret instanceof InputStream)) {
|
|
157
786
|
throw new TypeError('Resource error: Not a valid "InputStream" resource.');
|
|
158
787
|
}
|
|
@@ -162,12 +791,20 @@ function trampoline8() {
|
|
|
162
791
|
captureTable1.set(rep, ret);
|
|
163
792
|
handle0 = rscTableCreateOwn(handleTable1, rep);
|
|
164
793
|
}
|
|
794
|
+
_debugLog('[iface="wasi:cli/stdin@0.2.3", function="get-stdin"][Instruction::Return]', {
|
|
795
|
+
funcName: 'get-stdin',
|
|
796
|
+
paramCount: 1,
|
|
797
|
+
postReturn: false
|
|
798
|
+
});
|
|
165
799
|
return handle0;
|
|
166
800
|
}
|
|
167
801
|
|
|
168
802
|
|
|
169
803
|
function trampoline9() {
|
|
804
|
+
_debugLog('[iface="wasi:cli/stdout@0.2.3", function="get-stdout"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
805
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'get-stdout');
|
|
170
806
|
const ret = getStdout();
|
|
807
|
+
_debugLog('[iface="wasi:cli/stdout@0.2.3", function="get-stdout"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
171
808
|
if (!(ret instanceof OutputStream)) {
|
|
172
809
|
throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
|
|
173
810
|
}
|
|
@@ -177,6 +814,11 @@ function trampoline9() {
|
|
|
177
814
|
captureTable2.set(rep, ret);
|
|
178
815
|
handle0 = rscTableCreateOwn(handleTable2, rep);
|
|
179
816
|
}
|
|
817
|
+
_debugLog('[iface="wasi:cli/stdout@0.2.3", function="get-stdout"][Instruction::Return]', {
|
|
818
|
+
funcName: 'get-stdout',
|
|
819
|
+
paramCount: 1,
|
|
820
|
+
postReturn: false
|
|
821
|
+
});
|
|
180
822
|
return handle0;
|
|
181
823
|
}
|
|
182
824
|
|
|
@@ -202,7 +844,15 @@ function trampoline10(arg0) {
|
|
|
202
844
|
throw new TypeError('invalid variant discriminant for expected');
|
|
203
845
|
}
|
|
204
846
|
}
|
|
847
|
+
_debugLog('[iface="wasi:cli/exit@0.2.3", function="exit"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
848
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'exit');
|
|
205
849
|
exit(variant0);
|
|
850
|
+
_debugLog('[iface="wasi:cli/exit@0.2.3", function="exit"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
851
|
+
_debugLog('[iface="wasi:cli/exit@0.2.3", function="exit"][Instruction::Return]', {
|
|
852
|
+
funcName: 'exit',
|
|
853
|
+
paramCount: 0,
|
|
854
|
+
postReturn: false
|
|
855
|
+
});
|
|
206
856
|
}
|
|
207
857
|
|
|
208
858
|
let exports2;
|
|
@@ -210,7 +860,10 @@ let memory0;
|
|
|
210
860
|
let realloc0;
|
|
211
861
|
|
|
212
862
|
function trampoline11(arg0) {
|
|
863
|
+
_debugLog('[iface="wasi:cli/environment@0.2.3", function="get-environment"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
864
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'get-environment');
|
|
213
865
|
const ret = getEnvironment();
|
|
866
|
+
_debugLog('[iface="wasi:cli/environment@0.2.3", function="get-environment"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
214
867
|
var vec3 = ret;
|
|
215
868
|
var len3 = vec3.length;
|
|
216
869
|
var result3 = realloc0(0, 0, 4, len3 * 16);
|
|
@@ -228,6 +881,11 @@ function trampoline11(arg0) {
|
|
|
228
881
|
}
|
|
229
882
|
dataView(memory0).setInt32(arg0 + 4, len3, true);
|
|
230
883
|
dataView(memory0).setInt32(arg0 + 0, result3, true);
|
|
884
|
+
_debugLog('[iface="wasi:cli/environment@0.2.3", function="get-environment"][Instruction::Return]', {
|
|
885
|
+
funcName: 'get-environment',
|
|
886
|
+
paramCount: 0,
|
|
887
|
+
postReturn: false
|
|
888
|
+
});
|
|
231
889
|
}
|
|
232
890
|
|
|
233
891
|
const handleTable6 = [T_FLAG, 0];
|
|
@@ -245,12 +903,15 @@ function trampoline12(arg0, arg1) {
|
|
|
245
903
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
246
904
|
}
|
|
247
905
|
curResourceBorrows.push(rsc0);
|
|
906
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.get-type"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
907
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.get-type');
|
|
248
908
|
let ret;
|
|
249
909
|
try {
|
|
250
910
|
ret = { tag: 'ok', val: rsc0.getType()};
|
|
251
911
|
} catch (e) {
|
|
252
912
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
253
913
|
}
|
|
914
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.get-type"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
254
915
|
for (const rsc of curResourceBorrows) {
|
|
255
916
|
rsc[symbolRscHandle] = undefined;
|
|
256
917
|
}
|
|
@@ -475,6 +1136,11 @@ function trampoline12(arg0, arg1) {
|
|
|
475
1136
|
throw new TypeError('invalid variant specified for result');
|
|
476
1137
|
}
|
|
477
1138
|
}
|
|
1139
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.get-type"][Instruction::Return]', {
|
|
1140
|
+
funcName: '[method]descriptor.get-type',
|
|
1141
|
+
paramCount: 0,
|
|
1142
|
+
postReturn: false
|
|
1143
|
+
});
|
|
478
1144
|
}
|
|
479
1145
|
|
|
480
1146
|
|
|
@@ -488,12 +1154,15 @@ function trampoline13(arg0, arg1) {
|
|
|
488
1154
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
489
1155
|
}
|
|
490
1156
|
curResourceBorrows.push(rsc0);
|
|
1157
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.metadata-hash"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
1158
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.metadata-hash');
|
|
491
1159
|
let ret;
|
|
492
1160
|
try {
|
|
493
1161
|
ret = { tag: 'ok', val: rsc0.metadataHash()};
|
|
494
1162
|
} catch (e) {
|
|
495
1163
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
496
1164
|
}
|
|
1165
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.metadata-hash"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
497
1166
|
for (const rsc of curResourceBorrows) {
|
|
498
1167
|
rsc[symbolRscHandle] = undefined;
|
|
499
1168
|
}
|
|
@@ -677,6 +1346,11 @@ function trampoline13(arg0, arg1) {
|
|
|
677
1346
|
throw new TypeError('invalid variant specified for result');
|
|
678
1347
|
}
|
|
679
1348
|
}
|
|
1349
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.metadata-hash"][Instruction::Return]', {
|
|
1350
|
+
funcName: '[method]descriptor.metadata-hash',
|
|
1351
|
+
paramCount: 0,
|
|
1352
|
+
postReturn: false
|
|
1353
|
+
});
|
|
680
1354
|
}
|
|
681
1355
|
|
|
682
1356
|
const handleTable0 = [T_FLAG, 0];
|
|
@@ -694,7 +1368,10 @@ function trampoline14(arg0, arg1) {
|
|
|
694
1368
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
695
1369
|
}
|
|
696
1370
|
curResourceBorrows.push(rsc0);
|
|
1371
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="filesystem-error-code"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
1372
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'filesystem-error-code');
|
|
697
1373
|
const ret = filesystemErrorCode(rsc0);
|
|
1374
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="filesystem-error-code"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
698
1375
|
for (const rsc of curResourceBorrows) {
|
|
699
1376
|
rsc[symbolRscHandle] = undefined;
|
|
700
1377
|
}
|
|
@@ -866,6 +1543,11 @@ function trampoline14(arg0, arg1) {
|
|
|
866
1543
|
}
|
|
867
1544
|
dataView(memory0).setInt8(arg1 + 1, enum3, true);
|
|
868
1545
|
}
|
|
1546
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="filesystem-error-code"][Instruction::Return]', {
|
|
1547
|
+
funcName: 'filesystem-error-code',
|
|
1548
|
+
paramCount: 0,
|
|
1549
|
+
postReturn: false
|
|
1550
|
+
});
|
|
869
1551
|
}
|
|
870
1552
|
|
|
871
1553
|
|
|
@@ -888,12 +1570,15 @@ function trampoline15(arg0, arg1, arg2, arg3, arg4) {
|
|
|
888
1570
|
var ptr4 = arg2;
|
|
889
1571
|
var len4 = arg3;
|
|
890
1572
|
var result4 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr4, len4));
|
|
1573
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.metadata-hash-at"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
1574
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.metadata-hash-at');
|
|
891
1575
|
let ret;
|
|
892
1576
|
try {
|
|
893
1577
|
ret = { tag: 'ok', val: rsc0.metadataHashAt(flags3, result4)};
|
|
894
1578
|
} catch (e) {
|
|
895
1579
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
896
1580
|
}
|
|
1581
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.metadata-hash-at"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
897
1582
|
for (const rsc of curResourceBorrows) {
|
|
898
1583
|
rsc[symbolRscHandle] = undefined;
|
|
899
1584
|
}
|
|
@@ -1077,6 +1762,11 @@ function trampoline15(arg0, arg1, arg2, arg3, arg4) {
|
|
|
1077
1762
|
throw new TypeError('invalid variant specified for result');
|
|
1078
1763
|
}
|
|
1079
1764
|
}
|
|
1765
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.metadata-hash-at"][Instruction::Return]', {
|
|
1766
|
+
funcName: '[method]descriptor.metadata-hash-at',
|
|
1767
|
+
paramCount: 0,
|
|
1768
|
+
postReturn: false
|
|
1769
|
+
});
|
|
1080
1770
|
}
|
|
1081
1771
|
|
|
1082
1772
|
|
|
@@ -1090,12 +1780,15 @@ function trampoline16(arg0, arg1, arg2) {
|
|
|
1090
1780
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
1091
1781
|
}
|
|
1092
1782
|
curResourceBorrows.push(rsc0);
|
|
1783
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.read-via-stream"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
1784
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.read-via-stream');
|
|
1093
1785
|
let ret;
|
|
1094
1786
|
try {
|
|
1095
1787
|
ret = { tag: 'ok', val: rsc0.readViaStream(BigInt.asUintN(64, arg1))};
|
|
1096
1788
|
} catch (e) {
|
|
1097
1789
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
1098
1790
|
}
|
|
1791
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.read-via-stream"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
1099
1792
|
for (const rsc of curResourceBorrows) {
|
|
1100
1793
|
rsc[symbolRscHandle] = undefined;
|
|
1101
1794
|
}
|
|
@@ -1286,6 +1979,11 @@ function trampoline16(arg0, arg1, arg2) {
|
|
|
1286
1979
|
throw new TypeError('invalid variant specified for result');
|
|
1287
1980
|
}
|
|
1288
1981
|
}
|
|
1982
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.read-via-stream"][Instruction::Return]', {
|
|
1983
|
+
funcName: '[method]descriptor.read-via-stream',
|
|
1984
|
+
paramCount: 0,
|
|
1985
|
+
postReturn: false
|
|
1986
|
+
});
|
|
1289
1987
|
}
|
|
1290
1988
|
|
|
1291
1989
|
|
|
@@ -1299,12 +1997,15 @@ function trampoline17(arg0, arg1, arg2) {
|
|
|
1299
1997
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
1300
1998
|
}
|
|
1301
1999
|
curResourceBorrows.push(rsc0);
|
|
2000
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.write-via-stream"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
2001
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.write-via-stream');
|
|
1302
2002
|
let ret;
|
|
1303
2003
|
try {
|
|
1304
2004
|
ret = { tag: 'ok', val: rsc0.writeViaStream(BigInt.asUintN(64, arg1))};
|
|
1305
2005
|
} catch (e) {
|
|
1306
2006
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
1307
2007
|
}
|
|
2008
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.write-via-stream"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
1308
2009
|
for (const rsc of curResourceBorrows) {
|
|
1309
2010
|
rsc[symbolRscHandle] = undefined;
|
|
1310
2011
|
}
|
|
@@ -1495,6 +2196,11 @@ function trampoline17(arg0, arg1, arg2) {
|
|
|
1495
2196
|
throw new TypeError('invalid variant specified for result');
|
|
1496
2197
|
}
|
|
1497
2198
|
}
|
|
2199
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.write-via-stream"][Instruction::Return]', {
|
|
2200
|
+
funcName: '[method]descriptor.write-via-stream',
|
|
2201
|
+
paramCount: 0,
|
|
2202
|
+
postReturn: false
|
|
2203
|
+
});
|
|
1498
2204
|
}
|
|
1499
2205
|
|
|
1500
2206
|
|
|
@@ -1508,12 +2214,15 @@ function trampoline18(arg0, arg1) {
|
|
|
1508
2214
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
1509
2215
|
}
|
|
1510
2216
|
curResourceBorrows.push(rsc0);
|
|
2217
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.append-via-stream"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
2218
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.append-via-stream');
|
|
1511
2219
|
let ret;
|
|
1512
2220
|
try {
|
|
1513
2221
|
ret = { tag: 'ok', val: rsc0.appendViaStream()};
|
|
1514
2222
|
} catch (e) {
|
|
1515
2223
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
1516
2224
|
}
|
|
2225
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.append-via-stream"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
1517
2226
|
for (const rsc of curResourceBorrows) {
|
|
1518
2227
|
rsc[symbolRscHandle] = undefined;
|
|
1519
2228
|
}
|
|
@@ -1704,6 +2413,11 @@ function trampoline18(arg0, arg1) {
|
|
|
1704
2413
|
throw new TypeError('invalid variant specified for result');
|
|
1705
2414
|
}
|
|
1706
2415
|
}
|
|
2416
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.append-via-stream"][Instruction::Return]', {
|
|
2417
|
+
funcName: '[method]descriptor.append-via-stream',
|
|
2418
|
+
paramCount: 0,
|
|
2419
|
+
postReturn: false
|
|
2420
|
+
});
|
|
1707
2421
|
}
|
|
1708
2422
|
|
|
1709
2423
|
const handleTable5 = [T_FLAG, 0];
|
|
@@ -1721,12 +2435,15 @@ function trampoline19(arg0, arg1) {
|
|
|
1721
2435
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
1722
2436
|
}
|
|
1723
2437
|
curResourceBorrows.push(rsc0);
|
|
2438
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.read-directory"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
2439
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.read-directory');
|
|
1724
2440
|
let ret;
|
|
1725
2441
|
try {
|
|
1726
2442
|
ret = { tag: 'ok', val: rsc0.readDirectory()};
|
|
1727
2443
|
} catch (e) {
|
|
1728
2444
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
1729
2445
|
}
|
|
2446
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.read-directory"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
1730
2447
|
for (const rsc of curResourceBorrows) {
|
|
1731
2448
|
rsc[symbolRscHandle] = undefined;
|
|
1732
2449
|
}
|
|
@@ -1917,6 +2634,11 @@ function trampoline19(arg0, arg1) {
|
|
|
1917
2634
|
throw new TypeError('invalid variant specified for result');
|
|
1918
2635
|
}
|
|
1919
2636
|
}
|
|
2637
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.read-directory"][Instruction::Return]', {
|
|
2638
|
+
funcName: '[method]descriptor.read-directory',
|
|
2639
|
+
paramCount: 0,
|
|
2640
|
+
postReturn: false
|
|
2641
|
+
});
|
|
1920
2642
|
}
|
|
1921
2643
|
|
|
1922
2644
|
|
|
@@ -1930,12 +2652,15 @@ function trampoline20(arg0, arg1) {
|
|
|
1930
2652
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
1931
2653
|
}
|
|
1932
2654
|
curResourceBorrows.push(rsc0);
|
|
2655
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.stat"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
2656
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.stat');
|
|
1933
2657
|
let ret;
|
|
1934
2658
|
try {
|
|
1935
2659
|
ret = { tag: 'ok', val: rsc0.stat()};
|
|
1936
2660
|
} catch (e) {
|
|
1937
2661
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
1938
2662
|
}
|
|
2663
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.stat"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
1939
2664
|
for (const rsc of curResourceBorrows) {
|
|
1940
2665
|
rsc[symbolRscHandle] = undefined;
|
|
1941
2666
|
}
|
|
@@ -2193,6 +2918,11 @@ function trampoline20(arg0, arg1) {
|
|
|
2193
2918
|
throw new TypeError('invalid variant specified for result');
|
|
2194
2919
|
}
|
|
2195
2920
|
}
|
|
2921
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.stat"][Instruction::Return]', {
|
|
2922
|
+
funcName: '[method]descriptor.stat',
|
|
2923
|
+
paramCount: 0,
|
|
2924
|
+
postReturn: false
|
|
2925
|
+
});
|
|
2196
2926
|
}
|
|
2197
2927
|
|
|
2198
2928
|
|
|
@@ -2215,12 +2945,15 @@ function trampoline21(arg0, arg1, arg2, arg3, arg4) {
|
|
|
2215
2945
|
var ptr4 = arg2;
|
|
2216
2946
|
var len4 = arg3;
|
|
2217
2947
|
var result4 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr4, len4));
|
|
2948
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.stat-at"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
2949
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.stat-at');
|
|
2218
2950
|
let ret;
|
|
2219
2951
|
try {
|
|
2220
2952
|
ret = { tag: 'ok', val: rsc0.statAt(flags3, result4)};
|
|
2221
2953
|
} catch (e) {
|
|
2222
2954
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
2223
2955
|
}
|
|
2956
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.stat-at"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
2224
2957
|
for (const rsc of curResourceBorrows) {
|
|
2225
2958
|
rsc[symbolRscHandle] = undefined;
|
|
2226
2959
|
}
|
|
@@ -2478,6 +3211,11 @@ function trampoline21(arg0, arg1, arg2, arg3, arg4) {
|
|
|
2478
3211
|
throw new TypeError('invalid variant specified for result');
|
|
2479
3212
|
}
|
|
2480
3213
|
}
|
|
3214
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.stat-at"][Instruction::Return]', {
|
|
3215
|
+
funcName: '[method]descriptor.stat-at',
|
|
3216
|
+
paramCount: 0,
|
|
3217
|
+
postReturn: false
|
|
3218
|
+
});
|
|
2481
3219
|
}
|
|
2482
3220
|
|
|
2483
3221
|
|
|
@@ -2520,12 +3258,15 @@ function trampoline22(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
|
|
|
2520
3258
|
requestedWriteSync: Boolean(arg5 & 16),
|
|
2521
3259
|
mutateDirectory: Boolean(arg5 & 32),
|
|
2522
3260
|
};
|
|
3261
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.open-at"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
3262
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]descriptor.open-at');
|
|
2523
3263
|
let ret;
|
|
2524
3264
|
try {
|
|
2525
3265
|
ret = { tag: 'ok', val: rsc0.openAt(flags3, result4, flags5, flags6)};
|
|
2526
3266
|
} catch (e) {
|
|
2527
3267
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
2528
3268
|
}
|
|
3269
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.open-at"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
2529
3270
|
for (const rsc of curResourceBorrows) {
|
|
2530
3271
|
rsc[symbolRscHandle] = undefined;
|
|
2531
3272
|
}
|
|
@@ -2716,6 +3457,11 @@ function trampoline22(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
|
|
|
2716
3457
|
throw new TypeError('invalid variant specified for result');
|
|
2717
3458
|
}
|
|
2718
3459
|
}
|
|
3460
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.open-at"][Instruction::Return]', {
|
|
3461
|
+
funcName: '[method]descriptor.open-at',
|
|
3462
|
+
paramCount: 0,
|
|
3463
|
+
postReturn: false
|
|
3464
|
+
});
|
|
2719
3465
|
}
|
|
2720
3466
|
|
|
2721
3467
|
|
|
@@ -2729,12 +3475,15 @@ function trampoline23(arg0, arg1) {
|
|
|
2729
3475
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
2730
3476
|
}
|
|
2731
3477
|
curResourceBorrows.push(rsc0);
|
|
3478
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]directory-entry-stream.read-directory-entry"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
3479
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]directory-entry-stream.read-directory-entry');
|
|
2732
3480
|
let ret;
|
|
2733
3481
|
try {
|
|
2734
3482
|
ret = { tag: 'ok', val: rsc0.readDirectoryEntry()};
|
|
2735
3483
|
} catch (e) {
|
|
2736
3484
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
2737
3485
|
}
|
|
3486
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]directory-entry-stream.read-directory-entry"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
2738
3487
|
for (const rsc of curResourceBorrows) {
|
|
2739
3488
|
rsc[symbolRscHandle] = undefined;
|
|
2740
3489
|
}
|
|
@@ -2971,6 +3720,11 @@ function trampoline23(arg0, arg1) {
|
|
|
2971
3720
|
throw new TypeError('invalid variant specified for result');
|
|
2972
3721
|
}
|
|
2973
3722
|
}
|
|
3723
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]directory-entry-stream.read-directory-entry"][Instruction::Return]', {
|
|
3724
|
+
funcName: '[method]directory-entry-stream.read-directory-entry',
|
|
3725
|
+
paramCount: 0,
|
|
3726
|
+
postReturn: false
|
|
3727
|
+
});
|
|
2974
3728
|
}
|
|
2975
3729
|
|
|
2976
3730
|
|
|
@@ -2984,12 +3738,15 @@ function trampoline24(arg0, arg1, arg2) {
|
|
|
2984
3738
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
2985
3739
|
}
|
|
2986
3740
|
curResourceBorrows.push(rsc0);
|
|
3741
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]input-stream.read"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
3742
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]input-stream.read');
|
|
2987
3743
|
let ret;
|
|
2988
3744
|
try {
|
|
2989
3745
|
ret = { tag: 'ok', val: rsc0.read(BigInt.asUintN(64, arg1))};
|
|
2990
3746
|
} catch (e) {
|
|
2991
3747
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
2992
3748
|
}
|
|
3749
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]input-stream.read"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
2993
3750
|
for (const rsc of curResourceBorrows) {
|
|
2994
3751
|
rsc[symbolRscHandle] = undefined;
|
|
2995
3752
|
}
|
|
@@ -3042,6 +3799,11 @@ function trampoline24(arg0, arg1, arg2) {
|
|
|
3042
3799
|
throw new TypeError('invalid variant specified for result');
|
|
3043
3800
|
}
|
|
3044
3801
|
}
|
|
3802
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]input-stream.read"][Instruction::Return]', {
|
|
3803
|
+
funcName: '[method]input-stream.read',
|
|
3804
|
+
paramCount: 0,
|
|
3805
|
+
postReturn: false
|
|
3806
|
+
});
|
|
3045
3807
|
}
|
|
3046
3808
|
|
|
3047
3809
|
|
|
@@ -3055,12 +3817,15 @@ function trampoline25(arg0, arg1, arg2) {
|
|
|
3055
3817
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
3056
3818
|
}
|
|
3057
3819
|
curResourceBorrows.push(rsc0);
|
|
3820
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]input-stream.blocking-read"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
3821
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]input-stream.blocking-read');
|
|
3058
3822
|
let ret;
|
|
3059
3823
|
try {
|
|
3060
3824
|
ret = { tag: 'ok', val: rsc0.blockingRead(BigInt.asUintN(64, arg1))};
|
|
3061
3825
|
} catch (e) {
|
|
3062
3826
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
3063
3827
|
}
|
|
3828
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]input-stream.blocking-read"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3064
3829
|
for (const rsc of curResourceBorrows) {
|
|
3065
3830
|
rsc[symbolRscHandle] = undefined;
|
|
3066
3831
|
}
|
|
@@ -3113,6 +3878,11 @@ function trampoline25(arg0, arg1, arg2) {
|
|
|
3113
3878
|
throw new TypeError('invalid variant specified for result');
|
|
3114
3879
|
}
|
|
3115
3880
|
}
|
|
3881
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]input-stream.blocking-read"][Instruction::Return]', {
|
|
3882
|
+
funcName: '[method]input-stream.blocking-read',
|
|
3883
|
+
paramCount: 0,
|
|
3884
|
+
postReturn: false
|
|
3885
|
+
});
|
|
3116
3886
|
}
|
|
3117
3887
|
|
|
3118
3888
|
|
|
@@ -3126,12 +3896,15 @@ function trampoline26(arg0, arg1) {
|
|
|
3126
3896
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
3127
3897
|
}
|
|
3128
3898
|
curResourceBorrows.push(rsc0);
|
|
3899
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.check-write"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
3900
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]output-stream.check-write');
|
|
3129
3901
|
let ret;
|
|
3130
3902
|
try {
|
|
3131
3903
|
ret = { tag: 'ok', val: rsc0.checkWrite()};
|
|
3132
3904
|
} catch (e) {
|
|
3133
3905
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
3134
3906
|
}
|
|
3907
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.check-write"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3135
3908
|
for (const rsc of curResourceBorrows) {
|
|
3136
3909
|
rsc[symbolRscHandle] = undefined;
|
|
3137
3910
|
}
|
|
@@ -3178,6 +3951,11 @@ function trampoline26(arg0, arg1) {
|
|
|
3178
3951
|
throw new TypeError('invalid variant specified for result');
|
|
3179
3952
|
}
|
|
3180
3953
|
}
|
|
3954
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.check-write"][Instruction::Return]', {
|
|
3955
|
+
funcName: '[method]output-stream.check-write',
|
|
3956
|
+
paramCount: 0,
|
|
3957
|
+
postReturn: false
|
|
3958
|
+
});
|
|
3181
3959
|
}
|
|
3182
3960
|
|
|
3183
3961
|
|
|
@@ -3194,12 +3972,15 @@ function trampoline27(arg0, arg1, arg2, arg3) {
|
|
|
3194
3972
|
var ptr3 = arg1;
|
|
3195
3973
|
var len3 = arg2;
|
|
3196
3974
|
var result3 = new Uint8Array(memory0.buffer.slice(ptr3, ptr3 + len3 * 1));
|
|
3975
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.write"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
3976
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]output-stream.write');
|
|
3197
3977
|
let ret;
|
|
3198
3978
|
try {
|
|
3199
3979
|
ret = { tag: 'ok', val: rsc0.write(result3)};
|
|
3200
3980
|
} catch (e) {
|
|
3201
3981
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
3202
3982
|
}
|
|
3983
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.write"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3203
3984
|
for (const rsc of curResourceBorrows) {
|
|
3204
3985
|
rsc[symbolRscHandle] = undefined;
|
|
3205
3986
|
}
|
|
@@ -3245,6 +4026,11 @@ function trampoline27(arg0, arg1, arg2, arg3) {
|
|
|
3245
4026
|
throw new TypeError('invalid variant specified for result');
|
|
3246
4027
|
}
|
|
3247
4028
|
}
|
|
4029
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.write"][Instruction::Return]', {
|
|
4030
|
+
funcName: '[method]output-stream.write',
|
|
4031
|
+
paramCount: 0,
|
|
4032
|
+
postReturn: false
|
|
4033
|
+
});
|
|
3248
4034
|
}
|
|
3249
4035
|
|
|
3250
4036
|
|
|
@@ -3261,12 +4047,15 @@ function trampoline28(arg0, arg1, arg2, arg3) {
|
|
|
3261
4047
|
var ptr3 = arg1;
|
|
3262
4048
|
var len3 = arg2;
|
|
3263
4049
|
var result3 = new Uint8Array(memory0.buffer.slice(ptr3, ptr3 + len3 * 1));
|
|
4050
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.blocking-write-and-flush"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
4051
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]output-stream.blocking-write-and-flush');
|
|
3264
4052
|
let ret;
|
|
3265
4053
|
try {
|
|
3266
4054
|
ret = { tag: 'ok', val: rsc0.blockingWriteAndFlush(result3)};
|
|
3267
4055
|
} catch (e) {
|
|
3268
4056
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
3269
4057
|
}
|
|
4058
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.blocking-write-and-flush"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3270
4059
|
for (const rsc of curResourceBorrows) {
|
|
3271
4060
|
rsc[symbolRscHandle] = undefined;
|
|
3272
4061
|
}
|
|
@@ -3312,6 +4101,11 @@ function trampoline28(arg0, arg1, arg2, arg3) {
|
|
|
3312
4101
|
throw new TypeError('invalid variant specified for result');
|
|
3313
4102
|
}
|
|
3314
4103
|
}
|
|
4104
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.blocking-write-and-flush"][Instruction::Return]', {
|
|
4105
|
+
funcName: '[method]output-stream.blocking-write-and-flush',
|
|
4106
|
+
paramCount: 0,
|
|
4107
|
+
postReturn: false
|
|
4108
|
+
});
|
|
3315
4109
|
}
|
|
3316
4110
|
|
|
3317
4111
|
|
|
@@ -3325,12 +4119,15 @@ function trampoline29(arg0, arg1) {
|
|
|
3325
4119
|
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
3326
4120
|
}
|
|
3327
4121
|
curResourceBorrows.push(rsc0);
|
|
4122
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.blocking-flush"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
4123
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, '[method]output-stream.blocking-flush');
|
|
3328
4124
|
let ret;
|
|
3329
4125
|
try {
|
|
3330
4126
|
ret = { tag: 'ok', val: rsc0.blockingFlush()};
|
|
3331
4127
|
} catch (e) {
|
|
3332
4128
|
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
3333
4129
|
}
|
|
4130
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.blocking-flush"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3334
4131
|
for (const rsc of curResourceBorrows) {
|
|
3335
4132
|
rsc[symbolRscHandle] = undefined;
|
|
3336
4133
|
}
|
|
@@ -3376,11 +4173,19 @@ function trampoline29(arg0, arg1) {
|
|
|
3376
4173
|
throw new TypeError('invalid variant specified for result');
|
|
3377
4174
|
}
|
|
3378
4175
|
}
|
|
4176
|
+
_debugLog('[iface="wasi:io/streams@0.2.3", function="[method]output-stream.blocking-flush"][Instruction::Return]', {
|
|
4177
|
+
funcName: '[method]output-stream.blocking-flush',
|
|
4178
|
+
paramCount: 0,
|
|
4179
|
+
postReturn: false
|
|
4180
|
+
});
|
|
3379
4181
|
}
|
|
3380
4182
|
|
|
3381
4183
|
|
|
3382
4184
|
function trampoline30(arg0, arg1) {
|
|
4185
|
+
_debugLog('[iface="wasi:random/random@0.2.3", function="get-random-bytes"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
4186
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'get-random-bytes');
|
|
3383
4187
|
const ret = getRandomBytes(BigInt.asUintN(64, arg0));
|
|
4188
|
+
_debugLog('[iface="wasi:random/random@0.2.3", function="get-random-bytes"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3384
4189
|
var val0 = ret;
|
|
3385
4190
|
var len0 = val0.byteLength;
|
|
3386
4191
|
var ptr0 = realloc0(0, 0, 1, len0 * 1);
|
|
@@ -3388,11 +4193,19 @@ function trampoline30(arg0, arg1) {
|
|
|
3388
4193
|
(new Uint8Array(memory0.buffer, ptr0, len0 * 1)).set(src0);
|
|
3389
4194
|
dataView(memory0).setInt32(arg1 + 4, len0, true);
|
|
3390
4195
|
dataView(memory0).setInt32(arg1 + 0, ptr0, true);
|
|
4196
|
+
_debugLog('[iface="wasi:random/random@0.2.3", function="get-random-bytes"][Instruction::Return]', {
|
|
4197
|
+
funcName: 'get-random-bytes',
|
|
4198
|
+
paramCount: 0,
|
|
4199
|
+
postReturn: false
|
|
4200
|
+
});
|
|
3391
4201
|
}
|
|
3392
4202
|
|
|
3393
4203
|
|
|
3394
4204
|
function trampoline31(arg0) {
|
|
4205
|
+
_debugLog('[iface="wasi:filesystem/preopens@0.2.3", function="get-directories"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
4206
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'get-directories');
|
|
3395
4207
|
const ret = getDirectories();
|
|
4208
|
+
_debugLog('[iface="wasi:filesystem/preopens@0.2.3", function="get-directories"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3396
4209
|
var vec3 = ret;
|
|
3397
4210
|
var len3 = vec3.length;
|
|
3398
4211
|
var result3 = realloc0(0, 0, 4, len3 * 12);
|
|
@@ -3416,6 +4229,11 @@ function trampoline31(arg0) {
|
|
|
3416
4229
|
}
|
|
3417
4230
|
dataView(memory0).setInt32(arg0 + 4, len3, true);
|
|
3418
4231
|
dataView(memory0).setInt32(arg0 + 0, result3, true);
|
|
4232
|
+
_debugLog('[iface="wasi:filesystem/preopens@0.2.3", function="get-directories"][Instruction::Return]', {
|
|
4233
|
+
funcName: 'get-directories',
|
|
4234
|
+
paramCount: 0,
|
|
4235
|
+
postReturn: false
|
|
4236
|
+
});
|
|
3419
4237
|
}
|
|
3420
4238
|
|
|
3421
4239
|
const handleTable3 = [T_FLAG, 0];
|
|
@@ -3424,7 +4242,10 @@ let captureCnt3 = 0;
|
|
|
3424
4242
|
handleTables[3] = handleTable3;
|
|
3425
4243
|
|
|
3426
4244
|
function trampoline32(arg0) {
|
|
4245
|
+
_debugLog('[iface="wasi:cli/terminal-stdin@0.2.3", function="get-terminal-stdin"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
4246
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'get-terminal-stdin');
|
|
3427
4247
|
const ret = getTerminalStdin();
|
|
4248
|
+
_debugLog('[iface="wasi:cli/terminal-stdin@0.2.3", function="get-terminal-stdin"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3428
4249
|
var variant1 = ret;
|
|
3429
4250
|
if (variant1 === null || variant1=== undefined) {
|
|
3430
4251
|
dataView(memory0).setInt8(arg0 + 0, 0, true);
|
|
@@ -3442,6 +4263,11 @@ function trampoline32(arg0) {
|
|
|
3442
4263
|
}
|
|
3443
4264
|
dataView(memory0).setInt32(arg0 + 4, handle0, true);
|
|
3444
4265
|
}
|
|
4266
|
+
_debugLog('[iface="wasi:cli/terminal-stdin@0.2.3", function="get-terminal-stdin"][Instruction::Return]', {
|
|
4267
|
+
funcName: 'get-terminal-stdin',
|
|
4268
|
+
paramCount: 0,
|
|
4269
|
+
postReturn: false
|
|
4270
|
+
});
|
|
3445
4271
|
}
|
|
3446
4272
|
|
|
3447
4273
|
const handleTable4 = [T_FLAG, 0];
|
|
@@ -3450,7 +4276,10 @@ let captureCnt4 = 0;
|
|
|
3450
4276
|
handleTables[4] = handleTable4;
|
|
3451
4277
|
|
|
3452
4278
|
function trampoline33(arg0) {
|
|
4279
|
+
_debugLog('[iface="wasi:cli/terminal-stdout@0.2.3", function="get-terminal-stdout"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
4280
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'get-terminal-stdout');
|
|
3453
4281
|
const ret = getTerminalStdout();
|
|
4282
|
+
_debugLog('[iface="wasi:cli/terminal-stdout@0.2.3", function="get-terminal-stdout"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3454
4283
|
var variant1 = ret;
|
|
3455
4284
|
if (variant1 === null || variant1=== undefined) {
|
|
3456
4285
|
dataView(memory0).setInt8(arg0 + 0, 0, true);
|
|
@@ -3468,11 +4297,19 @@ function trampoline33(arg0) {
|
|
|
3468
4297
|
}
|
|
3469
4298
|
dataView(memory0).setInt32(arg0 + 4, handle0, true);
|
|
3470
4299
|
}
|
|
4300
|
+
_debugLog('[iface="wasi:cli/terminal-stdout@0.2.3", function="get-terminal-stdout"][Instruction::Return]', {
|
|
4301
|
+
funcName: 'get-terminal-stdout',
|
|
4302
|
+
paramCount: 0,
|
|
4303
|
+
postReturn: false
|
|
4304
|
+
});
|
|
3471
4305
|
}
|
|
3472
4306
|
|
|
3473
4307
|
|
|
3474
4308
|
function trampoline34(arg0) {
|
|
4309
|
+
_debugLog('[iface="wasi:cli/terminal-stderr@0.2.3", function="get-terminal-stderr"] [Instruction::CallInterface] (async? sync, @ enter)');
|
|
4310
|
+
const _interface_call_currentTaskID = startCurrentTask(0, false, 'get-terminal-stderr');
|
|
3475
4311
|
const ret = getTerminalStderr();
|
|
4312
|
+
_debugLog('[iface="wasi:cli/terminal-stderr@0.2.3", function="get-terminal-stderr"] [Instruction::CallInterface] (sync, @ post-call)');
|
|
3476
4313
|
var variant1 = ret;
|
|
3477
4314
|
if (variant1 === null || variant1=== undefined) {
|
|
3478
4315
|
dataView(memory0).setInt8(arg0 + 0, 0, true);
|
|
@@ -3490,6 +4327,11 @@ function trampoline34(arg0) {
|
|
|
3490
4327
|
}
|
|
3491
4328
|
dataView(memory0).setInt32(arg0 + 4, handle0, true);
|
|
3492
4329
|
}
|
|
4330
|
+
_debugLog('[iface="wasi:cli/terminal-stderr@0.2.3", function="get-terminal-stderr"][Instruction::Return]', {
|
|
4331
|
+
funcName: 'get-terminal-stderr',
|
|
4332
|
+
paramCount: 0,
|
|
4333
|
+
postReturn: false
|
|
4334
|
+
});
|
|
3493
4335
|
}
|
|
3494
4336
|
|
|
3495
4337
|
let exports3;
|
|
@@ -3805,7 +4647,10 @@ function generate(arg0, arg1) {
|
|
|
3805
4647
|
}
|
|
3806
4648
|
}
|
|
3807
4649
|
}
|
|
4650
|
+
_debugLog('[iface="generate", function="generate"] [Instruction::CallWasm] (async? false, @ enter)');
|
|
4651
|
+
const _wasm_call_currentTaskID = startCurrentTask(0, false, 'exports1Generate');
|
|
3808
4652
|
const ret = exports1Generate(ptr0);
|
|
4653
|
+
endCurrentTask(0);
|
|
3809
4654
|
let variant39;
|
|
3810
4655
|
switch (dataView(memory0).getUint8(ret + 0, true)) {
|
|
3811
4656
|
case 0: {
|
|
@@ -3880,12 +4725,25 @@ function generate(arg0, arg1) {
|
|
|
3880
4725
|
throw new TypeError('invalid variant discriminant for expected');
|
|
3881
4726
|
}
|
|
3882
4727
|
}
|
|
3883
|
-
|
|
4728
|
+
_debugLog('[iface="generate", function="generate"][Instruction::Return]', {
|
|
4729
|
+
funcName: 'generate',
|
|
4730
|
+
paramCount: 1,
|
|
4731
|
+
postReturn: true
|
|
4732
|
+
});
|
|
4733
|
+
const retCopy = variant39;
|
|
4734
|
+
|
|
4735
|
+
let cstate = getOrCreateAsyncState(0);
|
|
4736
|
+
cstate.mayLeave = false;
|
|
3884
4737
|
postReturn0(ret);
|
|
3885
|
-
|
|
3886
|
-
|
|
4738
|
+
cstate.mayLeave = true;
|
|
4739
|
+
|
|
4740
|
+
|
|
4741
|
+
|
|
4742
|
+
if (typeof retCopy === 'object' && retCopy.tag === 'err') {
|
|
4743
|
+
throw new ComponentError(retCopy.val);
|
|
3887
4744
|
}
|
|
3888
|
-
return
|
|
4745
|
+
return retCopy.val;
|
|
4746
|
+
|
|
3889
4747
|
}
|
|
3890
4748
|
let exports1GenerateTypes;
|
|
3891
4749
|
|
|
@@ -4086,7 +4944,10 @@ function generateTypes(arg0, arg1) {
|
|
|
4086
4944
|
}
|
|
4087
4945
|
}
|
|
4088
4946
|
}
|
|
4947
|
+
_debugLog('[iface="generate-types", function="generate-types"] [Instruction::CallWasm] (async? false, @ enter)');
|
|
4948
|
+
const _wasm_call_currentTaskID = startCurrentTask(0, false, 'exports1GenerateTypes');
|
|
4089
4949
|
const ret = exports1GenerateTypes(ptr0);
|
|
4950
|
+
endCurrentTask(0);
|
|
4090
4951
|
let variant33;
|
|
4091
4952
|
switch (dataView(memory0).getUint8(ret + 0, true)) {
|
|
4092
4953
|
case 0: {
|
|
@@ -4123,12 +4984,25 @@ function generateTypes(arg0, arg1) {
|
|
|
4123
4984
|
throw new TypeError('invalid variant discriminant for expected');
|
|
4124
4985
|
}
|
|
4125
4986
|
}
|
|
4126
|
-
|
|
4987
|
+
_debugLog('[iface="generate-types", function="generate-types"][Instruction::Return]', {
|
|
4988
|
+
funcName: 'generate-types',
|
|
4989
|
+
paramCount: 1,
|
|
4990
|
+
postReturn: true
|
|
4991
|
+
});
|
|
4992
|
+
const retCopy = variant33;
|
|
4993
|
+
|
|
4994
|
+
let cstate = getOrCreateAsyncState(0);
|
|
4995
|
+
cstate.mayLeave = false;
|
|
4127
4996
|
postReturn1(ret);
|
|
4128
|
-
|
|
4129
|
-
|
|
4997
|
+
cstate.mayLeave = true;
|
|
4998
|
+
|
|
4999
|
+
|
|
5000
|
+
|
|
5001
|
+
if (typeof retCopy === 'object' && retCopy.tag === 'err') {
|
|
5002
|
+
throw new ComponentError(retCopy.val);
|
|
4130
5003
|
}
|
|
4131
|
-
return
|
|
5004
|
+
return retCopy.val;
|
|
5005
|
+
|
|
4132
5006
|
}
|
|
4133
5007
|
|
|
4134
5008
|
let _initialized = false;
|
|
@@ -4136,8 +5010,8 @@ export const $init = (() => {
|
|
|
4136
5010
|
let gen = (function* init () {
|
|
4137
5011
|
const module0 = fetchCompile(new URL('./js-component-bindgen-component.core.wasm', import.meta.url));
|
|
4138
5012
|
const module1 = fetchCompile(new URL('./js-component-bindgen-component.core2.wasm', import.meta.url));
|
|
4139
|
-
const module2 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBH9/f38Bf2AFf39/f38AYAR/f39/AGAFf39/fn8Bf2AFf39/f38Bf2AJf39/f39+fn9/AX9gAX8Bf2ADf39/AX9gB39/f39/f38AYAJ+fwADJiUCBAcECAkCAgIKAgsBAQAAAAUDAwAAAAUMAAMDAAYGAA0BAQEBBAUBcAElJQe7ASYBMAAAATEAAQEyAAIBMwADATQABAE1AAUBNgAGATcABwE4AAgBOQAJAjEwAAoCMTEACwIxMgAMAjEzAA0CMTQADgIxNQAPAjE2ABACMTcAEQIxOAASAjE5ABMCMjAAFAIyMQAVAjIyABYCMjMAFwIyNAAYAjI1ABkCMjYAGgIyNwAbAjI4ABwCMjkAHQIzMAAeAjMxAB8CMzIAIAIzMwAhAjM0ACICMzUAIwIzNgAkCCRpbXBvcnRzAQAK+
|
|
4140
|
-
const module3 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBH9/f38Bf2AFf39/f38AYAR/f39/AGAFf39/fn8Bf2AFf39/f38Bf2AJf39/f39+fn9/AX9gAX8Bf2ADf39/AX9gB39/f39/f38AYAJ+
|
|
5013
|
+
const module2 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBH9/f38Bf2AFf39/f38AYAR/f39/AGAFf39/fn8Bf2AFf39/f38Bf2AJf39/f39+fn9/AX9gAX8Bf2ADf39/AX9gB39/f39/f38AYAJ+fwADJiUCBAcECAkCAgIKAgsBAQAAAAUDAwAAAAUMAAMDAAYGAA0BAQEBBAUBcAElJQe7ASYBMAAAATEAAQEyAAIBMwADATQABAE1AAUBNgAGATcABwE4AAgBOQAJAjEwAAoCMTEACwIxMgAMAjEzAA0CMTQADgIxNQAPAjE2ABACMTcAEQIxOAASAjE5ABMCMjAAFAIyMQAVAjIyABYCMjMAFwIyNAAYAjI1ABkCMjYAGgIyNwAbAjI4ABwCMjkAHQIzMAAeAjMxAB8CMzIAIAIzMwAhAjM0ACICMzUAIwIzNgAkCCRpbXBvcnRzAQAK+QMlCwAgACABQQARAgALDwAgACABIAIgA0EBEQQACxEAIAAgASACIAMgBEECEQcACw8AIAAgASACIANBAxEEAAsRACAAIAEgAiADIARBBBEIAAsZACAAIAEgAiADIAQgBSAGIAcgCEEFEQkACwsAIAAgAUEGEQIACwsAIAAgAUEHEQIACwsAIAAgAUEIEQIACwkAIABBCREKAAsLACAAIAFBChECAAsNACAAIAEgAkELEQsACwkAIABBDBEBAAsJACAAQQ0RAQALCwAgACABQQ4RAAALCwAgACABQQ8RAAALCwAgACABQRARAAALEQAgACABIAIgAyAEQRERBQALDQAgACABIAJBEhEDAAsNACAAIAEgAkETEQMACwsAIAAgAUEUEQAACwsAIAAgAUEVEQAACwsAIAAgAUEWEQAACxEAIAAgASACIAMgBEEXEQUACxUAIAAgASACIAMgBCAFIAZBGBEMAAsLACAAIAFBGREAAAsNACAAIAEgAkEaEQMACw0AIAAgASACQRsRAwALCwAgACABQRwRAAALDwAgACABIAIgA0EdEQYACw8AIAAgASACIANBHhEGAAsLACAAIAFBHxEAAAsLACAAIAFBIBENAAsJACAAQSERAQALCQAgAEEiEQEACwkAIABBIxEBAAsJACAAQSQRAQALAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMzUuMA');
|
|
5014
|
+
const module3 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBH9/f38Bf2AFf39/f38AYAR/f39/AGAFf39/fn8Bf2AFf39/f38Bf2AJf39/f39+fn9/AX9gAX8Bf2ADf39/AX9gB39/f39/f38AYAJ+fwAC5AEmAAEwAAIAATEABAABMgAHAAEzAAQAATQACAABNQAJAAE2AAIAATcAAgABOAACAAE5AAoAAjEwAAIAAjExAAsAAjEyAAEAAjEzAAEAAjE0AAAAAjE1AAAAAjE2AAAAAjE3AAUAAjE4AAMAAjE5AAMAAjIwAAAAAjIxAAAAAjIyAAAAAjIzAAUAAjI0AAwAAjI1AAAAAjI2AAMAAjI3AAMAAjI4AAAAAjI5AAYAAjMwAAYAAjMxAAAAAjMyAA0AAjMzAAEAAjM0AAEAAjM1AAEAAjM2AAEACCRpbXBvcnRzAXABJSUJKwEAQQALJQABAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4fICEiIyQALwlwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQENd2l0LWNvbXBvbmVudAcwLjIzNS4w');
|
|
4141
5015
|
({ exports: exports0 } = yield instantiateCore(yield module2));
|
|
4142
5016
|
({ exports: exports1 } = yield instantiateCore(yield module0, {
|
|
4143
5017
|
wasi_snapshot_preview1: {
|