@swf2es/codegen 0.1.38 → 0.1.39
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.third-party +38 -7
- package/README.md +5 -4
- package/dist/codegen.wasm +0 -0
- package/dist/index.d.ts +49 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +850 -126
- package/dist/index.js.map +1 -1
- package/dist/zig.d.ts +141 -0
- package/dist/zig.d.ts.map +1 -0
- package/dist/zig.js +384 -0
- package/dist/zig.js.map +1 -0
- package/package.json +5 -9
- package/src/index.ts +1053 -138
- package/src/webassembly.d.ts +2 -1
- package/src/zig.ts +596 -0
- package/dist/codegen.d.ts +0 -342
- package/dist/codegen.js +0 -336
package/LICENSE.third-party
CHANGED
|
@@ -39,13 +39,13 @@ SOFTWARE.
|
|
|
39
39
|
AssemblyScript
|
|
40
40
|
==============
|
|
41
41
|
|
|
42
|
-
dist/codegen.wasm
|
|
43
|
-
https://github.com/AssemblyScript/assemblyscript,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
formatting (std/assembly/util/number.ts),
|
|
47
|
-
its
|
|
48
|
-
|
|
42
|
+
dist/codegen.wasm holds ports of two parts of AssemblyScript's standard
|
|
43
|
+
library, https://github.com/AssemblyScript/assemblyscript, under the
|
|
44
|
+
Apache License 2.0 (LICENSE), so that the compiler writes and reads
|
|
45
|
+
numbers as it did when AssemblyScript compiled it: its Grisu2 number
|
|
46
|
+
formatting (std/assembly/util/number.ts), ported to zig/src/dtoa.zig, and
|
|
47
|
+
its integer parsing (strtol of std/assembly/util/string.ts), ported to
|
|
48
|
+
zig/src/parse.zig. Its NOTICE:
|
|
49
49
|
|
|
50
50
|
The following authors have all licensed their contributions to AssemblyScript
|
|
51
51
|
under the licensing terms detailed in LICENSE:
|
|
@@ -140,3 +140,34 @@ the following terms:
|
|
|
140
140
|
|
|
141
141
|
Copyright (c) Arm Limited
|
|
142
142
|
The MIT License (https://opensource.org/licenses/MIT)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
Zig
|
|
146
|
+
===
|
|
147
|
+
|
|
148
|
+
dist/codegen.wasm is compiled by Zig 0.17.0,
|
|
149
|
+
https://ziglang.org, and holds the parts of its standard library the
|
|
150
|
+
compiler uses and compiler-rt's routines it calls (memcpy, memset), under
|
|
151
|
+
the MIT License:
|
|
152
|
+
|
|
153
|
+
The MIT License (Expat)
|
|
154
|
+
|
|
155
|
+
Copyright (c) Zig contributors
|
|
156
|
+
|
|
157
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
158
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
159
|
+
in the Software without restriction, including without limitation the rights
|
|
160
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
161
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
162
|
+
furnished to do so, subject to the following conditions:
|
|
163
|
+
|
|
164
|
+
The above copyright notice and this permission notice shall be included in
|
|
165
|
+
all copies or substantial portions of the Software.
|
|
166
|
+
|
|
167
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
168
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
169
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
170
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
171
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
172
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
173
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @swf2es/codegen
|
|
2
2
|
|
|
3
3
|
The compiler of [swf2es](https://github.com/swf2es/swf2es): ABC (AS3) and
|
|
4
|
-
AVM1 (AS1/2) bytecode to ES modules, written in
|
|
5
|
-
|
|
4
|
+
AVM1 (AS1/2) bytecode to ES modules, written in Zig and built to
|
|
5
|
+
`codegen.wasm`. The same binary is the player's JIT and the `swf2es`
|
|
6
6
|
command's ahead-of-time compiler, so both give the same modules. Most pages
|
|
7
7
|
want [`@swf2es/web`](https://www.npmjs.com/package/@swf2es/web); the
|
|
8
8
|
command is [`@swf2es/cli`](https://www.npmjs.com/package/@swf2es/cli).
|
|
@@ -23,5 +23,6 @@ const codegen = await createCodegen(wasm); // a compiler, for one player
|
|
|
23
23
|
The module imports nothing but `env.abort`. `codegen.wasm` is also
|
|
24
24
|
exported as `@swf2es/codegen/codegen.wasm` for a bundler or an import map.
|
|
25
25
|
|
|
26
|
-
Apache-2.0 ([LICENSE](LICENSE));
|
|
27
|
-
|
|
26
|
+
Apache-2.0 ([LICENSE](LICENSE)); Zig's notice, AssemblyScript's for the
|
|
27
|
+
number formatting and parsing ported from it, and Ruffle's for the AVM1
|
|
28
|
+
decoder's readings, in [LICENSE.third-party](LICENSE.third-party).
|
package/dist/codegen.wasm
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compiles ABC and AVM1 bytecode to ES modules.
|
|
3
3
|
*
|
|
4
|
-
* The compiler itself is
|
|
5
|
-
* This wrapper instantiates it and gives its exports their
|
|
4
|
+
* The compiler itself is Zig (zig/), built to codegen.wasm, whose exports
|
|
5
|
+
* zig.ts binds. This wrapper instantiates it and gives its exports their
|
|
6
|
+
* types. The same wasm runs as the browser JIT
|
|
6
7
|
* (a module per ABC as its SWF loads) and as the ahead-of-time compiler,
|
|
7
8
|
* so both produce identical output. See docs/architecture/overview.md.
|
|
8
9
|
*/
|
|
@@ -146,6 +147,34 @@ export interface LoggedModule {
|
|
|
146
147
|
module: string;
|
|
147
148
|
log: string | null;
|
|
148
149
|
}
|
|
150
|
+
/** How long compactStep may go on: as an IdleDeadline, the milliseconds left. */
|
|
151
|
+
export interface CompactDeadline {
|
|
152
|
+
timeRemaining(): number;
|
|
153
|
+
}
|
|
154
|
+
/** What compactStep did (see Codegen.compactStep). */
|
|
155
|
+
export type CompactProgress = "none" | "moving" | "done";
|
|
156
|
+
/** Why a move compactStep started was given up, the domain left as it was. */
|
|
157
|
+
export type MoveAbort =
|
|
158
|
+
/** The spare instance panicked, trapped or ran out of memory. */
|
|
159
|
+
"spare"
|
|
160
|
+
/** The spare refused: the domain too large to move, or a part that did not load, rebuild or replay. */
|
|
161
|
+
| "refused"
|
|
162
|
+
/** A call meanwhile could not be journaled, so the spare could not catch up. */
|
|
163
|
+
| "unjournaled"
|
|
164
|
+
/** The domain was reset, recovered from a panic, or rebuilt in place meanwhile. */
|
|
165
|
+
| "superseded";
|
|
166
|
+
/**
|
|
167
|
+
* compactStep's moves: started, completed, and given up by why; and of the
|
|
168
|
+
* last one completed, the calls replayed into its spare after its rebuild,
|
|
169
|
+
* and the bytes of its snapshot, which recovery keeps as its checkpoint.
|
|
170
|
+
*/
|
|
171
|
+
export interface MoveCounts {
|
|
172
|
+
started: number;
|
|
173
|
+
completed: number;
|
|
174
|
+
aborted: Record<MoveAbort, number>;
|
|
175
|
+
lastCaughtUp: number;
|
|
176
|
+
lastSavedBytes: number;
|
|
177
|
+
}
|
|
149
178
|
/**
|
|
150
179
|
* The compiler. ABCs are added to a domain in the order the SWF loads them
|
|
151
180
|
* (the builtins first), and the last one added compiles to its module,
|
|
@@ -203,18 +232,34 @@ export interface Codegen {
|
|
|
203
232
|
* a host calls this when it has time, as when idle; nothing else does.
|
|
204
233
|
*/
|
|
205
234
|
compact(): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* compact a part at a time, for a host that goes on compiling meanwhile:
|
|
237
|
+
* a move into the spare instance is snapshotted, loaded and rebuilt there
|
|
238
|
+
* while `deadline.timeRemaining()` is above 0 (one part at least), the
|
|
239
|
+
* calls made meanwhile replayed into it, and it takes this instance's
|
|
240
|
+
* place once it has caught up. "moving" while some is left, to be called
|
|
241
|
+
* again; "done" once a rebuild finished in this call; "none" if none was
|
|
242
|
+
* due, or the move was given up, the domain left as it was. Only a small
|
|
243
|
+
* domain is rebuilt in place, in one call; a larger one moves.
|
|
244
|
+
*/
|
|
245
|
+
compactStep(deadline: CompactDeadline): CompactProgress;
|
|
206
246
|
/**
|
|
207
247
|
* What the ABCs hold of codegen's memory, roughly, in bytes: the live
|
|
208
248
|
* ones', and the dropped and evicted domains' that compact would free;
|
|
209
249
|
* the size of codegen's memory, which grows and never shrinks but when
|
|
210
|
-
* compact moves the domain to a new instance;
|
|
211
|
-
* failed, each leaving the domain as it was, rebuilt in place if at all
|
|
250
|
+
* compact moves the domain to a new instance; how many such moves
|
|
251
|
+
* failed, each leaving the domain as it was, rebuilt in place if at all;
|
|
252
|
+
* compactStep's moves; and what the recovery from a panic holds outside
|
|
253
|
+
* codegen's memory: its checkpoint and the inputs journaled since, in
|
|
254
|
+
* bytes.
|
|
212
255
|
*/
|
|
213
256
|
usage(): {
|
|
214
257
|
live: number;
|
|
215
258
|
dead: number;
|
|
216
259
|
memory: number;
|
|
217
260
|
failedMoves: number;
|
|
261
|
+
moves: MoveCounts;
|
|
262
|
+
recovery: number;
|
|
218
263
|
};
|
|
219
264
|
/** The size of codegen's memory in bytes, as usage gives it: cheap, for a host that shows it often. */
|
|
220
265
|
memoryBytes(): number;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,eAAe,EAAE,WAAW,EAAoC,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAUvD,OAAO,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