porffor 0.50.22 → 0.50.24
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 +7 -52
- package/compiler/codegen.js +13 -12
- package/package.json +2 -2
- package/runner/index.js +1 -1
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
|
|
@@ -99,8 +99,8 @@ Porffor can run Test262 via some hacks/transforms which remove unsupported featu
|
|
99
99
|
## Codebase
|
100
100
|
- `compiler`: contains the compiler itself
|
101
101
|
- `2c.js`: porffor's custom wasm-to-c engine
|
102
|
-
- `allocators.js`: static
|
103
|
-
- `assemble.js`: assembles wasm ops and metadata into a wasm module/file
|
102
|
+
- `allocators.js`: static/compile-time allocator
|
103
|
+
- `assemble.js`: assembles wasm ops and metadata into a spec-compliant wasm module/file
|
104
104
|
- `builtins.js`: all manually written built-ins of the engine (spec, custom. vars, funcs)
|
105
105
|
- `builtins_object.js`: all the various built-in objects (think `String`, `globalThis`, etc.)
|
106
106
|
- `builtins_precompiled.js`: dynamically generated builtins from the `builtins/` folder
|
@@ -114,22 +114,21 @@ Porffor can run Test262 via some hacks/transforms which remove unsupported featu
|
|
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
134
|
- `test`: contains many test files for majority of supported features
|
@@ -143,38 +142,6 @@ Currently, Porffor is seriously limited in features and functionality, however i
|
|
143
142
|
- Potential for SIMD operations and other lower level concepts.
|
144
143
|
- More in future probably?
|
145
144
|
|
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
145
|
## Wasm proposals used
|
179
146
|
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
147
|
|
@@ -184,20 +151,8 @@ Porffor intentionally does not use Wasm proposals which are not commonly impleme
|
|
184
151
|
- Exception handling (optional, only for errors)
|
185
152
|
- Tail calls (opt-in, off by default)
|
186
153
|
|
187
|
-
##
|
188
|
-
|
189
|
-
### 1. Why the name?
|
154
|
+
## The name
|
190
155
|
`purple` in Welsh is `porffor`. Why purple?
|
191
156
|
- No other JS engine is purple colored
|
192
157
|
- Purple is pretty cool
|
193
158
|
- 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/codegen.js
CHANGED
@@ -1697,14 +1697,12 @@ const getNodeType = (scope, node) => {
|
|
1697
1697
|
}
|
1698
1698
|
|
1699
1699
|
if (node.type === 'MetaProperty') {
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
}
|
1704
|
-
|
1705
|
-
default:
|
1706
|
-
return todo(scope, `meta property object ${node.meta.name} is not supported yet`, true);
|
1700
|
+
if (scope.constr && node.meta.name === 'new' && node.property.name === 'target') {
|
1701
|
+
// new.target
|
1702
|
+
return [ [ Opcodes.local_get, scope.locals['#newtarget#type'].idx ] ];
|
1707
1703
|
}
|
1704
|
+
|
1705
|
+
return TYPES.undefined;
|
1708
1706
|
}
|
1709
1707
|
|
1710
1708
|
if (node.type === 'SequenceExpression') {
|
@@ -5295,14 +5293,17 @@ const generateEmpty = (scope, decl) => {
|
|
5295
5293
|
};
|
5296
5294
|
|
5297
5295
|
const generateMeta = (scope, decl) => {
|
5298
|
-
|
5299
|
-
|
5300
|
-
|
5296
|
+
if (decl.meta.name === 'new' && decl.property.name === 'target') {
|
5297
|
+
// new.target
|
5298
|
+
if (scope.constr) return [
|
5299
|
+
[ Opcodes.local_get, scope.locals['#newtarget'].idx ]
|
5301
5300
|
];
|
5302
5301
|
|
5303
|
-
|
5304
|
-
|
5302
|
+
// not constructor so does not exist, return undefined
|
5303
|
+
return [ number(UNDEFINED) ];
|
5305
5304
|
}
|
5305
|
+
|
5306
|
+
return todo(scope, `meta property object ${decl.meta.name} is not supported yet`, true);
|
5306
5307
|
};
|
5307
5308
|
|
5308
5309
|
let pages = new Map();
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "porffor",
|
3
3
|
"description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
|
4
|
-
"version": "0.50.
|
4
|
+
"version": "0.50.24",
|
5
5
|
"author": "CanadaHonk",
|
6
6
|
"license": "MIT",
|
7
7
|
"scripts": {},
|
8
8
|
"dependencies": {
|
9
|
-
"acorn": "^8.
|
9
|
+
"acorn": "^8.14.0",
|
10
10
|
"node-repl-polyfill": "^0.1.1"
|
11
11
|
},
|
12
12
|
"optionalDependencies": {
|