@daugasauron/dolly 0.0.0-stage → 0.1.4-rc.0

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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +89 -2
  3. package/dist/dolly-build-id.mjs +1 -0
  4. package/dist/dolly-dso-0.wasm +0 -0
  5. package/dist/dolly-image-build-id.mjs +1 -0
  6. package/dist/dolly-kernel-plugin-abi.mjs +2 -0
  7. package/dist/dolly-process-0.wasm +0 -0
  8. package/dist/dolly-process-abi.mjs +1 -0
  9. package/dist/dolly-process-dso.mjs +1575 -0
  10. package/dist/dolly-process-gate-0.wasm +0 -0
  11. package/dist/dolly-process-stack.mjs +50 -0
  12. package/dist/dolly-process-worker.mjs +275 -0
  13. package/dist/dolly-threads-0.wasm +0 -0
  14. package/dist/dolly.wasm +0 -0
  15. package/host/abi.mjs +5 -0
  16. package/host/dso/abi.mjs +13 -0
  17. package/host/dso/dso.mjs +26 -0
  18. package/host/dso/module.json +15 -0
  19. package/host/http/abi.mjs +28 -0
  20. package/host/http/broker.mjs +325 -0
  21. package/host/http/http.mjs +74 -0
  22. package/host/http/local-services.mjs +37 -0
  23. package/host/http/module.json +15 -0
  24. package/host/http/policy.mjs +293 -0
  25. package/host/modules.mjs +373 -0
  26. package/host/nena/abi.mjs +19 -0
  27. package/host/nena/module.json +15 -0
  28. package/host/nena/nena.mjs +131 -0
  29. package/host/packages/module.json +13 -0
  30. package/host/packages/packages.mjs +15 -0
  31. package/host/packages/service.mjs +59 -0
  32. package/host/requirements.mjs +62 -0
  33. package/host/runtime/abi.mjs +8 -0
  34. package/host/runtime/boot-files.mjs +45 -0
  35. package/host/runtime/grower.mjs +14 -0
  36. package/host/runtime/lease-bridge.mjs +65 -0
  37. package/host/runtime/module.json +16 -0
  38. package/host/runtime/runtime.mjs +209 -0
  39. package/host/snapshot/abi.mjs +16 -0
  40. package/host/snapshot/module.json +15 -0
  41. package/host/snapshot/snapshot.mjs +138 -0
  42. package/host/snapshot/transport.mjs +132 -0
  43. package/host/snapshot/ui.mjs +207 -0
  44. package/host/stack/abi.mjs +5 -0
  45. package/host/stack/module.json +17 -0
  46. package/host/stack/stack.mjs +19 -0
  47. package/host/threads/abi.mjs +8 -0
  48. package/host/threads/module.json +13 -0
  49. package/host/threads/threads.mjs +36 -0
  50. package/package.json +12 -4
  51. package/src/alphabetical.mjs +4 -0
  52. package/src/browser.mjs +237 -0
  53. package/src/build-log.mjs +30 -0
  54. package/src/image-entry.mjs +29 -0
  55. package/src/image-inputs.mjs +20 -0
  56. package/src/image-names.mjs +11 -0
  57. package/src/images.mjs +10 -0
  58. package/src/kernel-plugin.mjs +77 -0
  59. package/src/packaged-snapshot.mjs +175 -0
  60. package/src/page-chords.mjs +43 -0
  61. package/src/page-indicators.mjs +27 -0
  62. package/src/process-abi.mjs +69 -0
  63. package/src/process-constants.mjs +242 -0
  64. package/src/process-supervisor.mjs +1002 -0
  65. package/src/runtime-worker.mjs +55 -0
  66. package/src/session-store.mjs +198 -0
  67. package/src/snapshot-records.mjs +109 -0
  68. package/src/static-asset.mjs +97 -0
  69. package/src/terminal-text.mjs +72 -0
  70. package/src/version.mjs +3 -0
  71. package/src/wasm-interface.mjs +440 -0
  72. package/src/worker-image.mjs +137 -0
Binary file
@@ -0,0 +1,50 @@
1
+ // host/stack/abi.mjs
2
+ var DOLLY_STACK_CONTINUE = 116;
3
+ var DOLLY_STACK_CHECK_SLOTS = 16384;
4
+ var DOLLY_ERRNO = Object.freeze({ E2BIG: 1, EACCES: 2, EADDRINUSE: 3, EADDRNOTAVAIL: 4, EAFNOSUPPORT: 5, EAGAIN: 6, EALREADY: 7, EBADF: 8, EBADMSG: 9, EBUSY: 10, ECANCELED: 11, ECHILD: 12, ECONNABORTED: 13, ECONNREFUSED: 14, ECONNRESET: 15, EDEADLK: 16, EDESTADDRREQ: 17, EDOM: 18, EDQUOT: 19, EEXIST: 20, EFAULT: 21, EFBIG: 22, EHOSTUNREACH: 23, EIDRM: 24, EILSEQ: 25, EINPROGRESS: 26, EINTR: 27, EINVAL: 28, EIO: 29, EISCONN: 30, EISDIR: 31, ELOOP: 32, EMFILE: 33, EMLINK: 34, EMSGSIZE: 35, EMULTIHOP: 36, ENAMETOOLONG: 37, ENETDOWN: 38, ENETRESET: 39, ENETUNREACH: 40, ENFILE: 41, ENOBUFS: 42, ENODEV: 43, ENOENT: 44, ENOEXEC: 45, ENOLCK: 46, ENOLINK: 47, ENOMEM: 48, ENOMSG: 49, ENOPROTOOPT: 50, ENOSPC: 51, ENOSYS: 52, ENOTCONN: 53, ENOTDIR: 54, ENOTEMPTY: 55, ENOTRECOVERABLE: 56, ENOTSOCK: 57, ENOTTY: 59, ENXIO: 60, EOVERFLOW: 61, EOWNERDEAD: 62, EPERM: 63, EPIPE: 64, EPROTO: 65, EPROTONOSUPPORT: 66, EPROTOTYPE: 67, ERANGE: 68, EROFS: 69, ESPIPE: 70, ESRCH: 71, ESTALE: 72, ETIMEDOUT: 73, ETXTBSY: 74, EXDEV: 75, ENODATA: 116, ENOTSUP: 138 });
5
+
6
+ // host/stack/process.mjs
7
+ var entry = new WebAssembly.Module(Uint8Array.from(atob(
8
+ "AGFzbQEAAAABBAFgAAACFAEHcHJvZ3JhbQhjb250aW51ZQAAAwMCAAAGCwJpAdBpC38BQQALBxoDBGRvbmUDAQVlbnRlcgABB3JldGhyb3cAAgoqAhgAAmkfQAEDABAAC0EBJAEPCyQAQQIkAQsPAQFpIwAhANBpJAAgAAoL"
9
+ ), (character) => character.charCodeAt(0)));
10
+ var probeSlots = 23;
11
+ var roomOf = (probes) => Math.floor(probes * probeSlots / 2);
12
+ function serve({ instance, stack }) {
13
+ const { dolly_stack_room: room, dolly_stack_continue: resume } = instance.exports;
14
+ if (!(room instanceof WebAssembly.Global) || typeof resume !== "function") {
15
+ throw new TypeError("an executable recording stack@0 must export dolly_stack_room and dolly_stack_continue");
16
+ }
17
+ const fresh = roomOf(stack.depths.promising);
18
+ room.value = stack.promisingEntry ? fresh : roomOf(stack.depths.direct);
19
+ let failure, helper, enter;
20
+ return {
21
+ handles: (operation) => operation === DOLLY_STACK_CONTINUE,
22
+ call(operation, request, response) {
23
+ if (request.size || response.size) return -BigInt(DOLLY_ERRNO.EINVAL);
24
+ if (!WebAssembly.promising || fresh < DOLLY_STACK_CHECK_SLOTS) {
25
+ failure ??= new Error(WebAssembly.promising ? `a fresh stack gives ${fresh} slots, fewer than stack@0 needs` : "this browser has no WebAssembly.promising, which stack@0 needs");
26
+ return -BigInt(DOLLY_ERRNO.ENOSYS);
27
+ }
28
+ helper ??= new WebAssembly.Instance(entry, { program: { continue: resume } });
29
+ enter ??= WebAssembly.promising(helper.exports.enter);
30
+ const { done, rethrow } = helper.exports;
31
+ const saved = room.value;
32
+ room.value = fresh;
33
+ done.value = 0;
34
+ enter().catch((error) => {
35
+ failure ??= error;
36
+ });
37
+ room.value = saved;
38
+ const outcome = done.value;
39
+ done.value = 0;
40
+ if (outcome === 2) rethrow();
41
+ return outcome === 1 ? 0n : 1n;
42
+ },
43
+ get failure() {
44
+ return failure;
45
+ }
46
+ };
47
+ }
48
+ export {
49
+ serve
50
+ };
@@ -0,0 +1,275 @@
1
+ // src/process-constants.mjs
2
+ var DOLLY_PROCESS_PACKET_LIMIT = 1048576;
3
+ var DOLLY_PROCESS_EXIT = 5;
4
+ var DOLLY_PROCESS_CLOCK_TIME = 48;
5
+ var DOLLY_PROCESS_INTERRUPT_POLL = 66;
6
+ var DOLLY_PROCESS_CLOCK_REALTIME = 0;
7
+ var DOLLY_PROCESS_CLOCK_MONOTONIC = 1;
8
+ var DOLLY_ERRNO = Object.freeze({
9
+ E2BIG: 1,
10
+ EACCES: 2,
11
+ EADDRINUSE: 3,
12
+ EADDRNOTAVAIL: 4,
13
+ EAFNOSUPPORT: 5,
14
+ EAGAIN: 6,
15
+ EALREADY: 7,
16
+ EBADF: 8,
17
+ EBADMSG: 9,
18
+ EBUSY: 10,
19
+ ECANCELED: 11,
20
+ ECHILD: 12,
21
+ ECONNABORTED: 13,
22
+ ECONNREFUSED: 14,
23
+ ECONNRESET: 15,
24
+ EDEADLK: 16,
25
+ EDESTADDRREQ: 17,
26
+ EDOM: 18,
27
+ EDQUOT: 19,
28
+ EEXIST: 20,
29
+ EFAULT: 21,
30
+ EFBIG: 22,
31
+ EHOSTUNREACH: 23,
32
+ EIDRM: 24,
33
+ EILSEQ: 25,
34
+ EINPROGRESS: 26,
35
+ EINTR: 27,
36
+ EINVAL: 28,
37
+ EIO: 29,
38
+ EISCONN: 30,
39
+ EISDIR: 31,
40
+ ELOOP: 32,
41
+ EMFILE: 33,
42
+ EMLINK: 34,
43
+ EMSGSIZE: 35,
44
+ EMULTIHOP: 36,
45
+ ENAMETOOLONG: 37,
46
+ ENETDOWN: 38,
47
+ ENETRESET: 39,
48
+ ENETUNREACH: 40,
49
+ ENFILE: 41,
50
+ ENOBUFS: 42,
51
+ ENODEV: 43,
52
+ ENOENT: 44,
53
+ ENOEXEC: 45,
54
+ ENOLCK: 46,
55
+ ENOLINK: 47,
56
+ ENOMEM: 48,
57
+ ENOMSG: 49,
58
+ ENOPROTOOPT: 50,
59
+ ENOSPC: 51,
60
+ ENOSYS: 52,
61
+ ENOTCONN: 53,
62
+ ENOTDIR: 54,
63
+ ENOTEMPTY: 55,
64
+ ENOTRECOVERABLE: 56,
65
+ ENOTSOCK: 57,
66
+ ENOTTY: 59,
67
+ ENXIO: 60,
68
+ EOVERFLOW: 61,
69
+ EOWNERDEAD: 62,
70
+ EPERM: 63,
71
+ EPIPE: 64,
72
+ EPROTO: 65,
73
+ EPROTONOSUPPORT: 66,
74
+ EPROTOTYPE: 67,
75
+ ERANGE: 68,
76
+ EROFS: 69,
77
+ ESPIPE: 70,
78
+ ESRCH: 71,
79
+ ESTALE: 72,
80
+ ETIMEDOUT: 73,
81
+ ETXTBSY: 74,
82
+ EXDEV: 75,
83
+ ENODATA: 116,
84
+ ENOTSUP: 138
85
+ });
86
+ var DOLLY_PROCESS_SIZEOF = Object.freeze({
87
+ dolly_process_vector_sizes: 16,
88
+ dolly_process_fd_io_request: 16,
89
+ dolly_process_fd_pread_request: 24,
90
+ dolly_process_fd_truncate_request: 16,
91
+ dolly_process_fd_request: 8,
92
+ dolly_process_timestamp: 16,
93
+ dolly_process_fd_times_request: 40,
94
+ dolly_process_fd_dup_request: 16,
95
+ dolly_process_fd_flags: 8,
96
+ dolly_process_fd_lock_request: 32,
97
+ dolly_process_fd_lock_response: 24,
98
+ dolly_process_poll_request: 16,
99
+ dolly_process_poll_query: 8,
100
+ dolly_process_poll_response: 16,
101
+ dolly_process_poll_result: 8,
102
+ dolly_process_directory_entry: 24,
103
+ dolly_process_directory_request: 24,
104
+ dolly_process_stat_response: 88,
105
+ dolly_process_filesystem_stat_response: 96,
106
+ dolly_process_spawn_request: 56,
107
+ dolly_process_fd_mapping: 8,
108
+ dolly_process_exec_state: 16,
109
+ dolly_process_exec_request: 48,
110
+ dolly_process_pipe_request: 8,
111
+ dolly_process_two_path_request: 16,
112
+ dolly_process_path_times_request: 48,
113
+ dolly_process_terminal_request: 24,
114
+ dolly_process_terminal_response: 16,
115
+ dolly_process_clock_sleep_request: 16,
116
+ dolly_process_exit_request: 8,
117
+ dolly_process_wait_request: 8,
118
+ dolly_process_wait_response: 16,
119
+ dolly_process_signal_request: 8,
120
+ dolly_process_alarm: 16,
121
+ dolly_process_fd_seek_request: 16,
122
+ dolly_process_clock_request: 16,
123
+ dolly_process_path_request: 16
124
+ });
125
+
126
+ // host/threads/abi.mjs
127
+ var DOLLY_THREAD_EXIT = 146;
128
+ var DOLLY_ERRNO2 = Object.freeze({ E2BIG: 1, EACCES: 2, EADDRINUSE: 3, EADDRNOTAVAIL: 4, EAFNOSUPPORT: 5, EAGAIN: 6, EALREADY: 7, EBADF: 8, EBADMSG: 9, EBUSY: 10, ECANCELED: 11, ECHILD: 12, ECONNABORTED: 13, ECONNREFUSED: 14, ECONNRESET: 15, EDEADLK: 16, EDESTADDRREQ: 17, EDOM: 18, EDQUOT: 19, EEXIST: 20, EFAULT: 21, EFBIG: 22, EHOSTUNREACH: 23, EIDRM: 24, EILSEQ: 25, EINPROGRESS: 26, EINTR: 27, EINVAL: 28, EIO: 29, EISCONN: 30, EISDIR: 31, ELOOP: 32, EMFILE: 33, EMLINK: 34, EMSGSIZE: 35, EMULTIHOP: 36, ENAMETOOLONG: 37, ENETDOWN: 38, ENETRESET: 39, ENETUNREACH: 40, ENFILE: 41, ENOBUFS: 42, ENODEV: 43, ENOENT: 44, ENOEXEC: 45, ENOLCK: 46, ENOLINK: 47, ENOMEM: 48, ENOMSG: 49, ENOPROTOOPT: 50, ENOSPC: 51, ENOSYS: 52, ENOTCONN: 53, ENOTDIR: 54, ENOTEMPTY: 55, ENOTRECOVERABLE: 56, ENOTSOCK: 57, ENOTTY: 59, ENXIO: 60, EOVERFLOW: 61, EOWNERDEAD: 62, EPERM: 63, EPIPE: 64, EPROTO: 65, EPROTONOSUPPORT: 66, EPROTOTYPE: 67, ERANGE: 68, EROFS: 69, ESPIPE: 70, ESRCH: 71, ESTALE: 72, ETIMEDOUT: 73, ETXTBSY: 74, EXDEV: 75, ENODATA: 116, ENOTSUP: 138 });
129
+
130
+ // src/process-worker.mjs
131
+ var PROCESS_EXIT = Symbol("Dolly process exit");
132
+ var THREAD_EXIT = Symbol("Dolly thread exit");
133
+ var configuration = await new Promise((resolve, reject) => {
134
+ const timeout = setTimeout(
135
+ () => reject(new Error("Dolly process configuration was not provided")),
136
+ 1e4
137
+ );
138
+ self.addEventListener("message", function configure(event) {
139
+ if (event.data?.type !== "configure") return;
140
+ self.removeEventListener("message", configure);
141
+ clearTimeout(timeout);
142
+ resolve(event.data);
143
+ });
144
+ });
145
+ if (!(configuration.module instanceof WebAssembly.Module) || !(configuration.memory instanceof WebAssembly.Memory) || !(configuration.control instanceof SharedArrayBuffer) || !Array.isArray(configuration.local) || configuration.control.byteLength !== 16 || !Number.isFinite(configuration.clockOrigin) || !Number.isInteger(configuration.pid) || configuration.pid <= 0) {
146
+ throw new Error("Dolly process received an invalid configuration");
147
+ }
148
+ var control = new Int32Array(configuration.control);
149
+ var clockOffset = performance.timeOrigin - configuration.clockOrigin;
150
+ var lastSignalCheck = -Infinity;
151
+ var threadResult;
152
+ var instance;
153
+ var localModules = [];
154
+ function packetRange(addressValue, sizeValue) {
155
+ const address = Number(addressValue);
156
+ const size = Number(sizeValue);
157
+ const length = configuration.memory.buffer.byteLength;
158
+ return !Number.isSafeInteger(address) || !Number.isSafeInteger(size) || address < 0 || size < 0 || address > length - size || size !== 0 && address === 0 ? null : { address, size };
159
+ }
160
+ function decodeResult() {
161
+ const low = BigInt(Atomics.load(control, 2) >>> 0);
162
+ const high = BigInt(Atomics.load(control, 3) >>> 0);
163
+ return BigInt.asIntN(64, low | high << 32n);
164
+ }
165
+ function clockResponse(clock, response, now) {
166
+ const nanoseconds = Math.round(
167
+ (clock === DOLLY_PROCESS_CLOCK_REALTIME ? Date.now() : now + clockOffset) * 1e6
168
+ );
169
+ new DataView(configuration.memory.buffer, response.address, 8).setBigUint64(0, BigInt(nanoseconds), true);
170
+ return 8n;
171
+ }
172
+ function call(operation, requestAddressValue, requestSizeValue, responseAddressValue, responseCapacityValue) {
173
+ operation >>>= 0;
174
+ const request = packetRange(requestAddressValue, requestSizeValue);
175
+ const response = packetRange(responseAddressValue, responseCapacityValue);
176
+ if (!request || !response) return -BigInt(DOLLY_ERRNO.EFAULT);
177
+ for (const module of localModules) {
178
+ if (module.handles(operation)) return module.call(operation, request, response);
179
+ }
180
+ const exitingResult = operation === DOLLY_THREAD_EXIT && request.size === 8 ? new DataView(configuration.memory.buffer, request.address, 8).getBigUint64(0, true) : void 0;
181
+ let clock;
182
+ if (operation === DOLLY_PROCESS_CLOCK_TIME && request.size === 16 && response.size >= 8 && response.size <= DOLLY_PROCESS_PACKET_LIMIT) {
183
+ const packet = new DataView(configuration.memory.buffer, request.address, 16);
184
+ const id = packet.getUint32(0, true);
185
+ if ((id === DOLLY_PROCESS_CLOCK_REALTIME || id === DOLLY_PROCESS_CLOCK_MONOTONIC) && packet.getUint32(4, true) === 0) clock = id;
186
+ const now = performance.now();
187
+ if (clock !== void 0 && now - lastSignalCheck < 1) return clockResponse(clock, response, now);
188
+ }
189
+ if (operation === DOLLY_PROCESS_INTERRUPT_POLL && request.size === 0 && response.size >= 4 && performance.now() - lastSignalCheck < 1) {
190
+ new DataView(configuration.memory.buffer, response.address, 4).setInt32(0, 0, true);
191
+ return 4n;
192
+ }
193
+ if (request.size > DOLLY_PROCESS_PACKET_LIMIT || response.size > DOLLY_PROCESS_PACKET_LIMIT) {
194
+ return -BigInt(DOLLY_ERRNO.E2BIG);
195
+ }
196
+ const sequence = Atomics.load(control, 0) % 2147483647 + 1;
197
+ Atomics.store(control, 0, sequence);
198
+ self.postMessage({
199
+ type: "syscall",
200
+ pid: configuration.pid,
201
+ tid: configuration.tid,
202
+ sequence,
203
+ operation,
204
+ requestAddress: request.address,
205
+ requestSize: request.size,
206
+ responseAddress: response.address,
207
+ responseCapacity: response.size
208
+ });
209
+ for (; ; ) {
210
+ const observed = Atomics.load(control, 1);
211
+ if (observed === sequence) break;
212
+ Atomics.wait(control, 1, observed);
213
+ }
214
+ const result = decodeResult();
215
+ if (result === -(1n << 63n)) throw PROCESS_EXIT;
216
+ lastSignalCheck = result === -BigInt(DOLLY_ERRNO.EINTR) ? -Infinity : performance.now();
217
+ if (operation === DOLLY_THREAD_EXIT && result >= 0n) {
218
+ threadResult = exitingResult;
219
+ throw THREAD_EXIT;
220
+ }
221
+ if (clock !== void 0 && result === 8n) return clockResponse(clock, response, lastSignalCheck);
222
+ if (operation === DOLLY_PROCESS_EXIT && result >= 0n) throw PROCESS_EXIT;
223
+ return result;
224
+ }
225
+ try {
226
+ instance = await WebAssembly.instantiate(configuration.module, {
227
+ env: { memory: configuration.memory },
228
+ dolly_process_0: { call }
229
+ });
230
+ if (typeof instance.exports._start !== "function") {
231
+ throw new TypeError("Dolly process does not export _start");
232
+ }
233
+ localModules = await Promise.all(configuration.local.map(async ({ bundle, configuration: options }) => {
234
+ const url = URL.createObjectURL(bundle);
235
+ try {
236
+ return (await import(url)).serve({
237
+ ...options,
238
+ instance,
239
+ memory: configuration.memory,
240
+ processInterface: configuration.processInterface,
241
+ threaded: configuration.threaded,
242
+ stack: { promisingEntry: configuration.promisingEntry, depths: configuration.stackDepths }
243
+ });
244
+ } finally {
245
+ URL.revokeObjectURL(url);
246
+ }
247
+ }));
248
+ self.postMessage({ type: "started", pid: configuration.pid, tid: configuration.tid });
249
+ const enter = configuration.promisingEntry ? WebAssembly.promising : (entry) => entry;
250
+ if (configuration.argument !== void 0) {
251
+ threadResult = await enter(instance.exports.dolly_thread_start)(configuration.tid, configuration.argument);
252
+ self.postMessage({ type: "thread-finished", pid: configuration.pid, tid: configuration.tid, result: threadResult });
253
+ } else {
254
+ await enter(instance.exports._start)();
255
+ self.postMessage({ type: "finished", pid: configuration.pid, tid: configuration.tid });
256
+ }
257
+ } catch (caught) {
258
+ if (caught === THREAD_EXIT && configuration.threaded && typeof threadResult === "bigint") {
259
+ self.postMessage({ type: "thread-finished", pid: configuration.pid, tid: configuration.tid, result: threadResult });
260
+ } else if (caught === PROCESS_EXIT) {
261
+ self.postMessage({ type: "finished", pid: configuration.pid, tid: configuration.tid });
262
+ } else {
263
+ await null;
264
+ const error = localModules.map((module) => module.failure).find(Boolean) ?? caught;
265
+ self.postMessage({
266
+ type: "failed",
267
+ pid: configuration.pid,
268
+ tid: configuration.tid,
269
+ message: error instanceof Error ? error.message : String(error),
270
+ stack: error instanceof Error ? error.stack ?? "" : ""
271
+ });
272
+ }
273
+ } finally {
274
+ self.close();
275
+ }
Binary file
Binary file
package/host/abi.mjs ADDED
@@ -0,0 +1,5 @@
1
+ // Generated from abi/dolly-host-0.wat.
2
+ export const DOLLY_HOST_RECORD_BYTES = 72;
3
+ export const DOLLY_HOST_NAME_BYTES = 32;
4
+ export const DOLLY_HOST_DIGEST_BYTES = 32;
5
+ export const DOLLY_HOST_MAX_RECORDS = 64;
@@ -0,0 +1,13 @@
1
+ // Generated from host/dso/dolly-dso-0.wat, host/dso/dso.h, include/dolly/process.h.
2
+ export const DOLLY_DSO_OPEN = 112;
3
+ export const DOLLY_DSO_SYMBOL = 113;
4
+ export const DOLLY_DSO_CLOSE = 114;
5
+ export const DOLLY_DSO_GLOBAL = 1;
6
+ export const DOLLY_DSO_LIMIT = 536870912;
7
+ export const DOLLY_DSO_ERROR_CAPACITY = 240;
8
+ export const DOLLY_FFI_CALL = 120;
9
+ export const DOLLY_FFI_CLOSURE_ALLOC = 121;
10
+ export const DOLLY_FFI_CLOSURE_FREE = 122;
11
+ export const DOLLY_FFI_CLOSURE_PREP = 123;
12
+ export const DOLLY_ERRNO = Object.freeze({ E2BIG: 1, EACCES: 2, EADDRINUSE: 3, EADDRNOTAVAIL: 4, EAFNOSUPPORT: 5, EAGAIN: 6, EALREADY: 7, EBADF: 8, EBADMSG: 9, EBUSY: 10, ECANCELED: 11, ECHILD: 12, ECONNABORTED: 13, ECONNREFUSED: 14, ECONNRESET: 15, EDEADLK: 16, EDESTADDRREQ: 17, EDOM: 18, EDQUOT: 19, EEXIST: 20, EFAULT: 21, EFBIG: 22, EHOSTUNREACH: 23, EIDRM: 24, EILSEQ: 25, EINPROGRESS: 26, EINTR: 27, EINVAL: 28, EIO: 29, EISCONN: 30, EISDIR: 31, ELOOP: 32, EMFILE: 33, EMLINK: 34, EMSGSIZE: 35, EMULTIHOP: 36, ENAMETOOLONG: 37, ENETDOWN: 38, ENETRESET: 39, ENETUNREACH: 40, ENFILE: 41, ENOBUFS: 42, ENODEV: 43, ENOENT: 44, ENOEXEC: 45, ENOLCK: 46, ENOLINK: 47, ENOMEM: 48, ENOMSG: 49, ENOPROTOOPT: 50, ENOSPC: 51, ENOSYS: 52, ENOTCONN: 53, ENOTDIR: 54, ENOTEMPTY: 55, ENOTRECOVERABLE: 56, ENOTSOCK: 57, ENOTTY: 59, ENXIO: 60, EOVERFLOW: 61, EOWNERDEAD: 62, EPERM: 63, EPIPE: 64, EPROTO: 65, EPROTONOSUPPORT: 66, EPROTOTYPE: 67, ERANGE: 68, EROFS: 69, ESPIPE: 70, ESRCH: 71, ESTALE: 72, ETIMEDOUT: 73, ETXTBSY: 74, EXDEV: 75, ENODATA: 116, ENOTSUP: 138 });
13
+ export const DOLLY_DSO_ABI_DIGEST = "f620970cf60972fe67e4d14dd3441edb9652092ed2ebc27a511c24d2931fb800";
@@ -0,0 +1,26 @@
1
+ import { parseWasmInterface } from "../../src/wasm-interface.mjs";
2
+ export { DOLLY_DSO_ABI_DIGEST as digest } from "./abi.mjs";
3
+
4
+ // The loader and the FFI dispatcher (process.mjs) run inside the process Worker
5
+ // of an executable that records dso@0. This side fetches their bundle and the
6
+ // side-module contract once, as the supervisor fetches the process Worker:
7
+ // starting a program makes no request.
8
+ export function worker({ get, abi, runtimeBase }) {
9
+ return {
10
+ async start() {
11
+ const [contract, bundle] = await Promise.all(["dolly-dso-0.wasm", "dolly-process-dso.mjs"].map(async name => {
12
+ const response = await fetch(new URL(`dist/${name}`, runtimeBase), {
13
+ cache: "no-store", credentials: "same-origin", redirect: "error",
14
+ });
15
+ if (!response.ok) throw new Error(`Dolly ${name} returned HTTP ${response.status}`);
16
+ return response.arrayBuffer();
17
+ }));
18
+ // abi is the live set of modules the image admits; a loaded library's
19
+ // own records are checked against it.
20
+ // threads: it serves each thread's Worker of a program using threads@0.
21
+ get("runtime").serveInProcess("dso@0", { bundle: new Blob([bundle], { type: "text/javascript" }),
22
+ configuration: { contract: parseWasmInterface(contract, "dolly-dso-0"), hostAbi: abi }, threads: true });
23
+ },
24
+ disabled() { get("runtime").serveInProcess("dso@0"); },
25
+ };
26
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "dso",
3
+ "version": 0,
4
+ "gives": "dlopen and FFI in the process's own Worker",
5
+ "dependencies": ["runtime@0"],
6
+ "phase": "kernel",
7
+ "imports": [],
8
+ "host": "dso.mjs",
9
+ "processWorker": "process.mjs",
10
+ "contracts": [],
11
+ "process": ["dolly-dso-0.wat"],
12
+ "headers": ["dso.h", "dso-abi.h"],
13
+ "kernel": [],
14
+ "client": ["client.c", "ffi.c"]
15
+ }
@@ -0,0 +1,28 @@
1
+ // Generated from host/http/dolly-http-0.wat, host/http/http.h, include/dolly/process.h.
2
+ export const DOLLY_HTTP_SLOT_COUNT = 16;
3
+ export const DOLLY_HTTP_CHUNK_CAPACITY = 65536;
4
+ export const DOLLY_HTTP_MAX_METHOD = 32;
5
+ export const DOLLY_HTTP_MAX_URL = 8192;
6
+ export const DOLLY_HTTP_MAX_HEADERS = 65536;
7
+ export const DOLLY_HTTP_MAX_BODY = 8388608;
8
+ export const DOLLY_HTTP_HEADER_SIZE = 64;
9
+ export const DOLLY_HTTP_WORD_STATE = 0;
10
+ export const DOLLY_HTTP_WORD_SEQUENCE = 1;
11
+ export const DOLLY_HTTP_WORD_STATUS = 2;
12
+ export const DOLLY_HTTP_WORD_LENGTH = 3;
13
+ export const DOLLY_HTTP_WORD_EOF = 4;
14
+ export const DOLLY_HTTP_WORD_ERROR = 5;
15
+ export const DOLLY_HTTP_WORD_KIND = 6;
16
+ export const DOLLY_HTTP_STATE_IDLE = 0;
17
+ export const DOLLY_HTTP_STATE_WRITABLE = 1;
18
+ export const DOLLY_HTTP_STATE_READABLE = 2;
19
+ export const DOLLY_HTTP_STATE_FAILED = 3;
20
+ export const DOLLY_HTTP_KIND_URL = 1;
21
+ export const DOLLY_HTTP_KIND_HEADER = 2;
22
+ export const DOLLY_HTTP_KIND_BODY = 3;
23
+ export const DOLLY_HTTP_START = 80;
24
+ export const DOLLY_HTTP_POLL = 81;
25
+ export const DOLLY_HTTP_CANCEL = 82;
26
+ export const DOLLY_HTTP_BODY_WRITE = 83;
27
+ export const DOLLY_ERRNO = Object.freeze({ E2BIG: 1, EACCES: 2, EADDRINUSE: 3, EADDRNOTAVAIL: 4, EAFNOSUPPORT: 5, EAGAIN: 6, EALREADY: 7, EBADF: 8, EBADMSG: 9, EBUSY: 10, ECANCELED: 11, ECHILD: 12, ECONNABORTED: 13, ECONNREFUSED: 14, ECONNRESET: 15, EDEADLK: 16, EDESTADDRREQ: 17, EDOM: 18, EDQUOT: 19, EEXIST: 20, EFAULT: 21, EFBIG: 22, EHOSTUNREACH: 23, EIDRM: 24, EILSEQ: 25, EINPROGRESS: 26, EINTR: 27, EINVAL: 28, EIO: 29, EISCONN: 30, EISDIR: 31, ELOOP: 32, EMFILE: 33, EMLINK: 34, EMSGSIZE: 35, EMULTIHOP: 36, ENAMETOOLONG: 37, ENETDOWN: 38, ENETRESET: 39, ENETUNREACH: 40, ENFILE: 41, ENOBUFS: 42, ENODEV: 43, ENOENT: 44, ENOEXEC: 45, ENOLCK: 46, ENOLINK: 47, ENOMEM: 48, ENOMSG: 49, ENOPROTOOPT: 50, ENOSPC: 51, ENOSYS: 52, ENOTCONN: 53, ENOTDIR: 54, ENOTEMPTY: 55, ENOTRECOVERABLE: 56, ENOTSOCK: 57, ENOTTY: 59, ENXIO: 60, EOVERFLOW: 61, EOWNERDEAD: 62, EPERM: 63, EPIPE: 64, EPROTO: 65, EPROTONOSUPPORT: 66, EPROTOTYPE: 67, ERANGE: 68, EROFS: 69, ESPIPE: 70, ESRCH: 71, ESTALE: 72, ETIMEDOUT: 73, ETXTBSY: 74, EXDEV: 75, ENODATA: 116, ENOTSUP: 138 });
28
+ export const DOLLY_HTTP_ABI_DIGEST = "429f0fdb280240a4429fdeb550e6710453d81ac51b7eb662dd43b024fcfaaaed";