porffor 0.58.1 → 0.58.3
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 +6 -6
- package/compiler/codegen.js +3 -2
- package/compiler/index.js +17 -9
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/runtime/index.js +5 -5
- package/asur/README.md +0 -2
- package/asur/index.js +0 -1262
- package/regex_notes.md +0 -74
- package/richards_direct.js +0 -558
package/README.md
CHANGED
@@ -5,8 +5,8 @@ A from-scratch experimental **AOT** optimizing JS/TS -> Wasm/C engine/compiler/r
|
|
5
5
|
|
6
6
|
## Design
|
7
7
|
Porffor is a very unique JS engine, due many wildly different approaches. It is seriously limited, but what it can do, it does pretty well. Key differences:
|
8
|
-
- 100% AOT compiled (no JIT)
|
9
|
-
-
|
8
|
+
- 100% AOT compiled (no JIT or interpreter)
|
9
|
+
- Zero constant runtime/preluded code
|
10
10
|
- Least Wasm imports possible (only I/O)
|
11
11
|
|
12
12
|
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.
|
@@ -50,11 +50,11 @@ Expect nothing to work! Only very limited JS is currently supported. See files i
|
|
50
50
|
|
51
51
|
**`porf debug path/to/script.js`**
|
52
52
|
|
53
|
-
### Debugging the compiled Wasm of a JS file
|
53
|
+
<!-- ### Debugging the compiled Wasm of a JS file
|
54
54
|
> [!WARNING]
|
55
55
|
> Very experimental WIP feature!
|
56
56
|
|
57
|
-
**`porf dissect path/to/script.js`**
|
57
|
+
**`porf dissect path/to/script.js`** -->
|
58
58
|
|
59
59
|
|
60
60
|
### Options
|
@@ -73,8 +73,8 @@ Expect nothing to work! Only very limited JS is currently supported. See files i
|
|
73
73
|
|
74
74
|
## Sub-engines
|
75
75
|
|
76
|
-
### Asur
|
77
|
-
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.
|
76
|
+
<!-- ### Asur
|
77
|
+
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. -->
|
78
78
|
|
79
79
|
### 2c
|
80
80
|
2c is Porffor's own Wasm -> C compiler, using generated Wasm bytecode and internal info to generate specific and efficient C code. Little boilerplate/preluded code or required external files, just for CLI binaries (not like wasm2c very much).
|
package/compiler/codegen.js
CHANGED
@@ -1760,7 +1760,7 @@ const getNodeType = (scope, node) => {
|
|
1760
1760
|
const out = typeof ret === 'number' ? [ number(ret, Valtype.i32) ] : ret;
|
1761
1761
|
if (guess != null) out.guess = typeof guess === 'number' ? [ number(guess, Valtype.i32) ] : guess;
|
1762
1762
|
|
1763
|
-
typeUsed(scope, knownType(scope, out));
|
1763
|
+
if (!node._doNotMarkTypeUsed) typeUsed(scope, knownType(scope, out));
|
1764
1764
|
return out;
|
1765
1765
|
};
|
1766
1766
|
|
@@ -2595,7 +2595,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2595
2595
|
args = args.slice(0, paramCount - 1);
|
2596
2596
|
args.push({
|
2597
2597
|
type: 'ArrayExpression',
|
2598
|
-
elements: restArgs
|
2598
|
+
elements: restArgs,
|
2599
|
+
_doNotMarkTypeUsed: true
|
2599
2600
|
});
|
2600
2601
|
}
|
2601
2602
|
}
|
package/compiler/index.js
CHANGED
@@ -253,11 +253,19 @@ export default (code, module = undefined) => {
|
|
253
253
|
const compiler = (Prefs.compiler ?? process.env.CC ?? 'cc').split(' ');
|
254
254
|
const cO = Prefs._cO ?? 'O3';
|
255
255
|
|
256
|
-
const
|
257
|
-
|
256
|
+
const args = [
|
257
|
+
...compiler,
|
258
|
+
'-xc', '-', // use stdin as c source in
|
259
|
+
'-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), // set path for output
|
258
260
|
|
259
|
-
|
260
|
-
|
261
|
+
// default cc args, always
|
262
|
+
'-lm', // link math.h
|
263
|
+
'-fno-exceptions', // disable exceptions
|
264
|
+
'-fno-ident', '-ffunction-sections', '-fdata-sections', // remove unneeded binary sections
|
265
|
+
'-' + cO
|
266
|
+
];
|
267
|
+
|
268
|
+
if (Prefs.clangFast) args.push('-flto=thin', '-march=native', '-ffast-math', '-fno-asynchronous-unwind-tables');
|
261
269
|
|
262
270
|
if (Prefs.s) args.push('-s');
|
263
271
|
|
@@ -269,12 +277,12 @@ export default (code, module = undefined) => {
|
|
269
277
|
if (logProgress) progressStart(`compiling C to native (using ${compiler})...`);
|
270
278
|
const t5 = performance.now();
|
271
279
|
|
272
|
-
fs.writeFileSync(tmpfile, c);
|
273
|
-
|
274
280
|
// obvious command escape is obvious
|
275
|
-
execSync(args.join(' '), {
|
276
|
-
|
277
|
-
|
281
|
+
execSync(args.join(' '), {
|
282
|
+
stdio: [ 'pipe', 'inherit', 'inherit' ],
|
283
|
+
input: c,
|
284
|
+
encoding: 'utf8'
|
285
|
+
});
|
278
286
|
|
279
287
|
if (logProgress) progressStart(`compiled C to native (using ${compiler})`, t5);
|
280
288
|
|
package/jsr.json
CHANGED
package/package.json
CHANGED
package/runtime/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import fs from 'node:fs';
|
3
|
-
globalThis.version = '0.58.
|
3
|
+
globalThis.version = '0.58.3';
|
4
4
|
|
5
5
|
// deno compat
|
6
6
|
if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
|
@@ -27,7 +27,7 @@ if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
27
27
|
'Analyze': [],
|
28
28
|
profile: [ 93, 'foo.js', 'View detailed func-by-func performance' ],
|
29
29
|
debug: [ 33, 'foo.js', 'Debug the source of a file' ],
|
30
|
-
dissect: [ 33, 'foo.js', 'Debug the compiled Wasm of a file' ],
|
30
|
+
// dissect: [ 33, 'foo.js', 'Debug the compiled Wasm of a file' ],
|
31
31
|
})) {
|
32
32
|
if (color == null) {
|
33
33
|
// header
|
@@ -113,9 +113,9 @@ if (['precompile', 'run', 'wasm', 'native', 'c', 'profile', 'debug', 'dissect'].
|
|
113
113
|
process.argv.push(`--target=${file}`);
|
114
114
|
}
|
115
115
|
|
116
|
-
if (file === 'dissect') {
|
117
|
-
|
118
|
-
}
|
116
|
+
// if (file === 'dissect') {
|
117
|
+
// process.argv.push('--asur', '--wasm-debug');
|
118
|
+
// }
|
119
119
|
|
120
120
|
file = process.argv.slice(2).find(x => x[0] !== '-');
|
121
121
|
|
package/asur/README.md
DELETED