porffor 0.50.25 → 0.50.26

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
@@ -918,5 +918,5 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
918
918
  const makeIncludes = includes => [...includes.keys()].map(x => `#include <${x}>\n`).join('');
919
919
  out = platformSpecific(makeIncludes(winIncludes), makeIncludes(unixIncludes), false) + '\n' + makeIncludes(includes) + '\n' + alwaysPreface + [...prepend.values()].join('\n') + '\n\n' + out;
920
920
 
921
- return `// generated by porffor ${globalThis.version}\n` + out.trim();
921
+ return `// generated by porffor ${globalThis.version ?? ''}\n` + out.trim();
922
922
  };
package/compiler/opt.js CHANGED
@@ -11,11 +11,6 @@ export default (funcs, globals, pages, tags, exceptions) => {
11
11
  const tailCall = Prefs.tailCall;
12
12
  if (tailCall) log.warning('opt', 'tail call proposal is not widely implemented! (you used --tail-call)');
13
13
 
14
- // todo: this breaks exceptions after due to indexes not being adjusted
15
- // const tagUse = tags.reduce((acc, x) => { acc[x.idx] = 0; return acc; }, {});
16
- // const exceptionUse = exceptions.reduce((acc, _, i) => { acc[i] = 0; return acc; }, {});
17
-
18
- // wasm transform pass
19
14
  let fi = 0;
20
15
  for (const f of funcs) {
21
16
  const wasm = f.wasm;
@@ -34,13 +29,6 @@ export default (funcs, globals, pages, tags, exceptions) => {
34
29
  inst = [ ...inst ];
35
30
  wasm[i] = inst;
36
31
 
37
- // if (inst[0] === Opcodes.throw) {
38
- // tagUse[inst[1]]++;
39
-
40
- // const exceptId = read_signedLEB128(wasm[i - 1].slice(1));
41
- // exceptionUse[exceptId]++;
42
- // }
43
-
44
32
  if (inst[0] === Opcodes.block) {
45
33
  // remove unneeded blocks (no brs inside)
46
34
  // block
@@ -251,19 +239,4 @@ export default (funcs, globals, pages, tags, exceptions) => {
251
239
  }
252
240
  }
253
241
  }
254
-
255
- // for (const x in tagUse) {
256
- // if (tagUse[x] === 0) {
257
- // const el = tags.find(y => y.idx === x);
258
- // tags.splice(tags.indexOf(el), 1);
259
- // }
260
- // }
261
-
262
- // for (const x of Object.keys(exceptionUse).sort((a, b) => b - a)) {
263
- // if (exceptionUse[x] === 0) {
264
- // exceptions.splice(+x, 1);
265
- // }
266
- // }
267
-
268
- // return funcs;
269
242
  };
@@ -1,18 +1,36 @@
1
- const enumify = (...args) => {
2
- const obj = {};
3
-
4
- for (let i = 0; i < args.length; i++) {
5
- obj[i] = args[i];
6
- obj[args[i]] = i;
7
- }
1
+ export const Magic = [ 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00 ];
2
+ export const PageSize = 65536; // 64KiB
3
+ export const FuncType = 0x60;
8
4
 
9
- return obj;
5
+ export const Section = {
6
+ custom: 0,
7
+ type: 1,
8
+ import: 2,
9
+ func: 3,
10
+ table: 4,
11
+ memory: 5,
12
+ global: 6,
13
+ export: 7,
14
+ start: 8,
15
+ element: 9,
16
+ code: 10,
17
+ data: 11,
18
+ data_count: 12,
19
+ tag: 13
10
20
  };
11
21
 
12
- export const Section = enumify('custom', 'type', 'import', 'func', 'table', 'memory', 'global', 'export', 'start', 'element', 'code', 'data', 'data_count', 'tag');
13
- export const ExportDesc = enumify('func', 'table', 'mem', 'global', 'tag');
22
+ export const ExportDesc = {
23
+ func: 0,
24
+ table: 1,
25
+ mem: 2,
26
+ global: 3,
27
+ tag: 4
28
+ };
14
29
 
15
- export const Mut = enumify('const', 'var');
30
+ export const Mut = {
31
+ const: 0,
32
+ var: 1
33
+ };
16
34
 
17
35
  export const Valtype = {
18
36
  i32: 0x7f,
@@ -21,13 +39,21 @@ export const Valtype = {
21
39
  v128: 0x7b
22
40
  };
23
41
 
42
+ export const ValtypeSize = {
43
+ i8: 1,
44
+ i16: 2,
45
+ i32: 4,
46
+ i64: 8,
47
+ f64: 8
48
+ };
49
+
24
50
  export const Reftype = {
25
51
  funcref: 0x70,
26
52
  externref: 0x6f
27
53
  };
28
54
 
29
55
  export const Blocktype = {
30
- void: 0x40,
56
+ void: 0x40
31
57
  };
32
58
 
33
59
  export const Opcodes = {
@@ -221,21 +247,4 @@ export const Opcodes = {
221
247
  v128_or: [ 0xfd, 80 ],
222
248
  v128_xor: [ 0xfd, 81 ],
223
249
  v128_any_true: [ 0xfd, 83 ]
224
- };
225
-
226
- export const FuncType = 0x60;
227
- export const Empty = 0x00;
228
-
229
- export const Magic = [ 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00 ];
230
-
231
- export const PageSize = 65536; // 64KiB (1024 * 8)
232
-
233
- export const ValtypeSize = {
234
- i32: 4,
235
- i64: 8,
236
- f64: 8,
237
-
238
- // special
239
- i8: 1,
240
- i16: 2
241
250
  };
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.50.25",
4
+ "version": "0.50.26",
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.50.25';
3
+ globalThis.version = '0.50.26';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {