porffor 0.24.7 → 0.24.8

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/index.js CHANGED
@@ -108,10 +108,10 @@ export default (code, flags) => {
108
108
 
109
109
  if (Prefs.profileCompiler) console.log(`3. optimized in ${(performance.now() - t2).toFixed(2)}ms`);
110
110
 
111
- const out = { funcs, globals, tags, exceptions, pages, data };
111
+ const t3 = performance.now();
112
+ const out = { funcs, globals, tags, exceptions, pages, data, times: [ t0, t1, t2, t3 ] };
112
113
  if (globalThis.precompile) return out;
113
114
 
114
- const t3 = performance.now();
115
115
  const wasm = out.wasm = assemble(funcs, globals, tags, pages, data, flags);
116
116
  if (Prefs.profileCompiler) console.log(`4. assembled in ${(performance.now() - t3).toFixed(2)}ms`);
117
117
 
@@ -15,6 +15,7 @@ globalThis.precompile = true;
15
15
 
16
16
  const argv = process.argv.slice();
17
17
 
18
+ const timing = {};
18
19
  const compile = async (file, _funcs) => {
19
20
  let source = fs.readFileSync(file, 'utf8');
20
21
  let first = source.slice(0, source.indexOf('\n'));
@@ -32,7 +33,14 @@ const compile = async (file, _funcs) => {
32
33
 
33
34
  const porfCompile = (await import(`./index.js?_=${Date.now()}`)).default;
34
35
 
35
- let { funcs, globals, data, exceptions } = porfCompile(source, ['module', 'typed']);
36
+ let { funcs, globals, data, exceptions, times } = porfCompile(source, ['module', 'typed']);
37
+
38
+ timing.parse ??= 0;
39
+ timing.parse += times[1] - times[0];
40
+ timing.codegen ??= 0;
41
+ timing.codegen += times[2] - times[1];
42
+ timing.opt ??= 0;
43
+ timing.opt += times[3] - times[2];
36
44
 
37
45
  const allocated = new Set();
38
46
 
@@ -179,10 +187,11 @@ const precompile = async () => {
179
187
  throw e;
180
188
  }
181
189
 
182
- process.stdout.write(`\r${' '.repeat(100)}\r\u001b[90m${`[${(performance.now() - t).toFixed(2)}ms]`.padEnd(16, ' ')}\u001b[0m\u001b[92m${file}\u001b[0m`);
190
+ process.stdout.write(`\r${' '.repeat(100)}\r\u001b[90m${`[${(performance.now() - t).toFixed(2)}ms]`.padEnd(12, ' ')}\u001b[0m\u001b[92m${file}\u001b[0m`);
183
191
  }
184
192
 
185
- console.log(`\r${' '.repeat(100)}\r\u001b[90m${`[${(performance.now() - t).toFixed(2)}ms]`.padEnd(16, ' ')}\u001b[0m\u001b[92mcompiled ${fileCount} files (${funcs.length} funcs)\u001b[0m`);
193
+ const total = performance.now() - t;
194
+ console.log(`\r${' '.repeat(100)}\r\u001b[90m${`[${total.toFixed(2)}ms]`.padEnd(12, ' ')}\u001b[0m\u001b[92mcompiled ${fileCount} files (${funcs.length} funcs)\u001b[0m \u001b[90m(${['parse', 'codegen', 'opt'].map(x => `${x}: ${((timing[x] / total) * 100).toFixed(2)}%`).join(', ')})\u001b[0m`);
186
195
 
187
196
  return `// autogenerated by compiler/precompile.js
188
197
  import { number } from './embedding.js';
package/compiler/wrap.js CHANGED
@@ -26,7 +26,7 @@ export const readByteStr = (memory, ptr) => {
26
26
  export const writeByteStr = (memory, ptr, str) => {
27
27
  const length = str.length;
28
28
 
29
- if (dv.memory !== memory) dv = new DataView(memory.buffer);
29
+ if (dv?.memory !== memory) dv = new DataView(memory.buffer);
30
30
  dv.setUint32(ptr, length, true);
31
31
 
32
32
  const arr = read(Uint8Array, memory, ptr + 4, length);
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.24.7+23de87c30",
4
+ "version": "0.24.8+02241f0c9",
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.24.7+23de87c30';
3
+ globalThis.version = '0.24.8+02241f0c9';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {