porffor 0.50.23 → 0.50.25
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 +9 -55
- package/compiler/index.js +0 -4
- package/package.json +1 -1
- package/runner/index.js +1 -1
- package/compiler/diagram.js +0 -31
package/README.md
CHANGED
@@ -67,7 +67,7 @@ Expect nothing to work! Only very limited JS is currently supported. See files i
|
|
67
67
|
- `-O2` to enable advanced opt (partial evaluation). unstable!
|
68
68
|
|
69
69
|
## Current limitations
|
70
|
-
- Limited async support
|
70
|
+
- Limited async support (`Promise` and `await` have known bugs)
|
71
71
|
- No variables between scopes (except args and globals)
|
72
72
|
- No `eval()`/`Function()` etc (since it is AOT)
|
73
73
|
|
@@ -98,41 +98,39 @@ Porffor can run Test262 via some hacks/transforms which remove unsupported featu
|
|
98
98
|
|
99
99
|
## Codebase
|
100
100
|
- `compiler`: contains the compiler itself
|
101
|
-
- `
|
102
|
-
- `
|
103
|
-
- `
|
101
|
+
- `builtins`: built-in apis written in typescript
|
102
|
+
- `2c.js`: custom wasm-to-c engine
|
103
|
+
- `allocator.js`: static/compile-time allocator
|
104
|
+
- `assemble.js`: assembles wasm ops and metadata into a spec-compliant wasm module/file
|
104
105
|
- `builtins.js`: all manually written built-ins of the engine (spec, custom. vars, funcs)
|
105
106
|
- `builtins_object.js`: all the various built-in objects (think `String`, `globalThis`, etc.)
|
106
107
|
- `builtins_precompiled.js`: dynamically generated builtins from the `builtins/` folder
|
107
108
|
- `codegen.js`: code (wasm) generation, ast -> wasm. The bulk of the effort
|
108
109
|
- `cyclone.js`: wasm partial constant evaluator (it is fast and dangerous hence "cyclone")
|
109
110
|
- `decompile.js`: basic wasm decompiler for debug info
|
110
|
-
- `diagram.js`: produces [Mermaid](https://mermaid.js.org) graphs
|
111
111
|
- `embedding.js`: utils for embedding consts
|
112
112
|
- `encoding.js`: utils for encoding things as bytes as wasm expects
|
113
113
|
- `expression.js`: mapping most operators to an opcode (advanced are as built-ins eg `f64_%`)
|
114
114
|
- `havoc.js`: wasm rewrite library (it wreaks havoc upon wasm bytecode hence "havoc")
|
115
115
|
- `index.js`: doing all the compiler steps, takes code in, wasm out
|
116
116
|
- `opt.js`: self-made wasm bytecode optimizer
|
117
|
-
- `parse.js`: parser simply wrapping acorn
|
117
|
+
- `parse.js`: parser simply wrapping acorn (or other acorn-like parsers)
|
118
118
|
- `pgo.js`: a profile guided optimizer
|
119
119
|
- `precompile.js`: the tool to generate `builtins_precompied.js`
|
120
120
|
- `prefs.js`: a utility to read command line arguments
|
121
|
-
- `prototype.js`: some builtin prototype functions
|
121
|
+
- `prototype.js`: some builtin prototype functions (~legacy)
|
122
122
|
- `types.js`: definitions for each of the builtin types
|
123
123
|
- `wasmSpec.js`: "enums"/info from wasm spec
|
124
124
|
- `wrap.js`: wrapper for compiler which instantiates and produces nice exports
|
125
125
|
|
126
126
|
- `runner`: contains utils for running JS with the compiler
|
127
127
|
- `index.js`: the main file, you probably want to use this
|
128
|
-
- `info.js`: runs with extra info printed
|
129
128
|
- `repl.js`: basic repl (uses `node:repl`)
|
130
129
|
|
131
130
|
- `rhemyn`: contains [Rhemyn](#rhemyn) - our regex engine (used by Porffor)
|
132
|
-
- `compile.js`: compiles regex ast into wasm bytecode
|
131
|
+
- `compile.js`: compiles regex ast into wasm bytecode aot
|
133
132
|
- `parse.js`: own regex parser
|
134
133
|
|
135
|
-
- `test`: contains many test files for majority of supported features
|
136
134
|
- `test262`: test262 runner and utils
|
137
135
|
|
138
136
|
## Usecases
|
@@ -143,38 +141,6 @@ Currently, Porffor is seriously limited in features and functionality, however i
|
|
143
141
|
- Potential for SIMD operations and other lower level concepts.
|
144
142
|
- More in future probably?
|
145
143
|
|
146
|
-
## Todo
|
147
|
-
No particular order and no guarantees, just what could happen soon™
|
148
|
-
|
149
|
-
- Asur
|
150
|
-
- Support memory
|
151
|
-
- Support exceptions
|
152
|
-
- Exceptions
|
153
|
-
- Rethrowing inside catch
|
154
|
-
- Optimizations
|
155
|
-
- Rewrite local indexes per func for smallest local header and remove unused idxs
|
156
|
-
- Smarter inline selection (snapshots?)
|
157
|
-
- Memory alignment
|
158
|
-
- Runtime
|
159
|
-
- WASI target
|
160
|
-
- Run precompiled Wasm file if given
|
161
|
-
- Cool proposals
|
162
|
-
- [Optional Chaining Assignment](https://github.com/tc39/proposal-optional-chaining-assignment)
|
163
|
-
- [Modulus and Additional Integer Math](https://github.com/tc39/proposal-integer-and-modulus-math)
|
164
|
-
- [Array Equality](https://github.com/tc39/proposal-array-equality)
|
165
|
-
- [Declarations in Conditionals](https://github.com/tc39/proposal-Declarations-in-Conditionals)
|
166
|
-
- [Seeded Pseudo-Random Numbers](https://github.com/tc39/proposal-seeded-random)
|
167
|
-
- [`do` expressions](https://github.com/tc39/proposal-do-expressions)
|
168
|
-
- [String Trim Characters](https://github.com/Kingwl/proposal-string-trim-characters)
|
169
|
-
- Posts
|
170
|
-
- Inlining investigation
|
171
|
-
- JS -> Native
|
172
|
-
- Precompiled TS built-ins
|
173
|
-
- Asur
|
174
|
-
- `escape()` optimization
|
175
|
-
- PGO
|
176
|
-
- Self hosted testing?
|
177
|
-
|
178
144
|
## Wasm proposals used
|
179
145
|
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.
|
180
146
|
|
@@ -184,20 +150,8 @@ Porffor intentionally does not use Wasm proposals which are not commonly impleme
|
|
184
150
|
- Exception handling (optional, only for errors)
|
185
151
|
- Tail calls (opt-in, off by default)
|
186
152
|
|
187
|
-
##
|
188
|
-
|
189
|
-
### 1. Why the name?
|
153
|
+
## The name
|
190
154
|
`purple` in Welsh is `porffor`. Why purple?
|
191
155
|
- No other JS engine is purple colored
|
192
156
|
- Purple is pretty cool
|
193
157
|
- Purple apparently represents "ambition", which is one word to describe this project
|
194
|
-
|
195
|
-
### 2. Why at all?
|
196
|
-
Yes!
|
197
|
-
|
198
|
-
### 3. Isn't this the same as AssemblyScript/other Wasm langs?
|
199
|
-
No. they are not alike at all internally and have very different goals/ideals:
|
200
|
-
- Porffor is made as a generic JS engine, not for Wasm stuff specifically
|
201
|
-
- Porffor primarily consumes JS
|
202
|
-
- Porffor is written in pure JS and compiles itself, not using Binaryen/etc
|
203
|
-
- (Also I didn't know it existed when I started this, lol)
|
package/compiler/index.js
CHANGED
@@ -9,7 +9,6 @@ import toc from './2c.js';
|
|
9
9
|
import * as pgo from './pgo.js';
|
10
10
|
import cyclone from './cyclone.js';
|
11
11
|
import './prefs.js';
|
12
|
-
import * as Diagram from './diagram.js';
|
13
12
|
|
14
13
|
globalThis.decompile = decompile;
|
15
14
|
|
@@ -188,9 +187,6 @@ export default (code, module = undefined) => {
|
|
188
187
|
}
|
189
188
|
};
|
190
189
|
print(data);
|
191
|
-
|
192
|
-
// const url = Diagram.url(Diagram.tree(data));
|
193
|
-
// console.log(`built-in tree: ${url}`);
|
194
190
|
}
|
195
191
|
|
196
192
|
if (logProgress) progressStart('assembling...');
|
package/package.json
CHANGED
package/runner/index.js
CHANGED
package/compiler/diagram.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
export const tree = data => {
|
2
|
-
let out = 'flowchart LR\n';
|
3
|
-
let ids = new Map();
|
4
|
-
|
5
|
-
const run = (x, parent = null) => {
|
6
|
-
for (const [ name, children ] of x) {
|
7
|
-
const alreadyHas = ids.has(name);
|
8
|
-
if (!alreadyHas) ids.set(name, ids.size);
|
9
|
-
const id = ids.get(name);
|
10
|
-
|
11
|
-
if (!alreadyHas || parent != null) {
|
12
|
-
if (parent != null) out += `${parent}-->`;
|
13
|
-
out += `${id}${alreadyHas ? '' : `["${name}"]`}\n`;
|
14
|
-
}
|
15
|
-
|
16
|
-
if (children) run(children, id);
|
17
|
-
}
|
18
|
-
};
|
19
|
-
run(data);
|
20
|
-
|
21
|
-
return out;
|
22
|
-
};
|
23
|
-
|
24
|
-
export const url = code => `https://mermaid.live/view#${btoa(JSON.stringify({
|
25
|
-
mermaid: code.length > 10000 ? { theme: 'dark', securityLevel: 'loose', maxEdges: 5000 } : { theme: 'dark' },
|
26
|
-
updateDiagram: true,
|
27
|
-
autoSync: true,
|
28
|
-
rough: false,
|
29
|
-
panZoom: true,
|
30
|
-
code
|
31
|
-
}))}`;
|