porffor 0.21.1 → 0.21.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 CHANGED
@@ -1,6 +1,7 @@
1
1
  # Porffor &nbsp;<sup><sub>/ˈpɔrfɔr/ &nbsp;*(poor-for)*</sup></sub>
2
- A from-scratch experimental **AOT** optimizing JS/TS -> Wasm/C engine/compiler/runtime in JS. Not serious/intended for (real) use. (this is a straight forward, honest readme)<br>
3
- Age: ~6 months (very on and off)
2
+ A from-scratch experimental **AOT** optimizing JS/TS -> Wasm/C engine/compiler/runtime in JS. Not serious/intended for (real) use.<br>
3
+
4
+ <img src="https://github.com/CanadaHonk/porffor/assets/19228318/de8ad753-8ce3-4dcd-838e-f4d49452f8f8" alt="Screenshot of terminal showing Porffor running and compiling a hello world" width="60%">
4
5
 
5
6
  ## Design
6
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,7 +9,7 @@ Porffor is a very unique JS engine, due many wildly different approaches. It is
8
9
  - No constant runtime/preluded code
9
10
  - Least Wasm imports possible (only I/O)
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
+ 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.
12
13
 
13
14
  ## Usage
14
15
  Expect nothing to work! Only very limited JS is currently supported. See files in `bench` for examples.
@@ -218,6 +219,8 @@ Mostly for reducing size. I do not really care about compiler perf/time as long
218
219
  ## Test262
219
220
  Porffor can run Test262 via some hacks/transforms which remove unsupported features whilst still doing the same asserts (eg simpler error messages using literals only). It currently passes >14% (see latest commit desc for latest and details). Use `node test262` to test, it will also show a difference of overall results between the last commit and current results.
220
221
 
222
+ ![image](https://github.com/CanadaHonk/porffor/assets/19228318/5320da7d-e945-4d16-857b-499f3a6c1180)
223
+
221
224
  ## Codebase
222
225
  - `compiler`: contains the compiler itself
223
226
  - `builtins.js`: all built-ins of the engine (spec, custom. vars, funcs)
package/compiler/2c.js CHANGED
@@ -811,7 +811,7 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
811
811
  break;
812
812
  }
813
813
 
814
- log.warning('2c', `unimplemented op: ${invOpcodes[i[0]]} \x1b[90m(${f.name})`);
814
+ // log.warning('2c', `unimplemented op: ${invOpcodes[i[0]]} \x1b[90m(${f.name})`);
815
815
  }
816
816
 
817
817
  lastCond = false;
@@ -261,6 +261,25 @@ export const __Object_prototype_propertyIsEnumerable = (_this: any, prop: any) =
261
261
  };
262
262
 
263
263
 
264
+ export const __Object_is = (x: any, y: any): boolean => {
265
+ if (x === y) {
266
+ if (x == 0) {
267
+ // check +0 vs -0
268
+ return 1 / x == 1 / y;
269
+ }
270
+
271
+ return true;
272
+ }
273
+
274
+ // check NaN
275
+ if (Porffor.rawType(x) == Porffor.TYPES.number && Number.isNaN(x)) {
276
+ return Number.isNaN(y);
277
+ }
278
+
279
+ return false;
280
+ };
281
+
282
+
264
283
  export const __Object_prototype_toString = (_this: object) => {
265
284
  let out: bytestring = '[object Object]';
266
285
  return out;
@@ -1707,6 +1707,12 @@ export const BuiltinFuncs = function() {
1707
1707
  returns: [124,127], typedReturns: 1,
1708
1708
  locals: [124,127,127,124,124,124], localNames: ["_this","_this#type","prop","prop#type","p","p#type","#last_type","t","entryPtr","keys"],
1709
1709
  };
1710
+ this.__Object_is = {
1711
+ wasm: (scope, {builtin}) => [[2,127,"string_only"],[32,0],[34,4,"string_only"],[32,2],[34,5,"string_only"],[32,1,"string_only|start"],[65,195,1],[70],[32,3],[65,195,1],[70],[113],[4,64],[32,4],[252,3],[34,6],[32,5],[252,3],[34,8],[71],[4,127],[32,6],[40,0,0],[34,7],[32,8],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,9],[32,7],[33,10],[3,64],[32,9],[32,6],[106],[45,0,4],[32,9],[32,8],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,9],[65,1],[106],[34,9],[32,10],[72],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,1],[65,195,0],[70],[32,1],[65,195,1],[70],[114],[32,3],[65,195,0],[70],[32,3],[65,195,1],[70],[114],[114],[4,64],[32,4],[252,3],[34,6],[32,5],[252,3],[34,8],[71],[4,127],[32,6],[40,0,0],[34,7],[32,8],[40,0,0],[32,1],[65,195,1],[70],[4,64],[32,6],[32,7],[16, ...builtin('__Porffor_bytestringToString')],[33,6],[11],[32,3],[65,195,1],[70],[4,64],[32,8],[32,8],[40,0,0],[16, ...builtin('__Porffor_bytestringToString')],[33,8],[11],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,9],[32,7],[65,2],[108],[33,10],[3,64],[32,9],[32,6],[106],[47,0,4],[32,9],[32,8],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,9],[65,2],[106],[34,9],[32,10],[72],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,1],[65,128,1],[114],[32,3],[65,128,1],[114],[70],[113],[4,64],[32,0],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,240,63],[32,0],[163],[68,0,0,0,0,0,0,240,63],[32,2],[163],[97],[184],[65,2],[15],[11],[68,0,0,0,0,0,0,240,63],[65,2],[15],[11],[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,240,63],[97],[184],[34,11],[252,3],[4,124],[32,0],[16, ...builtin('__Number_isNaN')],[65,2],[33,12],[5],[32,11],[65,2],[33,12],[11],[33,13],[32,12],[33,14],[2,127],[32,14],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,13],[252,3],[40,1,0],[12,1],[11],[32,14],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,13],[252,3],[40,1,0],[12,1],[11],[32,13],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,2],[16, ...builtin('__Number_isNaN')],[65,2],[15],[11],[68,0,0,0,0,0,0,0,0],[65,2],[15]],
1712
+ params: [124,127,124,127], typedParams: 1,
1713
+ returns: [124,127], typedReturns: 1,
1714
+ locals: [124,124,127,127,127,127,127,124,127,124,127], localNames: ["x","x#type","y","y#type","__tmpop_left","__tmpop_right","compare_left_pointer","compare_left_length","compare_right_pointer","compare_index","compare_index_end","logictmp","#last_type","#logicinner_tmp","#typeswitch_tmp"],
1715
+ };
1710
1716
  this.__Object_prototype_toString = {
1711
1717
  wasm: (scope, {allocPage}) => [...number(allocPage(scope, 'bytestring: __Object_prototype_toString/out', 'i8') * pageSize, 124),[34,2],[65,195,1],[15]],
1712
1718
  params: [124,127], typedParams: 1,
package/package.json CHANGED
@@ -1,7 +1,7 @@
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.21.1+340e8d4dd",
4
+ "version": "0.21.3+bc501abaf",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.21.1+340e8d4dd';
3
+ globalThis.version = '0.21.3+bc501abaf';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {