porffor 0.2.0-af678f0 → 0.2.0-c1d7382
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/README.md +60 -62
- package/package.json +1 -1
package/README.md
CHANGED
@@ -10,6 +10,65 @@ 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
|
+
1. Clone this repo (`git clone https://github.com/CanadaHonk/porffor.git`)
|
18
|
+
2. `npm install` - for parser(s)
|
19
|
+
|
20
|
+
### Running a file
|
21
|
+
The repos comes with easy alias files for Unix and Windows, which you can use like so:
|
22
|
+
- Unix: `./porf path/to/script.js`
|
23
|
+
- Windows: `.\porf path/to/script.js`
|
24
|
+
|
25
|
+
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.
|
26
|
+
|
27
|
+
### Trying a REPL
|
28
|
+
**`./porf`**. Just run it with no script file argument.
|
29
|
+
|
30
|
+
### Compiling to native binaries
|
31
|
+
> [!WARNING]
|
32
|
+
> Compiling to native binaries uses [2c](#2c), Porffor's own Wasm -> C compiler, which is experimental.
|
33
|
+
|
34
|
+
**`./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.
|
35
|
+
|
36
|
+
### Compiling to C
|
37
|
+
> [!WARNING]
|
38
|
+
> Compiling to C uses [2c](#2c), Porffor's own Wasm -> C compiler, which is experimental.
|
39
|
+
|
40
|
+
**`./porf c path/to/script.js (out.c)`**. When not including an output file, it will be printed to stdout instead.
|
41
|
+
|
42
|
+
### Compiling to a Wasm binary
|
43
|
+
**`./porf compile path/to/script.js out.wasm`**. Currently it does not use an import standard like WASI, so it is mostly unusable.
|
44
|
+
|
45
|
+
### Options
|
46
|
+
- `-target=wasm|c|native` (default: `wasm`) to set target output (native compiles c output to binary, see args below)
|
47
|
+
- `-target=c|native` only:
|
48
|
+
- `-o=out.c|out.exe|out` to set file to output c or binary
|
49
|
+
- `-target=native` only:
|
50
|
+
- `-compiler=clang` to set compiler binary (path/name) to use to compile
|
51
|
+
- `-cO=O3` to set compiler opt argument
|
52
|
+
- `-parser=acorn|@babel/parser|meriyah|hermes-parser` (default: `acorn`) to set which parser to use
|
53
|
+
- `-parse-types` to enable parsing type annotations/typescript. if `-parser` is unset, changes default to `@babel/parser`. does not type check
|
54
|
+
- `-opt-types` to perform optimizations using type annotations as compiler hints. does not type check
|
55
|
+
- `-valtype=i32|i64|f64` (default: `f64`) to set valtype
|
56
|
+
- `-O0` to disable opt
|
57
|
+
- `-O1` (default) to enable basic opt (simplify insts, treeshake wasm imports)
|
58
|
+
- `-O2` to enable advanced opt (inlining). unstable
|
59
|
+
- `-O3` to enable advanceder opt (precompute const math). unstable
|
60
|
+
- `-no-run` to not run wasm output, just compile
|
61
|
+
- `-opt-log` to log some opts
|
62
|
+
- `-code-log` to log some codegen (you probably want `-funcs`)
|
63
|
+
- `-regex-log` to log some regex
|
64
|
+
- `-funcs` to log funcs
|
65
|
+
- `-ast-log` to log AST
|
66
|
+
- `-opt-funcs` to log funcs after opt
|
67
|
+
- `-sections` to log sections as hex
|
68
|
+
- `-opt-no-inline` to not inline any funcs
|
69
|
+
- `-tail-call` to enable tail calls (experimental + not widely implemented)
|
70
|
+
- `-compile-hints` to enable V8 compilation hints (experimental + doesn't seem to do much?)
|
71
|
+
|
13
72
|
## Limitations
|
14
73
|
- No full object support yet
|
15
74
|
- Little built-ins/prototype
|
@@ -147,9 +206,7 @@ No particular order and no guarentees, just what could happen soon™
|
|
147
206
|
- Self hosted testing?
|
148
207
|
|
149
208
|
## Performance
|
150
|
-
*For the
|
151
|
-
|
152
|
-

|
209
|
+
*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.
|
153
210
|
|
154
211
|
## Optimizations
|
155
212
|
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.
|
@@ -214,65 +271,6 @@ Basically none right now (other than giving people headaches). Potential ideas:
|
|
214
271
|
- Compiling JS to native binaries. This is still very early!
|
215
272
|
- More in future probably?
|
216
273
|
|
217
|
-
## Usage
|
218
|
-
Basically nothing will work :). See files in `test` and `bench` for examples.
|
219
|
-
|
220
|
-
### Setup
|
221
|
-
1. Clone this repo
|
222
|
-
2. `npm install` - for parser(s)
|
223
|
-
|
224
|
-
### Running a file
|
225
|
-
The repos comes with easy alias files for Unix and Windows, which you can use like so:
|
226
|
-
- Unix: `./porf path/to/script.js`
|
227
|
-
- Windows: `.\porf path/to/script.js`
|
228
|
-
|
229
|
-
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.
|
230
|
-
|
231
|
-
### Trying a REPL
|
232
|
-
**`./porf`**. Just run it with no script file argument.
|
233
|
-
|
234
|
-
### Compiling to native binaries
|
235
|
-
> [!WARNING]
|
236
|
-
> Compiling to native binaries uses [2c](#2c), Porffor's own Wasm->C compiler, which is experimental.
|
237
|
-
|
238
|
-
**`./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.
|
239
|
-
|
240
|
-
### Compiling to C
|
241
|
-
> [!WARNING]
|
242
|
-
> Compiling to C uses [2c](#2c), Porffor's own Wasm->C compiler, which is experimental.
|
243
|
-
|
244
|
-
**`./porf c path/to/script.js (out.c)`**. When not including an output file, it will be printed to stdout instead.
|
245
|
-
|
246
|
-
### Compiling to a Wasm binary
|
247
|
-
**`./porf compile path/to/script.js out.wasm`**. Currently it does not use an import standard like WASI, so it is mostly unusable.
|
248
|
-
|
249
|
-
### Options
|
250
|
-
- `-target=wasm|c|native` (default: `wasm`) to set target output (native compiles c output to binary, see args below)
|
251
|
-
- `-target=c|native` only:
|
252
|
-
- `-o=out.c|out.exe|out` to set file to output c or binary
|
253
|
-
- `-target=native` only:
|
254
|
-
- `-compiler=clang` to set compiler binary (path/name) to use to compile
|
255
|
-
- `-cO=O3` to set compiler opt argument
|
256
|
-
- `-parser=acorn|@babel/parser|meriyah|hermes-parser` (default: `acorn`) to set which parser to use
|
257
|
-
- `-parse-types` to enable parsing type annotations/typescript. if `-parser` is unset, changes default to `@babel/parser`. does not type check
|
258
|
-
- `-opt-types` to perform optimizations using type annotations as compiler hints. does not type check
|
259
|
-
- `-valtype=i32|i64|f64` (default: `f64`) to set valtype
|
260
|
-
- `-O0` to disable opt
|
261
|
-
- `-O1` (default) to enable basic opt (simplify insts, treeshake wasm imports)
|
262
|
-
- `-O2` to enable advanced opt (inlining). unstable
|
263
|
-
- `-O3` to enable advanceder opt (precompute const math). unstable
|
264
|
-
- `-no-run` to not run wasm output, just compile
|
265
|
-
- `-opt-log` to log some opts
|
266
|
-
- `-code-log` to log some codegen (you probably want `-funcs`)
|
267
|
-
- `-regex-log` to log some regex
|
268
|
-
- `-funcs` to log funcs
|
269
|
-
- `-ast-log` to log AST
|
270
|
-
- `-opt-funcs` to log funcs after opt
|
271
|
-
- `-sections` to log sections as hex
|
272
|
-
- `-opt-no-inline` to not inline any funcs
|
273
|
-
- `-tail-call` to enable tail calls (experimental + not widely implemented)
|
274
|
-
- `-compile-hints` to enable V8 compilation hints (experimental + doesn't seem to do much?)
|
275
|
-
|
276
274
|
## VSCode extension
|
277
275
|
There is a vscode extension in `porffor-for-vscode` which tweaks JS syntax highlighting to be nicer with porffor features (eg highlighting wasm inside of inline asm).
|
278
276
|
|
package/package.json
CHANGED