porffor 0.37.13 → 0.37.14

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/compiler/2c.js CHANGED
@@ -208,8 +208,7 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
208
208
  for (const x in globals) {
209
209
  const g = globals[x];
210
210
 
211
- out += `${CValtype[g.type]} ${sanitize(x)} = ${g.init ?? 0}`;
212
- out += ';\n';
211
+ out += `${CValtype[g.type]} ${sanitize(x)} = ${g.init ?? 0};\n`;
213
212
  }
214
213
 
215
214
  if (pages.size > 0) {
@@ -222,7 +221,6 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
222
221
  const dataOffset = x => pages.get(x.page).ind * pageSize;
223
222
  if (Prefs['2cMemcpy']) {
224
223
  prependMain.set('_data', activeData.map(x => `memcpy(_memory + ${dataOffset(x)}, (unsigned char[]){${x.bytes.join(',')}}, ${x.bytes.length});`).join('\n '));
225
- includes.set('string.h', true);
226
224
  } else {
227
225
  prependMain.set('_data', activeData.map(x => x.bytes.reduce((acc, y, i) => acc + (y === 0 ? '' : `_memory[${dataOffset(x) + i}]=(u8)${y};`), '')).join('\n '));
228
226
  }
@@ -17,9 +17,56 @@ export const __Porffor_strcmp = (a: any, b: any): boolean => {
17
17
  // bytestring, bytestring
18
18
  // this path is hyper-optimized as it is by far the most common and (perf) important
19
19
 
20
- let ap: i32 = a - 4;
21
- let bp: i32 = b - 4;
20
+ let ap: i32 = a - 28;
21
+ let bp: i32 = b - 28;
22
22
  Porffor.wasm`
23
+ ;; load in 2 i64x2 chunks while length >= 32
24
+ local.get ${al}
25
+ i32.const 32
26
+ i32.ge_s
27
+ if 64
28
+ loop 64
29
+ local.get ${ap}
30
+ local.get ${al}
31
+ i32.add
32
+ v128.load 0 0
33
+
34
+ local.get ${bp}
35
+ local.get ${al}
36
+ i32.add
37
+ v128.load 0 0
38
+
39
+ v128.xor
40
+
41
+ local.get ${ap}
42
+ local.get ${al}
43
+ i32.add
44
+ v128.load 0 16
45
+
46
+ local.get ${bp}
47
+ local.get ${al}
48
+ i32.add
49
+ v128.load 0 16
50
+
51
+ v128.xor
52
+ v128.or
53
+ v128.any_true
54
+ if 64
55
+ i32.const 0
56
+ i32.const 2
57
+ return
58
+ end
59
+
60
+ local.get ${al}
61
+ i32.const 32
62
+ i32.sub
63
+ local.tee ${al}
64
+ i32.const 32
65
+ i32.ge_s
66
+ br_if 0
67
+ end
68
+ end
69
+
23
70
  ;; load in i64 chunks while length >= 8
24
71
  local.get ${al}
25
72
  i32.const 8
@@ -29,12 +76,12 @@ if 64
29
76
  local.get ${ap}
30
77
  local.get ${al}
31
78
  i32.add
32
- i64.load 0 0
79
+ i64.load 0 24
33
80
 
34
81
  local.get ${bp}
35
82
  local.get ${al}
36
83
  i32.add
37
- i64.load 0 0
84
+ i64.load 0 24
38
85
 
39
86
  i64.ne
40
87
  if 64
@@ -59,15 +106,15 @@ i32.const 2
59
106
  i32.ge_s
60
107
  if 64
61
108
  loop 64
62
- local.get ${ap}
109
+ local.get ${a}
63
110
  local.get ${al}
64
111
  i32.add
65
- i32.load16_u 0 6
112
+ i32.load16_u 0 2
66
113
 
67
- local.get ${bp}
114
+ local.get ${b}
68
115
  local.get ${al}
69
116
  i32.add
70
- i32.load16_u 0 6
117
+ i32.load16_u 0 2
71
118
 
72
119
  i32.ne
73
120
  if 64
@@ -17,7 +17,7 @@ usedTypes:[80,7,195],
17
17
  globalInits:{underlyingKeys:(_,{allocPage,glbl,loc})=>[...number(allocPage(_,'array: __internal_object.ts/underlyingKeys','f64'),124),...glbl(36,'underlyingKeys',124),...glbl(35,'underlyingKeys',124),[252,3],[33,loc('#makearray_pointer_tmp',127)],[32,loc('#makearray_pointer_tmp',127)],[65,0],[54,1,0],[32,loc('#makearray_pointer_tmp',127)],[68,0],[252,3],[54,1,0],[32,loc('#makearray_pointer_tmp',127)],[26]],underlyingVals:(_,{allocPage,glbl,loc})=>[...number(allocPage(_,'array: __internal_object.ts/underlyingVals','f64'),124),...glbl(36,'underlyingVals',124),...glbl(35,'underlyingVals',124),[252,3],[33,loc('#makearray_pointer_tmp',127)],[32,loc('#makearray_pointer_tmp',127)],[65,0],[54,1,0],[32,loc('#makearray_pointer_tmp',127)],[68,0],[252,3],[54,1,0],[32,loc('#makearray_pointer_tmp',127)],[26]]},data:{"bytestring: __Porffor_object_makeObject/key1":[9,0,0,0,112,114,111,116,111,116,121,112,101],"bytestring: __Porffor_object_makeObject/key2":[11,0,0,0,99,111,110,115,116,114,117,99,116,111,114]},
18
18
  };
19
19
  this.__Porffor_strcmp = {
20
- wasm:()=>[[32,0],[32,2],[70],[4,64],[65,1],[65,2],[15],[11],[32,0],[40,0,0],[33,4],[32,2],[40,0,0],[33,5],[32,4],[32,5],[71],[4,64],[65,0],[65,2],[15],[11],[32,1],[65,195,1],[70],[4,64],[32,3],[65,195,1],[70],[4,64],[32,0],[65,4],[107],[33,6],[32,2],[65,4],[107],[33,7],[32,4],[65,8],[78],[4,64],[3,64],[32,6],[32,4],[106],[41,0,0],[32,7],[32,4],[106],[41,0,0],[82],[4,64],[65,0],[65,2],[15],[11],[32,4],[65,8],[107],[34,4],[65,8],[78],[13,0],[11],[11],[32,4],[65,2],[78],[4,64],[3,64],[32,6],[32,4],[106],[47,0,6],[32,7],[32,4],[106],[47,0,6],[71],[4,64],[65,0],[65,2],[15],[11],[32,4],[65,2],[107],[34,4],[65,2],[78],[13,0],[11],[11],[32,4],[65,1],[70],[4,64],[32,0],[45,0,4],[32,2],[45,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[11],[65,1],[65,2],[15],[5],[65,0],[33,8],[3,64],[32,8],[32,4],[72],[4,64],[32,0],[32,8],[106],[45,0,4],[32,2],[32,8],[65,2],[108],[106],[47,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[32,8],[65,1],[106],[33,8],[12,1],[11],[11],[65,1],[65,2],[15],[11],[5],[32,3],[65,195,1],[70],[4,64],[65,0],[33,8],[3,64],[32,8],[32,4],[72],[4,64],[32,0],[32,8],[65,2],[108],[106],[47,0,4],[32,2],[32,8],[106],[45,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[32,8],[65,1],[106],[33,8],[12,1],[11],[11],[65,1],[65,2],[15],[5],[32,0],[65,4],[107],[33,6],[32,2],[65,4],[107],[33,7],[3,64],[32,6],[32,4],[65,2],[108],[106],[41,0,0],[32,7],[32,4],[65,2],[108],[106],[41,0,0],[82],[4,64],[65,0],[65,2],[15],[11],[32,4],[65,4],[107],[34,4],[65,4],[78],[13,0],[11],[65,0],[33,8],[3,64],[32,8],[32,4],[72],[4,64],[32,0],[32,8],[65,2],[108],[106],[47,0,4],[32,2],[32,8],[65,2],[108],[106],[47,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[32,8],[65,1],[106],[33,8],[12,1],[11],[11],[65,1],[65,2],[15],[11],[11],[65,0],[65,128,1],[15]],
20
+ wasm:()=>[[32,0],[32,2],[70],[4,64],[65,1],[65,2],[15],[11],[32,0],[40,0,0],[33,4],[32,2],[40,0,0],[33,5],[32,4],[32,5],[71],[4,64],[65,0],[65,2],[15],[11],[32,1],[65,195,1],[70],[4,64],[32,3],[65,195,1],[70],[4,64],[32,0],[65,28],[107],[33,6],[32,2],[65,28],[107],[33,7],[32,4],[65,32],[78],[4,64],[3,64],[32,6],[32,4],[106],[253,0,0,0],[32,7],[32,4],[106],[253,0,0,0],[253,81],[32,6],[32,4],[106],[253,0,0,16],[32,7],[32,4],[106],[253,0,0,16],[253,81],[253,80],[253,83],[4,64],[65,0],[65,2],[15],[11],[32,4],[65,32],[107],[34,4],[65,32],[78],[13,0],[11],[11],[32,4],[65,8],[78],[4,64],[3,64],[32,6],[32,4],[106],[41,0,24],[32,7],[32,4],[106],[41,0,24],[82],[4,64],[65,0],[65,2],[15],[11],[32,4],[65,8],[107],[34,4],[65,8],[78],[13,0],[11],[11],[32,4],[65,2],[78],[4,64],[3,64],[32,0],[32,4],[106],[47,0,2],[32,2],[32,4],[106],[47,0,2],[71],[4,64],[65,0],[65,2],[15],[11],[32,4],[65,2],[107],[34,4],[65,2],[78],[13,0],[11],[11],[32,4],[65,1],[70],[4,64],[32,0],[45,0,4],[32,2],[45,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[11],[65,1],[65,2],[15],[5],[65,0],[33,8],[3,64],[32,8],[32,4],[72],[4,64],[32,0],[32,8],[106],[45,0,4],[32,2],[32,8],[65,2],[108],[106],[47,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[32,8],[65,1],[106],[33,8],[12,1],[11],[11],[65,1],[65,2],[15],[11],[5],[32,3],[65,195,1],[70],[4,64],[65,0],[33,8],[3,64],[32,8],[32,4],[72],[4,64],[32,0],[32,8],[65,2],[108],[106],[47,0,4],[32,2],[32,8],[106],[45,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[32,8],[65,1],[106],[33,8],[12,1],[11],[11],[65,1],[65,2],[15],[5],[32,0],[65,4],[107],[33,6],[32,2],[65,4],[107],[33,7],[3,64],[32,6],[32,4],[65,2],[108],[106],[41,0,0],[32,7],[32,4],[65,2],[108],[106],[41,0,0],[82],[4,64],[65,0],[65,2],[15],[11],[32,4],[65,4],[107],[34,4],[65,4],[78],[13,0],[11],[65,0],[33,8],[3,64],[32,8],[32,4],[72],[4,64],[32,0],[32,8],[65,2],[108],[106],[47,0,4],[32,2],[32,8],[65,2],[108],[106],[47,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[32,8],[65,1],[106],[33,8],[12,1],[11],[11],[65,1],[65,2],[15],[11],[11],[65,0],[65,128,1],[15]],
21
21
  params:[127,127,127,127],typedParams:1,returns:[127,127],typedReturns:1,
22
22
  locals:[127,127,127,127,127],localNames:["a","a#type","b","b#type","al","bl","ap","bp","i"],
23
23
  };
@@ -217,6 +217,10 @@ export const Opcodes = {
217
217
  i32x4_add: [ 0xfd, 0xae, 0x01 ],
218
218
  i32x4_sub: [ 0xfd, 0xb1, 0x01 ],
219
219
  i32x4_mul: [ 0xfd, 0xb5, 0x01 ],
220
+
221
+ v128_or: [ 0xfd, 80 ],
222
+ v128_xor: [ 0xfd, 81 ],
223
+ v128_any_true: [ 0xfd, 83 ]
220
224
  };
221
225
 
222
226
  export const FuncType = 0x60;
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.37.13+08fb072a3",
4
+ "version": "0.37.14+ebe5bcdbc",
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.37.13+08fb072a3';
3
+ globalThis.version = '0.37.14+ebe5bcdbc';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {