porffor 0.16.0-e5b6b94c8 → 0.16.0-f9dde1759
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/CONTRIBUTING.md +4 -3
- package/compiler/2c.js +53 -65
- package/compiler/assemble.js +5 -4
- package/compiler/builtins/console.ts +1 -1
- package/compiler/builtins/porffor.d.ts +11 -0
- package/compiler/builtins/set.ts +3 -2
- package/compiler/builtins/symbol.ts +6 -6
- package/compiler/builtins.js +25 -5
- package/compiler/codegen.js +20 -42
- package/compiler/cyclone.js +535 -0
- package/compiler/decompile.js +3 -1
- package/compiler/generated_builtins.js +1 -1
- package/compiler/havoc.js +93 -0
- package/compiler/index.js +89 -6
- package/compiler/opt.js +3 -39
- package/compiler/parse.js +2 -2
- package/compiler/pgo.js +207 -0
- package/compiler/precompile.js +3 -1
- package/compiler/prefs.js +6 -1
- package/compiler/wrap.js +53 -12
- package/no_pgo.txt +923 -0
- package/package.json +3 -5
- package/pgo.txt +916 -0
- package/runner/index.js +21 -11
- /package/runner/{profiler.js → profile.js} +0 -0
package/runner/index.js
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
3
|
-
import compile from '../compiler/wrap.js';
|
4
2
|
import fs from 'node:fs';
|
5
3
|
|
6
4
|
const start = performance.now();
|
@@ -59,12 +57,22 @@ if (process.argv.includes('--help')) {
|
|
59
57
|
}
|
60
58
|
|
61
59
|
let file = process.argv.slice(2).find(x => x[0] !== '-');
|
62
|
-
if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(file)) {
|
60
|
+
if (['precompile', 'run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(file)) {
|
63
61
|
// remove this arg
|
64
62
|
process.argv.splice(process.argv.indexOf(file), 1);
|
65
63
|
|
64
|
+
if (file === 'precompile') {
|
65
|
+
await import('../compiler/precompile.js');
|
66
|
+
await new Promise(() => {}); // do nothing for the rest of this file
|
67
|
+
}
|
68
|
+
|
66
69
|
if (file === 'profile') {
|
67
|
-
await import('./
|
70
|
+
await import('./profile.js');
|
71
|
+
await new Promise(() => {}); // do nothing for the rest of this file
|
72
|
+
}
|
73
|
+
|
74
|
+
if (file === 'debug') {
|
75
|
+
await import('./debug.js');
|
68
76
|
await new Promise(() => {}); // do nothing for the rest of this file
|
69
77
|
}
|
70
78
|
|
@@ -76,11 +84,6 @@ if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(fi
|
|
76
84
|
process.argv.push('--asur', '--wasm-debug');
|
77
85
|
}
|
78
86
|
|
79
|
-
if (file === 'debug') {
|
80
|
-
await import('./debug.js');
|
81
|
-
await new Promise(() => {}); // do nothing for the rest of this file
|
82
|
-
}
|
83
|
-
|
84
87
|
file = process.argv.slice(2).find(x => x[0] !== '-');
|
85
88
|
|
86
89
|
const nonOptOutFile = process.argv.slice(process.argv.indexOf(file) + 1).find(x => x[0] !== '-');
|
@@ -89,6 +92,8 @@ if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(fi
|
|
89
92
|
}
|
90
93
|
}
|
91
94
|
|
95
|
+
globalThis.file = file;
|
96
|
+
|
92
97
|
if (!file) {
|
93
98
|
if (process.argv.includes('-v') || process.argv.includes('--version')) {
|
94
99
|
// just print version
|
@@ -103,6 +108,8 @@ if (!file) {
|
|
103
108
|
|
104
109
|
const source = fs.readFileSync(file, 'utf8');
|
105
110
|
|
111
|
+
const compile = (await import('../compiler/wrap.js')).default;
|
112
|
+
|
106
113
|
let cache = '';
|
107
114
|
const print = str => {
|
108
115
|
/* cache += str;
|
@@ -115,17 +122,20 @@ const print = str => {
|
|
115
122
|
process.stdout.write(str);
|
116
123
|
};
|
117
124
|
|
125
|
+
let runStart;
|
118
126
|
try {
|
119
127
|
if (process.argv.includes('-b')) {
|
120
128
|
const { wasm, exports } = await compile(source, process.argv.includes('--module') ? [ 'module' ] : [], {}, print);
|
121
129
|
|
130
|
+
runStart = performance.now();
|
122
131
|
if (!process.argv.includes('--no-run')) exports.main();
|
123
132
|
|
124
133
|
console.log(`\n\nwasm size: ${wasm.byteLength} bytes`);
|
125
134
|
} else {
|
126
135
|
const { exports } = await compile(source, process.argv.includes('--module') ? [ 'module' ] : [], {}, print);
|
127
136
|
|
128
|
-
|
137
|
+
runStart = performance.now();
|
138
|
+
if (!process.argv.includes('--no-run')) exports.main();
|
129
139
|
}
|
130
140
|
// if (cache) process.stdout.write(cache);
|
131
141
|
} catch (e) {
|
@@ -133,4 +143,4 @@ try {
|
|
133
143
|
console.error(process.argv.includes('-i') ? e : `${e.constructor.name}: ${e.message}`);
|
134
144
|
}
|
135
145
|
|
136
|
-
if (process.argv.includes('-t')) console.log(`${process.argv.includes('-b') ? '' : '\n\n'}total time: ${(performance.now() - start).toFixed(2)}ms`);
|
146
|
+
if (process.argv.includes('-t')) console.log(`${process.argv.includes('-b') ? '' : '\n\n'}total time: ${(performance.now() - start).toFixed(2)}ms\nexecution time: ${(performance.now() - runStart).toFixed(2)}ms`);
|
File without changes
|