@yabgu_gm/tensionscript 0.0.0-stage → 0.10.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.
- package/LICENSE +201 -0
- package/NOTICE +97 -0
- package/README.md +158 -2
- package/bin/tensionscript.js +35 -0
- package/dist/asc.d.ts +4 -0
- package/dist/asc.generated.d.ts +12000 -0
- package/dist/asc.js +23474 -0
- package/dist/asc.js.map +7 -0
- package/dist/assemblyscript.d.ts +4 -0
- package/dist/assemblyscript.generated.d.ts +13214 -0
- package/dist/assemblyscript.js +337 -0
- package/dist/assemblyscript.js.map +7 -0
- package/dist/importmap.json +9 -0
- package/dist/transform.cjs +1 -0
- package/dist/transform.d.ts +1 -0
- package/dist/transform.js +1 -0
- package/dist/web.js +22 -0
- package/lib/binaryen.d.ts +2 -0
- package/lib/binaryen.js +2 -0
- package/package.json +116 -4
- package/std/README.md +6 -0
- package/std/assembly/array.ts +526 -0
- package/std/assembly/arraybuffer.ts +77 -0
- package/std/assembly/atomics.ts +127 -0
- package/std/assembly/bindings/asyncify.ts +16 -0
- package/std/assembly/bindings/dom.ts +291 -0
- package/std/assembly/bindings/node.ts +6 -0
- package/std/assembly/builtins.ts +2642 -0
- package/std/assembly/closures.ts +22 -0
- package/std/assembly/compat.ts +2 -0
- package/std/assembly/console.ts +42 -0
- package/std/assembly/crypto.ts +9 -0
- package/std/assembly/dataview.ts +181 -0
- package/std/assembly/date.ts +373 -0
- package/std/assembly/diagnostics.ts +11 -0
- package/std/assembly/error.ts +44 -0
- package/std/assembly/function.ts +38 -0
- package/std/assembly/index.d.ts +2721 -0
- package/std/assembly/iterator.ts +35 -0
- package/std/assembly/map.ts +260 -0
- package/std/assembly/math.ts +3289 -0
- package/std/assembly/memory.ts +123 -0
- package/std/assembly/number.ts +388 -0
- package/std/assembly/object.ts +36 -0
- package/std/assembly/performance.ts +9 -0
- package/std/assembly/polyfills.ts +27 -0
- package/std/assembly/process.ts +50 -0
- package/std/assembly/reference.ts +48 -0
- package/std/assembly/regexp.ts +12 -0
- package/std/assembly/rt/README.md +81 -0
- package/std/assembly/rt/common.ts +81 -0
- package/std/assembly/rt/index-incremental.ts +2 -0
- package/std/assembly/rt/index-minimal.ts +2 -0
- package/std/assembly/rt/index-stub.ts +1 -0
- package/std/assembly/rt/index.d.ts +37 -0
- package/std/assembly/rt/itcms.ts +419 -0
- package/std/assembly/rt/rtrace.ts +15 -0
- package/std/assembly/rt/stub.ts +133 -0
- package/std/assembly/rt/tcms.ts +254 -0
- package/std/assembly/rt/tlsf.ts +592 -0
- package/std/assembly/rt.ts +87 -0
- package/std/assembly/set.ts +220 -0
- package/std/assembly/shared/feature.ts +65 -0
- package/std/assembly/shared/runtime.ts +11 -0
- package/std/assembly/shared/target.ts +11 -0
- package/std/assembly/shared/tsconfig.json +11 -0
- package/std/assembly/shared/typeinfo.ts +72 -0
- package/std/assembly/staticarray.ts +401 -0
- package/std/assembly/string.ts +847 -0
- package/std/assembly/symbol.ts +114 -0
- package/std/assembly/table.ts +16 -0
- package/std/assembly/task-rt.ts +609 -0
- package/std/assembly/task.ts +90 -0
- package/std/assembly/tsconfig.json +6 -0
- package/std/assembly/typedarray.ts +1945 -0
- package/std/assembly/uri.ts +17 -0
- package/std/assembly/util/bytes.ts +135 -0
- package/std/assembly/util/casemap.ts +497 -0
- package/std/assembly/util/error.ts +54 -0
- package/std/assembly/util/hash.ts +117 -0
- package/std/assembly/util/math.ts +1922 -0
- package/std/assembly/util/memory.ts +290 -0
- package/std/assembly/util/number.ts +873 -0
- package/std/assembly/util/sort.ts +313 -0
- package/std/assembly/util/string.ts +1202 -0
- package/std/assembly/util/uri.ts +275 -0
- package/std/assembly/vector.ts +4 -0
- package/std/assembly.json +16 -0
- package/std/portable/index.d.ts +462 -0
- package/std/portable/index.js +416 -0
- package/std/portable.json +11 -0
- package/std/types/assembly/index.d.ts +1 -0
- package/std/types/assembly/package.json +3 -0
- package/std/types/portable/index.d.ts +1 -0
- package/std/types/portable/package.json +3 -0
- package/tsconfig-base.json +13 -0
- package/util/README.md +23 -0
- package/util/browser/fs.js +1 -0
- package/util/browser/module.js +5 -0
- package/util/browser/path.js +520 -0
- package/util/browser/process.js +59 -0
- package/util/browser/url.js +23 -0
- package/util/cpu.d.ts +9 -0
- package/util/cpu.js +42 -0
- package/util/find.d.ts +6 -0
- package/util/find.js +20 -0
- package/util/node.d.ts +21 -0
- package/util/node.js +34 -0
- package/util/options.d.ts +70 -0
- package/util/options.js +262 -0
- package/util/terminal.d.ts +52 -0
- package/util/terminal.js +35 -0
- package/util/text.d.ts +26 -0
- package/util/text.js +114 -0
- package/util/tsconfig.json +9 -0
- package/util/web.d.ts +11 -0
- package/util/web.js +33 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/// <reference path="./rt/index.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The base class of a task's on-heap record.
|
|
5
|
+
*
|
|
6
|
+
* The eight fields are `docs/async-await-plan-v2.md` §3.2's layout, verbatim and
|
|
7
|
+
* in order — the byte offsets are the contract codegen's typed read depends on
|
|
8
|
+
* (`src/compiler.ts:8025-8027` reads `payload` at 8 for the integer and `bool`
|
|
9
|
+
* kinds, and `f0`/`f1` at 16 for `f32` and the 64-bit kinds), so the declaration
|
|
10
|
+
* order and the types below are load-bearing:
|
|
11
|
+
*
|
|
12
|
+
* | field | offset | meaning |
|
|
13
|
+
* |---|---|---|
|
|
14
|
+
* | `class_` | 0 | the class the completion arrived as; 0 before delivery |
|
|
15
|
+
* | `key` | 4 | the producer's submit-time id (§3.1) |
|
|
16
|
+
* | `payload` | 8 | the producer's `b`, verbatim |
|
|
17
|
+
* | `status` | 12 | 0, or the capability's errno (§3.4) |
|
|
18
|
+
* | `f0` | 16 | the producer's `f0` |
|
|
19
|
+
* | `f1` | 20 | the producer's `f1` |
|
|
20
|
+
* | `tag` | 24 | the await tag; 0 today |
|
|
21
|
+
* | `done` | 28 | 0 = parked, 1 = settled |
|
|
22
|
+
*
|
|
23
|
+
* **Why std and not the framework** (Phase 4 ruling, plan §3.2): §7.1 gives the
|
|
24
|
+
* task machine to std and §3.2 gives it these offsets; a machine that must read
|
|
25
|
+
* `payload` at 8 cannot be written over a class that declares no fields. A
|
|
26
|
+
* capability that needs more subclasses `TaskRecord` — a subclass's fields start
|
|
27
|
+
* after the base's, so the offsets above are unchanged — and
|
|
28
|
+
* `__taskBindRecordFactory` (`task-rt.ts`) is how `__taskRegister` comes to
|
|
29
|
+
* allocate that subclass.
|
|
30
|
+
*
|
|
31
|
+
* It is a *managed* class so that `Task<T>._record` is a traced reference: a
|
|
32
|
+
* class-typed field is visited by the compiler-generated visitor (the
|
|
33
|
+
* `fieldType.isManaged` arm, `builtins.ts:10951-10962`), where a `usize` would
|
|
34
|
+
* not be. That trace is the bottom half of §4.4's root chain — task table →
|
|
35
|
+
* `TaskRecord` → state struct → environment — and it is what keeps a suspended
|
|
36
|
+
* task's record, state struct and environment alive when the only remaining
|
|
37
|
+
* reference is a handle the guest is holding.
|
|
38
|
+
*/
|
|
39
|
+
export class TaskRecord {
|
|
40
|
+
/** Offset 0: the class the completion arrived as; 0 before delivery. */
|
|
41
|
+
class_: i32 = 0;
|
|
42
|
+
/** Offset 4: the producer's submit-time id (§3.1). */
|
|
43
|
+
key: i32 = 0;
|
|
44
|
+
/** Offset 8: the producer's `b`, verbatim — integer and `bool` results. */
|
|
45
|
+
payload: i32 = 0;
|
|
46
|
+
/** Offset 12: 0, or the capability's errno (§3.4). */
|
|
47
|
+
status: i32 = 0;
|
|
48
|
+
/** Offset 16: the producer's `f0` — `f32` results, and the low half of 64-bit ones. */
|
|
49
|
+
f0: f32 = 0;
|
|
50
|
+
/** Offset 20: the producer's `f1` — the high half of 64-bit results. */
|
|
51
|
+
f1: f32 = 0;
|
|
52
|
+
/** Offset 24: the await tag (§3.1's limitation); 0 today. */
|
|
53
|
+
tag: i32 = 0;
|
|
54
|
+
/** Offset 28: 0 = parked, 1 = settled. */
|
|
55
|
+
done: i32 = 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A handle to an asynchronous operation's result.
|
|
60
|
+
*
|
|
61
|
+
* `Task<T>` is what a call to an `async function f(): T` produces, and what a
|
|
62
|
+
* capability's reader returns for work the host completes later
|
|
63
|
+
* (`docs/async-await-plan-v2.md` §1.2 rule 2 and §3.3). One handle type, one
|
|
64
|
+
* name: the design has no `Promise` and no second `Awaitable<T>` (§2.4).
|
|
65
|
+
*
|
|
66
|
+
* The type argument exists for the type checker. The layout is identical for
|
|
67
|
+
* every `T` — one word — exactly as `Function<T>`'s is (`std/assembly/function.ts`):
|
|
68
|
+
* the runtime's task record holds the value, and `await` reads it back through
|
|
69
|
+
* the record's typed read (§3.2).
|
|
70
|
+
*
|
|
71
|
+
* The runtime table, not this field, is the record's strong reference while a
|
|
72
|
+
* task is parked; a settled record nothing references is ordinary garbage (§3.2).
|
|
73
|
+
* The field is nonetheless a traced managed reference rather than an opaque
|
|
74
|
+
* `usize` (the divergence §2.4's "single opaque `usize` field" left open, resolved
|
|
75
|
+
* in favor of §3.2's "managed reference to the owning `TaskRecord`"): a `usize`
|
|
76
|
+
* field is not traced by the generated visitor, so a handle the guest holds across
|
|
77
|
+
* a suspension would be the *only* path to the record and the collector could not
|
|
78
|
+
* see through it — the record, its state struct and its environment could be
|
|
79
|
+
* collected while the task was still parked, and the resume would be a
|
|
80
|
+
* use-after-free. As a class-typed field it is traced, and the handle alone keeps
|
|
81
|
+
* the chain alive. The layout is unchanged: one word, identical for every `T`.
|
|
82
|
+
*
|
|
83
|
+
* Not `private`: the runtime that creates the record owns the handle's
|
|
84
|
+
* construction, and the lowering reads it from generated code (§4.1's
|
|
85
|
+
* `state.handle`). Nothing else may touch it.
|
|
86
|
+
*/
|
|
87
|
+
@final export class Task<T> {
|
|
88
|
+
/** Managed reference to the runtime's record for this task. */
|
|
89
|
+
_record!: TaskRecord;
|
|
90
|
+
}
|