porffor 0.37.13 → 0.37.15

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,21 +17,69 @@ 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 ap32: i32 = a - 28;
21
+ let bp32: i32 = b - 28;
22
+ let ap8: i32 = a - 4;
23
+ let bp8: i32 = b - 4;
22
24
  Porffor.wasm`
25
+ ;; load in 2 i64x2 chunks while length >= 32
26
+ local.get ${al}
27
+ i32.const 32
28
+ i32.ge_s
29
+ if 64
30
+ loop 64
31
+ local.get ${ap32}
32
+ local.get ${al}
33
+ i32.add
34
+ v128.load 0 0
35
+
36
+ local.get ${bp32}
37
+ local.get ${al}
38
+ i32.add
39
+ v128.load 0 0
40
+ v128.xor
41
+
42
+ local.get ${ap32}
43
+ local.get ${al}
44
+ i32.add
45
+ v128.load 0 16
46
+
47
+ local.get ${bp32}
48
+ local.get ${al}
49
+ i32.add
50
+ v128.load 0 16
51
+ v128.xor
52
+
53
+ v128.or
54
+ v128.any_true
55
+ if 64
56
+ i32.const 0
57
+ i32.const 2
58
+ return
59
+ end
60
+
61
+ local.get ${al}
62
+ i32.const 32
63
+ i32.sub
64
+ local.tee ${al}
65
+ i32.const 32
66
+ i32.ge_s
67
+ br_if 0
68
+ end
69
+ end
70
+
23
71
  ;; load in i64 chunks while length >= 8
24
72
  local.get ${al}
25
73
  i32.const 8
26
74
  i32.ge_s
27
75
  if 64
28
76
  loop 64
29
- local.get ${ap}
77
+ local.get ${ap8}
30
78
  local.get ${al}
31
79
  i32.add
32
80
  i64.load 0 0
33
81
 
34
- local.get ${bp}
82
+ local.get ${bp8}
35
83
  local.get ${al}
36
84
  i32.add
37
85
  i64.load 0 0
@@ -59,15 +107,15 @@ i32.const 2
59
107
  i32.ge_s
60
108
  if 64
61
109
  loop 64
62
- local.get ${ap}
110
+ local.get ${a}
63
111
  local.get ${al}
64
112
  i32.add
65
- i32.load16_u 0 6
113
+ i32.load16_u 0 2
66
114
 
67
- local.get ${bp}
115
+ local.get ${b}
68
116
  local.get ${al}
69
117
  i32.add
70
- i32.load16_u 0 6
118
+ i32.load16_u 0 2
71
119
 
72
120
  i32.ne
73
121
  if 64
@@ -17,9 +17,9 @@ 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,0],[65,4],[107],[33,8],[32,2],[65,4],[107],[33,9],[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,8],[32,4],[106],[41,0,0],[32,9],[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,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,10],[3,64],[32,10],[32,4],[72],[4,64],[32,0],[32,10],[106],[45,0,4],[32,2],[32,10],[65,2],[108],[106],[47,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[32,10],[65,1],[106],[33,10],[12,1],[11],[11],[65,1],[65,2],[15],[11],[5],[32,3],[65,195,1],[70],[4,64],[65,0],[33,10],[3,64],[32,10],[32,4],[72],[4,64],[32,0],[32,10],[65,2],[108],[106],[47,0,4],[32,2],[32,10],[106],[45,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[32,10],[65,1],[106],[33,10],[12,1],[11],[11],[65,1],[65,2],[15],[5],[32,0],[65,4],[107],[33,11],[32,2],[65,4],[107],[33,12],[3,64],[32,11],[32,4],[65,2],[108],[106],[41,0,0],[32,12],[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,10],[3,64],[32,10],[32,4],[72],[4,64],[32,0],[32,10],[65,2],[108],[106],[47,0,4],[32,2],[32,10],[65,2],[108],[106],[47,0,4],[71],[4,64],[65,0],[65,2],[15],[11],[32,10],[65,1],[106],[33,10],[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
- locals:[127,127,127,127,127],localNames:["a","a#type","b","b#type","al","bl","ap","bp","i"],
22
+ locals:[127,127,127,127,127,127,127,127,127],localNames:["a","a#type","b","b#type","al","bl","ap32","bp32","ap8","bp8","i","ap","bp"],
23
23
  };
24
24
  this.__Porffor_strcat = {
25
25
  wasm:(_,{builtin})=>[[32,0],[40,0,0],[33,4],[32,2],[40,0,0],[33,5],[32,1],[65,195,1],[70],[4,64],[32,3],[65,195,1],[70],[4,64],[65,4],[32,4],[106],[32,5],[106],[16,builtin('__Porffor_allocateBytes')],[34,6],[32,4],[32,5],[106],[54,0,0],[32,6],[65,4],[106],[32,0],[65,4],[106],[32,4],[252,10,0,0],[32,6],[65,4],[106],[32,4],[106],[32,2],[65,4],[106],[32,5],[252,10,0,0],[32,6],[65,195,1],[15],[5],[65,4],[32,4],[32,5],[106],[65,2],[108],[106],[16,builtin('__Porffor_allocateBytes')],[34,6],[32,4],[32,5],[106],[54,0,0],[65,0],[33,7],[3,64],[32,7],[32,4],[72],[4,64],[32,6],[32,7],[65,2],[108],[106],[32,0],[32,7],[106],[45,0,4],[59,0,4],[32,7],[65,1],[106],[33,7],[12,1],[11],[11],[32,6],[65,4],[106],[32,4],[65,2],[108],[106],[32,2],[65,4],[106],[32,5],[65,2],[108],[252,10,0,0],[32,6],[65,195,0],[15],[11],[5],[32,3],[65,195,1],[70],[4,64],[65,4],[32,4],[32,5],[106],[65,2],[108],[106],[16,builtin('__Porffor_allocateBytes')],[34,6],[32,4],[32,5],[106],[54,0,0],[32,6],[65,4],[106],[32,0],[65,4],[106],[32,4],[65,2],[108],[252,10,0,0],[32,6],[32,4],[65,2],[108],[106],[33,8],[65,0],[33,7],[3,64],[32,7],[32,5],[72],[4,64],[32,8],[32,7],[65,2],[108],[106],[32,2],[32,7],[106],[45,0,4],[59,0,4],[32,7],[65,1],[106],[33,7],[12,1],[11],[11],[32,6],[65,195,0],[15],[5],[65,4],[32,4],[32,5],[106],[65,2],[108],[106],[16,builtin('__Porffor_allocateBytes')],[34,6],[32,4],[32,5],[106],[54,0,0],[32,6],[65,4],[106],[32,0],[65,4],[106],[32,4],[65,2],[108],[252,10,0,0],[32,6],[65,4],[106],[32,4],[65,2],[108],[106],[32,2],[65,4],[106],[32,5],[65,2],[108],[252,10,0,0],[32,6],[65,195,0],[15],[11],[11],[65,0],[65,128,1],[15]],
@@ -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.15+ef676dd35",
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.15+ef676dd35';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {