porffor 0.41.0 → 0.41.2

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.
@@ -1,3 +1,3 @@
1
- const uniq = [...new Set(require('../nova.json').pass.map(x => x.slice(5))).difference(new Set(require('./test262/results.json').passes))];
1
+ const uniq = [...new Set(require('../hermes.json').pass.map(x => x.slice(5))).difference(new Set(require('./test262/results.json').passes))];
2
2
  console.log([...uniq.reduce((acc, x) => { let k = x.split('/').slice(0, -1).join('/'); return acc.set(k, (acc.get(k) || 0) + 1); }, new Map()).entries()].sort((a, b) => a[1] - b[1]).slice(-20).map(x => x[0] + ': ' + x[1]).join('\n'));
3
3
  console.log(uniq.filter(x => x.startsWith('built-ins/Object/defineProperty')).join('\n'))
@@ -13,6 +13,9 @@ export const __Porffor_object_underlying = (obj: any): any => {
13
13
  }
14
14
 
15
15
  if (Porffor.fastAnd(t > 0x05, t != Porffor.TYPES.undefined)) {
16
+ // this causes memory corruption things in some situations in test262?
17
+ // let idx: i32 = Porffor.array.fastIndexOf(underlyingKeys, obj);
18
+
16
19
  let idx: i32 = underlyingKeys.indexOf(obj);
17
20
  if (idx == -1) {
18
21
  const underlying: object = {};
@@ -68,13 +68,6 @@ export const __Array_from = (arg: any, mapFn: any): any[] => {
68
68
  return out;
69
69
  };
70
70
 
71
- export const __Porffor_array_fastPush = (arr: any[], el: any): i32 => {
72
- let len: i32 = arr.length;
73
- arr[len] = el;
74
- arr.length = ++len;
75
- return len;
76
- };
77
-
78
71
  export const __Array_prototype_push = (_this: any[], ...items: any[]) => {
79
72
  let len: i32 = _this.length;
80
73
  const itemsLen: i32 = items.length;
@@ -871,4 +864,21 @@ export const __Array_prototype_flat = (_this: any[], _depth: any) => {
871
864
  out.length = j;
872
865
 
873
866
  return out;
867
+ };
868
+
869
+
870
+ export const __Porffor_array_fastPush = (arr: any[], el: any): i32 => {
871
+ let len: i32 = arr.length;
872
+ arr[len] = el;
873
+ arr.length = ++len;
874
+ return len;
875
+ };
876
+
877
+ export const __Porffor_array_fastIndexOf = (arr: any[], el: any): i32 => {
878
+ const len: i32 = arr.length;
879
+ for (let i: i32 = 0; i < len; i++) {
880
+ if (arr[i] === el) return i;
881
+ }
882
+
883
+ return -1;
874
884
  };
@@ -2,8 +2,6 @@ export default () => {
2
2
  let out = '';
3
3
 
4
4
  const error = name => out += `export const ${name} = function (message: any) {
5
- new.target; // trick compiler into allowing as constructor
6
-
7
5
  const _empty: bytestring = '';
8
6
  if (message === undefined) message = _empty;
9
7
  else message = ecma262.ToString(message);
@@ -35,6 +35,7 @@ type PorfforGlobal = {
35
35
 
36
36
  array: {
37
37
  fastPush(arr: any[], el: any): i32;
38
+ fastIndexOf(arr: any[], el: any): i32;
38
39
  }
39
40
 
40
41
  arraybuffer: {
@@ -952,7 +952,7 @@ export const BuiltinFuncs = function() {
952
952
  this.__Porffor_bytestringToString = {
953
953
  params: [ Valtype.i32, Valtype.i32 ],
954
954
  locals: [ Valtype.i32, Valtype.i32 ],
955
- localNames: [ 'src', 'len', '#bytestring_to_string_counter', '#bytestring_to_string_dst' ],
955
+ localNames: [ 'src', 'len', 'counter', 'dst' ],
956
956
  returns: [ Valtype.i32 ],
957
957
  returnType: TYPES.string,
958
958
  wasm: [
@@ -967,10 +967,6 @@ export const BuiltinFuncs = function() {
967
967
  [ Opcodes.local_get, 1 ],
968
968
  [ Opcodes.i32_store, 0, 0 ],
969
969
 
970
- // counter = 0
971
- [ Opcodes.i32_const, 0 ],
972
- [ Opcodes.local_set, 2 ],
973
-
974
970
  [ Opcodes.loop, Blocktype.void ],
975
971
 
976
972
  // base for store later
@@ -347,12 +347,6 @@ locals:[124,124,124,127,124,127,124,124,127,127,127,127,127,124,127,124,127,124,
347
347
  usedTypes:[80,67,195],
348
348
  table:1,
349
349
  };
350
- this.__Porffor_array_fastPush = {
351
- wasm:()=>[[32,0],[252,3],[40,1,0],[184],[33,4],[32,0],[33,7],[32,4],[33,8],[32,7],[252,3],[32,8],[252,3],[65,9],[108],[106],[34,6],[32,2],[34,5],[57,0,4],[32,6],[32,3],[58,0,12],[32,0],[252,3],[34,10],[32,4],[68,1],[160],[34,4],[34,9],[252,3],[54,1,0],[32,4],[65,1],[15]],
352
- params:[124,127,124,127],typedParams:1,returns:[124,127],typedReturns:1,
353
- locals:[124,124,127,124,124,124,127],localNames:["arr","arr#type","el","el#type","len","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_obj","#member_prop_assign","__length_setter_tmp","__member_setter_ptr_tmp"],
354
- usedTypes:[80],
355
- };
356
350
  this.__Array_prototype_push = {
357
351
  wasm:()=>[[32,0],[252,3],[40,1,0],[184],[33,4],[32,2],[252,3],[40,1,0],[184],[33,5],[68,0],[33,6],[3,64],[32,6],[32,5],[99],[4,64],[32,0],[33,9],[32,6],[32,4],[160],[33,10],[32,9],[252,3],[32,10],[252,3],[65,9],[108],[106],[34,8],[32,2],[33,9],[32,6],[34,11],[252,3],[65,9],[108],[32,9],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[33,12],[34,7],[57,0,4],[32,8],[32,12],[58,0,12],[32,6],[68,1],[160],[33,6],[12,1],[11],[11],[32,0],[252,3],[34,15],[32,4],[32,5],[160],[34,14],[252,3],[54,1,0],[32,14],[65,1],[15]],
358
352
  params:[124,127,124,127],typedParams:1,returns:[124,127],typedReturns:1,
@@ -580,6 +574,18 @@ params:[124,127,124,127],typedParams:1,returns:[124,127],typedReturns:1,
580
574
  locals:[124,127,124,124,124,124,124,127,124,124,127,127,127,127,127,124,127,124,127,124,127,124,127,127,124,127],localNames:["_this","_this#type","_depth","_depth#type","depth","#last_type","out","len","i","j","x","x#type","#member_obj","#member_prop","#loadArray_offset","#forof_base_pointer0","#forof_length0","#forof_counter0","#forof_itertype0","#forof_tmp0","#forof_tmp0#type","y","y#type","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_prop_assign","#typeswitch_tmp1","#forof_allocd","__length_setter_tmp","__member_setter_ptr_tmp"],
581
575
  usedTypes:[80,67,195],
582
576
  };
577
+ this.__Porffor_array_fastPush = {
578
+ wasm:()=>[[32,0],[252,3],[40,1,0],[184],[33,4],[32,0],[33,7],[32,4],[33,8],[32,7],[252,3],[32,8],[252,3],[65,9],[108],[106],[34,6],[32,2],[34,5],[57,0,4],[32,6],[32,3],[58,0,12],[32,0],[252,3],[34,10],[32,4],[68,1],[160],[34,4],[34,9],[252,3],[54,1,0],[32,4],[65,1],[15]],
579
+ params:[124,127,124,127],typedParams:1,returns:[124,127],typedReturns:1,
580
+ locals:[124,124,127,124,124,124,127],localNames:["arr","arr#type","el","el#type","len","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_obj","#member_prop_assign","__length_setter_tmp","__member_setter_ptr_tmp"],
581
+ usedTypes:[80],
582
+ };
583
+ this.__Porffor_array_fastIndexOf = {
584
+ wasm:(_,{builtin})=>[[32,0],[252,3],[40,1,0],[184],[33,4],[68,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127],[32,0],[33,6],[32,5],[34,7],[252,3],[65,9],[108],[32,6],[252,3],[106],[34,9],[43,0,4],[32,9],[45,0,12],[33,8],[34,10],[32,2],[34,11],[32,8],[65,128,1],[114],[65,195,1],[70],[32,3],[65,128,1],[114],[65,195,1],[70],[114],[4,64],[32,10],[32,8],[32,11],[32,3],[16,builtin('__Porffor_compareStrings')],[26],[252,3],[12,1],[11],[97],[11],[32,8],[65,128,1],[114],[32,3],[65,128,1],[114],[70],[113],[4,64],[32,5],[65,1],[15],[11],[11],[32,5],[68,1],[160],[33,5],[12,1],[11],[11],[68,-1],[65,1],[15]],
585
+ params:[124,127,124,127],typedParams:1,returns:[124,127],typedReturns:1,
586
+ locals:[124,124,124,124,127,127,124,124],localNames:["arr","arr#type","el","el#type","len","i","#member_obj","#member_prop","#last_type","#loadArray_offset","__tmpop_left","__tmpop_right"],
587
+ usedTypes:[80],
588
+ };
583
589
  this.__ArrayBuffer_isView = {
584
590
  wasm:()=>[[32,1],[184],[34,2],[68,23],[97],[32,2],[68,88],[102],[32,2],[68,96],[101],[113],[114],[4,64],[68,1],[65,2],[15],[11],[68,0],[65,2],[15]],
585
591
  params:[124,127],typedParams:1,returns:[124,127],typedReturns:1,
@@ -3747,8 +3747,20 @@ const ifIdentifierErrors = (scope, decl) => {
3747
3747
  const generateUnary = (scope, decl) => {
3748
3748
  switch (decl.operator) {
3749
3749
  case '+':
3750
- // stub
3751
- return generate(scope, decl.argument);
3750
+ // 13.5.4 Unary + Operator, 13.5.4.1 Runtime Semantics: Evaluation
3751
+ // https://tc39.es/ecma262/#sec-unary-plus-operator-runtime-semantics-evaluation
3752
+ // 1. Let expr be ? Evaluation of UnaryExpression.
3753
+ // 2. Return ? ToNumber(? GetValue(expr)).
3754
+ return generate(scope, {
3755
+ type: 'CallExpression',
3756
+ callee: {
3757
+ type: 'Identifier',
3758
+ name: '__ecma262_ToNumber'
3759
+ },
3760
+ arguments: [
3761
+ decl.argument
3762
+ ]
3763
+ });
3752
3764
 
3753
3765
  case '-':
3754
3766
  // * -1
package/compiler/index.js CHANGED
@@ -164,8 +164,26 @@ export default (code, module = undefined) => {
164
164
  data[i] = run(data[i]);
165
165
  }
166
166
 
167
- const url = Diagram.url(Diagram.tree(data));
168
- console.log(`built-in tree: ${url}`);
167
+ const print = (x, depth = []) => {
168
+ for (const [ name, inc ] of x) {
169
+ if (inc.length === 0) continue;
170
+ console.log(name);
171
+
172
+ for (let i = 0; i < inc.length; i++) {
173
+ if (inc[i][1].length === 0) continue;
174
+ process.stdout.write(`${depth.join(' ')}${depth.length > 0 ? ' ' : ''}${i != inc.length - 1 ? '├' : '└' } `);
175
+
176
+ const newDepth = [...depth];
177
+ newDepth.push(i != inc.length - 1 ? '│' : '');
178
+
179
+ print([ inc[i] ], newDepth);
180
+ }
181
+ }
182
+ };
183
+ print(data);
184
+
185
+ // const url = Diagram.url(Diagram.tree(data));
186
+ // console.log(`built-in tree: ${url}`);
169
187
  }
170
188
 
171
189
  if (logProgress) progressStart('assembling...');
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.41.0+16662abac",
4
+ "version": "0.41.2+5b89877a2",
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.41.0+16662abac';
3
+ globalThis.version = '0.41.2+5b89877a2';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {