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 +2 -2
- package/compiler/precompile.js +12 -3
- package/compiler/wrap.js +1 -1
- package/package.json +1 -1
- package/runner/index.js +1 -1
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
|
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
|
|
package/compiler/precompile.js
CHANGED
@@ -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(
|
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
|
-
|
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
|
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