porffor 0.2.0-6aff0fa → 0.2.0-767de65
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/.vscode/launch.json +18 -0
- package/LICENSE +20 -20
- package/README.md +54 -41
- package/asur/index.js +624 -340
- package/byg/index.js +237 -0
- package/compiler/2c.js +1 -1
- package/compiler/{sections.js → assemble.js} +57 -10
- 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 +3 -5
- package/compiler/builtins/crypto.ts +120 -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 +27 -8
- package/compiler/builtins/string.ts +1055 -0
- package/compiler/builtins/tostring.ts +45 -0
- package/compiler/builtins.js +405 -108
- package/compiler/{codeGen.js → codegen.js} +654 -246
- package/compiler/embedding.js +22 -22
- package/compiler/encoding.js +108 -10
- package/compiler/generated_builtins.js +682 -2
- package/compiler/index.js +16 -14
- package/compiler/log.js +2 -2
- package/compiler/opt.js +23 -22
- package/compiler/parse.js +31 -25
- package/compiler/precompile.js +19 -25
- package/compiler/prefs.js +2 -2
- package/compiler/prototype.js +2 -18
- package/compiler/types.js +37 -0
- package/compiler/wasmSpec.js +13 -1
- package/compiler/wrap.js +36 -42
- package/empty.js +0 -0
- package/hello.js +2 -0
- package/package.json +9 -5
- package/porf +2 -0
- package/rhemyn/compile.js +3 -2
- package/rhemyn/parse.js +323 -320
- package/rhemyn/test/parse.js +58 -58
- package/runner/compare.js +34 -34
- package/runner/debug.js +122 -0
- package/runner/index.js +26 -10
- package/runner/profiler.js +45 -26
- package/runner/repl.js +40 -7
- package/runner/sizes.js +37 -37
- package/test262_changes_from_1afe9b87d2_to_04-09.md +270 -0
- package/runner/info.js +0 -89
- package/runner/transform.js +0 -15
- package/util/enum.js +0 -20
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
3
|
+
// Hover to view descriptions of existing attributes.
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
5
|
+
"version": "0.2.0",
|
6
|
+
"configurations": [
|
7
|
+
{
|
8
|
+
"type": "node",
|
9
|
+
"request": "launch",
|
10
|
+
"name": "Launch Program",
|
11
|
+
"skipFiles": [
|
12
|
+
"<node_internals>/**"
|
13
|
+
],
|
14
|
+
"program": "${workspaceFolder}/runner/index.js",
|
15
|
+
"args": ["bench/bf.js", "-no-run"]
|
16
|
+
}
|
17
|
+
]
|
18
|
+
}
|
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
@@ -150,20 +150,24 @@ These include some early (stage 1/0) and/or dead (last commit years ago) proposa
|
|
150
150
|
- `for...of` (arrays and strings)
|
151
151
|
- Array member setting (`arr[0] = 2`, `arr[0] += 2`, etc)
|
152
152
|
- Array constructor (`Array(5)`, `new Array(1, 2, 3)`)
|
153
|
+
- Labelled statements (`foo: while (...)`)
|
153
154
|
|
154
155
|
### Built-ins
|
155
156
|
|
156
157
|
- `NaN` and `Infinity` (f64 only)
|
157
158
|
- `isNaN()` and `isFinite()` (f64 only)
|
158
159
|
- Most of `Number` (`MAX_VALUE`, `MIN_VALUE`, `MAX_SAFE_INTEGER`, `MIN_SAFE_INTEGER`, `POSITIVE_INFINITY`, `NEGATIVE_INFINITY`, `EPSILON`, `NaN`, `isNaN`, `isFinite`, `isInteger`, `isSafeInteger`) (some f64 only)
|
159
|
-
- Some `Math` funcs (`
|
160
|
+
- Some `Math` funcs (`sqrt`, `abs`, `floor`, `sign`, `round`, `trunc`, `clz32`, `fround`, `random`) (f64 only)
|
160
161
|
- Basic `globalThis` support
|
161
162
|
- Basic `Boolean` and `Number`
|
162
163
|
- Basic `eval` for literals
|
163
164
|
- `Math.random()` using self-made xorshift128+ PRNG
|
164
165
|
- Some of `performance` (`now()`)
|
165
166
|
- Some of `Array.prototype` (`at`, `push`, `pop`, `shift`, `fill`)
|
167
|
+
- Some of `Array` (`of`, `isArray`)
|
166
168
|
- Some of `String.prototype` (`at`, `charAt`, `charCodeAt`)
|
169
|
+
- Some of `crypto` (`randomUUID`)
|
170
|
+
- `escape`
|
167
171
|
|
168
172
|
### Custom
|
169
173
|
|
@@ -172,44 +176,6 @@ These include some early (stage 1/0) and/or dead (last commit years ago) proposa
|
|
172
176
|
- Intrinsic functions (see below)
|
173
177
|
- Inlining wasm via ``asm`...``\` "macro"
|
174
178
|
|
175
|
-
## Todo
|
176
|
-
No particular order and no guarentees, just what could happen soon™
|
177
|
-
|
178
|
-
- Arrays
|
179
|
-
- More of `Array` prototype
|
180
|
-
- Arrays/strings inside arrays
|
181
|
-
- Destructuring
|
182
|
-
- Objects
|
183
|
-
- Basic object expressions (eg `{}`, `{ a: 0 }`)
|
184
|
-
- Wasm
|
185
|
-
- *Basic* Wasm engine (interpreter) in JS
|
186
|
-
- More math operators (`**`, etc)
|
187
|
-
- `do { ... } while (...)`
|
188
|
-
- Typed export inputs (array)
|
189
|
-
- Exceptions
|
190
|
-
- Rewrite to use actual strings (optional?)
|
191
|
-
- `try { } finally { }`
|
192
|
-
- Rethrowing inside catch
|
193
|
-
- Optimizations
|
194
|
-
- Rewrite local indexes per func for smallest local header and remove unused idxs
|
195
|
-
- Smarter inline selection (snapshots?)
|
196
|
-
- Remove const ifs (`if (true)`, etc)
|
197
|
-
- Memory alignment
|
198
|
-
- Runtime
|
199
|
-
- WASI target
|
200
|
-
- Run precompiled Wasm file if given
|
201
|
-
- Cool proposals
|
202
|
-
- [Optional Chaining Assignment](https://github.com/tc39/proposal-optional-chaining-assignment)
|
203
|
-
- [Modulus and Additional Integer Math](https://github.com/tc39/proposal-integer-and-modulus-math)
|
204
|
-
- [Array Equality](https://github.com/tc39/proposal-array-equality)
|
205
|
-
- [Declarations in Conditionals](https://github.com/tc39/proposal-Declarations-in-Conditionals)
|
206
|
-
- [Seeded Pseudo-Random Numbers](https://github.com/tc39/proposal-seeded-random)
|
207
|
-
- [`do` expressions](https://github.com/tc39/proposal-do-expressions)
|
208
|
-
- [String Trim Characters](https://github.com/Kingwl/proposal-string-trim-characters)
|
209
|
-
- Posts
|
210
|
-
- Inlining investigation
|
211
|
-
- Self hosted testing?
|
212
|
-
|
213
179
|
## Performance
|
214
180
|
*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.
|
215
181
|
|
@@ -246,7 +212,7 @@ Porffor can run Test262 via some hacks/transforms which remove unsupported featu
|
|
246
212
|
## Codebase
|
247
213
|
- `compiler`: contains the compiler itself
|
248
214
|
- `builtins.js`: all built-ins of the engine (spec, custom. vars, funcs)
|
249
|
-
- `
|
215
|
+
- `codegen.js`: code (wasm) generation, ast -> wasm. The bulk of the effort
|
250
216
|
- `decompile.js`: basic wasm decompiler for debug info
|
251
217
|
- `embedding.js`: utils for embedding consts
|
252
218
|
- `encoding.js`: utils for encoding things as bytes as wasm expects
|
@@ -254,7 +220,7 @@ Porffor can run Test262 via some hacks/transforms which remove unsupported featu
|
|
254
220
|
- `index.js`: doing all the compiler steps, takes code in, wasm out
|
255
221
|
- `opt.js`: self-made wasm bytecode optimizer
|
256
222
|
- `parse.js`: parser simply wrapping acorn
|
257
|
-
- `
|
223
|
+
- `assemble.js`: assembles wasm ops and metadata into a wasm module/file
|
258
224
|
- `wasmSpec.js`: "enums"/info from wasm spec
|
259
225
|
- `wrap.js`: wrapper for compiler which instantiates and produces nice exports
|
260
226
|
|
@@ -276,6 +242,53 @@ Basically none right now (other than giving people headaches). Potential ideas:
|
|
276
242
|
- Compiling JS to native binaries. This is still very early!
|
277
243
|
- More in future probably?
|
278
244
|
|
245
|
+
## Todo
|
246
|
+
No particular order and no guarentees, just what could happen soon™
|
247
|
+
|
248
|
+
- Arrays
|
249
|
+
- More of `Array` prototype
|
250
|
+
- Arrays/strings inside arrays
|
251
|
+
- Destructuring
|
252
|
+
- Objects
|
253
|
+
- Basic object expressions (eg `{}`, `{ a: 0 }`)
|
254
|
+
- Asur
|
255
|
+
- Support memory
|
256
|
+
- Support exceptions
|
257
|
+
- More math operators (`**`, etc)
|
258
|
+
- Typed export inputs (array)
|
259
|
+
- Exceptions
|
260
|
+
- Rewrite to use actual strings (optional?)
|
261
|
+
- `try { } finally { }`
|
262
|
+
- Rethrowing inside catch
|
263
|
+
- Optimizations
|
264
|
+
- Rewrite local indexes per func for smallest local header and remove unused idxs
|
265
|
+
- Smarter inline selection (snapshots?)
|
266
|
+
- Remove const ifs (`if (true)`, etc)
|
267
|
+
- Memory alignment
|
268
|
+
- Add general pref for always using "fast" (non-short circuiting) or/and
|
269
|
+
- Runtime
|
270
|
+
- WASI target
|
271
|
+
- Run precompiled Wasm file if given
|
272
|
+
- Docs
|
273
|
+
- Update codebase readme section
|
274
|
+
- REPL
|
275
|
+
- Basic polyfill of `node:repl` for non-Node runtimes to work
|
276
|
+
- Cool proposals
|
277
|
+
- [Optional Chaining Assignment](https://github.com/tc39/proposal-optional-chaining-assignment)
|
278
|
+
- [Modulus and Additional Integer Math](https://github.com/tc39/proposal-integer-and-modulus-math)
|
279
|
+
- [Array Equality](https://github.com/tc39/proposal-array-equality)
|
280
|
+
- [Declarations in Conditionals](https://github.com/tc39/proposal-Declarations-in-Conditionals)
|
281
|
+
- [Seeded Pseudo-Random Numbers](https://github.com/tc39/proposal-seeded-random)
|
282
|
+
- [`do` expressions](https://github.com/tc39/proposal-do-expressions)
|
283
|
+
- [String Trim Characters](https://github.com/Kingwl/proposal-string-trim-characters)
|
284
|
+
- Posts
|
285
|
+
- Inlining investigation
|
286
|
+
- JS -> Native
|
287
|
+
- Precompiled TS built-ins
|
288
|
+
- Asur
|
289
|
+
- `escape()` optimization
|
290
|
+
- Self hosted testing?
|
291
|
+
|
279
292
|
## VSCode extension
|
280
293
|
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).
|
281
294
|
|