porffor 0.2.0-77e30e8 → 0.2.0-812b38c
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 +20 -20
- package/README.md +164 -77
- package/asur/README.md +2 -0
- package/asur/index.js +1262 -0
- package/byg/index.js +237 -0
- package/compiler/2c.js +325 -72
- package/compiler/{sections.js → assemble.js} +64 -16
- package/compiler/builtins/annexb_string.js +72 -0
- package/compiler/builtins/annexb_string.ts +19 -0
- package/compiler/builtins/array.ts +145 -0
- package/compiler/builtins/base64.ts +151 -0
- package/compiler/builtins/crypto.ts +120 -0
- package/compiler/builtins/date.ts +1466 -0
- package/compiler/builtins/escape.ts +141 -0
- package/compiler/builtins/int.ts +147 -0
- package/compiler/builtins/number.ts +527 -0
- package/compiler/builtins/porffor.d.ts +42 -0
- package/compiler/builtins/string.ts +1055 -0
- package/compiler/builtins/tostring.ts +45 -0
- package/compiler/builtins.js +601 -272
- package/compiler/{codeGen.js → codegen.js} +1321 -505
- package/compiler/decompile.js +11 -13
- package/compiler/embedding.js +22 -22
- package/compiler/encoding.js +98 -114
- package/compiler/generated_builtins.js +1262 -0
- package/compiler/index.js +40 -37
- package/compiler/log.js +6 -3
- package/compiler/opt.js +65 -29
- package/compiler/parse.js +44 -11
- package/compiler/precompile.js +128 -0
- package/compiler/prefs.js +27 -0
- package/compiler/prototype.js +177 -37
- package/compiler/types.js +37 -0
- package/compiler/wasmSpec.js +31 -7
- package/compiler/wrap.js +144 -46
- package/fib.js +7 -0
- package/package.json +9 -5
- package/porf +4 -0
- package/rhemyn/compile.js +46 -27
- package/rhemyn/parse.js +322 -320
- package/rhemyn/test/parse.js +58 -58
- package/runner/compare.js +34 -34
- package/runner/debug.js +122 -0
- package/runner/index.js +91 -11
- package/runner/profiler.js +102 -0
- package/runner/repl.js +44 -11
- package/runner/sizes.js +37 -37
- package/compiler/builtins/base64.js +0 -92
- package/runner/info.js +0 -89
- package/runner/profile.js +0 -46
- package/runner/results.json +0 -1
- package/runner/transform.js +0 -15
- package/util/enum.js +0 -20
package/LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2023 CanadaHonk
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 CanadaHonk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Porffor <sup><sub>/ˈpɔrfɔr/ *(poor-for)*</sup></sub>
|
2
|
-
A from-scratch experimental
|
2
|
+
A from-scratch experimental **AOT** optimizing JS/TS -> Wasm/C engine/compiler/runtime in JS. Not serious/intended for (real) use. (this is a straight forward, honest readme)<br>
|
3
3
|
Age: ~6 months (very on and off)
|
4
4
|
|
5
5
|
## Design
|
@@ -10,6 +10,80 @@ Porffor is a very unique JS engine, due many wildly different approaches. It is
|
|
10
10
|
|
11
11
|
Porffor is primarily built from scratch, the only thing that is not is the parser (using [Acorn](https://github.com/acornjs/acorn)). Binaryen/etc is not used, we make final wasm binaries ourself. You could imagine it as compiling a language which is a sub (some things unsupported) and super (new/custom apis) set of javascript. Not based on any particular spec version, focusing on function/working over spec compliance.
|
12
12
|
|
13
|
+
## Usage
|
14
|
+
Expect nothing to work! Only very limited JS is currently supported. See files in `bench` for examples.
|
15
|
+
|
16
|
+
### Setup
|
17
|
+
**`npm install -g porffor`**. It's that easy (hopefully) :)
|
18
|
+
|
19
|
+
### Trying a REPL
|
20
|
+
**`porf`**. Just run it with no script file argument.
|
21
|
+
|
22
|
+
### Running a JS file
|
23
|
+
**`porf path/to/script.js`**
|
24
|
+
|
25
|
+
### Compiling to Wasm
|
26
|
+
**`porf wasm path/to/script.js out.wasm`**. Currently it does not use an import standard like WASI, so it is mostly unusable on its own.
|
27
|
+
|
28
|
+
### Compiling to native binaries
|
29
|
+
> [!WARNING]
|
30
|
+
> Compiling to native binaries uses [2c](#2c), Porffor's own Wasm -> C compiler, which is experimental.
|
31
|
+
|
32
|
+
**`porf native path/to/script.js out(.exe)`**. You can specify the compiler with `--compiler=clang/zig/gcc`, and which opt level to use with `--cO=O3` (`Ofast` by default). Output binaries are also stripped by default.
|
33
|
+
|
34
|
+
### Compiling to C
|
35
|
+
> [!WARNING]
|
36
|
+
> Compiling to C uses [2c](#2c), Porffor's own Wasm -> C compiler, which is experimental.
|
37
|
+
|
38
|
+
**`porf c path/to/script.js (out.c)`**. When not including an output file, it will be printed to stdout instead.
|
39
|
+
|
40
|
+
### Profiling a JS file
|
41
|
+
> [!WARNING]
|
42
|
+
> Very experimental WIP feature!
|
43
|
+
|
44
|
+
**`porf profile path/to/script.js`**
|
45
|
+
|
46
|
+
### Debugging a JS file
|
47
|
+
> [!WARNING]
|
48
|
+
> Very experimental WIP feature!
|
49
|
+
|
50
|
+
**`porf debug path/to/script.js`**
|
51
|
+
|
52
|
+
### Profiling the generated Wasm of a JS file
|
53
|
+
> [!WARNING]
|
54
|
+
> Very experimental WIP feature!
|
55
|
+
|
56
|
+
**`porf debug-wasm path/to/script.js`**
|
57
|
+
|
58
|
+
|
59
|
+
### Options
|
60
|
+
- `--parser=acorn|@babel/parser|meriyah|hermes-parser` (default: `acorn`) to set which parser to use
|
61
|
+
- `--parse-types` to enable parsing type annotations/typescript. if `-parser` is unset, changes default to `@babel/parser`. does not type check
|
62
|
+
- `--opt-types` to perform optimizations using type annotations as compiler hints. does not type check
|
63
|
+
- `--valtype=i32|i64|f64` (default: `f64`) to set valtype
|
64
|
+
- `-O0` to disable opt
|
65
|
+
- `-O1` (default) to enable basic opt (simplify insts, treeshake wasm imports)
|
66
|
+
- `-O2` to enable advanced opt (inlining). unstable
|
67
|
+
- `-O3` to enable advanceder opt (precompute const math). unstable
|
68
|
+
- `--no-run` to not run wasm output, just compile
|
69
|
+
- `--opt-log` to log some opts
|
70
|
+
- `--code-log` to log some codegen (you probably want `-funcs`)
|
71
|
+
- `--regex-log` to log some regex
|
72
|
+
- `--funcs` to log funcs
|
73
|
+
- `--ast-log` to log AST
|
74
|
+
- `--opt-funcs` to log funcs after opt
|
75
|
+
- `--sections` to log sections as hex
|
76
|
+
- `--opt-no-inline` to not inline any funcs
|
77
|
+
- `--tail-call` to enable tail calls (experimental + not widely implemented)
|
78
|
+
- `--compile-hints` to enable V8 compilation hints (experimental + doesn't seem to do much?)
|
79
|
+
|
80
|
+
### Running in the repo
|
81
|
+
The repo comes with easy alias files for Unix and Windows, which you can use like so:
|
82
|
+
- Unix: `./porf path/to/script.js`
|
83
|
+
- Windows: `.\porf path/to/script.js`
|
84
|
+
|
85
|
+
Please note that further examples below will just use `./porf`, you need to use `.\porf` on Windows. You can also swap out `node` in the alias to use another runtime like Deno (`deno run -A`) or Bun (`bun ...`), or just use it yourself (eg `node runner/index.js ...`, `bun runner/index.js ...`). Node and Bun should work great, Deno support is WIP.
|
86
|
+
|
13
87
|
## Limitations
|
14
88
|
- No full object support yet
|
15
89
|
- Little built-ins/prototype
|
@@ -18,10 +92,15 @@ Porffor is primarily built from scratch, the only thing that is not is the parse
|
|
18
92
|
- Literal callees only in calls (eg `print()` works, `a = print; a()` does not)
|
19
93
|
- No `eval()` etc (since it is AOT)
|
20
94
|
|
21
|
-
##
|
95
|
+
## Sub-engines
|
96
|
+
|
97
|
+
### Asur
|
98
|
+
Asur is Porffor's own Wasm engine; it is an intentionally simple interpreter written in JS. It is very WIP. See [its readme](asur/README.md) for more details.
|
99
|
+
|
100
|
+
### Rhemyn
|
22
101
|
Rhemyn is Porffor's own regex engine; it compiles literal regex to Wasm bytecode AOT (remind you of anything?). It is quite basic and WIP. See [its readme](rhemyn/README.md) for more details.
|
23
102
|
|
24
|
-
|
103
|
+
### 2c
|
25
104
|
2c is Porffor's own Wasm -> C compiler, using generated Wasm bytecode and internal info to generate specific and efficient/fast C code. Little boilerplate/preluded code or required external files, just for CLI binaries (not like wasm2c very much).
|
26
105
|
|
27
106
|
## Supported
|
@@ -86,20 +165,29 @@ These include some early (stage 1/0) and/or dead (last commit years ago) proposa
|
|
86
165
|
- `for...of` (arrays and strings)
|
87
166
|
- Array member setting (`arr[0] = 2`, `arr[0] += 2`, etc)
|
88
167
|
- Array constructor (`Array(5)`, `new Array(1, 2, 3)`)
|
168
|
+
- Labelled statements (`foo: while (...)`)
|
169
|
+
- `do...while` loops
|
89
170
|
|
90
171
|
### Built-ins
|
91
172
|
|
92
|
-
- `NaN` and `Infinity`
|
93
|
-
- `isNaN()` and `isFinite()`
|
94
|
-
- Most of `Number` (`MAX_VALUE`, `MIN_VALUE`, `MAX_SAFE_INTEGER`, `MIN_SAFE_INTEGER`, `POSITIVE_INFINITY`, `NEGATIVE_INFINITY`, `EPSILON`, `NaN`, `isNaN`, `isFinite`, `isInteger`, `isSafeInteger`)
|
95
|
-
- Some `Math` funcs (`
|
173
|
+
- `NaN` and `Infinity`
|
174
|
+
- `isNaN()` and `isFinite()`
|
175
|
+
- Most of `Number` (`MAX_VALUE`, `MIN_VALUE`, `MAX_SAFE_INTEGER`, `MIN_SAFE_INTEGER`, `POSITIVE_INFINITY`, `NEGATIVE_INFINITY`, `EPSILON`, `NaN`, `isNaN`, `isFinite`, `isInteger`, `isSafeInteger`)
|
176
|
+
- Some `Math` funcs (`sqrt`, `abs`, `floor`, `sign`, `round`, `trunc`, `clz32`, `fround`, `random`)
|
96
177
|
- Basic `globalThis` support
|
97
178
|
- Basic `Boolean` and `Number`
|
98
179
|
- Basic `eval` for literals
|
99
180
|
- `Math.random()` using self-made xorshift128+ PRNG
|
100
|
-
- Some of `performance` (`now()`)
|
101
|
-
- Some of `Array.prototype` (`at`, `push`, `pop`, `shift`, `fill`)
|
102
|
-
- Some of `
|
181
|
+
- Some of `performance` (`now()`, `timeOrigin`)
|
182
|
+
- Some of `Array.prototype` (`at`, `push`, `pop`, `shift`, `fill`, `slice`, `indexOf`, `lastIndexOf`, `includes`, `with`, `reverse`, `toReversed`)
|
183
|
+
- Some of `Array` (`of`, `isArray`)
|
184
|
+
- Most of `String.prototype` (`at`, `charAt`, `charCodeAt`, `toUpperCase`, `toLowerCase`, `startsWith`, `endsWith`, `indexOf`, `lastIndexOf`, `includes`, `padStart`, `padEnd`, `substring`, `substr`, `slice`, `trimStart`, `trimEnd`, `trim`, `toString`, `big`, `blink`, `bold`, `fixed`, `italics`, `small`, `strike`, `sub`, `sup`, `trimLeft`, `trimRight`, )
|
185
|
+
- Some of `crypto` (`randomUUID`)
|
186
|
+
- `escape`
|
187
|
+
- `btoa`
|
188
|
+
- Most of `Number.prototype` (`toString`, `toFixed`, `toExponential`)
|
189
|
+
- `parseInt`
|
190
|
+
- Spec-compliant `Date`
|
103
191
|
|
104
192
|
### Custom
|
105
193
|
|
@@ -108,34 +196,8 @@ These include some early (stage 1/0) and/or dead (last commit years ago) proposa
|
|
108
196
|
- Intrinsic functions (see below)
|
109
197
|
- Inlining wasm via ``asm`...``\` "macro"
|
110
198
|
|
111
|
-
## Todo
|
112
|
-
No particular order and no guarentees, just what could happen soon™
|
113
|
-
|
114
|
-
- Arrays
|
115
|
-
- More of `Array` prototype
|
116
|
-
- Arrays/strings inside arrays
|
117
|
-
- Destructuring
|
118
|
-
- Objects
|
119
|
-
- Basic object expressions (eg `{}`, `{ a: 0 }`)
|
120
|
-
- Wasm
|
121
|
-
- *Basic* Wasm engine (interpreter) in js
|
122
|
-
- More math operators (`**`, etc)
|
123
|
-
- `do { ... } while (...)`
|
124
|
-
- Rewrite `console.log` to work with strings/arrays
|
125
|
-
- Exceptions
|
126
|
-
- Rewrite to use actual strings (optional?)
|
127
|
-
- `try { } finally { }`
|
128
|
-
- Rethrowing inside catch
|
129
|
-
- Optimizations
|
130
|
-
- Rewrite local indexes per func for smallest local header and remove unused idxs
|
131
|
-
- Smarter inline selection (snapshots?)
|
132
|
-
- Remove const ifs (`if (true)`, etc)
|
133
|
-
- Use type(script) information to remove unneeded typechecker code
|
134
|
-
|
135
199
|
## Performance
|
136
|
-
*For the
|
137
|
-
|
138
|
-

|
200
|
+
*For the features it supports most of the time*, Porffor is *blazingly fast* compared to most interpreters and common engines running without JIT. For those with JIT, it is usually slower by default, but can catch up with compiler arguments and typed input, even more so when compiling to native binaries.
|
139
201
|
|
140
202
|
## Optimizations
|
141
203
|
Mostly for reducing size. I do not really care about compiler perf/time as long as it is reasonable. We do not use/rely on external opt tools (`wasm-opt`, etc), instead doing optimization inside the compiler itself creating even smaller code sizes than `wasm-opt` itself can produce as we have more internal information.
|
@@ -143,7 +205,7 @@ Mostly for reducing size. I do not really care about compiler perf/time as long
|
|
143
205
|
### Traditional opts
|
144
206
|
- Inlining functions (WIP, limited)
|
145
207
|
- Inline const math ops
|
146
|
-
- Tail calls (behind flag
|
208
|
+
- Tail calls (behind flag `--tail-call`)
|
147
209
|
|
148
210
|
### Wasm transforms
|
149
211
|
- `local.set`, `local.get` -> `local.tee`
|
@@ -157,10 +219,12 @@ Mostly for reducing size. I do not really care about compiler perf/time as long
|
|
157
219
|
- Remove unneeded blocks (no `br`s inside)
|
158
220
|
- Remove unused imports
|
159
221
|
- Use data segments for initing arrays/strings
|
222
|
+
- (Likely more not documented yet, todo)
|
160
223
|
|
161
224
|
### Wasm module
|
162
225
|
- Type cache/index (no repeated types)
|
163
226
|
- No main func if empty (and other exports)
|
227
|
+
- No tags if unused/optimized out
|
164
228
|
|
165
229
|
## Test262
|
166
230
|
Porffor can run Test262 via some hacks/transforms which remove unsupported features whilst still doing the same asserts (eg simpler error messages using literals only). It currently passes >10% (see latest commit desc for latest and details). Use `node test262` to test, it will also show a difference of overall results between the last commit and current results.
|
@@ -168,7 +232,7 @@ Porffor can run Test262 via some hacks/transforms which remove unsupported featu
|
|
168
232
|
## Codebase
|
169
233
|
- `compiler`: contains the compiler itself
|
170
234
|
- `builtins.js`: all built-ins of the engine (spec, custom. vars, funcs)
|
171
|
-
- `
|
235
|
+
- `codegen.js`: code (wasm) generation, ast -> wasm. The bulk of the effort
|
172
236
|
- `decompile.js`: basic wasm decompiler for debug info
|
173
237
|
- `embedding.js`: utils for embedding consts
|
174
238
|
- `encoding.js`: utils for encoding things as bytes as wasm expects
|
@@ -176,11 +240,11 @@ Porffor can run Test262 via some hacks/transforms which remove unsupported featu
|
|
176
240
|
- `index.js`: doing all the compiler steps, takes code in, wasm out
|
177
241
|
- `opt.js`: self-made wasm bytecode optimizer
|
178
242
|
- `parse.js`: parser simply wrapping acorn
|
179
|
-
- `
|
243
|
+
- `assemble.js`: assembles wasm ops and metadata into a wasm module/file
|
180
244
|
- `wasmSpec.js`: "enums"/info from wasm spec
|
181
245
|
- `wrap.js`: wrapper for compiler which instantiates and produces nice exports
|
182
246
|
|
183
|
-
- `runner`: contains utils for running
|
247
|
+
- `runner`: contains utils for running JS with the compiler
|
184
248
|
- `index.js`: the main file, you probably want to use this
|
185
249
|
- `info.js`: runs with extra info printed
|
186
250
|
- `repl.js`: basic repl (uses `node:repl`)
|
@@ -193,57 +257,80 @@ Porffor can run Test262 via some hacks/transforms which remove unsupported featu
|
|
193
257
|
- `test262`: test262 runner and utils
|
194
258
|
|
195
259
|
## Usecases
|
196
|
-
Basically none (other than giving people headaches). Potential ideas
|
260
|
+
Basically none right now (other than giving people headaches). Potential ideas:
|
261
|
+
- Safety. As Porffor is written in JS, a memory-safe language\*, and compiles JS to Wasm, a fully sandboxed environment\*, it is quite safe. (\* These rely on the underlying implementations being secure. You could also run Wasm, or even Porffor itself, with an interpreter instead of a JIT for bonus security points too.)
|
262
|
+
- Compiling JS to native binaries. This is still very early!
|
263
|
+
- More in future probably?
|
197
264
|
|
198
|
-
##
|
199
|
-
|
265
|
+
## Todo
|
266
|
+
No particular order and no guarentees, just what could happen soon™
|
200
267
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
268
|
+
- Arrays
|
269
|
+
- More of `Array` prototype
|
270
|
+
- Arrays/strings inside arrays
|
271
|
+
- Destructuring
|
272
|
+
- Objects
|
273
|
+
- Basic object expressions (eg `{}`, `{ a: 0 }`)
|
274
|
+
- Asur
|
275
|
+
- Support memory
|
276
|
+
- Support exceptions
|
277
|
+
- More math operators (`**`, etc)
|
278
|
+
- Typed export inputs (array)
|
279
|
+
- Exceptions
|
280
|
+
- Rewrite to use actual strings (optional?)
|
281
|
+
- `try { } finally { }`
|
282
|
+
- Rethrowing inside catch
|
283
|
+
- Optimizations
|
284
|
+
- Rewrite local indexes per func for smallest local header and remove unused idxs
|
285
|
+
- Smarter inline selection (snapshots?)
|
286
|
+
- Remove const ifs (`if (true)`, etc)
|
287
|
+
- Memory alignment
|
288
|
+
- Add general pref for always using "fast" (non-short circuiting) or/and
|
289
|
+
- Runtime
|
290
|
+
- WASI target
|
291
|
+
- Run precompiled Wasm file if given
|
292
|
+
- Docs
|
293
|
+
- Update codebase readme section
|
294
|
+
- Cool proposals
|
295
|
+
- [Optional Chaining Assignment](https://github.com/tc39/proposal-optional-chaining-assignment)
|
296
|
+
- [Modulus and Additional Integer Math](https://github.com/tc39/proposal-integer-and-modulus-math)
|
297
|
+
- [Array Equality](https://github.com/tc39/proposal-array-equality)
|
298
|
+
- [Declarations in Conditionals](https://github.com/tc39/proposal-Declarations-in-Conditionals)
|
299
|
+
- [Seeded Pseudo-Random Numbers](https://github.com/tc39/proposal-seeded-random)
|
300
|
+
- [`do` expressions](https://github.com/tc39/proposal-do-expressions)
|
301
|
+
- [String Trim Characters](https://github.com/Kingwl/proposal-string-trim-characters)
|
302
|
+
- Posts
|
303
|
+
- Inlining investigation
|
304
|
+
- JS -> Native
|
305
|
+
- Precompiled TS built-ins
|
306
|
+
- Asur
|
307
|
+
- `escape()` optimization
|
308
|
+
- Self hosted testing?
|
205
309
|
|
206
|
-
|
310
|
+
## VSCode extension
|
311
|
+
There is a vscode extension in `vscode-ext` which tweaks JS syntax highlighting to be nicer with porffor features (eg highlighting wasm inside of inline asm).
|
207
312
|
|
208
|
-
|
209
|
-
|
210
|
-
- `-target=c|native` only:
|
211
|
-
- `-o=out.c|out.exe|out` to set file to output c or binary
|
212
|
-
- `-target=native` only:
|
213
|
-
- `-compiler=clang` to set compiler binary (path/name) to use to compile
|
214
|
-
- `-cO=O3` to set compiler opt argument
|
215
|
-
- `-valtype=i32|i64|f64` (default: `f64`) to set valtype
|
216
|
-
- `-O0` to disable opt
|
217
|
-
- `-O1` (default) to enable basic opt (simplify insts, treeshake wasm imports)
|
218
|
-
- `-O2` to enable advanced opt (inlining)
|
219
|
-
- `-O3` to enable advanceder opt (precompute const math)
|
220
|
-
- `-no-run` to not run wasm output, just compile
|
221
|
-
- `-opt-log` to log some opts
|
222
|
-
- `-code-log` to log some codegen (you probably want `-funcs`)
|
223
|
-
- `-regex-log` to log some regex
|
224
|
-
- `-funcs` to log funcs
|
225
|
-
- `-ast-log` to log AST
|
226
|
-
- `-opt-funcs` to log funcs after opt
|
227
|
-
- `-sections` to log sections as hex
|
228
|
-
- `-opt-no-inline` to not inline any funcs
|
229
|
-
- `-tail-call` to enable tail calls (experimental + not widely implemented)
|
230
|
-
- `-compile-hints` to enable V8 compilation hints (experimental + doesn't seem to do much?)
|
313
|
+
## Wasm proposals used
|
314
|
+
Porffor intentionally does not use Wasm proposals which are not commonly implemented yet (eg GC) so it can be used in as many places as possible.
|
231
315
|
|
232
|
-
|
233
|
-
|
316
|
+
- Multi-value **(required)**
|
317
|
+
- Non-trapping float-to-int conversions **(required)**
|
318
|
+
- Bulk memory operations (required, but uncommonly used)
|
319
|
+
- Exception handling (optional, for errors)
|
320
|
+
- Tail calls (opt-in, off by default)
|
234
321
|
|
235
322
|
## Isn't this the same as AssemblyScript/other Wasm langs?
|
236
323
|
No. they are not alike at all internally and have very different goals/ideals:
|
237
324
|
- Porffor is made as a generic JS engine, not for Wasm stuff specifically
|
238
|
-
- Porffor
|
239
|
-
- Porffor is
|
325
|
+
- Porffor primarily consumes JS
|
326
|
+
- Porffor is written in pure JS and compiles itself, not using Binaryen/etc
|
240
327
|
- (Also I didn't know it existed when I started this, lol)
|
241
328
|
|
242
329
|
## FAQ
|
243
330
|
|
244
331
|
### 1. Why the name?
|
245
332
|
`purple` in Welsh is `porffor`. Why purple?
|
246
|
-
- No other
|
333
|
+
- No other JS engine is purple colored
|
247
334
|
- Purple is pretty cool
|
248
335
|
- Purple apparently represents "ambition", which is.. one word to describe this project
|
249
336
|
- The hard to speak name is also the noise your brain makes in reaction to this idea!
|
package/asur/README.md
ADDED